diff options
author | Igor Sfiligoi <isfiligoi@ucsd.edu> | 2013-11-07 21:15:36 +0000 |
---|---|---|
committer | Igor Sfiligoi <isfiligoi@ucsd.edu> | 2013-11-07 21:15:36 +0000 |
commit | 8468a9354afda0a8d76d827bd8eaf3b318f92ddd (patch) | |
tree | e6861e765f9f8a625901f7d3afbbb0076c41e03a /src | |
parent | 660a4ca8812507512255bd930618463e0790a9dd (diff) |
Add options to RRDFile and RRFileSum, and use thim in the Async classes
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/rrdFile.js | 5 | ||||
-rw-r--r-- | src/lib/rrdFlotAsync.js | 16 | ||||
-rw-r--r-- | src/lib/rrdMultiFile.js | 26 |
3 files changed, 38 insertions, 9 deletions
diff --git a/src/lib/rrdFile.js b/src/lib/rrdFile.js index 35a892b..eabebc7 100644 --- a/src/lib/rrdFile.js +++ b/src/lib/rrdFile.js @@ -389,7 +389,10 @@ RRDHeader.prototype.getRRAInfo = function(idx) { //
// Arguments:
// bf must be an object compatible with the BinaryFile interface
-function RRDFile(bf) {
+// file_options - currently no semantics... introduced for future expandability
+function RRDFile(bf,file_options) {
+ this.file_options=file_options;
+
var rrd_data=bf
this.rrd_header=new RRDHeader(rrd_data);
diff --git a/src/lib/rrdFlotAsync.js b/src/lib/rrdFlotAsync.js index 6785867..dbf6293 100644 --- a/src/lib/rrdFlotAsync.js +++ b/src/lib/rrdFlotAsync.js @@ -45,7 +45,7 @@ function rrdFlotAsyncCallback(bf,obj) { return 1;
}
try {
- i_rrd_data=new RRDFile(bf);
+ i_rrd_data=new RRDFile(bf,obj.file_options);
} catch(err) {
alert("File "+obj.url+" is not a valid RRD archive!\n"+err);
}
@@ -58,6 +58,7 @@ function rrdFlotAsyncCallback(bf,obj) { /* Use url==null if you do not know the url yet */
function rrdFlotAsync(html_id, url,
+ file_options, // see rrdFile.js::RRDFile for documentation
graph_options, ds_graph_options, rrdflot_defaults, // see rrdFlot.js::rrdFlot for documentation of these
ds_op_list, // if defined, see rrdFilter.js::RRDFilterOp for documentation
rra_op_list, // if defined, see rrdFilter.js::RRDRRAFilterAvg for documentation
@@ -65,6 +66,7 @@ function rrdFlotAsync(html_id, url, ) {
this.html_id=html_id;
this.url=url;
+ this.file_options=file_options;
this.graph_options=graph_options;
this.ds_graph_options=ds_graph_options;
this.rrdflot_defaults=rrdflot_defaults;
@@ -116,7 +118,7 @@ function rrdFlotMultiAsyncCallback(bf,arr) { alert("File "+obj.url_list[idx]+" is empty (possibly loading failed)! You may get a parial result in the graph.");
} else {
try {
- i_rrd_data=new RRDFile(bf);
+ i_rrd_data=new RRDFile(bf,obj.file_options);
} catch(err) {
alert("File "+obj.url_list[idx]+" is not a valid RRD archive! You may get a partial result in the graph.\n"+err);
}
@@ -150,7 +152,9 @@ function rrdFlotMultiAsyncReload(obj,url_list) { /* Use url_list==null if you do not know the urls yet */
-function rrdFlotSumAsync(html_id, url_list,
+function rrdFlotSumAsync(html_id, url_list,
+ file_options, // see rrdFile.js::RRDFile for documentation
+ sumfile_options, // see rrdMultiFile.js::RRDFileSum for documentation
graph_options, ds_graph_options, rrdflot_defaults, // see rrdFlot.js::rrdFlot for documentation of these
ds_op_list, // if defined, see rrdFilter.js::RRDFilterOp for documentation
rra_op_list, // if defined, see rrdFilter.js::RRDRRAFilterAvg for documentation
@@ -158,6 +162,8 @@ function rrdFlotSumAsync(html_id, url_list, ) {
this.html_id=html_id;
this.url_list=url_list;
+ this.file_options=file_options;
+ this.sumfile_options=sumfile_options;
this.graph_options=graph_options;
this.ds_graph_options=ds_graph_options;
this.rrdflot_defaults=rrdflot_defaults;
@@ -187,7 +193,7 @@ rrdFlotSumAsync.prototype.callback = function() { var el=this.loaded_data[i];
if (el!=undefined) real_data_arr.push(el);
}
- var rrd_sum=new RRDFileSum(real_data_arr);
+ var rrd_sum=new RRDFileSum(real_data_arr,this.sumfile_options);
if (this.rrd_data!=null) delete this.rrd_data;
this.rrd_data=rrd_sum;
@@ -204,6 +210,7 @@ rrdFlotSumAsync.prototype.callback = function() { /* Use url_list==null if you do not know the urls yet */
function rrdFlotMatrixAsync(html_id,
url_pair_list, ds_list, // see rrdFlotMatrix.js::rrdFlotMatrix for documentation of these
+ file_options, // see rrdFile.js::RRDFile for documentation
graph_options, rrd_graph_options, rrdflot_defaults, // see rrdFlotMatrix.js::rrdFlotMatrix for documentation of these
ds_op_list, // if defined, see rrdFilter.js::RRDFilterOp for documentation
rra_op_list, // if defined, see rrdFilter.js::RRDRRAFilterAvg for documentation
@@ -212,6 +219,7 @@ function rrdFlotMatrixAsync(html_id, this.html_id=html_id;
this.url_pair_list=url_pair_list;
this.ds_list=ds_list;
+ this.file_options=file_options;
this.graph_options=graph_options;
this.rrd_graph_options=rrd_graph_options;
this.rrdflot_defaults=rrdflot_defaults;
diff --git a/src/lib/rrdMultiFile.js b/src/lib/rrdMultiFile.js index 1e2af85..c591aad 100644 --- a/src/lib/rrdMultiFile.js +++ b/src/lib/rrdMultiFile.js @@ -107,11 +107,29 @@ function rrdFileSort(f1, f2) { * They must all have the same DSes and the same RRAs
*/
-function RRDFileSum(file_list,treat_undefined_as_zero) {
- if (treat_undefined_as_zero==undefined) {
+
+/*
+ * sumfile_options, if defined, must be an object containing any of these
+ * treat_undefined_as_zero
+ *
+ */
+
+// For backwards comatibility, if sumfile_options is a boolean,
+// it is interpreted like the "old treat_undefined_as_zero" argument
+
+function RRDFileSum(file_list,sumfile_options) {
+ if (sumfile_options==undefined) {
+ sumfile_options={};
+ } elif (typeof(sumfile_options)=="boolean") {
+ sumfile_options={treat_undefined_as_zero:sumfile_options};
+ }
+ this.sumfile_options=sumfile_options;
+
+
+ if (this.sumfile_options.treat_undefined_as_zero==undefined) {
this.treat_undefined_as_zero=true;
- } else {
- this.treat_undefined_as_zero=treat_undefined_as_zero;
+ } else {
+ this.treat_undefined_as_zero=this.sumfile_options.treat_undefined_as_zero;
}
this.file_list=file_list;
this.file_list.sort();
|