Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chart link button to metric explorer #974

Merged
merged 4 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions html/gui/css/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ h3 {
.blank {
background-image: url(../images/s.gif) !important;
}
.chart_bar_link {
background-image: url(../images/chart_bar_link.png) !important;
}
.xd-toolbar {
background-color:#ffffff !important;
background-image: none !important;
Expand Down
Binary file added html/gui/images/chart_bar_link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 39 additions & 4 deletions html/gui/js/PortalModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ XDMoD.ToolbarItem = {
DURATION_SELECTOR: 1,
EXPORT_MENU: 2,
PRINT_BUTTON: 3,
REPORT_CHECKBOX: 4
REPORT_CHECKBOX: 4,
CHART_LINK_BUTTON: 5

};//XDMoD.ToolbarItem

Expand Down Expand Up @@ -57,7 +58,8 @@ XDMoD.PortalModule = Ext.extend(Ext.Panel, {
durationSelector: false,
exportMenu: false,
printButton: false,
reportCheckbox: false
reportCheckbox: false,
chartLinkButton: false

},//toolbarItems

Expand All @@ -69,7 +71,8 @@ XDMoD.PortalModule = Ext.extend(Ext.Panel, {
XDMoD.ToolbarItem.DURATION_SELECTOR,
XDMoD.ToolbarItem.EXPORT_MENU,
XDMoD.ToolbarItem.PRINT_BUTTON,
XDMoD.ToolbarItem.REPORT_CHECKBOX
XDMoD.ToolbarItem.REPORT_CHECKBOX,
XDMoD.ToolbarItem.CHART_LINK_BUTTON

],

Expand Down Expand Up @@ -190,6 +193,27 @@ XDMoD.PortalModule = Ext.extend(Ext.Panel, {

// ----------------------------------------

var createChartLinkButton = function () {
var chartLinkButton = new Ext.Button({

text: 'Link to Current Chart',
iconCls: 'chart_bar_link',
tooltip: 'Link to Current Chart',
scope: this,
handler: function () {
self.fireEvent('chart_link_clicked');
} // handler

}); // chartLinkButton

self.getChartLinkButton = function () {
return chartLinkButton;
};

return chartLinkButton;
}; // createChartLinkButton

// ----------------------------------------
var moduleConfig = {

layout: 'border',
Expand Down Expand Up @@ -329,7 +353,18 @@ XDMoD.PortalModule = Ext.extend(Ext.Panel, {
}

break;


case XDMoD.ToolbarItem.CHART_LINK_BUTTON:

if (self.toolbarItems.chartLinkButton === true) {
if (moduleConfig.tbar.items.getCount() > 1 && employSeparator) {
moduleConfig.tbar.addItem('-');
}
moduleConfig.tbar.addItem(createChartLinkButton(self.module_id));
}

break;

default:

if (moduleConfig.tbar.items.getCount() > 1 && employSeparator)
Expand Down
23 changes: 22 additions & 1 deletion html/gui/js/modules/metric_explorer/MetricExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,8 @@ Ext.extend(XDMoD.Module.MetricExplorer, XDMoD.PortalModule, {
durationSelector: true,
exportMenu: true,
printButton: true,
reportCheckbox: true
reportCheckbox: true,
chartLinkButton: true

},

Expand Down Expand Up @@ -5494,6 +5495,8 @@ Ext.extend(XDMoD.Module.MetricExplorer, XDMoD.PortalModule, {

self.getReportCheckbox().setDisabled(noData);

self.getChartLinkButton().setDisabled(noData);

var reportGeneratorMeta = chartStore.getAt(0).get('reportGeneratorMeta');

self.getReportCheckbox().storeChartArguments(reportGeneratorMeta.chart_args,
Expand Down Expand Up @@ -6236,6 +6239,20 @@ Ext.extend(XDMoD.Module.MetricExplorer, XDMoD.PortalModule, {

// ---------------------------------------------------------

self.on('chart_link_clicked', function () {
var encodedData = window.btoa(JSON.stringify(this.getConfig()));
var link = window.location.protocol + '//' + window.location.host + '/#main_tab_panel:metric_explorer?config=' + encodedData;
var msg = 'Use the following link to share the current chart. Note that the link does not override the access controls. So if you send the link to someone who does not have access to the data, they will still not be able to see the data. <br> We recommend using Chrome or Firefox if the link does not work in Internet Explorer.<br><b>' + link + '</b>';
Ext.Msg.show({
title: 'Link to Chart',
minWidth: 700,
msg: msg,
buttons: Ext.Msg.OK
});
}); // self.on('chart_link_clicked', ...

// ---------------------------------------------------------

this.loadAll = function() {
this.queries_store_loaded_handler = function() {
this.createQueryFunc.call(this, null, null, null, null, null, null, false);
Expand Down Expand Up @@ -6286,6 +6303,10 @@ Ext.extend(XDMoD.Module.MetricExplorer, XDMoD.PortalModule, {
listeners: {
activate: function( /*panel*/ ) {
this.updateRawDataWindowVisibility();
if (location.hash.split('config=')[1]) {
var config = JSON.parse(window.atob(location.hash.split('config=')[1]));
XDMoD.Module.MetricExplorer.setConfig(config, config.title, false);
}
}, // activate

deactivate: function( /*panel*/ ) {
Expand Down