allow show-X-at for before, after, duration, update-every and selection; fixes #3571
Costa Tsaousis (ktsaou) committed
Mar 26, 2018 at 14:30 UTC
f0b34a87b52a5d1b471ac17e2d99b49d18b90c60
2 files changed
+50
-4
web/dashboard.js
+49
-3
@@ -2559,6 +2559,9 @@ var NETDATA = window.NETDATA || {};
2559
2560
this.last_t = t;
2561
2562
+ if (state.foreign_element_selection !== null)
2563
+ state.foreign_element_selection.innerText = NETDATA.dateTime.localeDateString(t) + ' ' + NETDATA.dateTime.localeTimeString(t);
2564
+
2565
if (this.timeout_id)
2566
NETDATA.timeout.clear(this.timeout_id);
2567
@@ -2800,7 +2803,13 @@ var NETDATA = window.NETDATA || {};
2803
2804
this.force_update_every = null; // number - overwrite the visualization update frequency of the chart
2805
2803
- that.tmp = {};
2806
+ this.tmp = {};
2807
+
2808
+ this.foreign_element_before = null;
2809
+ this.foreign_element_after = null;
2810
+ this.foreign_element_duration = null;
2811
+ this.foreign_element_update_every = null;
2812
+ this.foreign_element_selection = null;
2813
2814
// ============================================================================================================
2815
// PRIVATE FUNCTIONS
@@ -2948,6 +2957,28 @@ var NETDATA = window.NETDATA || {};
2957
2958
that.chart_url = null; // string - the url to download chart info
2959
that.chart = null; // object - the chart as downloaded from the server
2960
+
2961
+ function get_foreign_element_by_id(opt) {
2962
+ var id = NETDATA.dataAttribute(that.element, opt, null);
2963
+ if(id === null) {
2964
+ //that.log('option "' + opt + '" is undefined');
2965
+ return null;
2966
+ }
2967
+
2968
+ var el = document.getElementById(id);
2969
+ if(typeof el === 'undefined') {
2970
+ that.log('cannot find an element with name "' + id.toString() + '"');
2971
+ return null;
2972
+ }
2973
+
2974
+ return el;
2975
+ }
2976
+
2977
+ that.foreign_element_before = get_foreign_element_by_id('show-before-at');
2978
+ that.foreign_element_after = get_foreign_element_by_id('show-after-at');
2979
+ that.foreign_element_duration = get_foreign_element_by_id('show-duration-at');
2980
+ that.foreign_element_update_every = get_foreign_element_by_id('show-update-every-at');
2981
+ that.foreign_element_selection = get_foreign_element_by_id('show-selection-at');
2982
};
2983
2984
var destroyDOM = function() {
@@ -3537,7 +3568,7 @@ var NETDATA = window.NETDATA || {};
3568
};
3569
3570
// ----------------------------------------------------------------------------------------------------------------
3540
- // global selection sync
3571
+ // global selection sync for slaves
3572
3573
// can the chart participate to the global selection sync as a slave?
3574
this.globalSelectionSyncIsEligible = function() {
@@ -3557,6 +3588,9 @@ var NETDATA = window.NETDATA || {};
3588
if(this.selected === true && this.debug === true)
3589
this.log('selection set to ' + t.toString());
3590
3591
+ if (this.foreign_element_selection !== null)
3592
+ this.foreign_element_selection.innerText = NETDATA.dateTime.localeDateString(t) + ' ' + NETDATA.dateTime.localeTimeString(t);
3593
+
3594
return this.selected;
3595
};
3596
@@ -4835,6 +4869,18 @@ var NETDATA = window.NETDATA || {};
4869
4870
if(this.refresh_dt_element !== null)
4871
this.refresh_dt_element.innerText = this.refresh_dt_ms.toString();
4872
+
4873
+ if(this.foreign_element_before !== null)
4874
+ this.foreign_element_before.innerText = NETDATA.dateTime.localeDateString(this.view_before) + ' ' + NETDATA.dateTime.localeTimeString(this.view_before);
4875
+
4876
+ if(this.foreign_element_after !== null)
4877
+ this.foreign_element_after.innerText = NETDATA.dateTime.localeDateString(this.view_after) + ' ' + NETDATA.dateTime.localeTimeString(this.view_after);
4878
+
4879
+ if(this.foreign_element_duration !== null)
4880
+ this.foreign_element_duration.innerText = NETDATA.seconds4human(Math.floor((this.view_before - this.view_after) / 1000) + 1);
4881
+
4882
+ if(this.foreign_element_update_every !== null)
4883
+ this.foreign_element_update_every.innerText = NETDATA.seconds4human(Math.floor(this.data_update_every / 1000));
4884
};
4885
4886
this.getSnapshotData = function(key) {
@@ -8098,8 +8144,8 @@ var NETDATA = window.NETDATA || {};
8144
}
8145
else {
8146
NETDATA.gaugeAnimation(state, false);
8101
- NETDATA.gaugeSet(state, null, null, null);
8147
NETDATA.gaugeSetLabels(state, null, null, null);
8148
+ NETDATA.gaugeSet(state, null, null, null);
8149
}
8150
8151
NETDATA.gaugeAnimation(state, true);
web/index.html
+1
-1
@@ -5719,6 +5719,6 @@
5719
</div>
5720
</div>
5721
<div id="hiddenDownloadLinks" style="display: none;" hidden></div>
5722
- <script type="text/javascript" src="dashboard.js?v20180210-4"></script>
5722
+ <script type="text/javascript" src="dashboard.js?v20180326-2"></script>
5723
</body>
5724
</html>