-function assert(outcome, description) {
- if (!outcome) {
- console.log(description);
- }
-}
-
-function templateFromId(id) {
- return _.template($(id).html());
-}
-
-function firstCharUpper(s) {
- return s.charAt(0).toUpperCase() + s.slice(1);
-}
-
HTMLView = Marionette.ItemView.extend({
render: function() {
this.$el.append(this.options.html);
},
});
+XOSRouter = Marionette.AppRouter.extend({
+ initialize: function() {\r
+ this.routeStack=[];\r
+ },\r
+\r
+ onRoute: function(x,y,z) {\r
+ this.routeStack.push(Backbone.history.fragment);\r
+ },\r
+\r
+ prevPage: function() {\r
+ return this.routeStack.slice(-2)[0];
+ },
+ });\r
+
+
+
XOSApplication = Marionette.Application.extend({
detailBoxId: "#detailBox",
errorBoxId: "#errorBox",
}
},
+ deleteShower: function(collection_name) {
+ var app=this;
+ return function(model_id) {
+ console.log("deleteCalled");
+ collection = xos[collection_name];
+ model = collection.get(model_id);
+ assert(model!=undefined, "failed to get model " + model_id + " from collection " + collection_name);
+ app.deleteDialog(model,"back");
+ }
+ },
+
detailShower: function(detailName, collection_name, regionName, title) {
var app=this;
showModelId = function(model_id) {
saveSuccess: function(model, result, xhr, infoMsgId, addToCollection) {
console.log("saveSuccess");
- if (addToCollection) {
- addToCollection.add(model);
- addToCollection.sort();
+ if (model.addToCollection) {
+ console.log("addToCollection");
+ model.addToCollection.add(model);
+ model.addToCollection.sort();
+ model.addToCollection = undefined;
}
result = {status: xhr.xhr.status, statusText: xhr.xhr.statusText};
result["what"] = "save " + model.modelName + " " + model.attributes.humanReadableName;
success: function(model, result, xhr) { that.destroySuccess(model,result,xhr,infoMsgId);}});
},
- deleteDialog: function(model, navToListAfterDelete) {
+ deleteDialog: function(model, afterDelete) {
var that=this;
+ console.log("XXX");
+ console.log(Backbone.history.fragment);
+ assert(model!=undefined, "deleteDialog's model is undefined");
//console.log("deleteDialog"); console.log(model);
this.confirmDialog(null, null, function() {
//console.log("deleteConfirm"); console.log(model);
modelName = model.modelName;
that.destroyModel(model);
- if (navToListAfterDelete) {
+ if (afterDelete=="list") {
that.navigate("list", modelName);
+ } else if (afterDelete=="back") {
+ prevPage = that.Router.prevPage();
+ if (prevPage) {
+ that.Router.navigate("#"+prevPage, {trigger: false, replace: true} );
+ }
}
});
deleteClicked: function(e) {
e.preventDefault();
- this.app.deleteDialog(this.model, true);
+ this.app.deleteDialog(this.model, "list");
},
tabClick: function(tabId, regionName) {
</script>
<script type="text/template" id="xos-delete-button-template">
- <a href="#delete?model=<%= modelName %>&id=<%= id %>">delete</a>
-</script>
-
-<script type="text/template" id="xos-delete-button-template">
- <a href="#delete?model=<%= modelName %>&id=<%= id %>">delete</a>
+ <a href="#delete<%= firstCharUpper(modelName) %>/<%= id %>">delete</a>
</script>
<script type="text/template" id="xos-detail-link-template">
<th>disk_format</th>
<th>container_format</th>
<th>path</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= disk_format %></td>
<td><%= container_format %></td>
<td><%= path %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-image-detail-template">
<th>translation</th>
<th>sharedNetworkName</th>
<th>sharedNetworkId</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= translation %></td>
<td><%= sharedNetworkName %></td>
<td><%= sharedNetworkId %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-networkTemplate-detail-template">
<th>ports</th>
<th>labels</th>
<th>owner</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= ports %></td>
<td><%= labels %></td>
<td><%= idToName(owner,"slices","name") %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-network-detail-template">
<th>sliver</th>
<th>ip</th>
<th>port_id</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(sliver,"slivers","name") %></td>
<td><%= ip %></td>
<td><%= port_id %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-networkSliver-detail-template">
<th>network</th>
<th>deployment</th>
<th>net_id</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(network,"networks","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= net_id %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-networkDeployment-detail-template">
<th>name</th>
<th>site</th>
<th>deployment</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: name}) %></td>
<td><%= idToName(site,"sites","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-node-detail-template">
<thead><tr>
<th>id</th>
<th>role</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<script type="text/template" id="xosAdmin-sliceRole-listitem-template">
<td> <%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: id}) %></td>
<td><%= role %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-sliceRole-detail-template">
<th>enabled</th>
<th>versionNumber</th>
<th>published</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= enabled %></td>
<td><%= versionNumber %></td>
<td><%= published %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-service-detail-template">
<th>login_base</th>
<th>is_public</th>
<th>abbreviated_name</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= login_base %></td>
<td><%= is_public %></td>
<td><%= abbreviated_name %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-site-detail-template">
<th>site</th>
<th>max_slivers</th>
<th>service</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(site,"sites","name") %></td>
<td><%= max_slivers %></td>
<td><%= idToName(service,"services","name") %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-slice-detail-template">
<th>slice</th>
<th>deployment</th>
<th>tenant_id</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(slice,"slices","name") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= tenant_id %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-sliceDeployment-detail-template">
<th>user</th>
<th>slice</th>
<th>role</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(user,"users","username") %></td>
<td><%= idToName(slice,"slices","name") %></td>
<td><%= idToName(role,"sliceRoles","role") %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-slicePrivilege-detail-template">
<th>deploymentNetwork</th>
<th>flavor</th>
<th>userData</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(deploymentNetwork,"deployments","name") %></td>
<td><%= flavor %></td>
<td><%= userData %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-sliver-detail-template">
<th>phone</th>
<th>user_url</th>
<th>site</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= phone %></td>
<td><%= user_url %></td>
<td><%= idToName(site,"sites","name") %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-user-detail-template">
<th>user</th>
<th>deployment</th>
<th>kuser_id</th>
+ <th>delete</th>
</tr></thead>
<tbody></tbody>
</table>
<td><%= idToName(user,"users","username") %></td>
<td><%= idToName(deployment,"deployments","name") %></td>
<td><%= kuser_id %></td>
+ <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
</script>
<script type="text/template" id="xosAdmin-userDeployment-detail-template">