dynamic home view with customization
[plstackapi.git] / planetstack / templates / admin / dashboard / developer.html
1 <div id="developerview"></div>
2
3 <script>
4 var oTable;
5
6 function updateUserSliceTable(){
7     log.debug("Should grab user slice info");
8     jQuery.ajax({
9         async:true,
10         dataType: 'json',
11         url: '/hpcdashuserslices',
12         success: function(data){
13             log.info("Got Data back for User SliceTable");
14             //parseData(data);
15             //createUserSliceTable(data);
16             setTimeout(function () { updateUserSliceTable() }, 5000);
17         },
18         error: function(data){
19             log.debug("COULDNT GET DATA BACK");
20             setTimeout(function () { updateUserSliceTable() }, 5000);
21         }
22     });
23 }
24
25 function createUserSliceTable(data) {
26     log.debug("Creating User Slice Table");
27
28     //Add check for #dynamicusersliceinfo_filter label-> input having focus here
29
30     $('#developerview').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamicusersliceinfo"></table>' );
31     var actualEntries = [];
32     log.debug(data['userSliceInfo']['rows'][0]['slicename']);
33
34     var rows = data['userSliceInfo']['rows'];
35     for (row in rows) {
36         log.debug(row[0]);
37         slicename = rows[row]['slicename'];
38         sliceid = rows[row]['sliceid'];
39         role = rows[row]['role'];
40         slivercount = rows[row]['slivercount'];
41         sitecount = rows[row]['sitecount'];
42         actualEntries.push(['<a href="http://{{request.get_host}}/admin/core/slice/' + sliceid + '">' + slicename + '</a>',
43                             role, slivercount, sitecount]);
44     }
45     oTable = $('#dynamicusersliceinfo').dataTable( {
46         "bJQueryUI": true,
47         "aaData":  actualEntries ,
48         "bStateSave": true,
49         "aoColumns": [
50             { "sTitle": "Slice" },
51             { "sTitle": "Privilege" , sClass: "alignCenter"},
52             { "sTitle": "Number of Slivers" , sClass: "alignCenter"},
53             { "sTitle": "Number of Sites" , sClass: "alignCenter"},
54         ]
55     } );
56
57     // If the filter had focus, reapply here
58
59     setTimeout(function() {
60        jQuery.ajax({
61            url: '/hpcdashuserslices',
62            dataType: 'json',
63            success: function(data){ createUserSliceTable(data); },
64            complete: function(){ },
65        });
66     },  10000);
67 }
68
69 function initTable(){
70     log.debug("Initializing Table")
71     jQuery.ajax({
72         url: '/hpcdashuserslices',
73         dataType: 'json',
74         success: function(data){ createUserSliceTable(data); },
75         complete: function(){
76         }
77     });
78     updateUserSliceTable();
79 }
80
81
82 initTable();
83
84 </script>