|
|
|
1 |
/* global console MyError dojo dojox dijit umc */ |
2 |
|
3 |
dojo.provide("umc.modules.mrtg"); |
4 |
|
5 |
dojo.require("umc.i18n"); |
6 |
dojo.require("umc.widgets.ContainerWidget"); |
7 |
dojo.require("umc.widgets.Module"); |
8 |
dojo.require("umc.widgets.Page"); |
9 |
dojo.require("umc.widgets.Text"); |
10 |
dojo.require("umc.widgets.ExpandingTitlePane"); |
11 |
dojo.require("umc.widgets.ContainerForm"); |
12 |
dojo.require("umc.widgets.TabbedModule"); |
13 |
dojo.require("dojox.layout.TableContainer"); |
14 |
dojo.require("dojox.string.sprintf"); |
15 |
|
16 |
// Inheriting from umc.widgets.TabbedModule so any pages being added |
17 |
// will become tabs automatically. |
18 |
dojo.declare("umc.modules.mrtg", [ umc.widgets.TabbedModule, umc.i18n.Mixin ], { |
19 |
|
20 |
_page: null, |
21 |
_form: null, |
22 |
|
23 |
// TODO should be set in the base class -> then remove it here. |
24 |
nested: true, // my tabs are 2nd level |
25 |
|
26 |
i18nClass: 'umc.modules.mrtg', |
27 |
|
28 |
buildRendering: function() { |
29 |
this.inherited(arguments); |
30 |
|
31 |
// key ...... the file name stub for all images on this tab |
32 |
// label .... the label of the tab itself |
33 |
// heading .. page heading of the tab contents |
34 |
// desc ..... help text (switchable) |
35 |
var page_setup = [ |
36 |
{ |
37 |
key: "0load", |
38 |
label: this._("Load"), |
39 |
heading: this._("System load"), |
40 |
desc: this._("System load in percent") |
41 |
}, |
42 |
{ |
43 |
key: "1sessions", |
44 |
label: this._("Sessions"), |
45 |
heading: this._("Terminal server sessions"), |
46 |
desc: this._("Number of active terminal server sessions") |
47 |
}, |
48 |
{ |
49 |
key: "2mem", |
50 |
label: this._("Memory"), |
51 |
heading: this._("Memory usage"), |
52 |
desc: this._("Utilization of system memory in percent") |
53 |
}, |
54 |
{ |
55 |
key: "3swap", |
56 |
label: this._("Swap"), |
57 |
heading: this._("Swap space"), |
58 |
desc: this._("Utilization of swap space in percent") |
59 |
} |
60 |
]; |
61 |
|
62 |
// key ...... file name stub (2nd part) for the corresponding PNG image |
63 |
// label .... how to label this image |
64 |
var tab_setup = [ |
65 |
{ |
66 |
key: "day", |
67 |
label: this._("previous day") |
68 |
}, |
69 |
{ |
70 |
key: "week", |
71 |
label: this._("previous week") |
72 |
}, |
73 |
{ |
74 |
key: "month", |
75 |
label: this._("previous month") |
76 |
}, |
77 |
{ |
78 |
key: "year", |
79 |
label: this._("previous year") |
80 |
} |
81 |
]; |
82 |
|
83 |
// Build tabs and attach them to page |
84 |
for (var idx=0; idx<page_setup.length; idx++) |
85 |
{ |
86 |
var tab = new umc.widgets.Page({ |
87 |
title: page_setup[idx].label, |
88 |
headerText: page_setup[idx].heading, |
89 |
helpText: page_setup[idx].desc, |
90 |
closable: false |
91 |
}); |
92 |
this.addChild(tab); |
93 |
|
94 |
// Title pane without rollup/down |
95 |
var cont = new umc.widgets.ExpandingTitlePane({ |
96 |
title: this._("Statistics") |
97 |
}); |
98 |
tab.addChild(cont); |
99 |
|
100 |
// ExpandingTitlePane doesn't honor 'scrollable' |
101 |
// but we might need it |
102 |
var scroll = new umc.widgets.ContainerWidget({ |
103 |
scrollable: true |
104 |
}); |
105 |
cont.addChild(scroll); |
106 |
|
107 |
// three-column grid layout |
108 |
var grid = new dojox.layout.TableContainer({ |
109 |
cols: 3 |
110 |
}); |
111 |
scroll.addChild(grid); |
112 |
for (var i=0; i<tab_setup.length; i++) |
113 |
{ |
114 |
grid.addChild(new dijit.layout.ContentPane({ |
115 |
content: dojox.string.sprintf( |
116 |
"<h1 style='white-space:nowrap;'>%s: %s<h1>", |
117 |
this._("Period"), |
118 |
tab_setup[i].label) |
119 |
})); |
120 |
grid.addChild(new dijit.layout.ContentPane({ |
121 |
content: dojox.string.sprintf( |
122 |
"<img src='/statistik/ucs_%s-%s.png'>", |
123 |
page_setup[idx].key, |
124 |
tab_setup[i].key) |
125 |
})); |
126 |
// third column used as spacer |
127 |
grid.addChild(new dijit.layout.ContentPane({ |
128 |
content: ' ' |
129 |
})); |
130 |
} |
131 |
} |
132 |
} |
133 |
}); |