prefix snapshot size and based on size give warnings
Costa Tsaousis (ktsaou) committed
Nov 13, 2017 at 21:43 UTC
eeddf788996eac7f91723742bc7fd13ebbe5e5fd
1 file changed
+30
-15
web/index.html
+30
-15
@@ -2920,6 +2920,9 @@
2920
loadBootstrapSlider(function() {
2921
var view_duration = options.duration;
2922
2923
+ var bytes_per_chart = 2048;
2924
+ var bytes_per_point_per_dimension = 5.3;
2925
+
2926
if(NETDATA.globalPanAndZoom.isActive() === true)
2927
view_duration = Math.round((NETDATA.globalPanAndZoom.force_before_ms - NETDATA.globalPanAndZoom.force_after_ms) / 1000);
2928
@@ -2953,22 +2956,24 @@
2956
formatter: function(value) {
2957
var points = Math.round(view_duration / value);
2958
var priority = 'info';
2956
- var msg = 'Moderate size.';
2959
+ var msg = 'A moderate snapshot.';
2960
+
2961
+ var sizemb = Math.round((options.data.charts_count * bytes_per_chart + options.data.dimensions_count * points * bytes_per_point_per_dimension) / 1024 / 1024);
2962
2958
- if(points < 500) {
2963
+ if(sizemb < 10) {
2964
priority = 'success';
2960
- msg = 'A small snapshot.';
2965
+ msg = 'A nice small snapshot!';
2966
}
2962
- if(points > 5000) {
2967
+ if(sizemb > 50) {
2968
priority = 'warning';
2964
- msg = 'Expect a large file and quite some pressure on your browser.';
2969
+ msg = 'Will stress your browser...';
2970
}
2966
- if(points > 10000) {
2971
+ if(sizemb > 100) {
2972
priority = 'danger';
2968
- msg = 'Will most probably crash your browser.';
2973
+ msg = 'Hm... good luck...';
2974
}
2975
2971
- saveSnapshotModalLog(priority, 'The snapshot will have ' + points.toString() + ' points per dimension. ' + msg);
2976
+ saveSnapshotModalLog(priority, 'The snapshot will have ' + points.toString() + ' points per dimension. Expected size ' + sizemb + ' MB. ' + msg);
2977
saveSnapshotSelectedSecondsPerPoint = value;
2978
return value + ' seconds per point';
2979
}
@@ -3030,8 +3035,10 @@
3035
var data = state.data;
3036
state.data = null;
3037
data.state = null;
3038
+ str = JSON.stringify(data);
3039
3034
- saveData.data[state.chartDataUniqueID()] = JSON.stringify(data);
3040
+ saveData.data[state.chartDataUniqueID()] = str;
3041
+ return str.length;
3042
}
3043
3044
var clearPanAndZoom = false;
@@ -3076,6 +3083,7 @@
3083
NETDATA.globalSelectionSync.stop();
3084
NETDATA.options.force_data_points = saveData.data_points;
3085
NETDATA.options.fake_chart_rendering = true;
3086
+ var size = 0;
3087
3088
function update_chart(idx) {
3089
if(saveSnapshotStop === true) {
@@ -3106,11 +3114,12 @@
3114
}
3115
else {
3116
charts_failed++;
3109
- saveSnapshotModalLog('danger', charts_failed.toString() + ' have failed to be downloaded');
3117
state.log('failed to be updated: ' + reason);
3118
}
3119
3113
- pack_api1_v1_chart_data(state);
3120
+ size += pack_api1_v1_chart_data(state);
3121
+
3122
+ saveSnapshotModalLog((charts_failed)?'danger':'info', 'Generated size ' + (Math.round(size * 100 / 1024 / 1024) / 100).toString() + ' MB. ' + ((charts_failed)?(charts_failed.toString() + ' charts have failed to be downloaded'):'').toString());
3123
3124
if (idx > 0) {
3125
update_chart(idx);
@@ -3875,8 +3884,9 @@
3884
</div>
3885
<div class="modal-body">
3886
<p>
3878
- netdata can save and load JSON snapshots of netdata dashboards.<br/>
3879
- Any netdata can import a saved snapshot of the dashboard of any other netdata.
3887
+ netdata can save and load snapshots of netdata dashboards.<br/>
3888
+ Any netdata dashboard can import a saved snapshot of the dashboard of any other netdata.<br/>
3889
+ The snapshot data are not uploaded to a server. The snapshot is only loaded to your web browser.
3890
</p>
3891
<p>
3892
<label class="btn btn-default">
@@ -3939,8 +3949,13 @@
3949
<div id="saveSnapshotStatus" class="alert alert-info" role="alert">
3950
Select resolution for saving the snapshot.
3951
</div>
3942
- The generated snapshot will include all charts of this dashboard, <b>for the visible timeframe</b>, so align pan and zoom the charts as need before saving.
3943
- The snapshot will be downloaded on your computer, as a JSON file, that can be loaded back into any netdata (no need to load it on this one).
3952
+ <p>
3953
+ The generated snapshot will include all charts of this dashboard, <b>for the visible timeframe</b>, so align, pan and zoom the charts as needed.
3954
+ The snapshot will be downloaded on your computer, as a JSON file, that can be loaded back into any netdata dashboard (no need to load it on this one).
3955
+ </p>
3956
+ <p>
3957
+ Snapshots are handled entirely by the web browser. The netdata servers are not aware of them.
3958
+ </p>
3959
</div>
3960
<div class="modal-footer">
3961
<a id="saveSnapshotExport" href="#" onclick="saveSnapshot(); return false;" type="button" class="btn btn-success">Export</a>