bzr branch
http://darksoft.org/webbzr/adei/trunk
231
by Suren A. Chilingaryan
Finish mergin RRDReader by Riku and few fixes for newer pecl-rrd |
1 |
function PLOT_CONFIG() |
2 |
{
|
|
3 |
this.plot_mode = null; |
|
4 |
}
|
|
5 |
||
6 |
function PLOT(plot_sel_id) |
|
7 |
{
|
|
8 |
this.cfg = new PLOT_CONFIG(); |
|
9 |
||
10 |
this.plotsel = new SELECT(plot_sel_id, plotUpdatePlotMode, this); |
|
11 |
||
12 |
this.updater = null; |
|
13 |
this.config = null; |
|
14 |
}
|
|
15 |
||
16 |
PLOT.prototype.AttachConfig = function(config) { |
|
17 |
this.config = config; |
|
18 |
config.Register(this); |
|
19 |
}
|
|
20 |
||
21 |
PLOT.prototype.Init = function(updater, opts) { |
|
22 |
if (typeof opts == "undefined") opts = new Object; |
|
23 |
||
24 |
this.updater = updater; |
|
25 |
||
26 |
opts.reload = true; |
|
27 |
opts.confirm = true; |
|
28 |
||
29 |
this.Update(opts); |
|
30 |
}
|
|
31 |
||
32 |
PLOT.prototype.SetPlot = function(val) { |
|
33 |
this.Update(new Object({ 'plot_mode': val, 'apply': true})); |
|
34 |
}
|
|
35 |
||
36 |
PLOT.prototype.ReadConfig = function(opts) { |
|
37 |
if (this.config) { |
|
38 |
var opts = new Object(/*{'apply': true}*/); |
|
39 |
if (this.config.cfg.plot_mode) |
|
40 |
opts.plot_mode = this.config.cfg.plot_mode; |
|
41 |
||
42 |
this.Update(opts); |
|
43 |
}
|
|
44 |
}
|
|
45 |
||
46 |
PLOT.prototype.Update = function(opts) { |
|
47 |
if (opts) { |
|
48 |
if (opts.reload) { |
|
49 |
this.plotsel.Update(adei.GetSelectService("plot_modes"), opts, opts?opts.plot_mode:null); |
|
50 |
} else { |
|
51 |
if (opts.plot_mode) { |
|
52 |
this.UpdatePlotMode(opts.plot_mode, opts); |
|
53 |
if (this.plotsel.GetValue() != opts.plot_mode) |
|
54 |
this.plotsel.SetValue(opts.plot_mode); |
|
55 |
}
|
|
56 |
}
|
|
57 |
}
|
|
58 |
}
|
|
59 |
||
60 |
PLOT.prototype.UpdatePlotMode = function(val, opts) |
|
61 |
{
|
|
62 |
this.cfg.plot_mode = val; |
|
63 |
||
64 |
if ((typeof opts == "undefined")||(opts.apply)) |
|
65 |
this.Apply(val); |
|
66 |
}
|
|
67 |
||
68 |
PLOT.prototype.Apply = function(plot_mode) { |
|
69 |
if (plot_mode) |
|
70 |
this.config.SetPlotSettings(plot_mode); |
|
71 |
else
|
|
72 |
this.config.SetPlotSettings(this.cfg.plot_mode); |
|
73 |
||
74 |
this.config.Save(); |
|
75 |
if (this.updater) this.updater.Update(); |
|
76 |
}
|
|
77 |
||
78 |
function plotUpdatePlotMode(self, val, opts) |
|
79 |
{
|
|
80 |
return self.UpdatePlotMode(val, opts); |
|
81 |
}
|