/*
    buildInstancesView create a full display of Instance on div_name
*/
function buildDatabaseView(div_name) {
    var table_columns = [
        { data: 'instance_id' },
        { data: 'heartbeat_at' },
        { data: 'leased_at' },
        { data: 'lease_end' }
    ];
    $('#table-' + div_name).DataTable({
        ajax: {
            url: '/database',
            dataSrc: function(instances) {
                return instances;
            }
        },
        columns: table_columns,
        lengthChange: false,
        pageLength: 25,
        columnDefs: [
            {
                targets: [0],
                render: function ( data, type, row ) {
                    var now = new Date()
                    var heartbeat_date = new Date(row.heartbeat_at)
                    // If a VM as not been seen since 1 week, we can delete it
                    // 7 * 25 * 60 * 60 * 1000 = 604800000
                    if (heartbeat_date < now - 604800000) {
                        return '<i class="material-icons red-text">delete_forever</i> ' +
                            formatText(data, MAX_STRING_LENGTH);
                    } else {
                        return formatText(data, MAX_STRING_LENGTH);
                    }
                }
            }],
        drawCallback: function(settings, json) {
            $(".tooltipped").tooltip();
        },
    });
}

@@ -9,17 +9,16 @@
 uild
-Instances
+Database
 View
@@ -47,16 +47,10 @@
  of 
-Instance
+Da
  on 
@@ -695,16 +695,17 @@
 w Date()
+;
 %0A       
@@ -764,16 +764,17 @@
 beat_at)
+;
 %0A       
@@ -999,67 +999,40 @@
 urn 
-'%3Ci class=%22material-icons red-text%22%3Edelete_forever%3C/i%3E ' +%0A
+buildDatabaseRowMenu(data) +%0A   
     
@@ -1355,8 +1355,1148 @@
   %7D);%0A%7D%0A
+%0A/*%0A    buildDatabaseRowMenu build a menu for each row of Database Table%0A*/%0Afunction buildDatabaseRowMenu(data) %7B%0A    menu = '%3Ca class=%22btn-floating waves-effect waves-light tiny%22 onClick=%22swapDatabaseRowMenu(%5C'' + data + '%5C')%22%3E' +%0A           '%3Ci class=%22material-icons%22 id=%22database-icon-' + data + '%22%3Echevron_right%3C/i%3E%3C/a%3E ' +%0A           '%3Cspan hidden id=%22database-delete-' + data + '%22%3E' +%0A           '%3Ca class=%22btn-floating waves-effect waves-light red lighten-2%22' +%0A           'onClick=%22deleteDatabase(%5C'' + data + '%5C')%22%3E' +%0A           '%3Ci class=%22material-icons%22%3Edelete%3C/i%3E%3C/a%3E%3C/span%3E ';%0A    return menu;%0A%7D%0A%0A/*%0A    swapDatabaseRowMenu swap on/off the delete button%0A*/%0Afunction swapDatabaseRowMenu(button) %7B%0A    if ($('#database-delete-' + button).css('display') == 'none') %7B%0A        $('#database-icon-' + button).text('chevron_left');%0A    %7D else %7B%0A        $('#database-icon-' + button).text('chevron_right');%0A    %7D%0A    $('#database-delete-' + button).toggle();%0A%7D%0A%0A/*%0A    deleteDatabase delete entry in database%0A*/%0Afunction deleteDatabase(entry) %7B%0A    console.log('Entry: ' + entry + ' as been deleted');%0A    swapDatabaseRowMenu(entry);%0A%7D

Modify delete display