<script type="text/template" id="developer-slicetable-template">
<thead>\r
<tr class='header'>\r
- <th>Slice</th>\r
- <th>Privilege</th>\r
- <th>Number of Slivers</th>\r
- <th>Number of Sites</th>\r
+ <th>Slice <span class="sort" id="sort-asc-name">▲</span><span class="sort" id="sort-desc-name">▼</span></th>\r
+ <th>Privilege<span class="sort" id="sort-asc-sliceInfo.roles">▲</span><span class="sort" id="sort-desc-sliceInfo.roles">▼</span></th>\r
+ <th>Number of Slivers<span class="sort" id="sort-asc-sliceInfo.sliverCount">▲</span><span class="sort" id="sort-desc-sliceInfo.sliverCount">▼</span></th>\r
+ <th>Number of Sites<span class="sort" id="sort-asc-sliceInfo.siteCount">▲</span><span class="sort" id="sort-desc-sliceInfo.siteCount">▼</span></th>\r
</tr>\r
</thead>\r
<tbody>\r
</script>
<script type="text/template" id="developer-slicedetail-template">
- <td><%= name %></td><td><%= sliceInfo.roles[0] %></td><td><%= sliceInfo.sliverCount %></td><td><%= sliceInfo.siteCount %></td>\r
-</script>
+ <td><a href="http://{{request.get_host}}/admin/core/slice/<%= id %>/"><%= name %></a></td><td><%= sliceInfo.roles[0] %></td><td><%= sliceInfo.sliverCount %></td><td><%= sliceInfo.siteCount %></td>\r
+</script>\r
className: 'developer_slicedetail'\r
});
-/*
-DeveloperApp.SliceListView = Marionette.CollectionView.extend({
- tagName: "table",\r
- className: "table table-hover",\r
- template: "#developer-slicetable-template",\r
- childView: DeveloperApp.SliceDetailView,\r
-});\r
-*/\r
-\r
-DeveloperApp.SliceListView = Marionette.CompositeView.extend({\r
+DeveloperApp.SliceListView = Marionette.CompositeView.extend({
tagName: "table",\r
className: "table-striped table-bordered",\r
template: "#developer-slicetable-template",\r
childView: DeveloperApp.SliceDetailView,\r
childViewContainer: "tbody",\r
+\r
+ events: {"click .sort": "changeSort"},\r
+\r
+ changeSort: function(e) {\r
+ parts=$(e.currentTarget).attr("id").split('-');\r
+ order=parts[1];\r
+ fieldName=parts[2];\r
+ console.log(fieldName);\r
+ this.collection.sortVar = fieldName;\r
+ this.collection.sortOrder = order;\r
+ this.collection.sort();\r
+ }\r
});\r
DeveloperApp.on("start", function() {
});\r
console.log(developerSliceListView);\r
DeveloperApp.mainRegion.show(developerSliceListView);\r
- xos.slicesPlus.startPolling(); //fetch();\r
+ xos.slicesPlus.startPolling();\r
});
$(document).ready(function(){
return this.models.map(function(element) { return element.attributes; });
},
- startPolling: function() {
+ initialize: function(){
+ this.sortVar = 'name';\r
+ this.sortOrder = 'asc';\r
+ },\r
+\r
+ simpleComparator: function( model ){\r
+ parts=this.sortVar.split(".");\r
+ result = model.get(parts[0]);\r
+ for (index=1; index<parts.length; ++index) {\r
+ result=result[parts[index]];\r
+ }\r
+ return result;\r
+ },\r
+\r
+ comparator: function (left, right) {\r
+ var l = this.simpleComparator(left);\r
+ var r = this.simpleComparator(right);\r
+\r
+ if (l === void 0) return -1;\r
+ if (r === void 0) return 1;\r
+\r
+ if (this.sortOrder=="desc") {\r
+ return l < r ? 1 : l > r ? -1 : 0;\r
+ } else {\r
+ return l < r ? -1 : l > r ? 1 : 0;\r
+ }\r
+ },\r
+\r
+ startPolling: function() {\r
if (!this._polling) {
collection=this;
setInterval(function() { console.log(collection); collection.fetch(); }, 10000);