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 XOSAdminApp = new XOSApplication({logTableId: "#logTable"});
6 XOSAdminApp.addRegions({
7 navigation: "#navigationPanel",
10 linkedObjs1: "#linkedObjs1",
11 linkedObjs2: "#linkedObjs2",
12 linkedObjs3: "#linkedObjs3",
13 linkedObjs4: "#linkedObjs4"
16 XOSAdminApp.navigateToModel = function(app, detailClass, detailNavLink, model) {
17 XOSAdminApp.Router.navigate(detailNavLink + "/" + model.id, {trigger: true});
20 ICON_CLASSES = {home: "icon-home", deployments: "icon-deployment", sites: "icon-site", slices: "icon-slice", users: "icon-user"};
\r
22 XOSAdminApp.updateNavigationPanel = function() {
\r
23 buttonTemplate=$("#xos-navbutton").html();
\r
24 assert(buttonTemplate != undefined, "buttonTemplate is undefined");
\r
25 html="<div class='left-nav'><ul>";
\r
26 for (var index in NAV_OBJS) {
\r
27 name = NAV_OBJS[index];
\r
28 collection_name = name+"s";
\r
29 nav_url = "#" + collection_name;
\r
31 icon_class = ICON_CLASSES[collection_name] || "icon-cog";
\r
33 html = html + _.template(buttonTemplate, {name: collection_name, router: "XOSAdminApp.Router", routeUrl: nav_url, iconClass: icon_class});
\r
36 html = html + "</ul>";
\r
38 $("#navigationPanel").html(html);
\r
41 XOSAdminApp.buildViews = function() {
\r
42 for (var index in OBJS) {
\r
44 tr_template = '#xosAdmin-' + name + '-listitem-template';
45 table_template = '#xosAdmin-' + name + '-list-template';
46 detail_template = '#xosAdmin-' + name + '-detail-template';
47 collection_name = name + "s";
48 region_name = name + "List";
49 detailNavLink = collection_name;
51 detailClass = XOSDetailView.extend({
52 template: detail_template,
\r
55 XOSAdminApp[collection_name + "DetailView"] = detailClass;
\r
57 itemViewClass = XOSItemView.extend({
58 detailClass: detailClass,
59 template: tr_template,
61 detailNavLink: detailNavLink,
64 listViewClass = XOSListView.extend({
65 childView: itemViewClass,
66 template: table_template,
67 collection: xos[collection_name],
72 XOSAdminApp[collection_name + "ListView"] = listViewClass;
74 xos[collection_name].fetch(); //startPolling();
78 XOSAdminApp.initRouter = function() {
\r
79 router = Marionette.AppRouter.extend({
\r
85 for (var index in OBJS) {
\r
87 collection_name = name + "s";
\r
88 nav_url = collection_name;
\r
89 api_command = "list" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1);
\r
90 listViewName = collection_name + "ListView";
\r
91 detailViewName = collection_name + "DetailView";
\r
93 api[api_command] = XOSAdminApp.listViewShower(listViewName, "detail");
\r
94 routes[nav_url] = api_command;
\r
96 nav_url = collection_name + "/:id";
\r
97 api_command = "detail" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1);
\r
99 api[api_command] = XOSAdminApp.detailShower(detailViewName, collection_name, "detail");
\r
100 routes[nav_url] = api_command;
\r
103 XOSAdminApp.Router = new router({ appRoutes: routes, controller: api });
\r
106 XOSAdminApp.on("start", function() {
\r
107 XOSAdminApp.buildViews();
109 XOSAdminApp.initRouter();
111 XOSAdminApp.updateNavigationPanel();
113 if (Backbone.history) {
114 console.log("history start");
115 Backbone.history.start();
119 $(document).ready(function(){