www/images.js
// Function to create a table.
Function to create a table.
Function to create a table .
function tableCreate(el, data)
    {
        var listBody = $('#table-list > tbody')[0];
        for (var i = 0; i < data.length; i++)
        {
            var tr = listBody.insertRow();
            var td = tr.insertCell();
            var id = data[i].Id.substring(0, 11);
            var idLink = data[i].Id;
            td.innerHTML = idLink;
            var td = tr.insertCell();
            td.appendChild(document.createTextNode(data[i].RepoTags));
            var td = tr.insertCell();
            var dt = convertUnixTime(data[i].Created);
            td.appendChild(document.createTextNode(dt));
            var td = tr.insertCell();
            td.appendChild(document.createTextNode(data[i].VirtualSize));
            var td = tr.insertCell();
            td.appendChild(document.createTextNode(data[i].ParentId.substring(0, 11)));
            var td = tr.insertCell();
            td.appendChild(document.createTextNode(data[i].Size));
            var td = tr.insertCell();
            var text = '';
            if (data[i].Labels !== 'undefined' && data[i].Labels !== null)  {
                for (var j = 0; j < data[i].Labels.length; j++)
                {
                    text += data[i].Labels[j] + '<br />';
                }
            }
            td.appendChild(document.createTextNode(text));
            var td = tr.insertCell();
            td.appendChild(document.createTextNode(data[i].RepoDigests));
        }
        $('#table-list > tbody > tr').each( function() {
            var td = $('td:eq(0)', this)[0];
            var val = td.textContent;
            var abbr = val.substring(0, 11);
            var link = document.createElement('a');
            var linkText = document.createTextNode(abbr);
            link.setAttribute('href', '#')
            link.className = '';
            link.appendChild(linkText);
            td.innerHTML = '';  
            td.appendChild(link);
            var historyBtn = buildButton('History', 'history icon');
            $(td).append($(historyBtn));
            var deleteBtn = buildButton('Delete', 'delete icon');
            $(td).append($(deleteBtn));
            $(historyBtn).click( function() {
                $('#tab-history-message').text('');
                var t = document.getElementById('table-history');
                var tbl = new Table();
                tbl.create(t);
                tbl.clear();
                $.getJSON('/' + apiVersion + '/nodes/' + nodeId + '/images/history/' + val, function() {
                })
                .done(function(data) {
                    if (data.length === 0) {
                        $('#tab-history-message').text('No history.');
                        $('#tab-history').modal('show');
                        return;
                    }
                    var t = document.getElementById('table-history');
                    var tbl = new Table();
                    tbl.create(t);
                    tbl.setHeader(['Created', 'Created By', 'Id', 'Size', 'Tags']);
                    tbl.addBody(data);
                    $('#tab-history').modal('show');
                })
            });
            $(link).click( function() {
                    $.getJSON('/' + apiVersion + '/nodes/' + nodeId  + '/images/inspect/' + val, function() {
                        })
                        .done(function(data) {
                            var html = renderJson(data);
                            $('#tab-inspect #results').html(html);
                            $('#tab-inspect').modal('show');
                        })
                        .fail(
                            function( jqxhr, textStatus, error ) {
                                var err = textStatus + ", " + error;
                                console.log( "Request Failed: " + err );
                            }
                        )
                        .always(function() {
                        })
                    ;
                }
            );
            $(deleteBtn).click( function() {
                $('#tab-delete').modal('show');
                $.getJSON('/' + apiVersion + '/nodes/' + nodeId  + '/images/delete/' + val, function() {
                })
                .done(function(data) {
                    var statusCode = data.StatusCode;
                    var html = renderJson(data);
                    $('#tab-delete #results').html(html);
                    $('#table-list-body').empty();
                    loadImageList();
                })
                .fail(
                    function( jqxhr, textStatus, error ) {
                        var err = textStatus + ", " + error;
                        console.log( "Request Failed: " + err );
                    }
                )
            });
        });
    }
