X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fxoslib%2Fstatic%2Fjs%2FxosDeveloper.js;h=aef640ec2293d8d3877592958097da39f752137c;hb=23728671481acb47aee46826a35e8dca289ed8d1;hp=94749f1a5fb6c4c4027858be5982a242b5224f5e;hpb=5dfd5020e947729d26e7f0dbb90ea8dfd9b33397;p=plstackapi.git diff --git a/planetstack/core/xoslib/static/js/xosDeveloper.js b/planetstack/core/xoslib/static/js/xosDeveloper.js index 94749f1..aef640e 100644 --- a/planetstack/core/xoslib/static/js/xosDeveloper.js +++ b/planetstack/core/xoslib/static/js/xosDeveloper.js @@ -1,4 +1,10 @@ -DeveloperApp = new Marionette.Application(); +/* This is an example that uses xoslib + marionette to display the developer + view. + + For an example that uses xoslib + datatables, see xosDeveloper_datatables.js + */ + + DeveloperApp = new Marionette.Application(); DeveloperApp.addRegions({ mainRegion: "#developerView" @@ -12,29 +18,40 @@ DeveloperApp.SliceDetailView = Marionette.ItemView.extend({ DeveloperApp.SliceListView = Marionette.CompositeView.extend({ tagName: "table", - className: "table table-bordered", + className: "table table-bordered table-striped", template: "#developer-slicetable-template", childView: DeveloperApp.SliceDetailView, childViewContainer: "tbody", events: {"click .sort": "changeSort"}, + initialize: function() { + this.listenTo(this.collection, 'change', this._renderChildren); + }, + changeSort: function(e) { parts=$(e.currentTarget).attr("id").split('-'); order=parts[1]; fieldName=parts[2]; - console.log(fieldName); this.collection.sortVar = fieldName; this.collection.sortOrder = order; this.collection.sort(); - } + }, + + attachHtml: function(compositeView, childView, index) { + // The REST API will let admin users see everything. For the developer + // view we still want to hide slices we are not members of. + if (childView.model.get("sliceInfo").roles.length == 0) { + return; + } + DeveloperApp.SliceListView.__super__.attachHtml(compositeView, childView, index); + }, }); DeveloperApp.on("start", function() { var developerSliceListView = new DeveloperApp.SliceListView({ collection: xos.slicesPlus }); - console.log(developerSliceListView); DeveloperApp.mainRegion.show(developerSliceListView); xos.slicesPlus.startPolling(); });