1
function SOURCE_CONFIG() {
10
function SOURCE(interval, srv_sel_id, db_sel_id, group_sel_id, mask_sel_id, item_sel_id, opts) {
11
this.cfg = new SOURCE_CONFIG;
13
// interval.SetSource(this);
14
this.interval = interval;
16
this.source_itemsel = new SELECT(item_sel_id, sourceUpdateItem, this);
17
this.source_masksel = new SELECT(mask_sel_id, sourceUpdateMask, this);
18
this.source_grsel = new SELECT(group_sel_id, sourceUpdateGroup, this);
19
this.source_dbsel = new SELECT(db_sel_id, sourceUpdateDatabase, this);
20
this.source_srvsel = new SELECT(srv_sel_id, sourceUpdateServer, this);
25
if (typeof opts == "object") this.opts = opts;
26
else this.opts = new Object();
29
SOURCE.prototype.Init = function(updater, opts) {
30
if (typeof opts == "undefined") opts = new Object;
34
this.updater = updater;
35
this.interval.SetUpdater(updater);
36
updater.RegisterControl(this);
42
SOURCE.prototype.AttachConfig = function(config) {
44
this.interval.SetConfig(config);
46
config.Register(this);
52
SOURCE.prototype.ApplyConfig = function(subcall) {
54
this.config.SetSource(this.cfg.db_server, this.cfg.db_name, this.cfg.db_group, this.cfg.db_mask);
55
this.interval.ApplyConfig(true);
57
if (typeof subcall == "undefined") {
64
SOURCE.prototype.ReadConfig = function(opts) {
66
if (typeof opts == "undefined") opts = new Object;
68
opts.db_server = this.config.cfg.db_server;
69
opts.db_name = this.config.cfg.db_name;
70
opts.db_group = this.config.cfg.db_group;
72
if (this.config.cfg.db_mask != null) {
73
var mask = this.config.cfg.db_mask;
74
if (mask.search(',')>=0) {
77
} else if (isNaN(mask)) {
86
this.interval.ReadConfig(opts);
92
SOURCE.prototype.Apply = function() {
94
if (this.updater) this.updater.Update();
97
SOURCE.prototype.RegisterGraph = function(graph) {
98
this.graphs.push(graph);
101
SOURCE.prototype.Update = function(opts) {
104
this.source_srvsel.Update(adei.GetService("server"), opts, opts?opts.db_server:null);
105
} else if ((opts.reset)||(opts.db_server)) {
106
if (!opts.db_server) opts.db_server = this.source_srvsel.GetValue(0);
108
this.UpdateServer(opts.db_server, opts);
110
if (this.source_srvsel.GetValue() != opts.db_server)
111
this.source_srvsel.SetValue(opts.db_server);
112
} else if (opts.confirm) {
113
this.config.Confirm(this, 0);
114
this.config.Confirm(this, 1);
115
this.config.Confirm(this, 2);
120
SOURCE.prototype.UpdateServer = function(srv, opts) {
121
if (typeof srv == "undefined") {
122
srv = this.source_srvsel.GetValue();
126
if (((opts)&&(opts.reload))||(srv != db_server)) {
129
if (typeof opts == "undefined") opts = new Object;
132
this.source_dbsel.Update(adei.GetService("database", "db_server=" + db_server), opts, opts?opts.db_name:null);
133
} else if ((opts)&&((opts.db_name)||(opts.reset))) {
134
if (!opts.db_name) opts.db_name = this.source_dbsel.GetValue(0);
136
this.UpdateDatabase(opts.db_name, opts);
138
if (this.source_dbsel.GetValue() != opts.db_name)
139
this.source_dbsel.SetValue(opts.db_name);
140
} else if ((opts)&&(opts.confirm)) {
141
this.config.Confirm(this, 0);
142
this.config.Confirm(this, 1);
143
this.config.Confirm(this, 2);
149
SOURCE.prototype.UpdateDatabase = function(db, opts) {
151
if (((opts)&&(opts.reload))||(db != db_name)) {
154
if (typeof opts == "undefined") opts = new Object;
157
this.source_grsel.Update(adei.GetService("loggroup", "db_server=" + db_server + "&db_name=" + db_name), opts, opts?opts.db_group:null);
158
} else if ((opts)&&((opts.db_group)||(opts.reset))) {
159
if (!opts.db_group) opts.db_group = this.source_grsel.GetValue(0);
161
this.UpdateGroup(opts.db_group, opts);
163
if (this.source_grsel.GetValue() != opts.db_group)
164
this.source_grsel.SetValue(opts.db_group);
165
} else if ((opts)&&(opts.confirm)) {
166
this.config.Confirm(this, 0);
167
this.config.Confirm(this, 1);
168
this.config.Confirm(this, 2);
173
/* Handling of Interval/Window updates.
174
a) INTERVAL value passed - UPDATING
175
b) 'keep_window' in global or local options - KEEPING
176
c) Group have changed - UPDATING
177
d) 'reset' in local options - UPDATING
182
SOURCE.prototype.UpdateGroup = function(group, opts) {
183
if (typeof opts == "undefined") opts = new Object;
185
if (!opts.experiment) {
186
if ((opts.keep_window)||(this.opts.keep_window)) {
187
opts.experiment = this.config.cfg.experiment;
188
opts.window_width = this.config.win_width;
189
opts.window = "auto";
194
if (((opts)&&(opts.reload))||(group != db_group)) {
199
this.source_itemsel.Update(adei.GetService("item", "db_server=" + db_server + "&db_name=" + db_name + "&db_group=" + db_group), opts, opts?opts.db_item:null);
200
this.source_masksel.Update(adei.GetService("mask", "db_server=" + db_server + "&db_name=" + db_name + "&db_group=" + db_group), opts, opts?opts.db_mask:null);
202
this.interval.Update(this.GetSourceProps(), opts);
203
} else if ((opts)&&((opts.db_mask)||(opts.db_item)||(opts.experiment)||(opts.reset))) {
204
if ((opts.db_mask)||(opts.reset)) {
205
if (!opts.db_mask) opts.db_mask = this.source_masksel.GetValue(0);
207
this.UpdateMask(opts.db_mask, opts);
209
if (this.source_masksel.GetValue() != opts.db_mask)
210
this.source_masksel.SetValue(opts.db_mask);
211
} else if (opts.confirm) {
212
this.config.Confirm(this, 0);
215
if ((opts.db_item)||(opts.reset)) {
216
if (!opts.db_item) opts.db_item = this.source_itemsel.GetValue(0);
218
this.UpdateItem(opts.db_item, opts);
220
if (this.source_itemsel.GetValue() != opts.db_item)
221
this.source_itemsel.SetValue(opts.db_item);
222
} else if (opts.confirm) {
223
this.config.Confirm(this, 1);
226
if ((opts.experiment)||(opts.reset)) {
227
this.interval.Update(this.GetSourceProps(), opts);
228
} else if (opts.confirm) {
229
this.config.Confirm(this, 2);
231
} else if (opts.confirm) {
232
this.config.Confirm(this, 0);
233
this.config.Confirm(this, 1);
234
this.config.Confirm(this, 2);
240
SOURCE.prototype.UpdateMask = function(mask, opts) {
242
if (((opts)&&(opts.reload))||(mask != db_mask)) {
246
this.source_itemsel.Show();
247
if (!this.module_on_display) this.fix_hidden = true;
249
if (typeof this.geometry_cb == "function") {
250
this.geometry_cb(this.geometry_cbattr);
253
if (!isNaN(db_mask)) {
254
if (!this.module_on_display) this.fix_hidden = true;
255
this.source_itemsel.Hide();
260
if ((typeof opts == "undefined")||((opts)&&(opts.apply))) this.Apply();
264
if ((opts)&&(opts.confirm)) {
265
this.config.Confirm(this, 0);
271
SOURCE.prototype.UpdateItem = function(item, opts) {
273
if (((opts)&&(opts.reload))||(item != db_item)) {
277
if ((typeof opts == "undefined")||((opts)&&(opts.apply))) this.Apply();
280
if ((opts)&&(opts.confirm)) this.config.Confirm(this, 1);
285
SOURCE.prototype.GetSourceProps = function() {
286
return "db_server=" + this.cfg.db_server + "&db_name=" + this.cfg.db_name + "&db_group=" + this.cfg.db_group;
289
SOURCE.prototype.RegisterGeometryCallback = function(cb, cbattr) {
290
this.interval.RegisterGeometryCallback(cb, cbattr);
291
this.geometry_cb = cb;
292
this.geometry_cbattr = cbattr;
295
SOURCE.prototype.FixHidden = function() {
296
// Fix IE bug, preventing unhiden hidden subnodes while within hidden element
297
if ((this.fix_hidden)&&(this.module_on_display)) {
298
if (isNaN(this.cfg.db_mask)) {
299
this.source_itemsel.Show();
300
this.source_itemsel.Hide();
302
this.source_itemsel.Hide();
303
this.source_itemsel.Show();
305
this.fix_hidden = false;
307
this.interval.FixHidden();
311
function sourceUpdateServer(src, srv, opts) {
312
return src.UpdateServer(srv, opts);
315
function sourceUpdateDatabase(src, db, opts) {
316
return src.UpdateDatabase(db, opts);
319
function sourceUpdateGroup(src, group, opts) {
320
return src.UpdateGroup(group, opts);
323
function sourceUpdateMask(src, mask, opts) {
324
return src.UpdateMask(mask, opts);
327
function sourceUpdateItem(src, item, opts) {
328
return src.UpdateItem(item, opts);
331
function sourceFixHidden(source) {