blob: 6da60da5a552c236b500712f383b88f315d3ac89 [file] [log] [blame]
Scott Bakerac868ac2014-07-15 10:29:17 -07001/* This is an example that uses xoslib + datatables to display the developer
2 view.
3
4 For an example that uses xoslib + marionette, see xosDeveloper.js
5 */
6
7 function updateSliceTable(data) {
8 $('#developerView').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamicusersliceinfo"></table>' );
9 var actualEntries = [];
10
11 for (rowkey in data.models) {
12 row = data.models[rowkey];
13 slicename = row.get("name");
14 sliceid = row.get("id");
15 role = row.get("sliceInfo").roles[0] || "";
16 slivercount = row.get("sliceInfo").sliverCount;
17 sitecount = row.get("sliceInfo").siteCount;
18 actualEntries.push(['<a href="/admin/core/slice/' + sliceid + '">' + slicename + '</a>',
19 role, slivercount, sitecount]);
20 }
21 oTable = $('#dynamicusersliceinfo').dataTable( {
22 "bJQueryUI": true,
23 "aaData": actualEntries ,
24 "bStateSave": true,
25 "aoColumns": [
26 { "sTitle": "Slice" },
27 { "sTitle": "Privilege" , sClass: "alignCenter"},
28 { "sTitle": "Number of Slivers" , sClass: "alignCenter"},
29 { "sTitle": "Number of Sites" , sClass: "alignCenter"},
30 ]
31 } );
32}
33
34$(document).ready(function(){
35 xos.slicesPlus.on("change", function() { console.log("change"); updateSliceTable(xos.slicesPlus); });
36 xos.slicesPlus.on("remove", function() { console.log("sort"); updateSliceTable(xos.slicesPlus); });
37 xos.slicesPlus.on("sort", function() { console.log("sort"); updateSliceTable(xos.slicesPlus); });
38
39 xos.slicesPlus.startPolling();
40});
41