1 OBJS = ['deployment', 'image', 'networkTemplate', 'network', 'networkSliver', 'networkDeployment', 'node', 'service', 'site', 'slice', 'sliceDeployment', 'slicePrivilege', 'sliver', 'user', 'sliceRole', 'userDeployment'];
2 NAV_OBJS = ['deployment', 'site', 'slice', 'user'];
4 function assert(outcome, description) {
6 console.log(description);
10 XOSAdminApp = new XOSApplication();
12 XOSAdminApp.addRegions({
13 navigation: "#navigationPanel",
16 linkedObjs1: "#linkedObjs1",
17 linkedObjs2: "#linkedObjs2",
18 linkedObjs3: "#linkedObjs3",
19 linkedObjs4: "#linkedObjs4"
22 XOSAdminApp.navigateToModel = function(app, detailClass, detailNavLink, model) {
23 XOSAdminApp.Router.navigate(detailNavLink + "/" + model.id, {trigger: true});
26 XOSAdminApp.updateNavigationPanel = function() {
\r
27 buttonTemplate=$("#xos-navbutton").html();
\r
28 assert(buttonTemplate != undefined, "buttonTemplate is undefined");
\r
30 for (var index in NAV_OBJS) {
\r
31 name = NAV_OBJS[index];
\r
32 collection_name = name+"s";
\r
33 nav_url = "/" + collection_name;
\r
36 html = html + _.template(buttonTemplate, {name: collection_name, router: "XOSAdminApp.Router", routeUrl: nav_url});
\r
39 $("#navigationPanel").html(html);
\r
42 XOSAdminApp.buildViews = function() {
\r
43 for (var index in OBJS) {
\r
45 tr_template = '#xosAdmin-' + name + '-listitem-template';
46 table_template = '#xosAdmin-' + name + '-list-template';
47 detail_template = '#xosAdmin-' + name + '-detail-template';
48 collection_name = name + "s";
49 region_name = name + "List";
50 detailNavLink = collection_name;
52 detailClass = XOSDetailView.extend({
53 template: detail_template,
\r
56 XOSAdminApp[collection_name + "DetailView"] = detailClass;
\r
58 itemViewClass = XOSItemView.extend({
59 detailClass: detailClass,
60 template: tr_template,
62 detailNavLink: detailNavLink,
65 listViewClass = XOSListView.extend({
66 childView: itemViewClass,
67 template: table_template,
68 collection: xos[collection_name],
73 XOSAdminApp[collection_name + "ListView"] = listViewClass;
75 xos[collection_name].fetch(); //startPolling();
79 XOSAdminApp.initRouter = function() {
\r
80 router = Marionette.AppRouter.extend({
\r
86 function listViewShower(listViewName) {
\r
88 XOSAdminApp.detail.show(new XOSAdminApp[listViewName]);
\r
92 function detailShower(detailName, collection_name) {
\r
93 shower = function(model_id) {
\r
94 model = xos[collection_name].get(model_id);
\r
95 if (model == undefined) {
\r
96 $("#detail").html("not ready yet");
\r
99 detailViewClass = XOSAdminApp[detailName];
\r
100 detailView = new detailViewClass({model: model});
\r
101 XOSAdminApp.detail.show(detailView);
\r
102 detailView.showLinkedItems();
\r
107 for (var index in OBJS) {
\r
108 name = OBJS[index];
\r
109 collection_name = name + "s";
\r
110 nav_url = collection_name;
\r
111 api_command = "list" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1);
\r
112 listViewName = collection_name + "ListView";
\r
113 detailViewName = collection_name + "DetailView";
\r
115 api[api_command] = listViewShower(listViewName);
\r
116 routes[nav_url] = api_command;
\r
118 nav_url = collection_name + "/:id";
\r
119 api_command = "detail" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1);
\r
121 api[api_command] = detailShower(detailViewName, collection_name);
\r
122 routes[nav_url] = api_command;
\r
125 XOSAdminApp.Router = new router({ appRoutes: routes, controller: api });
\r
128 XOSAdminApp.on("start", function() {
\r
129 XOSAdminApp.buildViews();
131 XOSAdminApp.initRouter();
133 XOSAdminApp.updateNavigationPanel();
135 if (Backbone.history) {
136 console.log("history start");
137 Backbone.history.start();
141 $(document).ready(function(){