function tableCreate ( el , data ) { var listBody = $ ( '#table-list > tbody' ) [ 0 ] ; for ( var i = 0 ; i < data . length ; i ++ ) { var tr = listBody . insertRow ( ) ; var td = tr . insertCell ( ) ; var id = data [ i ] . Id . substring ( 0 , 11 ) ; var idLink = data [ i ] . Id ; td . innerHTML = idLink ; var td = tr . insertCell ( ) ; td . appendChild ( document . createTextNode ( data [ i ] . RepoTags ) ) ; var td = tr . insertCell ( ) ; var dt = convertUnixTime ( data [ i ] . Created ) ; td . appendChild ( document . createTextNode ( dt ) ) ; var td = tr . insertCell ( ) ; td . appendChild ( document . createTextNode ( data [ i ] . VirtualSize ) ) ; var td = tr . insertCell ( ) ; td . appendChild ( document . createTextNode ( data [ i ] . ParentId . substring ( 0 , 11 ) ) ) ; var td = tr . insertCell ( ) ; td . appendChild ( document . createTextNode ( data [ i ] . Size ) ) ; var td = tr . insertCell ( ) ; var text = '' ; if ( data [ i ] . Labels !== 'undefined' && data [ i ] . Labels !== null ) { for ( var j = 0 ; j < data [ i ] . Labels . length ; j ++ ) { text += data [ i ] . Labels [ j ] + '<br />' ; } } td . appendChild ( document . createTextNode ( text ) ) ; var td = tr . insertCell ( ) ; td . appendChild ( document . createTextNode ( data [ i ] . RepoDigests ) ) ; } $ ( '#table-list > tbody > tr' ) . each ( function ( ) { var td = $ ( 'td:eq(0)' , this ) [ 0 ] ; var val = td . textContent ; var abbr = val . substring ( 0 , 11 ) ; var link = document . createElement ( 'a' ) ; var linkText = document . createTextNode ( abbr ) ; link . setAttribute ( 'href' , '#' ) link . className = '' ; link . appendChild ( linkText ) ; td . innerHTML = '' ; td . appendChild ( link ) ; var historyBtn = buildButton ( 'History' , 'history icon' ) ; $ ( td ) . append ( $ ( historyBtn ) ) ; var deleteBtn = buildButton ( 'Delete' , 'delete icon' ) ; $ ( td ) . append ( $ ( deleteBtn ) ) ; $ ( historyBtn ) . click ( function ( ) { $ ( '#tab-history-message' ) . text ( '' ) ; var t = document . getElementById ( 'table-history' ) ; var tbl = new Table ( ) ; tbl . create ( t ) ; tbl . clear ( ) ; $ . getJSON ( '/' + apiVersion + '/nodes/' + nodeId + '/images/history/' + val , function ( ) { } ) . done ( function ( data ) { if ( data . length === 0 ) { $ ( '#tab-history-message' ) . text ( 'No history.' ) ; $ ( '#tab-history' ) . modal ( 'show' ) ; return ; } var t = document . getElementById ( 'table-history' ) ; var tbl = new Table ( ) ; tbl . create ( t ) ; tbl . setHeader ( [ 'Created' , 'Created By' , 'Id' , 'Size' , 'Tags' ] ) ; tbl . addBody ( data ) ; $ ( '#tab-history' ) . modal ( 'show' ) ; } ) } ) ; $ ( link ) . click ( function ( ) { $ . getJSON ( '/' + apiVersion + '/nodes/' + nodeId + '/images/inspect/' + val , function ( ) { } ) . done ( function ( data ) { var html = renderJson ( data ) ; $ ( '#tab-inspect #results' ) . html ( html ) ; $ ( '#tab-inspect' ) . modal ( 'show' ) ; } ) . fail ( function ( jqxhr , textStatus , error ) { var err = textStatus + ", " + error ; console . log ( "Request Failed: " + err ) ; } ) . always ( function ( ) { } ) ; } ) ; $ ( deleteBtn ) . click ( function ( ) { $ ( '#tab-delete' ) . modal ( 'show' ) ; $ . getJSON ( '/' + apiVersion + '/nodes/' + nodeId + '/images/delete/' + val , function ( ) { } ) . done ( function ( data ) { var statusCode = data . StatusCode ; var html = renderJson ( data ) ; $ ( '#tab-delete #results' ) . html ( html ) ; $ ( '#table-list-body' ) . empty ( ) ; loadImageList ( ) ; } ) . fail ( function ( jqxhr , textStatus , error ) { var err = textStatus + ", " + error ; console . log ( "Request Failed: " + err ) ; } ) } ) ; } ) ; }
Function to create a table.
Function to create a table .
//var tbl  = document.createElement("table"); //var tbl = document.getElementById('table-list'); //var idLink = '<a href="images/inspect/' + data[i].Id  + '">' + id  + '</a>'; //var idLink = '<a onclick=""' + data[i].Id  + '">' + id  + '</a>'; //td.appendChild(document.createTextNode(idLink)); // Clear cell first. /*
             * Add buttons.
             */ /*
             * Bind button event handlers.
             */ // Get inspect data. //console.log('requested'); //$('#menu-tabs #menu-tabs-inspect').click(); // Get inspect data. //console.log('requested'); //$('#tab-inspect #results').text(JSON.stringify(data)); //console.log( "complete" ); //console.log('requested');