Skip to content

Commit

Permalink
Merge pull request #988 from jpwhite4/metric_explorer_chartjson
Browse files Browse the repository at this point in the history
Add a view chart json button for developers
  • Loading branch information
jpwhite4 authored Aug 21, 2019
2 parents ef3d0a9 + 40a38aa commit 5a8bdd8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions html/gui/css/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Binary file added html/gui/images/file_extension_bin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions html/gui/js/modules/metric_explorer/MetricExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<pre>' + Ext.util.Format.htmlEncode(JSON.stringify(filterConfigForExport(instance.getConfig()), null, 4)) + '</pre>'
}]
});
win.show();
}
});
}
}

if(newchart){
Expand Down

0 comments on commit 5a8bdd8

Please sign in to comment.