diff --git a/html/gui/css/viewer.css b/html/gui/css/viewer.css index 112b2f929a..d9608602df 100644 --- a/html/gui/css/viewer.css +++ b/html/gui/css/viewer.css @@ -227,6 +227,9 @@ h3 { .menu { background-image: url(../images/menu.png) !important; } +.json_file { + background-image: url(../images/file_extension_bin.png) !important; +} .drill { background-image: url(../images/drill2.png) !important; } diff --git a/html/gui/images/file_extension_bin.png b/html/gui/images/file_extension_bin.png new file mode 100644 index 0000000000..4c5411efb8 Binary files /dev/null and b/html/gui/images/file_extension_bin.png differ diff --git a/html/gui/js/modules/metric_explorer/MetricExplorer.js b/html/gui/js/modules/metric_explorer/MetricExplorer.js index 121669d8f7..da41f5535f 100644 --- a/html/gui/js/modules/metric_explorer/MetricExplorer.js +++ b/html/gui/js/modules/metric_explorer/MetricExplorer.js @@ -393,6 +393,60 @@ Ext.apply(XDMoD.Module.MetricExplorer, { ] }); //menu + + if (CCR.xdmod.ui.isDeveloper) { + var filterConfigForExport = function (config) { + var result = JSON.parse(JSON.stringify(config)); + + delete result.featured; + delete result.defaultDatasetConfig; + + var i; + var keys = ['x_axis', 'y_axis', 'legend']; + for (i = 0; i < keys.length; i++) { + if (Object.keys(result[keys[i]]).length === 0) { + delete result[keys[i]]; + } + } + + if (result.timeframe_label !== 'User Defined') { + delete result.start_date; + delete result.end_date; + } + + if (result.global_filters.total === 0) { + delete result.global_filters; + } + + for (i = 0; i < result.data_series.data.length; i++) { + delete result.data_series.data[i].category; + if (!result.data_series.data[i].std_err) { + delete result.data_series.data[i].std_err_labels; + } + } + + return result; + }; + menu.add({ + text: 'View chart json', + iconCls: 'json_file', + handler: function () { + var win = new Ext.Window({ + title: 'Chart Json', + width: 800, + height: 600, + layout: 'fit', + autoScroll: true, + closeAction: 'destroy', + items: [{ + autoScroll: true, + html: '
' + Ext.util.Format.htmlEncode(JSON.stringify(filterConfigForExport(instance.getConfig()), null, 4)) + '
' + }] + }); + win.show(); + } + }); + } } if(newchart){