
<!--
Copyright 2017-present Open Networking Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->


<div id="developerview"></div>

<script>
var oTable;

function updateUserSliceTable(){
    log.debug("Should grab user slice info");
    jQuery.ajax({
        async:true,
        dataType: 'json',
        url: '/hpcdashuserslices',
        success: function(data){
            log.info("Got Data back for User SliceTable");
            //parseData(data);
            //createUserSliceTable(data);
            setTimeout(function () { updateUserSliceTable() }, 5000);
        },
        error: function(data){
            log.debug("COULDNT GET DATA BACK");
            setTimeout(function () { updateUserSliceTable() }, 5000);
        }
    });
}

function createUserSliceTable(data) {
    log.debug("Creating User Slice Table");

    //Add check for #dynamicusersliceinfo_filter label-> input having focus here

    $('#developerview').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamicusersliceinfo"></table>' );
    var actualEntries = [];
    //log.debug(data['userSliceInfo']['rows'][0]['slicename']);

    var rows = data['userSliceInfo']['rows'];
    for (row in rows) {
        log.debug(row[0]);
        slicename = rows[row]['slicename'];
        sliceid = rows[row]['sliceid'];
        role = rows[row]['role'];
        instancecount = rows[row]['instancecount'];
        sitecount = rows[row]['sitecount'];
        actualEntries.push(['<a href="http://{{request.get_host}}/admin/core/slice/' + sliceid + '">' + slicename + '</a>',
                            role, instancecount, sitecount]);
    }
    oTable = $('#dynamicusersliceinfo').dataTable( {
        "bJQueryUI": true,
        "aaData":  actualEntries ,
        "bStateSave": true,
        "aoColumns": [
            { "sTitle": "Slice" },
            { "sTitle": "Privilege" , sClass: "alignCenter"},
            { "sTitle": "Number of Instances" , sClass: "alignCenter"},
            { "sTitle": "Number of Sites" , sClass: "alignCenter"},
        ]
    } );

    // If the filter had focus, reapply here

    setTimeout(function() {
       jQuery.ajax({
           url: '/hpcdashuserslices',
           dataType: 'json',
           success: function(data){ createUserSliceTable(data); },
           complete: function(){ },
       });
    },  10000);
}

function initTable(){
    log.debug("Initializing Table")
    jQuery.ajax({
        url: '/hpcdashuserslices',
        dataType: 'json',
        success: function(data){ createUserSliceTable(data); },
        complete: function(){
        }
    });
    updateUserSliceTable();
}


initTable();

</script>
