Commit 15d45d3c by Kálmán Viktor

dashboard: make select all button work in vm list

parent 73536165
...@@ -46,12 +46,12 @@ $(function() { ...@@ -46,12 +46,12 @@ $(function() {
$('.vm-list-table tbody tr .btn').attr('disabled', false); $('.vm-list-table tbody tr .btn').attr('disabled', false);
// show/hide group controls // show/hide group controls
if(selected.length > 1) { if(selected.length > 1) {
$('.vm-list-group-control .btn').attr('disabled', false); $('.vm-list-group-control a').attr('disabled', false);
for(var i = 0; i < selected.length; i++) { for(var i = 0; i < selected.length; i++) {
$('.vm-list-table tbody tr').eq(selected[i]).find('.btn').attr('disabled', true); $('.vm-list-table tbody tr').eq(selected[i]).find('.btn').attr('disabled', true);
} }
} else { } else {
$('.vm-list-group-control .btn').attr('disabled', true); $('.vm-list-group-control a').attr('disabled', true);
} }
return false; return false;
}); });
...@@ -86,7 +86,20 @@ $(function() { ...@@ -86,7 +86,20 @@ $(function() {
}); });
/* group actions */ /* group actions */
/* select all */
$('#vm-list-group-select-all').click(function() {
$('.vm-list-table tbody tr').each(function() {
var index = $(this).index();
if(selected.indexOf(index) < 0) {
selected.push(index);
$(this).addClass('vm-list-selected');
}
});
console.log(selected);
return false;
});
/* mass vm delete */ /* mass vm delete */
$('#vm-list-group-delete').click(function() { $('#vm-list-group-delete').click(function() {
$.ajax({ $.ajax({
...@@ -100,7 +113,8 @@ $(function() { ...@@ -100,7 +113,8 @@ $(function() {
$('.vm-list-table tbody tr').eq(selected[i]).fadeOut(500, function() { $('.vm-list-table tbody tr').eq(selected[i]).fadeOut(500, function() {
// reset group buttons // reset group buttons
selected = [] selected = []
$('.vm-list-group-control .btn').attr('disabled', true); $('.vm-list-group-control a').attr('disabled', true);
$(this).remove();
addMessage(data['message'], 'success'); addMessage(data['message'], 'success');
}); });
}, },
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="panel-body vm-list-group-control"> <div class="panel-body vm-list-group-control">
<p> <p>
<strong>Group actions</strong> <strong>Group actions</strong>
<button class="btn btn-info btn-xs" disabled>Select all</button> <button id="vm-list-group-select-all" class="btn btn-info btn-xs">Select all</button>
<a class="btn btn-default btn-xs" id="vm-list-group-migrate" disabled><i class="icon-truck"></i> Migrate</a> <a class="btn btn-default btn-xs" id="vm-list-group-migrate" disabled><i class="icon-truck"></i> Migrate</a>
<a disabled href="#" class="btn btn-default btn-xs"><i class="icon-refresh"></i> Reboot</a> <a disabled href="#" class="btn btn-default btn-xs"><i class="icon-refresh"></i> Reboot</a>
<a disabled href="#" class="btn btn-default btn-xs"><i class="icon-off"></i> Shutdown</a> <a disabled href="#" class="btn btn-default btn-xs"><i class="icon-off"></i> Shutdown</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment