switched default compression to pako.deflate.base64, since lzstring.utf16 generates faulty data on safari
Costa Tsaousis (ktsaou) committed
Nov 20, 2017 at 15:45 UTC
29fd6d32ba94ebbc9d5d32625373ca8f8db35f26
2 files changed
+58
-9
web/dashboard.js
+56
-7
@@ -4224,6 +4224,58 @@ var NETDATA = window.NETDATA || {};
4224
this.refresh_dt_element.innerText = this.refresh_dt_ms.toString();
4225
};
4226
4227
+ this.getSnapshotData = function(key) {
4228
+ if(this.debug === true)
4229
+ this.log('updating from snapshot: ' + key);
4230
+
4231
+ if(typeof netdataSnapshotData.data[key] === 'undefined') {
4232
+ this.log('snapshot does not include data for key "' + key + '"');
4233
+ return null;
4234
+ }
4235
+
4236
+ if(typeof netdataSnapshotData.data[key] !== 'string') {
4237
+ this.log('snapshot data for key "' + key + '" is not string');
4238
+ return null;
4239
+ }
4240
+
4241
+ var uncompressed;
4242
+ try {
4243
+ uncompressed = netdataSnapshotData.uncompress(netdataSnapshotData.data[key]);
4244
+
4245
+ if(uncompressed === null) {
4246
+ this.log('uncompressed snapshot data for key ' + key + ' is null');
4247
+ return null;
4248
+ }
4249
+
4250
+ if(typeof uncompressed === 'undefined') {
4251
+ this.log('uncompressed snapshot data for key ' + key + ' is undefined');
4252
+ return null;
4253
+ }
4254
+ }
4255
+ catch(e) {
4256
+ this.log('decompression of snapshot data for key ' + key + ' failed');
4257
+ console.log(e);
4258
+ uncompressed = null;
4259
+ }
4260
+
4261
+ if(typeof uncompressed !== 'string') {
4262
+ this.log('uncompressed snapshot data for key ' + key + ' is not string');
4263
+ return null;
4264
+ }
4265
+
4266
+ var data;
4267
+ try {
4268
+ data = JSON.parse(uncompressed);
4269
+ }
4270
+ catch(e) {
4271
+ this.log('parsing snapshot data for key ' + key + ' failed');
4272
+ console.log(e);
4273
+ data = null;
4274
+ }
4275
+
4276
+ return data;
4277
+ };
4278
+
4279
this.updateChart = function(callback) {
4280
if(this.debug === true)
4281
this.log('updateChart()');
@@ -4295,17 +4347,14 @@ var NETDATA = window.NETDATA || {};
4347
4348
if(netdataSnapshotData !== null) {
4349
var key = this.chartDataUniqueID();
4298
-
4299
- if(this.debug === true)
4300
- this.log('updating from snapshot: ' + key);
4301
-
4302
- if(typeof netdataSnapshotData.data[key] === 'string') {
4350
+ var data = this.getSnapshotData(key);
4351
+ if (data !== null) {
4352
ok = true;
4304
- this.updateChartWithData(JSON.parse(netdataSnapshotData.uncompress(netdataSnapshotData.data[key])));
4353
+ this.updateChartWithData(data);
4354
}
4355
else {
4356
ok = false;
4308
- error('data not found in snapshot for key: ' + key);
4357
+ error('cannot get data from snapshot for key: "' + key + '"');
4358
that.tm.last_autorefreshed = Date.now();
4359
}
4360
web/index.html
+2
-2
@@ -2981,7 +2981,7 @@
2981
2982
var snapshotOptions = {
2983
bytes_per_chart: 2048,
2984
- compressionDefault: 'lzstring.utf16',
2984
+ compressionDefault: 'pako.deflate.base64',
2985
2986
compressions: {
2987
'none': {
@@ -5326,6 +5326,6 @@
5326
</div>
5327
</div>
5328
<div id="hiddenDownloadLinks" style="display: none;" hidden></div>
5329
- <script type="text/javascript" src="dashboard.js?v20171118-6"></script>
5329
+ <script type="text/javascript" src="dashboard.js?v20171120-1"></script>
5330
</body>
5331
</html>