make tenantview method reslient of users with no site, catch users with no site in...
[plstackapi.git] / planetstack / core / xoslib / static / js / test.js
1 TestApp = new XOSApplication();
2
3 TestApp.addRegions({
4     deploymentList: "#deploymentList",
5     imageList: "#imageList",
6     networkTemplateList: "#networkTemplateList",
7     networkList: "#networkList",
8     nodeList: "#nodeList",
9     serviceList: "#serviceList",
10     siteList: "#siteList",
11     sliceList: "#sliceList",
12     sliverList: "#sliverList",
13     userList: "#userList",
14     detail: "#detail",
15     linkedObjs1: "#linkedObjs1",
16     linkedObjs2: "#linkedObjs2",
17     linkedObjs3: "#linkedObjs3",
18     linkedObjs4: "#linkedObjs4"
19 });
20
21 //TestApp.navigateToDetail = function(detailView) {
22 //     $(TestApp.detailBoxId).show();\r
23 //     TestApp.detail.show(detailView);\r
24 //};\r
25 \r
26 TestApp.navigateToModel = function(app, detailClass, detailNavLink, model) {\r
27 \r
28     var detailView = new detailClass({\r
29         model: model,\r
30     });\r
31 \r
32     $(app.detailBoxId).show();\r
33     app.detail.show(detailView);\r
34     detailView.showLinkedItems();\r
35 };\r
36 \r
37 TestApp.on("start", function() {\r
38      var objs = ['deployment', 'image', 'networkTemplate', 'network', 'networkSliver', 'networkDeployment', 'node', 'service', 'site', 'slice', 'sliceDeployment', 'slicePrivilege', 'sliver', 'user', 'sliceRole', 'userDeployment'];
39
40      for (var index in objs) {
41          name = objs[index];
42          tr_template = '#xosAdmin-' + name + '-listitem-template';
43          table_template = '#xosAdmin-' + name + '-list-template';
44          detail_template = '#xosAdmin-' + name + '-detail-template';
45          collection_name = name + "s";
46          region_name = name + "List";
47
48          detailClass = XOSDetailView.extend({
49             template: detail_template,\r
50             app: TestApp,\r
51          });\r
52
53          itemViewClass = XOSItemView.extend({
54              detailClass: detailClass,
55              template: tr_template,
56              app: TestApp,
57          });
58
59          listViewClass = XOSListView.extend({
60              childView: itemViewClass,
61              template: table_template,
62              collection: xos[collection_name],
63              title: name + "s",
64              app: TestApp,
65          });
66          TestApp[collection_name + "ListView"] = listViewClass;
67
68          var listView = new listViewClass();
69
70          if (region_name in TestApp.getRegions()) {
71              TestApp[region_name].show(listView);
72          }
73          xos[collection_name].fetch(); //startPolling();
74      }
75
76      $('#close-detail-view').unbind().bind('click', function() {
77          $('#detailBox').hide();
78      });
79 });
80
81 $(document).ready(function(){
82     TestApp.start();
83 });
84