Scott Baker | ac868ac | 2014-07-15 10:29:17 -0700 | [diff] [blame] | 1 | /* 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"); |
Scott Baker | e0e407a | 2015-01-20 17:02:53 -0800 | [diff] [blame] | 15 | role = row.get("sliceInfo").roles[0] || ""; |
Scott Baker | ac868ac | 2014-07-15 10:29:17 -0700 | [diff] [blame] | 16 | slivercount = row.get("sliceInfo").sliverCount; |
| 17 | sitecount = row.get("sliceInfo").siteCount; |
Scott Baker | 00363ea | 2014-08-28 14:47:29 -0700 | [diff] [blame] | 18 | backendHtml = row.get("backendHtml") |
Scott Baker | 2dd4a00 | 2014-07-15 10:38:06 -0700 | [diff] [blame] | 19 | |
Scott Baker | e0e407a | 2015-01-20 17:02:53 -0800 | [diff] [blame] | 20 | //if (! role) { |
| 21 | // continue; |
| 22 | //} |
| 23 | |
| 24 | if (! row.get("current_user_can_see") ) { |
Scott Baker | 2dd4a00 | 2014-07-15 10:38:06 -0700 | [diff] [blame] | 25 | continue; |
| 26 | } |
| 27 | |
Scott Baker | 00363ea | 2014-08-28 14:47:29 -0700 | [diff] [blame] | 28 | actualEntries.push([backendHtml + ' <a href="/admin/core/slice/' + sliceid + '">' + slicename + '</a>', |
Scott Baker | ac868ac | 2014-07-15 10:29:17 -0700 | [diff] [blame] | 29 | role, slivercount, sitecount]); |
| 30 | } |
| 31 | oTable = $('#dynamicusersliceinfo').dataTable( { |
| 32 | "bJQueryUI": true, |
| 33 | "aaData": actualEntries , |
| 34 | "bStateSave": true, |
| 35 | "aoColumns": [ |
| 36 | { "sTitle": "Slice" }, |
| 37 | { "sTitle": "Privilege" , sClass: "alignCenter"}, |
| 38 | { "sTitle": "Number of Slivers" , sClass: "alignCenter"}, |
| 39 | { "sTitle": "Number of Sites" , sClass: "alignCenter"}, |
| 40 | ] |
| 41 | } ); |
| 42 | } |
| 43 | |
| 44 | $(document).ready(function(){ |
Scott Baker | 48c52bb | 2014-07-15 11:23:03 -0700 | [diff] [blame] | 45 | xos.slicesPlus.on("change", function() { /*console.log("change");*/ updateSliceTable(xos.slicesPlus); }); |
| 46 | xos.slicesPlus.on("remove", function() { /*console.log("sort");*/ updateSliceTable(xos.slicesPlus); }); |
| 47 | xos.slicesPlus.on("sort", function() { /*console.log("sort");*/ updateSliceTable(xos.slicesPlus); }); |
Scott Baker | ac868ac | 2014-07-15 10:29:17 -0700 | [diff] [blame] | 48 | |
| 49 | xos.slicesPlus.startPolling(); |
| 50 | }); |
| 51 | |