1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <Export generator =" Cache" version =" 25" >
3+
4+ <CSP name =" DeepSeeLightPivotTable.css" application =" " >
5+ <![CDATA[ {{replace:css}}]]>
6+ </CSP >
7+
8+
9+ <CSP name =" DeepSeeLightPivotTable.js" application =" " >
10+ <![CDATA[ {{replace:js}}]]>
11+ </CSP >
12+
13+ <Class name =" DeepSee.LightPivotTable" >
14+ <Super >%DeepSee.Component.Portlet.abstractPortlet</Super >
15+ <TimeChanged >63515,72475.367191</TimeChanged >
16+ <TimeCreated >63515,61322.546099</TimeCreated >
17+
18+ <Parameter name =" INCLUDEFILES" >
19+ <Default >style:DeepSeeLightPivotTable.css,script:DeepSeeLightPivotTable.js</Default >
20+ </Parameter >
21+
22+ <Method name =" %OnGetPortletName" >
23+ <ClassMethod >1</ClassMethod >
24+ <ReturnType >%String</ReturnType >
25+ <Implementation ><![CDATA[ quit "Light pivot table"
26+ ]]> </Implementation >
27+ </Method >
28+
29+ <Method name =" %OnGetPortletIcon" >
30+ <ClassMethod >1</ClassMethod >
31+ <ReturnType >%String</ReturnType >
32+ <Implementation ><![CDATA[ quit "deepsee/ds2_dialpad_44.png"
33+ ]]> </Implementation >
34+ </Method >
35+
36+ <Method name =" %OnGetPortletSettings" >
37+ <ClassMethod >1</ClassMethod >
38+ <FormalSpec >*pInfo:%List</FormalSpec >
39+ <ReturnType >%Status</ReturnType >
40+ <Implementation ><![CDATA[
41+ kill pInfo // $LB(name,value,type,caption,title)
42+
43+ set pInfo($I(pInfo)) = $LB("dataSource","/SAMPLES","%String",$$$Text("MDX2JSON source","%DeepSee"),"THIS IS TITLE")
44+
45+ quit $$$OK
46+ ]]> </Implementation >
47+ </Method >
48+
49+ <Method name =" getConnectedController" >
50+ <Language >javascript</Language >
51+ <ClientMethod >1</ClientMethod >
52+ <Implementation ><![CDATA[
53+ var controller = this.getController();
54+
55+ if (null === controller) {
56+ this.connectToController();
57+ controller = this.getController();
58+ }
59+
60+ return controller;
61+ ]]> </Implementation >
62+ </Method >
63+
64+ <Method name =" onCreate" >
65+ <Language >javascript</Language >
66+ <ClientMethod >1</ClientMethod >
67+ <Implementation ><![CDATA[
68+ var container = document.getElementById(this.id),
69+ source,
70+ setup,
71+ _ = this,
72+ widget = this, // It's lie. It changes later.
73+ widgetKey,
74+ i, info = {};
75+
76+ var post = function (url, data, callback) {
77+
78+ var xhr = new XMLHttpRequest();
79+ xhr.open("POST", url);
80+ xhr.onreadystatechange = function () {
81+ if (xhr.readyState === 4 && xhr.status === 200) {
82+ callback((function () {
83+ try {
84+ return JSON.parse(xhr.responseText) || {}
85+ } catch (e) {
86+ return {
87+ error: "<h1>Unable to parse server response</h1><p>" + xhr.responseText
88+ + "</p>"
89+ };
90+ }
91+ })());
92+ } else if (xhr.readyState === 4 && xhr.status !== 200) {
93+ callback({ error: xhr.responseText
94+ || "Error while trying to retrieve data from server." });
95+ }
96+ };
97+ xhr.send(JSON.stringify(data));
98+
99+ };
100+
101+ if (!container) {
102+ console.error("Light pivot table: Unable to get widget with ID=" + this.id);
103+ return;
104+ }
105+
106+ for (i in container.childNodes) {
107+ if (container.childNodes[i].className === "lpt-container") {
108+ container = container.childNodes[i];
109+ break;
110+ }
111+ }
112+
113+ var _ = this;
114+
115+ setTimeout(function() { // onCreate fired when scripts are ready, but this.parent is missed.
116+
117+ // !ultra-bydlocode (get the widget object)
118+ while (widget["parent"]) {
119+ widget = widget["parent"];
120+ }
121+ // !ultra-bydlocode (possible you will have better suggestions to get widget key)
122+ widgetKey = parseInt(_.parent.parent.onwindowgrab.match(/[0-9]+/)[0]);
123+
124+ post((source = location.origin + container.getAttribute("data-source")) + "/Widgets", {
125+ Dashboard: widget["dashboardName"]
126+ }, function (data) {
127+ if (data.error) {
128+ container.innerHTML = "<br/><br/><h3>Unable to get data from server.</h3><p>Check if data source is configured and accessible: " + source + "/Widgets" + "</p>"
129+ } else {
130+ for (i in data.children) {
131+ if (data.children[i].key === widgetKey) {
132+ info = data.children[i];
133+ break;
134+ }
135+ }
136+ setup = {
137+ container: container,
138+ dataSource: {
139+ MDX2JSONSource: source,
140+ basicMDX: info["mdx"]
141+ }
142+ }
143+ post(source + "/DataSource", { DataSource: info["dataSource"] }, function (data) {
144+
145+ if (data["rowAxisOptions"] && data["rowAxisOptions"]["drilldownSpec"]) {
146+ console.log(data["rowAxisOptions"]["drilldownSpec"]);
147+ setup.DrillDownExpression = data["rowAxisOptions"]["drilldownSpec"];
148+ }
149+
150+ new LightPivotTable(setup);
151+
152+ });
153+ }
154+ });
155+
156+ }, 0);
157+ ]]> </Implementation >
158+ </Method >
159+
160+ <Method name =" %DrawHTML" >
161+ <Implementation ><![CDATA[
162+ set ..renderFlag = ..renderFlag + 1
163+
164+ &html<
165+ <div data-source="#(..settings("dataSource"))#" class="lpt-container" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%;">
166+
167+ </div>
168+ >
169+ ]]> </Implementation >
170+ </Method >
171+ </Class >
172+
173+ </Export >
0 commit comments