1 |
|
/* ************************************************************************
|
2 |
|
|
3 |
|
Vigigraph User Interface
|
4 |
|
Copyright: 2007-2009 CS-SI <http://www.c-s.fr>
|
5 |
|
|
6 |
|
License: GPLv2+
|
7 |
|
|
8 |
|
Authors: Arnaud MAZIN <arnaud.mazin@c-s.fr>
|
9 |
|
Aurelien BOMPARD <aurelien.bompard@c-s.fr>
|
10 |
|
Thomas BURGUIERE <thomas.burguiere@c-s.fr>
|
11 |
|
Francis LAHEUGUERE <francis.laheuguere@c-s.fr>
|
12 |
|
|
13 |
|
This program is free software; you can redistribute it and/or modify
|
14 |
|
it under the terms of the GNU General Public License as published by
|
15 |
|
the Free Software Foundation; either version 2 of the License, or
|
16 |
|
(at your option) any later version.
|
17 |
|
|
18 |
|
This program is distributed in the hope that it will be useful,
|
19 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
|
GNU General Public License for more details.
|
22 |
|
|
23 |
|
You should have received a copy of the GNU General Public License
|
24 |
|
along with this program; if not, write to the Free Software
|
25 |
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
26 |
|
|
27 |
|
************************************************************************ */
|
28 |
|
|
29 |
|
/* ************************************************************************
|
30 |
|
|
31 |
|
//#require(qx.event.handler.DragAndDropHandler)
|
32 |
|
//#resource(vigigraph.image:image)
|
33 |
|
|
34 |
|
// List all static resources that should be copied into the build version,
|
35 |
|
// if the resource filter option is enabled (default: disabled)
|
36 |
|
//#embed(qx.icontheme/32/status/dialog-information.png)
|
37 |
|
//#embed(vigigraph.image/test.png)
|
38 |
|
|
39 |
|
************************************************************************ */
|
40 |
|
|
41 |
|
var urls = {
|
42 |
|
"exportCSV": "vigirrd/",
|
43 |
|
"getImage": "vigirrd/",
|
44 |
|
"getIndicators": "rpc/getIndicators",
|
45 |
|
"getStartTime": "vigirrd/",
|
46 |
|
"graphgroups": "rpc/graphgroups",
|
47 |
|
"graphs": "rpc/graphs",
|
48 |
|
"graphsList": "rpc/graphsList",
|
49 |
|
"hostgroups": "rpc/hostgroups",
|
50 |
|
"hosts": "rpc/hosts",
|
51 |
|
"maingroups": "rpc/maingroups",
|
52 |
|
"searchHostAndGraph": "rpc/searchHostAndGraph",
|
53 |
|
"selectHostAndGraph": "rpc/selectHostAndGraph",
|
54 |
|
"supPage": "nagios/",
|
55 |
|
"tempoDelayRefresh": "rpc/tempoDelayRefresh"
|
56 |
|
};
|
57 |
|
|
58 |
|
/**
|
59 |
|
* Main Application (based on the qooxdoo skeleton)
|
60 |
|
*/
|
61 |
|
qx.Class.define("vigigraph.Application",
|
62 |
|
{
|
63 |
|
extend : qx.application.Gui,
|
64 |
|
|
65 |
|
|
66 |
|
/*
|
67 |
|
*****************************************************************************
|
68 |
|
MEMBERS
|
69 |
|
*****************************************************************************
|
70 |
|
*/
|
71 |
|
|
72 |
|
members :
|
73 |
|
{
|
74 |
|
/**
|
75 |
|
* Main function.
|
76 |
|
*
|
77 |
|
* @type member
|
78 |
|
*/
|
79 |
|
main : function()
|
80 |
|
{
|
81 |
|
this.base(arguments);
|
82 |
|
|
83 |
|
// Define alias for vigigraph resource path
|
84 |
|
qx.io.Alias.getInstance().add("vigigraph", qx.core.Setting.get("vigigraph.resourceUri"));
|
85 |
|
|
86 |
|
// Change the window title
|
87 |
|
document.title = "VigiGraph";
|
88 |
|
|
89 |
|
// Host picker
|
90 |
|
var w1 = new qx.ui.window.Window(this.tr("Host Picker"), "icon/16/devices/network-wired.png");
|
91 |
|
w1.setSpace(20, 250, 48, 102);
|
92 |
|
w1.setShowClose(false);
|
93 |
|
w1.setShowMinimize(false);
|
94 |
|
w1.setShowMaximize(false);
|
95 |
|
w1.setResizable(false, false, false, false);
|
96 |
|
|
97 |
|
var gl = new qx.ui.layout.GridLayout;
|
98 |
|
gl.setDimension("auto", "auto");
|
99 |
|
gl.setColumnCount(4);
|
100 |
|
gl.setRowCount(5); //Number of rows in the main window
|
101 |
|
gl.setVerticalSpacing(4);
|
102 |
|
gl.setHorizontalSpacing(2);
|
103 |
|
|
104 |
|
gl.setColumnWidth(0, 100);
|
105 |
|
gl.setColumnWidth(1, 180);
|
106 |
|
gl.setColumnWidth(2, 18);
|
107 |
|
gl.setColumnWidth(3, 18);
|
108 |
|
|
109 |
|
//gl.setColumnHorizontalAlignment(0, "right");
|
110 |
|
gl.setColumnVerticalAlignment(0, "middle");
|
111 |
|
|
112 |
|
gl.setRowHeight(0, 20);
|
113 |
|
gl.setRowHeight(1, 20);
|
114 |
|
gl.setRowHeight(2, 20);
|
115 |
|
gl.setRowHeight(3, 20);
|
116 |
|
gl.setRowHeight(4, 20);
|
117 |
|
|
118 |
|
gl.add(new qx.ui.basic.Label(this.tr("Main Group")), 0, 0);
|
119 |
|
gl.add(new qx.ui.basic.Label(this.tr("Host Group")), 0, 1);
|
120 |
|
gl.add(new qx.ui.basic.Label(this.tr("Host Name")), 0, 2);
|
121 |
|
gl.add(new qx.ui.basic.Label(this.tr("Graph Group")), 0, 3);
|
122 |
|
gl.add(new qx.ui.basic.Label(this.tr("Graph Name")), 0, 4);
|
123 |
|
|
124 |
|
var combo1 = new qx.ui.form.ComboBox;
|
125 |
|
var combo2 = new qx.ui.form.ComboBox;
|
126 |
|
var combo3 = new qx.ui.form.ComboBox;
|
127 |
|
var combo4 = new qx.ui.form.ComboBox;
|
128 |
|
var combo5 = new qx.ui.form.ComboBox;
|
129 |
|
|
130 |
|
var r1=new qx.ui.form.Button("","icon/16/actions/view-refresh.png");
|
131 |
|
r1.setToolTip(new qx.ui.popup.ToolTip(this.tr("Refresh")));
|
132 |
|
var r2=new qx.ui.form.Button("","icon/16/actions/view-refresh.png");
|
133 |
|
r2.setToolTip(new qx.ui.popup.ToolTip(this.tr("Refresh")));
|
134 |
|
var r3=new qx.ui.form.Button("","icon/16/actions/view-refresh.png");
|
135 |
|
r3.setToolTip(new qx.ui.popup.ToolTip(this.tr("Refresh")));
|
136 |
|
var r4=new qx.ui.form.Button("","icon/16/actions/view-refresh.png");
|
137 |
|
r4.setToolTip(new qx.ui.popup.ToolTip(this.tr("Refresh")));
|
138 |
|
var r5=new qx.ui.form.Button("","icon/16/actions/view-refresh.png");
|
139 |
|
r5.setToolTip(new qx.ui.popup.ToolTip(this.tr("Refresh")));
|
140 |
|
|
141 |
|
var b1=new qx.ui.form.Button("","icon/16/actions/zoom.png");
|
142 |
|
b1.setToolTip(new qx.ui.popup.ToolTip(this.tr("Search")));
|
143 |
|
var b3=new qx.ui.form.Button("","icon/16/actions/go-right.png");
|
144 |
|
b3.setToolTip(new qx.ui.popup.ToolTip(this.tr("Show Nagios page")));
|
145 |
|
b3.setEnabled(false);
|
146 |
|
var b5=new qx.ui.form.Button("","icon/16/actions/go-right.png");
|
147 |
|
b5.setToolTip(new qx.ui.popup.ToolTip(this.tr("Show graph")));
|
148 |
|
b5.setEnabled(false);
|
149 |
|
|
150 |
|
gl.add(r1,2,0);
|
151 |
|
gl.add(r2,2,1);
|
152 |
|
gl.add(r3,2,2);
|
153 |
|
gl.add(r4,2,3);
|
154 |
|
gl.add(r5,2,4);
|
155 |
|
|
156 |
|
gl.add(b1,3,0);
|
157 |
|
gl.add(b3,3,2);
|
158 |
|
gl.add(b5,3,4);
|
159 |
|
|
160 |
|
_updateServerGroupList();
|
161 |
|
|
162 |
|
var w2 = undefined;
|
163 |
|
|
164 |
|
function getIndexWindow (cdi, w)
|
165 |
|
{
|
166 |
|
// var cdi = qx.ui.core.ClientDocument.getInstance();
|
167 |
|
var index_l = -1;
|
168 |
|
if (cdi)
|
169 |
|
{
|
170 |
|
var nb = cdi.getChildren().length;
|
171 |
|
for (i = 0; i < nb; i++)
|
172 |
|
{
|
173 |
|
var c_l = cdi.getChildren()[i];
|
174 |
|
if (c_l)
|
175 |
|
{
|
176 |
|
if (c_l.name == "qx.ui.window.Window")
|
177 |
|
{
|
178 |
|
caption_l = c_l.getCaption();
|
179 |
|
if (c_l == w)
|
180 |
|
{
|
181 |
|
index_l = i;
|
182 |
|
}
|
183 |
|
}
|
184 |
|
}
|
185 |
|
}
|
186 |
|
}
|
187 |
|
return index_l;
|
188 |
|
}
|
189 |
|
|
190 |
|
// Buttons
|
191 |
|
bp = document.getElementById('print');
|
192 |
|
/// @XXX le addEventListener est ici celui du DOM (pas celui de qooxdoo)
|
193 |
|
/// Il faudrait migrer vers mootools et reprendre ce code pour assurer
|
194 |
|
/// la compatibilité avec les navigateurs n'ayant pas addEventListener
|
195 |
|
/// (ie: Internet Explorer).
|
196 |
|
bp.addEventListener("click",function(e) {
|
197 |
|
|
198 |
|
var graph_imgs = [];
|
199 |
|
var images = document.getElementsByTagName("img");
|
200 |
|
for (var i=0 ; i < images.length ; i++) {
|
201 |
|
if (images[i].parentNode.className == "graph") {
|
202 |
|
graph_imgs.push(images[i].src);
|
203 |
|
}
|
204 |
|
}
|
205 |
|
var print_url = urls.graphsList + "?";
|
206 |
|
for (var i=0 ; i < graph_imgs.length ; i++) {
|
207 |
|
if (i != 0) print_url += "&";
|
208 |
|
print_url += i + "=" + encodeURIComponent(graph_imgs[i]);
|
209 |
|
}
|
210 |
|
|
211 |
|
w2 = window.open(print_url);
|
212 |
|
w2.onload = function(){
|
213 |
|
w2.print();
|
214 |
|
}
|
215 |
|
e.stopPropagation();
|
216 |
|
e.preventDefault();
|
217 |
|
}, true);
|
218 |
|
|
219 |
|
b3.addEventListener("execute",function(e) {
|
220 |
|
var host = combo3.getSelected().getLabel();
|
221 |
|
var win = new qx.client.NativeWindow(urls.supPage+'/'+encodeURIComponent(host)
|
222 |
|
+'/cgi-bin/status.cgi?host='+encodeURIComponent(host)+'&style=detail&supNav=1');
|
223 |
|
win.setDimension(800,600);
|
224 |
|
win.setDependent(false);
|
225 |
|
win.open();
|
226 |
|
});
|
227 |
|
|
228 |
|
b5.addEventListener("execute",function(e) {
|
229 |
|
var host=combo3.getSelected().getLabel();
|
230 |
|
var graph=combo5.getSelected().getLabel();
|
231 |
|
this.openGraph(host, graph, null, null, true);
|
232 |
|
}, this);
|
233 |
|
|
234 |
|
b1.addEventListener("execute",function(e) {
|
235 |
|
var w_search = new qx.ui.window.Window(this.tr("Search"), "icon/16/actions/zoom.png");
|
236 |
|
w_search.addToDocument();
|
237 |
|
w_search.set({
|
238 |
|
showMinimize : false,
|
239 |
|
showMaximize : false,
|
240 |
|
resizable : true
|
241 |
|
});
|
242 |
|
var w_search_v = new qx.ui.layout.VerticalBoxLayout();
|
243 |
|
w_search_v.setWidth("100%");
|
244 |
|
w_search_v.setHeight("100%");
|
245 |
|
w_search_v.setHorizontalChildrenAlign("center");
|
246 |
|
w_search.add(w_search_v);
|
247 |
|
var w_search_h = new qx.ui.layout.HorizontalBoxLayout();
|
248 |
|
w_search_h.auto()
|
249 |
|
w_search_h.setVerticalChildrenAlign("middle");
|
250 |
|
w_search_h.setPadding(2, 5, 5, 5);
|
251 |
|
w_search_v.add(w_search_h);
|
252 |
|
w_search_h.add(new qx.ui.basic.Label(this.tr("Host:")));
|
253 |
|
var search_host = new qx.ui.form.TextField();
|
254 |
|
w_search_h.add(search_host);
|
255 |
|
search_host.setMarginRight(5);
|
256 |
|
search_host.setLiveUpdate(true);
|
257 |
|
search_host.tabIndex = 1;
|
258 |
|
search_host.setToolTip(new qx.ui.popup.ToolTip(this.tr("Search for a host (\"*\" for all, 100 max)")));
|
259 |
|
w_search_h.add(new qx.ui.basic.Label(this.tr("Graph:")));
|
260 |
|
var search_graph = new qx.ui.form.TextField();
|
261 |
|
w_search_h.add(search_graph);
|
262 |
|
search_graph.setMarginRight(5);
|
263 |
|
search_graph.setLiveUpdate(true);
|
264 |
|
search_graph.tabIndex = 2;
|
265 |
|
search_graph.setToolTip(new qx.ui.popup.ToolTip(this.tr("Search for a graph (\"*\" for all, 100 max)")));
|
266 |
|
var search_button=new qx.ui.form.Button("","icon/16/actions/zoom.png");
|
267 |
|
search_button.setWidth(20);
|
268 |
|
search_button.setHeight(20);
|
269 |
|
w_search_h.add(search_button);
|
270 |
|
var search_results_model = new qx.ui.table.model.Simple();
|
271 |
|
search_results_model.setColumns([ this.tr("Host"), this.tr("Graph") ]);
|
272 |
|
var custom = {
|
273 |
|
tableColumnModel :
|
274 |
|
function(obj)
|
275 |
|
{
|
276 |
|
return new qx.ui.table.columnmodel.Resize(obj);
|
277 |
|
}
|
278 |
|
};
|
279 |
|
var search_results = new qx.ui.table.Table(search_results_model, custom);
|
280 |
|
search_results.hide();
|
281 |
|
with (search_results) {
|
282 |
|
set({ left:0, top:0, right:0, bottom: 10, width:"95%", height:"90%", border:"inset-thin" });
|
283 |
|
//setMetaColumnCounts([1, -1]);
|
284 |
|
getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION);
|
285 |
|
setColumnVisibilityButtonVisible(false);
|
286 |
|
setStatusBarVisible(false);
|
287 |
|
var tcm = search_results.getTableColumnModel();
|
288 |
|
var resizeBehavior = tcm.getBehavior();
|
289 |
|
// This uses the set() method to set all attriutes at once; uses flex
|
290 |
|
resizeBehavior.set(0, { width:"1*", minWidth:40, maxWidth:180 });
|
291 |
|
resizeBehavior.set(1, { width:"1*", minWidth:40, maxWidth:180 });
|
292 |
|
|
293 |
|
//// We could also set them individually:
|
294 |
|
////resizeBehavior.setWidth(1, "50%");
|
295 |
|
////resizeBehavior.setMinWidth(1, 100);
|
296 |
|
////resizeBehavior.setMaxWidth(1, 320);
|
297 |
|
};
|
298 |
|
w_search_v.add(search_results);
|
299 |
|
//search_results.setLocation(10, 40);
|
300 |
|
function _searchResultsUpdater(host,graph,glass) {
|
301 |
|
var url = urls.searchHostAndGraph;
|
302 |
|
if (host && graph) {
|
303 |
|
url = url+"?host="+host+"&graph="+graph
|
304 |
|
} else if (host) {
|
305 |
|
url = url+"?host="+host;
|
306 |
|
} else if (graph) {
|
307 |
|
url = url+"?graph="+graph;
|
308 |
|
} else if (glass) {
|
309 |
|
url = url+"?graph=*";
|
310 |
|
}
|
311 |
|
|
312 |
|
|
313 |
|
search_results_model.setData([]);
|
314 |
|
var g=new qx.io.remote.Request(url,"GET","application/json");
|
315 |
|
g.addEventListener("completed", function(e) {
|
316 |
|
var rowData = [];
|
317 |
|
r=e.getContent().items;
|
318 |
|
for(var i=0,l=r.length ; i<l ; i++) // does not work in IE with "for (i in r)"
|
319 |
|
{
|
320 |
|
rowData.push(r[i]);
|
321 |
|
}
|
322 |
|
search_results_model.setData(rowData);
|
323 |
|
search_results.show();
|
324 |
|
//qx.log.Logger.ROOT_LOGGER.debug(rowData);
|
325 |
|
});
|
326 |
|
g.send();
|
327 |
|
}
|
328 |
|
function _chooseInCombos(host, host_main_group, host_sec_group, graph, graph_group) {
|
329 |
|
function _selectItem(o, item) {
|
330 |
|
var c_list = o.getList();
|
331 |
|
var c_item = c_list.findStringExact(item);
|
332 |
|
|
333 |
|
if (c_item) {
|
334 |
|
o.setSelected(c_item);
|
335 |
|
}
|
336 |
|
}
|
337 |
|
combo1.addEventListener("changeEnabled", function(e) {
|
338 |
|
if (e.getValue() == true) {
|
339 |
|
e.getTarget().removeEventListener("changeEnabled", arguments.callee);
|
340 |
|
_selectItem(e.getTarget(), host_main_group);
|
341 |
|
}
|
342 |
|
});
|
343 |
|
combo2.addEventListener("changeEnabled", function(e) {
|
344 |
|
if (e.getValue() == true) {
|
345 |
|
e.getTarget().removeEventListener("changeEnabled", arguments.callee);
|
346 |
|
_selectItem(e.getTarget(), host_sec_group);
|
347 |
|
}
|
348 |
|
});
|
349 |
|
combo3.addEventListener("changeEnabled", function(e) {
|
350 |
|
if (e.getValue() == true) {
|
351 |
|
e.getTarget().removeEventListener("changeEnabled", arguments.callee);
|
352 |
|
_selectItem(e.getTarget(), host);
|
353 |
|
}
|
354 |
|
});
|
355 |
|
if ((graph) && (graph_group)) {
|
356 |
|
combo4.addEventListener("changeEnabled", function(e) {
|
357 |
|
if (e.getValue() == true) {
|
358 |
|
e.getTarget().removeEventListener("changeEnabled", arguments.callee);
|
359 |
|
_selectItem(e.getTarget(), graph_group);
|
360 |
|
}
|
361 |
|
});
|
362 |
|
combo5.addEventListener("changeEnabled", function(e) {
|
363 |
|
if (e.getValue() == true) {
|
364 |
|
e.getTarget().removeEventListener("changeEnabled", arguments.callee);
|
365 |
|
_selectItem(e.getTarget(), graph);
|
366 |
|
}
|
367 |
|
});
|
368 |
|
}
|
369 |
|
_updateServerGroupList();
|
370 |
|
}
|
371 |
|
function _selectHostAndGraph(host, graph, mainObj)
|
372 |
|
{
|
373 |
|
var url = urls.selectHostAndGraph;
|
374 |
|
if (host && graph) {
|
375 |
|
url = url+"?host="+host+"&graph="+graph
|
376 |
|
} else if (host) {
|
377 |
|
url = url+"?host="+host
|
378 |
|
} else if (graph) {
|
379 |
|
url = url+"?graph="+graph
|
380 |
|
}
|
381 |
|
|
382 |
|
var g=new qx.io.remote.Request(url,"GET","application/json");
|
383 |
|
g.addEventListener("completed", function(e) {
|
384 |
|
r=e.getContent().items;
|
385 |
|
|
386 |
|
/// @XXX pour le moment, on suppose qu'il y a 2 SupItemGroup
|
387 |
|
/// dans la réponse. A terme, on devrait pouvoir en avoir plus.
|
388 |
|
/// De même, on suppose qu'il n'y a qu'un seul GraphGroup à
|
389 |
|
/// sélectionner. Une évolution consisterait à en avoir plus.
|
390 |
|
|
391 |
|
var host_main_group = r[0][0];
|
392 |
|
var host_sec_group = r[0][1];
|
393 |
|
|
394 |
|
if (!r[1].length) {
|
395 |
|
_chooseInCombos(host, host_main_group, host_sec_group, null, null);
|
396 |
|
}
|
397 |
|
else {
|
398 |
|
var graph_group = r[1][0];
|
399 |
|
_chooseInCombos(host, host_main_group, host_sec_group, graph, graph_group);
|
400 |
|
mainObj.openGraph(host, graph, null, null, true);
|
401 |
|
}
|
402 |
|
//qx.log.Logger.ROOT_LOGGER.debug(rowData);
|
403 |
|
});
|
404 |
|
g.send();
|
405 |
|
}
|
406 |
|
// On selection, update the Host Picker and close the search window
|
407 |
|
search_results.addEventListener("cellClick", function(e) {
|
408 |
|
var row = e.getRow();
|
409 |
|
var col = e.getColumn();
|
410 |
|
var value_host = search_results_model.getValue(0, row);
|
411 |
|
var value_graph = search_results_model.getValue(1, row);
|
412 |
|
if (!value_graph) {
|
413 |
|
_selectHostAndGraph(value_host, null, this);
|
414 |
|
} else {
|
415 |
|
_selectHostAndGraph(value_host, value_graph, this);
|
416 |
|
}
|
417 |
|
}, this);
|
418 |
|
// Give keyboard focus to the search field
|
419 |
|
search_host.addEventListener("appear", function(e)
|
420 |
|
{
|
421 |
|
this.getInputElement().focus();
|
422 |
|
}, search_host);
|
423 |
|
// Submit events
|
424 |
|
search_host.addEventListener("keydown", function(e) {
|
425 |
|
if (e.getKeyIdentifier() == "Enter") {
|
426 |
|
_searchResultsUpdater(search_host.getValue(), search_graph.getValue(), false);
|
427 |
|
}
|
428 |
|
});
|
429 |
|
search_host.addEventListener("changeValue", function(e) {
|
430 |
|
_searchResultsUpdater(search_host.getValue(), search_graph.getValue(), false);
|
431 |
|
});
|
432 |
|
search_graph.addEventListener("keydown", function(e) {
|
433 |
|
if (e.getKeyIdentifier() == "Enter") {
|
434 |
|
_searchResultsUpdater(search_host.getValue(), search_graph.getValue(), false);
|
435 |
|
}
|
436 |
|
});
|
437 |
|
search_graph.addEventListener("changeValue", function(e) {
|
438 |
|
_searchResultsUpdater(search_host.getValue(), search_graph.getValue(), false);
|
439 |
|
});
|
440 |
|
// Submit button
|
441 |
|
search_button.addEventListener("execute",function(e) {
|
442 |
|
_searchResultsUpdater(search_host.getValue(), search_graph.getValue(), true);
|
443 |
|
});
|
444 |
|
w_search.open();
|
445 |
|
w_search.setTop(w1.getTop());document.body.outerHTML
|
446 |
|
w_search.setLeft(qx.html.Location.getPageBoxRight(w1.getElement()));
|
447 |
|
// centerToBrowser does not work on window objects (breaks the buttons in the title bar)
|
448 |
|
//w_search.centerToBrowser()
|
449 |
|
}, this);
|
450 |
|
// end of b1
|
451 |
|
//////////////////////////////////////
|
452 |
|
|
453 |
|
|
454 |
|
gl.add(combo1, 1, 0);
|
455 |
|
gl.add(combo2, 1, 1);
|
456 |
|
gl.add(combo3, 1, 2);
|
457 |
|
gl.add(combo4, 1, 3);
|
458 |
|
gl.add(combo5, 1, 4);
|
459 |
|
w1.add(gl);
|
460 |
|
w1.open();
|
461 |
|
w1.addToDocument();
|
462 |
|
|
463 |
|
function _genericListUpdater(url,combobox)
|
464 |
|
{
|
465 |
|
var g=new qx.io.remote.Request(url,"GET","application/json");
|
466 |
|
g.addEventListener("completed", function(e) {
|
467 |
|
qx.log.Logger.ROOT_LOGGER.debug("AJAX call completed: "+url);
|
468 |
|
combobox.setEnabled(false);
|
469 |
|
combobox.getList().removeAll();
|
470 |
|
r=e.getContent().items;
|
471 |
|
for(var i = 0 ; i < r.length ; i++) // does not work in IE with "for (i in r)"
|
472 |
|
{
|
473 |
|
//var label = r[i][0];
|
474 |
|
//var id = r[i][1];
|
475 |
|
combobox.add(new qx.ui.form.ListItem(r[i][0], null, r[i][1]));
|
476 |
|
}
|
477 |
|
combobox.setSelected(null);
|
478 |
|
combobox.setEnabled(true);
|
479 |
|
});
|
480 |
|
g.send();
|
481 |
|
}
|
482 |
|
|
483 |
|
function _updateServerGroupList()
|
484 |
|
{
|
485 |
|
_genericListUpdater(urls.maingroups,combo1);
|
486 |
|
combo2.getList().removeAll();
|
487 |
|
combo2.setSelected(null);
|
488 |
|
combo3.getList().removeAll();
|
489 |
|
combo3.setSelected(null);
|
490 |
|
combo4.getList().removeAll();
|
491 |
|
combo4.setSelected(null);
|
492 |
|
combo5.getList().removeAll();
|
493 |
|
combo5.setSelected(null);
|
494 |
|
b3.setEnabled(false);
|
495 |
|
b5.setEnabled(false);
|
496 |
|
r2.setEnabled(false);
|
497 |
|
r3.setEnabled(false);
|
498 |
|
r4.setEnabled(false);
|
499 |
|
r5.setEnabled(false);
|
500 |
|
}
|
501 |
|
function _updateHostGroupList(maingroupid)
|
502 |
|
{
|
503 |
|
_genericListUpdater(urls.hostgroups+"?maingroupid="+maingroupid,combo2);
|
504 |
|
combo3.getList().removeAll();
|
505 |
|
combo3.setSelected(null);
|
506 |
|
combo4.getList().removeAll();
|
507 |
|
combo4.setSelected(null);
|
508 |
|
combo5.getList().removeAll();
|
509 |
|
combo5.setSelected(null);
|
510 |
|
b3.setEnabled(false);
|
511 |
|
b5.setEnabled(false);
|
512 |
|
r2.setEnabled(true);
|
513 |
|
r3.setEnabled(false);
|
514 |
|
r4.setEnabled(false);
|
515 |
|
r5.setEnabled(false);
|
516 |
|
}
|
517 |
|
function _updateHostList(othergroupid)
|
518 |
|
{
|
519 |
|
_genericListUpdater(urls.hosts+"?othergroupid="+othergroupid,combo3);
|
520 |
|
combo4.getList().removeAll();
|
521 |
|
combo4.setSelected(null);
|
522 |
|
combo5.getList().removeAll();
|
523 |
|
combo5.setSelected(null);
|
524 |
|
b3.setEnabled(false);
|
525 |
|
b5.setEnabled(false);
|
526 |
|
r3.setEnabled(true);
|
527 |
|
r4.setEnabled(false);
|
528 |
|
r5.setEnabled(false);
|
529 |
|
}
|
530 |
|
function _updateGraphGroupList(idhost)
|
531 |
|
{
|
532 |
|
_genericListUpdater(urls.graphgroups+"?idhost="+idhost,combo4);
|
533 |
|
combo5.getList().removeAll();
|
534 |
|
combo5.setSelected(null);
|
535 |
|
r4.setEnabled(true);
|
536 |
|
r5.setEnabled(false);
|
537 |
|
b5.setEnabled(false);
|
538 |
|
}
|
539 |
|
function _updateGraphList(idhost, idgraphgroup)
|
540 |
|
{
|
541 |
|
_genericListUpdater(urls.graphs+"?idgraphgroup="+idgraphgroup+"&idhost="+idhost,combo5);
|
542 |
|
r5.setEnabled(true);
|
543 |
|
b5.setEnabled(false);
|
544 |
|
}
|
545 |
|
combo1.addEventListener("changeSelected", function(e) { if(e.getValue()) _updateHostGroupList(e.getValue().getValue()); });
|
546 |
|
combo2.addEventListener("changeSelected", function(e) { if(e.getValue()) _updateHostList(e.getValue().getValue()); });
|
547 |
|
combo3.addEventListener("changeSelected", function(e) { if(e.getValue()) { b3.setEnabled(true);_updateGraphGroupList(e.getValue().getValue());} });
|
548 |
|
combo4.addEventListener("changeSelected", function(e) { if(e.getValue()) { _updateGraphList(combo3.getSelected().getValue(),e.getValue().getValue());} });
|
549 |
|
//combo4.addEventListener("changeSelected", function(e) { if(e.getValue()) { _updateGraphList(combo3.getSelected().getLabel(),e.getValue().getLabel());} });
|
550 |
|
combo5.addEventListener("changeSelected", function(e) { if(e.getValue()) b5.setEnabled(true); });
|
551 |
|
|
552 |
|
r1.addEventListener("execute",function(e) { _updateServerGroupList();});
|
553 |
|
r2.addEventListener("execute",function(e) { _updateHostGroupList(combo1.getSelected().getValue());});
|
554 |
|
r3.addEventListener("execute",function(e) { _updateHostList(combo2.getSelected().getValue());});
|
555 |
|
r4.addEventListener("execute",function(e) { _updateGraphGroupList(combo3.getSelected().getValue());});
|
556 |
|
r5.addEventListener("execute",function(e) { _updateGraphList(combo3.getSelected().getValue(),combo4.getSelected().getValue());});
|
557 |
|
// Restore previously opened windows
|
558 |
|
var state = qx.client.History.getInstance().getState();
|
559 |
|
qx.log.Logger.ROOT_LOGGER.debug("state: "+state);
|
560 |
|
if (state != "") {
|
561 |
|
var windows;
|
562 |
|
if (state.match(/\+/)) { // More than one windows opened
|
563 |
|
windows = state.split(/\+/);
|
564 |
|
} else {
|
565 |
|
windows = new Array(state);
|
566 |
|
}
|
567 |
|
for (var i=0, l=windows.length; i<l; i++) {
|
568 |
|
var item = windows[i];
|
569 |
|
if (!item.match(/;/)) { qx.log.Logger.ROOT_LOGGER.debug("skipping graph: "+item); continue; }
|
570 |
|
var item_a = item.split(/;/);
|
571 |
|
var host, graph, left, top;
|
572 |
|
host = item_a[0];
|
573 |
|
graph = decodeURIComponent(item_a[1]);
|
574 |
|
wleft = item_a[2];
|
575 |
|
wtop = item_a[3];
|
576 |
|
qx.log.Logger.ROOT_LOGGER.debug("restoring graph: "+host+";"+graph+";"+wleft+";"+wtop);
|
577 |
|
this.openGraph(host, graph, wleft, wtop, false);
|
578 |
|
}
|
579 |
|
}
|
580 |
|
},
|
581 |
|
|
582 |
|
|
583 |
|
/**
|
584 |
|
* Graph-opening function
|
585 |
|
*
|
586 |
|
* @type member
|
587 |
|
*/
|
588 |
|
|
589 |
|
openGraph: function(host, graph, wleft, wtop, add_to_history)
|
590 |
|
{
|
591 |
|
// position - sauvegarde valeurs courantes
|
592 |
|
var wleft_c = wleft;
|
593 |
|
var wtop_c = wtop;
|
594 |
|
|
595 |
|
var url;
|
596 |
|
var start;
|
597 |
|
var duration;
|
598 |
|
var fakeIncr=0;
|
599 |
|
// Create UI elements
|
600 |
|
var ellipse_host;
|
601 |
|
if (host.length > 35)
|
602 |
|
ellipse_host = host.substring(0, 15) + '(...)' + host.substring(host.length - 15, host.length);
|
603 |
|
else
|
604 |
|
ellipse_host = host;
|
605 |
|
var w=new qx.ui.window.Window(this.tr("Graph for \"%1\" on \"%2\"", graph, ellipse_host),
|
606 |
|
"icon/16/apps/accessories-time-tracking.png");
|
607 |
|
var l=new qx.ui.layout.FlowLayout;
|
608 |
|
l.set({"paddingTop": 26 });
|
609 |
|
var l2=new qx.ui.layout.HorizontalBoxLayout;
|
610 |
|
var bt_refresh=new qx.ui.form.Button("","icon/16/actions/view-refresh.png");
|
611 |
|
bt_refresh.setToolTip(new qx.ui.popup.ToolTip(this.tr("Reload graph")));
|
612 |
|
bt_refresh.setBorder("outset");
|
613 |
|
// Timeframe menu
|
614 |
|
var time_menu = new qx.ui.menu.Menu();
|
615 |
|
var timeframes = [
|
616 |
|
[12, this.tr("Last 12 hours")],
|
617 |
|
[24, this.tr("Last 24 hours")],
|
618 |
|
[48, this.tr("Last 48 hours")],
|
619 |
|
[7*24, this.tr("Last 7 days")],
|
620 |
|
[14*24, this.tr("Last 14 days")],
|
621 |
|
[3*31*24, this.tr("Last 3 months")],
|
622 |
|
[183*24, this.tr("Last 6 months")],
|
623 |
|
[365*24, this.tr("Last year")]
|
624 |
|
];
|
625 |
|
for (var i = 0, item; item = timeframes[i]; i++) {
|
626 |
|
var menu_bt = new qx.ui.menu.Button(item[1]);
|
627 |
|
menu_bt.title = item[0]
|
628 |
|
menu_bt.addEventListener("execute",function(e) { setTail(this.title); });
|
629 |
|
time_menu.add(menu_bt);
|
630 |
|
}
|
631 |
|
time_menu.addToDocument();
|
632 |
|
var time_menu_bt = new qx.ui.form.Button(this.tr("Timeframe"),"icon/16/actions/history.png");
|
633 |
|
time_menu_bt.setToolTip(new qx.ui.popup.ToolTip(this.tr("Timeframe menu")));
|
634 |
|
// Browse buttons
|
635 |
|
var bt_first=new qx.ui.form.Button("","icon/16/actions/start.png");
|
636 |
|
bt_first.setToolTip(new qx.ui.popup.ToolTip(this.tr("Graph start")));
|
637 |
|
var bt_prev=new qx.ui.form.Button("","icon/16/actions/go-previous.png");
|
638 |
|
bt_prev.setToolTip(new qx.ui.popup.ToolTip(this.tr("Previous section")));
|
639 |
|
var bt_next=new qx.ui.form.Button("","icon/16/actions/go-next.png");
|
640 |
|
bt_next.setToolTip(new qx.ui.popup.ToolTip(this.tr("Next section")));
|
641 |
|
var bt_last=new qx.ui.form.Button("","icon/16/actions/dialog-finish.png");
|
642 |
|
bt_last.setToolTip(new qx.ui.popup.ToolTip(this.tr("Graph end")));
|
643 |
|
var bt_zoomin=new qx.ui.form.Button("","icon/16/actions/zoom-in.png");
|
644 |
|
bt_zoomin.setToolTip(new qx.ui.popup.ToolTip(this.tr("Zoom in")));
|
645 |
|
var bt_zoomout=new qx.ui.form.Button("","icon/16/actions/zoom-out.png");
|
646 |
|
bt_zoomout.setToolTip(new qx.ui.popup.ToolTip(this.tr("Zoom out")));
|
647 |
|
var bt_print=new qx.ui.form.Button("","icon/16/actions/document-print.png");
|
648 |
|
bt_print.setToolTip(new qx.ui.popup.ToolTip(this.tr("Print Graph")));
|
649 |
|
var h1=new qx.ui.layout.HorizontalBoxLayout;
|
650 |
|
|
651 |
|
// Export Menu
|
652 |
|
var indicator_menu = new qx.ui.menu.Menu();
|
653 |
|
indicator_menu.addToDocument();
|
654 |
|
var indicator_menu_bt = new qx.ui.form.Button(this.tr("Export CSV"),"icon/16/actions/document-export.png");
|
655 |
|
indicator_menu_bt.setToolTip(new qx.ui.popup.ToolTip(this.tr("Export CSV")));
|
656 |
|
|
657 |
|
w.setDimension("auto", "auto");
|
658 |
|
w.setShowMinimize(false);
|
659 |
|
w.setShowMaximize(false);
|
660 |
|
w.setResizable(false, false, false, false);
|
661 |
|
|
662 |
|
function setUrl(start,duration)
|
663 |
|
{
|
664 |
|
url= urls.getImage+"/"+encodeURIComponent(host)+"/graph.png?start="+start+"&duration="+duration+"&graphtemplate="+encodeURIComponent(graph)+"&host="+encodeURIComponent(host);
|
665 |
|
qx.log.Logger.ROOT_LOGGER.debug(url);
|
666 |
|
}
|
667 |
|
function loadImage(myUrl,o)
|
668 |
|
{
|
669 |
|
o.removeAll();
|
670 |
|
var img = new qx.ui.basic.Image(myUrl);
|
671 |
|
img.addEventListener("insertDom", function(e) {
|
672 |
|
// Attention, la classe va être appliquée au div entourant l'image
|
673 |
|
e.getTarget().getElement().className = "graph";
|
674 |
|
});
|
675 |
|
o.add(img);
|
676 |
|
}
|
677 |
|
function getTime() // we use a function because the window can be opened a long time without reloading
|
678 |
|
{
|
679 |
|
var now_obj = new Date();
|
680 |
|
return parseInt(now_obj.getTime() / 1000);
|
681 |
|
}
|
682 |
|
function updateGraphOnStartTime()
|
683 |
|
{
|
684 |
|
var url= urls.getStartTime+"/"+encodeURIComponent(host)+"/starttime?host="+encodeURIComponent(host);
|
685 |
|
var g=new qx.io.remote.Request(url,"GET","application/json");
|
686 |
|
g.addEventListener("completed", function(e) {
|
687 |
|
start = parseInt(e.getContent().starttime);
|
688 |
|
setStep(start);
|
689 |
|
bt_first.setEnabled(false);
|
690 |
|
bt_prev.setEnabled(false);
|
691 |
|
});
|
692 |
|
g.send();
|
693 |
|
}
|
694 |
|
function getIndexWindow (cdi, w)
|
695 |
|
{
|
696 |
|
// var cdi = qx.ui.core.ClientDocument.getInstance();
|
697 |
|
var index_l = -1;
|
698 |
|
if (cdi)
|
699 |
|
{
|
700 |
|
var nb = cdi.getChildren().length;
|
701 |
|
for (i = 0; i < nb; i++)
|
702 |
|
{
|
703 |
|
var c_l = cdi.getChildren()[i];
|
704 |
|
if (c_l)
|
705 |
|
{
|
706 |
|
if (c_l.name == "qx.ui.window.Window")
|
707 |
|
{
|
708 |
|
caption_l = c_l.getCaption();
|
709 |
|
if (c_l == w)
|
710 |
|
{
|
711 |
|
index_l = i;
|
712 |
|
}
|
713 |
|
}
|
714 |
|
}
|
715 |
|
}
|
716 |
|
}
|
717 |
|
return index_l;
|
718 |
|
}
|
719 |
|
|
720 |
|
// timer pour rafraichissement
|
721 |
|
var delay = 5*60*1000;
|
722 |
|
var t = undefined;
|
723 |
|
function tempoFireRefresh()
|
724 |
|
{
|
725 |
|
t = setTimeout(tempoFallRefresh, delay);
|
726 |
|
}
|
727 |
|
function tempoFallRefresh()
|
728 |
|
{
|
729 |
|
var now = getTime();
|
730 |
|
start = now - 24 * 3600;
|
731 |
|
duration = 24 * 3600;
|
732 |
|
setUrl(start, duration);
|
733 |
|
loadImage(url,l);
|
734 |
|
|
735 |
|
bt_first.setEnabled(true);
|
736 |
|
bt_prev.setEnabled(true);
|
737 |
|
bt_next.setEnabled(true);
|
738 |
|
bt_last.setEnabled(true);
|
739 |
|
bt_zoomin.setEnabled(true);
|
740 |
|
bt_zoomout.setEnabled(true);
|
741 |
|
|
742 |
|
// rafraichissement periodique
|
743 |
|
tempoFireRefresh();
|
744 |
|
}
|
745 |
|
function tempoClearRefresh()
|
746 |
|
{
|
747 |
|
if (t != undefined)
|
748 |
|
{
|
749 |
|
clearTimeout(t);
|
750 |
|
}
|
751 |
|
}
|
752 |
|
function tempoDelayRefresh()
|
753 |
|
{
|
754 |
|
var url= urls.tempoDelayRefresh;
|
755 |
|
var r = new qx.io.remote.Request(url,"GET","text/plain");
|
756 |
|
r.addEventListener("completed", function(e) {
|
757 |
|
delay = e.getContent() * 1000;
|
758 |
|
});
|
759 |
|
r.send();
|
760 |
|
}
|
761 |
|
function getIndicators(host, graph)
|
762 |
|
{
|
763 |
|
function addExportButton(label, ds) {
|
764 |
|
var menu_bt = new qx.ui.menu.Button(label);
|
765 |
|
menu_bt.title = label
|
766 |
|
menu_bt.addEventListener("execute",function(e) { getExport(ds); });
|
767 |
|
indicator_menu.add(menu_bt);
|
768 |
|
}
|
769 |
|
var url= urls.getIndicators+"?host="+host+"&graph="+graph;
|
770 |
|
var r = new qx.io.remote.Request(url,"GET","application/json");
|
771 |
|
r.addEventListener("completed", function(e) {
|
772 |
|
r = e.getContent().items;
|
773 |
|
for(var i = 0; i < r.length; i++)
|
774 |
|
{
|
775 |
|
// on pourrait vouloir traduire les indicateurs un jour, donc deux arguments...
|
776 |
|
addExportButton(r[i], r[i]);
|
777 |
|
}
|
778 |
|
addExportButton(this.tr("All"), null);
|
779 |
|
});
|
780 |
|
r.send();
|
781 |
|
}
|
782 |
|
|
783 |
|
// Default
|
784 |
|
var now = getTime();
|
785 |
|
start = now - 24 * 3600;
|
786 |
|
duration = 24 * 3600;
|
787 |
|
setUrl(start, duration);
|
788 |
|
loadImage(url,l);
|
789 |
|
getIndicators(host, graph);
|
790 |
|
|
791 |
|
// Events
|
792 |
|
tempoDelayRefresh();
|
793 |
|
bt_refresh.addEventListener("execute",function(e) {
|
794 |
|
var state = "activated";
|
795 |
|
if (bt_refresh.hasState(state))
|
796 |
|
{
|
797 |
|
// bouton actif -> on le rend desactif
|
798 |
|
bt_refresh.setBorder("outset");
|
799 |
|
bt_refresh.removeState(state);
|
800 |
|
// liberation timer
|
801 |
|
tempoClearRefresh();
|
802 |
|
}
|
803 |
|
else
|
804 |
|
{
|
805 |
|
// bouton desactif -> on le rend actif
|
806 |
|
bt_refresh.setBorder("inset");
|
807 |
|
bt_refresh.addState(state);
|
808 |
|
loadImage(url,l);
|
809 |
|
// armement timer pour rafraichissement periodique
|
810 |
|
tempoFireRefresh();
|
811 |
|
}
|
812 |
|
});
|
813 |
|
|
814 |
|
bt_print.addEventListener("execute",function(e) {
|
815 |
|
var w3 = undefined;
|
816 |
|
|
817 |
|
var win = e.getTarget().getElement().parentNode.parentNode.parentNode;
|
818 |
|
var images = win.getElementsByTagName("img");
|
819 |
|
var src = null;
|
820 |
|
for (var i=0 ; i < images.length ; i++) {
|
821 |
|
if (images[i].parentNode.className != "graph") {
|
822 |
|
continue;
|
823 |
|
}
|
824 |
|
src = images[i].src
|
825 |
|
}
|
826 |
|
var print_url = urls.graphsList + "?1=" + encodeURIComponent(src);
|
827 |
|
w3 = window.open(print_url);
|
828 |
|
w3.onload = function(){
|
829 |
|
w3.print();
|
830 |
|
}
|
831 |
|
});
|
832 |
|
|
833 |
|
time_menu_bt.addEventListener("click", function(e)
|
834 |
|
{
|
835 |
|
if ( time_menu.isSeeable() )
|
836 |
|
{
|
837 |
|
time_menu.hide();
|
838 |
|
}
|
839 |
|
else
|
840 |
|
{
|
841 |
|
var el = this.getElement();
|
842 |
|
time_menu.setLeft(qx.html.Location.getPageBoxLeft(el));
|
843 |
|
time_menu.setTop(qx.html.Location.getPageBoxBottom(el));
|
844 |
|
time_menu.show();
|
845 |
|
}
|
846 |
|
e.setPropagationStopped(true);
|
847 |
|
});
|
848 |
|
time_menu_bt.addEventListener("mousedown", function(e) { e.setPropagationStopped(true); });
|
849 |
|
|
850 |
|
function setTail(hours)
|
851 |
|
{
|
852 |
|
now = getTime();
|
853 |
|
start=now-hours*3600;
|
854 |
|
duration=hours*3600;
|
855 |
|
|
856 |
|
setUrl(start,duration);
|
857 |
|
loadImage(url,l);
|
858 |
|
bt_first.setEnabled(true);
|
859 |
|
bt_prev.setEnabled(true);
|
860 |
|
bt_zoomin.setEnabled(true);
|
861 |
|
bt_zoomout.setEnabled(true);
|
862 |
|
}
|
863 |
|
function setStep(start_ts)
|
864 |
|
{
|
865 |
|
start = start_ts;
|
866 |
|
setUrl(start, duration);
|
867 |
|
|
868 |
|
loadImage(url,l);
|
869 |
|
bt_first.setEnabled(true);
|
870 |
|
bt_prev.setEnabled(true);
|
871 |
|
bt_next.setEnabled(true);
|
872 |
|
bt_last.setEnabled(true);
|
873 |
|
bt_zoomin.setEnabled(true);
|
874 |
|
bt_zoomout.setEnabled(true);
|
875 |
|
}
|
876 |
|
|
877 |
|
bt_first.addEventListener("execute", function(e) { updateGraphOnStartTime() });
|
878 |
|
bt_prev.addEventListener("execute", function(e) { setStep(start-duration); });
|
879 |
|
bt_next.addEventListener("execute", function(e) { setStep(start+duration); });
|
880 |
|
bt_last.addEventListener("execute", function(e) {
|
881 |
|
now = getTime();
|
882 |
|
setStep(now-duration);
|
883 |
|
});
|
884 |
|
bt_zoomin.addEventListener("execute", function(e) { duration = duration / 2; setStep(start+duration/2); });
|
885 |
|
bt_zoomout.addEventListener("execute", function(e) {
|
886 |
|
start = start - duration / 2;
|
887 |
|
duration = duration * 2;
|
888 |
|
setStep(start);
|
889 |
|
});
|
890 |
|
|
891 |
|
indicator_menu_bt.addEventListener("click", function(e)
|
892 |
|
{
|
893 |
|
if ( indicator_menu.isSeeable() )
|
894 |
|
{
|
895 |
|
indicator_menu.hide();
|
896 |
|
}
|
897 |
|
else
|
898 |
|
{
|
899 |
|
var el = this.getElement();
|
900 |
|
indicator_menu.setLeft(qx.html.Location.getPageBoxLeft(el));
|
901 |
|
indicator_menu.setTop(qx.html.Location.getPageBoxBottom(el));
|
902 |
|
indicator_menu.show();
|
903 |
|
}
|
904 |
|
e.setPropagationStopped(true);
|
905 |
|
});
|
906 |
|
indicator_menu_bt.addEventListener("mousedown", function(e) { e.setPropagationStopped(true); });
|
907 |
|
|
908 |
|
function getExport(indicator)
|
909 |
|
{
|
910 |
|
var w4 = undefined;
|
911 |
|
if (indicator != "")
|
912 |
|
{
|
913 |
|
var end = start + duration;
|
914 |
|
// @XXX: puisqu'on exporte soit tout le graphe soit un indicateur à
|
915 |
|
// la fois, on ne devrait pas avoir besoin de fournir le
|
916 |
|
// graphtemplate si on spécifie un ds.
|
917 |
|
var url= urls.exportCSV+"/"+encodeURIComponent(host)+"/export.csv?"
|
918 |
|
+"host="+encodeURIComponent(host)
|
919 |
|
+"&graphtemplate="+encodeURIComponent(graph)
|
920 |
|
+"&start="+start+"&end="+end;
|
921 |
|
if (indicator) {
|
922 |
|
url += "&ds="+encodeURIComponent(indicator);
|
923 |
|
}
|
924 |
|
w4 = window.open(url);
|
925 |
|
w4.onload = function(){
|
926 |
|
}
|
927 |
|
}
|
928 |
|
}
|
929 |
|
|
930 |
|
// Setup the UI
|
931 |
|
h1.add(bt_refresh);
|
932 |
|
h1.add(time_menu_bt);
|
933 |
|
h1.add(bt_first);
|
934 |
|
h1.add(bt_prev);
|
935 |
|
h1.add(bt_next);
|
936 |
|
h1.add(bt_last);
|
937 |
|
h1.add(bt_zoomin);
|
938 |
|
h1.add(bt_zoomout);
|
939 |
|
h1.add(indicator_menu_bt);
|
940 |
|
h1.add(bt_print);
|
941 |
|
h1.pack();
|
942 |
|
l2.add(l);
|
943 |
|
l2.add(h1);
|
944 |
|
w.add(l2);
|
945 |
|
|
946 |
|
w.addEventListener("appear", function(e) {
|
947 |
|
wleft_c = this.getLeft();
|
948 |
|
wtop_c = this.getTop();
|
949 |
|
});
|
950 |
|
|
951 |
|
w.addEventListener("disappear", function(e) {
|
952 |
|
var state = qx.client.History.getInstance().getState();
|
953 |
|
|
954 |
|
// parametres courants
|
955 |
|
var cp = host+";"+encodeURIComponent(graph)+";"+wleft_c+";"+wtop_c+"+";
|
956 |
|
var pos = state.indexOf(cp);
|
957 |
|
if (pos >= 0)
|
958 |
|
{
|
959 |
|
// actualisation etat
|
960 |
|
var state = state.replace(cp, "");
|
961 |
|
qx.client.History.getInstance().addToHistory(state, "VigiGraph");
|
962 |
|
}
|
963 |
|
|
964 |
|
// pour rafraichissement
|
965 |
|
var index_l = -1;
|
966 |
|
var cdi = qx.ui.core.ClientDocument.getInstance();
|
967 |
|
index_l = getIndexWindow(cdi, w);
|
968 |
|
if (index_l != -1)
|
969 |
|
{
|
970 |
|
// suppression element courant
|
971 |
|
c_l = cdi.getChildren()[index_l];
|
972 |
|
cdi.remove(c_l);
|
973 |
|
}
|
974 |
|
});
|
975 |
|
w._captionBar.addEventListener("mouseup", function(e) {
|
976 |
|
var state = qx.client.History.getInstance().getState();
|
977 |
|
|
978 |
|
var wleft = this.getLeft();
|
979 |
|
var wtop = this.getTop();
|
980 |
|
|
981 |
|
// parametres courants et actuels
|
982 |
|
var cp = host+";"+encodeURIComponent(graph)+";"+wleft_c+";"+wtop_c+"+";
|
983 |
|
var ap = host+";"+encodeURIComponent(graph)+";"+wleft+";"+wtop+"+";
|
984 |
|
|
985 |
|
var pos = state.indexOf(cp);
|
986 |
|
if (pos >= 0)
|
987 |
|
{
|
988 |
|
// actualisation etat
|
989 |
|
var state = state.replace(cp, ap);
|
990 |
|
qx.client.History.getInstance().addToHistory(state, "VigiGraph");
|
991 |
|
wleft_c = wleft;
|
992 |
|
wtop_c = wtop;
|
993 |
|
}
|
994 |
|
}, w);
|
995 |
|
w.addToDocument();
|
996 |
|
w.open();
|
997 |
|
wleft = parseInt(wleft);
|
998 |
|
wtop = parseInt(wtop);
|
999 |
|
if (wleft) {
|
1000 |
|
w.setLeft(wleft);
|
1001 |
|
} else {
|
1002 |
|
// w.setRight() makes the close button fixed on the page even if you move the window
|
1003 |
|
w.setLeft(qx.ui.core.ClientDocument.getInstance().getClientWidth() - 600);
|
1004 |
|
}
|
1005 |
|
if (wtop) {
|
1006 |
|
w.setTop(wtop);
|
1007 |
|
} else {
|
1008 |
|
w.setTop(5);
|
1009 |
|
}
|
1010 |
|
|
1011 |
|
// Add to history if we are opening a new window (not on restore)
|
1012 |
|
if (add_to_history) {
|
1013 |
|
var state = qx.client.History.getInstance().getState();
|
1014 |
|
var wleft = w.getLeft();
|
1015 |
|
if (!wleft) { wleft = 0; }
|
1016 |
|
var wtop = w.getTop();
|
1017 |
|
if (!wtop) { wtop = 0; }
|
1018 |
|
state += host+";"+encodeURIComponent(graph)+";"+wleft+";"+wtop+"+";
|
1019 |
|
qx.client.History.getInstance().addToHistory(state, "VigiGraph");
|
1020 |
|
qx.log.Logger.ROOT_LOGGER.debug("state: "+state);
|
1021 |
|
}
|
1022 |
|
},
|
1023 |
|
|
1024 |
|
|
1025 |
|
/**
|
1026 |
|
* On window close (verbatim from qooxdoo's skeleton)
|
1027 |
|
*
|
1028 |
|
* @type member
|
1029 |
|
*/
|
1030 |
|
close : function()
|
1031 |
|
{
|
1032 |
|
this.base(arguments);
|
1033 |
|
|
1034 |
|
// Prompt user
|
1035 |
|
// return "Do you really want to close the application?";
|
1036 |
|
},
|
1037 |
|
|
1038 |
|
|
1039 |
|
/**
|
1040 |
|
* Destructor (verbatim from qooxdoo's skeleton)
|
1041 |
|
*
|
1042 |
|
* @type member
|
1043 |
|
*/
|
1044 |
|
terminate : function() {
|
1045 |
|
this.base(arguments);
|
1046 |
|
}
|
1047 |
|
},
|
1048 |
|
|
1049 |
|
|
1050 |
|
|
1051 |
|
|
1052 |
|
/*
|
1053 |
|
*****************************************************************************
|
1054 |
|
SETTINGS
|
1055 |
|
*****************************************************************************
|
1056 |
|
*/
|
1057 |
|
|
1058 |
|
settings : {
|
1059 |
|
"vigigraph.resourceUri" : "./resource"
|
1060 |
|
}
|
1061 |
|
});
|
1062 |
|
|
1063 |
|
|
1064 |
|
// vim: set tabstop=2 shiftwidth=2 expandtab :
|