Skip to content

Commit 1bacfc2

Browse files
committedJan 18, 2016
Excel export fix - query with NONCE in case of NONCE support
1 parent 6e5ec73 commit 1bacfc2

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed
 

‎export/LightPivotTable-DeepSeePortlet.xml

+35-7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
<Type>%Boolean</Type>
6363
</Property>
6464

65+
<Property name="ExcelExportClass">
66+
<Type>%String</Type>
67+
</Property>
68+
6569
<Method name="%OnGetPortletName">
6670
<ClassMethod>1</ClassMethod>
6771
<ReturnType>%String</ReturnType>
@@ -94,6 +98,7 @@
9498
set pInfo($I(pInfo)) = $LB("EnableSearch", 1, "%Boolean", "Enable listing search", "Show search tools in listing mode")
9599
set pInfo($I(pInfo)) = $LB("StretchColumns", 0, "%Boolean", "Stretch columns", "Stretch columns to fill all available width")
96100
set pInfo($I(pInfo)) = $LB("ShowRowNumbers", 0, "%Boolean", "Show row nums", "Show row number in listing")
101+
set pInfo($I(pInfo)) = $LB("ExcelExportClass", "_DeepSee.UI.MDXExcel.cls", "%String", "Excel export class", "Class which exports MDX to Excel")
97102
98103
quit $$$OK
99104
]]></Implementation>
@@ -366,30 +371,53 @@ If LPT has been created before, method fires given callback immidiately.</Descri
366371
<ClientMethod>1</ClientMethod>
367372
<Implementation><![CDATA[
368373
var container = document.getElementById(this.id),
369-
controller = this.getConnectedController();
374+
controller = this.getConnectedController(),
375+
page = this.ExcelExportClass;
370376
371377
if (!this.LightPivotTable) return;
372378
373379
if (true) { // *.XLS export, false - *.CSV.
374380
375381
var controls = this.id.replace(/\/.*/, "") + "/control/",
376-
i = 1, n,
377-
filter = document.getElementById(controls + i),
382+
control, i = 1, n,
383+
//filter = document.getElementById(controls + i),
384+
widget = this.parent.parent,
378385
379386
filterNames = [],
380387
filterValues = [];
381388
382-
if (filter) do {
389+
/*if (filter) do {
383390
if ((n = (filter.getElementsByTagName("input")[0] || {}).name) === "$V_applyFilter" || n === "$V_setFilter") {
384391
filterNames.push((filter.parentNode.getElementsByClassName("zenLabel")[0] || {}).innerText || "");
385392
filterValues.push("SET");
386393
}
387394
filter = document.getElementById(controls + (++i));
388-
} while (filter);
395+
} while (filter);*/
396+
397+
for (j in widget.controlIndices) {
398+
control = zenPage.getComponent(widget.controlIndices[j]);
399+
if (control) {
400+
filterNames.push(control.label);
401+
filterValues.push(control.text);
402+
}
403+
}
404+
405+
var mdx = this.LightPivotTable.getActualMDX(),
406+
nonce, url;
407+
408+
if (zenPage.CreateQueryNonce) {
409+
nonce = zenPage.CreateQueryNonce(mdx);
410+
if (nonce.toString().indexOf('ERROR:') >= 0) {
411+
alert(nonce);
412+
return;
413+
}
414+
url = page + '?NONCE=' + encodeURIComponent(nonce);
415+
} else {
416+
url = page + '?MDX=' + encodeURIComponent(mdx);
417+
}
389418
390419
window.open(
391-
(location.origin + location.pathname).replace(/\/[^\/]*$/, "/_DeepSee.UI.MDXExcel.zen?MDX=")
392-
+ encodeURIComponent(this.LightPivotTable.getActualMDX())
420+
url
393421
+ "&ROWTOTALS=" + container.getElementsByTagName("div")[0].getAttribute("show-summary")
394422
+ "&ROWTOTALAGG=sum"
395423
+ "&COLUMNTOTALAGG=sum"

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "LightPivotTable",
33
"author": "ZitRo",
4-
"version": "1.6.2",
4+
"version": "1.6.3",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {

0 commit comments

Comments
 (0)