Commit 15d45d3c by Kálmán Viktor

dashboard: make select all button work in vm list

parent 73536165
......@@ -46,12 +46,12 @@ $(function() {
$('.vm-list-table tbody tr .btn').attr('disabled', false);
// show/hide group controls
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++) {
$('.vm-list-table tbody tr').eq(selected[i]).find('.btn').attr('disabled', true);
}
} else {
$('.vm-list-group-control .btn').attr('disabled', true);
$('.vm-list-group-control a').attr('disabled', true);
}
return false;
});
......@@ -87,6 +87,19 @@ $(function() {
/* 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 */
$('#vm-list-group-delete').click(function() {
$.ajax({
......@@ -100,7 +113,8 @@ $(function() {
$('.vm-list-table tbody tr').eq(selected[i]).fadeOut(500, function() {
// reset group buttons
selected = []
$('.vm-list-group-control .btn').attr('disabled', true);
$('.vm-list-group-control a').attr('disabled', true);
$(this).remove();
addMessage(data['message'], 'success');
});
},
......
......@@ -20,7 +20,7 @@
<div class="panel-body vm-list-group-control">
<p>
<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 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>
......
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