@cryptotaxi247 / netdata-1 / commits / af78a9506

include custom dashboard info into snapshots

Costa Tsaousis (ktsaou) committed Nov 14, 2017 at 16:03 UTC af78a95068cef718a46627bfeadb45fd71b600b0
1 file changed +25 -1
web/index.html
+25 -1
@@ -2593,7 +2593,7 @@
2593 // download all the charts the server knows
2594 NETDATA.chartRegistry.downloadAll(netdata_url, function(data) {
2595 if(data !== null) {
2596 - if(typeof data.custom_info !== 'undefined' && data.custom_info !== "") {
2596 + if(typeof data.custom_info !== 'undefined' && data.custom_info !== "" && netdataSnapshotData === null) {
2597 loadJs(NETDATA.serverDefault + data.custom_info, function () {
2598 $.extend(true, netdataDashboard, customDashboard);
2599 initializeDynamicDashboardWithData(data);
@@ -2833,6 +2833,21 @@
2833 $('#printModal').modal('show');
2834 }
2835
2836 + // --------------------------------------------------------------------
2837 +
2838 + function jsonStringifyFn(obj) {
2839 + return JSON.stringify(obj, function (key, value) {
2840 + return (typeof value === 'function' ) ? value.toString() : value;
2841 + });
2842 + }
2843 +
2844 + function jsonParseFn(str) {
2845 + return JSON.parse(str, function (key, value) {
2846 + if (typeof value != 'string') return value;
2847 + return ( value.substring(0, 8) == 'function') ? eval('(' + value + ')') : value;
2848 + });
2849 + }
2850 +
2851 // --------------------------------------------------------------------
2852 // loading snapshots
2853
@@ -2863,6 +2878,10 @@
2878 else
2879 urlOptions.hash = '#';
2880
2881 + if(typeof tmpSnapshotData.info !== 'undefined') {
2882 + $.extend(true, netdataDashboard, jsonParseFn(tmpSnapshotData.info));
2883 + }
2884 +
2885 netdataSnapshotData = tmpSnapshotData;
2886 initializeDynamicDashboard(netdataSnapshotData.url);
2887
@@ -3051,6 +3070,11 @@
3070 comments: document.getElementById('saveSnapshotComments').value.toString(),
3071 hash: urlOptions.hash,
3072 charts: options.data,
3073 + info: jsonStringifyFn({
3074 + menu: netdataDashboard.menu,
3075 + submenu: netdataDashboard.submenu,
3076 + context: netdataDashboard.context
3077 + }),
3078 data: {}
3079 };
3080