1
|
define([
|
2
|
'dojo/_base/declare',
|
3
|
'dijit/layout/TabContainer',
|
4
|
'dijit/layout/ContentPane',
|
5
|
'steam2/user'
|
6
|
], function(declare, TabContainer, ContentPane, user){
|
7
|
|
8
|
|
9
|
var Menu = declare('stabile.Menu', null, {
|
10
|
|
11
|
// dom ids of panes.
|
12
|
// ids: ["home", "servers", "images", "networks"],
|
13
|
// ids: ["home"],
|
14
|
|
15
|
constructor: function(args, node){
|
16
|
this.node = node;
|
17
|
|
18
|
var tabs = this.tabs = new TabContainer({
|
19
|
id: "tabContainer",
|
20
|
'class':"tabContainer"
|
21
|
});
|
22
|
|
23
|
this.homePane = this.getContentPane('home');
|
24
|
this.serversPane = this.getServersPane();
|
25
|
this.imagesPane = this.getImagesPane();
|
26
|
this.networksPane = this.getNetworksPane();
|
27
|
|
28
|
tabs.addChild(this.homePane);
|
29
|
tabs.addChild(this.serversPane);
|
30
|
tabs.addChild(this.imagesPane);
|
31
|
tabs.addChild(this.networksPane);
|
32
|
|
33
|
|
34
|
if(user.is_admin){
|
35
|
this.nodesPane = this.getNodesPane('nodes');
|
36
|
tabs.addChild(this.nodesPane);
|
37
|
require(['stabile/stores'], function(){
|
38
|
stores.nodes.fetch({query:{mac: "*"}}); // initialize store
|
39
|
});
|
40
|
}
|
41
|
|
42
|
tabs.placeAt(this.node);
|
43
|
tabs.startup();
|
44
|
},
|
45
|
|
46
|
// gets a new dijit content pane.
|
47
|
getContentPane: function(name){
|
48
|
var title = 'Dashboard';
|
49
|
//if (name == "servers") title = "machines";
|
50
|
//if (name == "images") title = "disks";
|
51
|
return new ContentPane({
|
52
|
id: name,
|
53
|
title: title,
|
54
|
href: "/stabile/static/html/" + name + ".html",
|
55
|
// we have a corresponding object For each pane,i.d.,home.init(), servers.init() ...
|
56
|
// is called onload
|
57
|
onLoad: function(){
|
58
|
window[name].init();
|
59
|
}
|
60
|
});
|
61
|
},
|
62
|
|
63
|
getServers2Pane: function(){
|
64
|
return new ContentPane({
|
65
|
title: 'Servers',
|
66
|
id: 'servers',
|
67
|
href: '/stabile/static/html/servers2.html',
|
68
|
onLoad: function(){
|
69
|
require(['steam2/ServersGrid'], function(ServersGrid){
|
70
|
var grid = new ServersGrid({}, 'servers2-grid');
|
71
|
grid.startup();
|
72
|
});
|
73
|
}
|
74
|
});
|
75
|
},
|
76
|
|
77
|
getServersPane: function(){
|
78
|
return new ContentPane({
|
79
|
title: 'Servers',
|
80
|
id: 'servers',
|
81
|
preload: true,
|
82
|
href: '/stabile/static/html/servers.html',
|
83
|
onLoad: function(){
|
84
|
require(['stabile/servers'], function(){
|
85
|
servers.init();
|
86
|
});
|
87
|
}
|
88
|
});
|
89
|
},
|
90
|
|
91
|
getImagesPane: function(){
|
92
|
return new ContentPane({
|
93
|
title: 'Images',
|
94
|
id: 'images',
|
95
|
preload: true,
|
96
|
href: '/stabile/static/html/images.html',
|
97
|
onLoad: function(){
|
98
|
require(['stabile/images'], function(){
|
99
|
images.init();
|
100
|
});
|
101
|
}
|
102
|
});
|
103
|
},
|
104
|
|
105
|
getNetworksPane: function(){
|
106
|
return new ContentPane({
|
107
|
title: 'Connections',
|
108
|
id: 'networks',
|
109
|
preload: true,
|
110
|
href: '/stabile/static/html/networks.html',
|
111
|
onLoad: function(){
|
112
|
require(['stabile/networks'], function(){
|
113
|
networks.init();
|
114
|
});
|
115
|
}
|
116
|
});
|
117
|
},
|
118
|
|
119
|
getNodesPane: function(){
|
120
|
return new ContentPane({
|
121
|
title: 'Nodes',
|
122
|
id: 'nodes',
|
123
|
href: '/stabile/static/html/nodes.html',
|
124
|
onLoad: function(){
|
125
|
require(['stabile/nodes'], function(){
|
126
|
nodes.init();
|
127
|
});
|
128
|
}
|
129
|
});
|
130
|
},
|
131
|
|
132
|
add: function(){
|
133
|
// adds the menu to the dom, if the user has no servers the welcome tab is shown.
|
134
|
|
135
|
// wrapped in functions to get the count of servers
|
136
|
// from the async datastore
|
137
|
|
138
|
// add as first tab ...
|
139
|
}
|
140
|
});
|
141
|
|
142
|
var menu = new Menu({}, "tabs");
|
143
|
window.menu = menu;
|
144
|
return menu;
|
145
|
|
146
|
});
|