@progress/telerik-jquery-report-viewer 21.24.130 → 22.24.514
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/accessibility.js +218 -0
- package/dist/cjs/binder.js +172 -0
- package/dist/cjs/command.js +32 -0
- package/dist/cjs/commandSet.js +167 -0
- package/dist/cjs/controller.js +1207 -0
- package/dist/cjs/documentMapArea.js +168 -0
- package/dist/cjs/domUtils.js +50 -0
- package/dist/cjs/enums.js +52 -0
- package/dist/cjs/event-emitter.js +17 -0
- package/dist/cjs/events.js +23 -0
- package/dist/cjs/globalSettings.js +9 -0
- package/dist/cjs/history.js +131 -0
- package/dist/cjs/index.js +58 -0
- package/dist/cjs/jqueryThrottleDebounce.js +48 -0
- package/dist/cjs/kendo-jquery.js +4 -0
- package/dist/cjs/mainMenu.js +332 -0
- package/dist/cjs/mem-storage.js +44 -0
- package/dist/cjs/pagesArea.js +641 -0
- package/dist/cjs/parameterValidators.js +167 -0
- package/dist/cjs/parameters.js +921 -0
- package/dist/cjs/parametersArea.js +502 -0
- package/dist/cjs/perspectives.js +138 -0
- package/dist/cjs/print.js +166 -0
- package/dist/cjs/report-viewer/report-viewer-settings.js +138 -0
- package/dist/cjs/reportViewer.js +654 -0
- package/dist/cjs/scroll.js +537 -0
- package/dist/cjs/search.js +634 -0
- package/dist/cjs/sendEmail.js +435 -0
- package/dist/cjs/service-client-sentinel.js +52 -0
- package/dist/cjs/serviceClient.js +405 -0
- package/dist/cjs/sideMenu.js +225 -0
- package/dist/cjs/sr.js +164 -0
- package/dist/cjs/stringResources.js +11 -0
- package/dist/cjs/telerikReportViewer.kendo.js +60196 -0
- package/dist/cjs/telerikReportViewer.kendo.min.js +19776 -0
- package/dist/cjs/template-cache.js +39 -0
- package/dist/cjs/touch.js +86 -0
- package/dist/cjs/uiController.js +142 -0
- package/dist/cjs/uiFreezeCoordinator.js +281 -0
- package/dist/cjs/utils.js +492 -0
- package/dist/es/accessibility.js +214 -0
- package/dist/es/binder.js +168 -0
- package/dist/es/command.js +28 -0
- package/dist/es/commandSet.js +163 -0
- package/dist/es/controller.js +1203 -0
- package/dist/es/documentMapArea.js +164 -0
- package/dist/es/domUtils.js +43 -0
- package/dist/es/enums.js +41 -0
- package/dist/es/event-emitter.js +13 -0
- package/dist/es/events.js +19 -0
- package/dist/es/globalSettings.js +5 -0
- package/dist/es/history.js +127 -0
- package/dist/es/index.js +24 -0
- package/dist/es/jqueryThrottleDebounce.js +46 -0
- package/dist/es/kendo-jquery.js +1 -0
- package/dist/es/mainMenu.js +328 -0
- package/dist/es/mem-storage.js +40 -0
- package/dist/es/pagesArea.js +637 -0
- package/dist/es/parameterValidators.js +163 -0
- package/dist/es/parameters.js +916 -0
- package/dist/es/parametersArea.js +498 -0
- package/dist/es/perspectives.js +134 -0
- package/dist/es/print.js +162 -0
- package/dist/es/report-viewer/report-viewer-settings.js +134 -0
- package/dist/es/reportViewer.js +650 -0
- package/dist/es/scroll.js +533 -0
- package/dist/es/search.js +630 -0
- package/dist/es/sendEmail.js +431 -0
- package/dist/es/service-client-sentinel.js +48 -0
- package/dist/es/serviceClient.js +401 -0
- package/dist/es/sideMenu.js +221 -0
- package/dist/es/sr.js +162 -0
- package/dist/es/stringResources.js +7 -0
- package/dist/es/telerikReportViewer.kendo.js +60194 -0
- package/dist/es/telerikReportViewer.kendo.min.js +19774 -0
- package/dist/es/template-cache.js +35 -0
- package/dist/es/touch.js +82 -0
- package/dist/es/uiController.js +138 -0
- package/dist/es/uiFreezeCoordinator.js +277 -0
- package/dist/es/utils.js +447 -0
- package/dist/font/font-icons.css +4 -4
- package/dist/font/font-icons.min.css +3 -3
- package/dist/js/telerikReportViewer.js +8574 -8249
- package/dist/js/telerikReportViewer.min.js +1 -17
- package/dist/js/telerikReportViewer.stringResources.js +166 -173
- package/dist/styles/telerikReportViewer.css +1 -1
- package/dist/styles/telerikReportViewer.min.css +1 -1
- package/dist/templates/telerikReportViewerTemplate-FA.html +3 -3
- package/dist/templates/telerikReportViewerTemplate.html +3 -3
- package/package.json +13 -7
- /package/dist/font/{ReportingIcons-18.0.24.130.ttf → ReportingIcons-18.1.24.514.ttf} +0 -0
@@ -0,0 +1,1207 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
var utils = require('./utils.js');
|
6
|
+
var stringResources = require('./stringResources.js');
|
7
|
+
var print = require('./print.js');
|
8
|
+
var parameterValidators = require('./parameterValidators.js');
|
9
|
+
var enums = require('./enums.js');
|
10
|
+
var serviceClientSentinel = require('./service-client-sentinel.js');
|
11
|
+
var eventEmitter = require('./event-emitter.js');
|
12
|
+
|
13
|
+
var defaultOptions = {
|
14
|
+
pagePollIntervalMs: 500,
|
15
|
+
documentInfoPollIntervalMs: 2e3
|
16
|
+
};
|
17
|
+
function ReportViewerController(options) {
|
18
|
+
var controller = {};
|
19
|
+
var clientId;
|
20
|
+
var reportInstanceId;
|
21
|
+
var reportDocumentId;
|
22
|
+
var registerClientPromise;
|
23
|
+
var registerInstancePromise;
|
24
|
+
var documentFormatsPromise;
|
25
|
+
var report;
|
26
|
+
var parameterValues;
|
27
|
+
var processedParameterValues;
|
28
|
+
var currentPageNumber;
|
29
|
+
var pageCount;
|
30
|
+
var viewMode = enums.ViewModes.INTERACTIVE;
|
31
|
+
var pageMode = enums.PageModes.CONTINUOUS_SCROLL;
|
32
|
+
var loader;
|
33
|
+
var printMode = enums.PrintModes.AUTO_SELECT;
|
34
|
+
var bookmarkNodes;
|
35
|
+
var renderingExtensions;
|
36
|
+
var clientHasExpired = false;
|
37
|
+
var parameterValidators$1 = parameterValidators.ParameterValidators;
|
38
|
+
var eventEmitter$1 = new eventEmitter.EventEmitter();
|
39
|
+
var serviceClientSentinel$1;
|
40
|
+
clearReportState();
|
41
|
+
options = utils.extend({}, defaultOptions, options);
|
42
|
+
var settings = options.settings;
|
43
|
+
if (typeof settings.getPrintMode === "function") {
|
44
|
+
printMode = settings.getPrintMode();
|
45
|
+
}
|
46
|
+
var client = options.serviceClient;
|
47
|
+
if (!client) {
|
48
|
+
throw stringResources.stringResources.noServiceClient;
|
49
|
+
}
|
50
|
+
clientId = settings.getClientId();
|
51
|
+
initializeAndStartSentinel();
|
52
|
+
function setClientId(id) {
|
53
|
+
clientId = id;
|
54
|
+
stopSentinel();
|
55
|
+
settings.setClientId(clientId);
|
56
|
+
initializeAndStartSentinel();
|
57
|
+
}
|
58
|
+
function clearClientId() {
|
59
|
+
clientId = null;
|
60
|
+
registerClientPromise = null;
|
61
|
+
stopSentinel();
|
62
|
+
serviceClientSentinel$1 = null;
|
63
|
+
settings.setClientId(null);
|
64
|
+
}
|
65
|
+
function initializeAndStartSentinel() {
|
66
|
+
if (typeof settings.getKeepClientAlive !== "function") {
|
67
|
+
throw new Error("Required settings.getKeepClientAlive() is not supplied for ReportViewerController");
|
68
|
+
}
|
69
|
+
if (settings.getKeepClientAlive() && clientId) {
|
70
|
+
return client.getClientsSessionTimeoutSeconds().then(function(sessionTimeout) {
|
71
|
+
serviceClientSentinel$1 = new serviceClientSentinel.ServiceClientSentinel(client, clientId, sessionTimeout);
|
72
|
+
serviceClientSentinel$1.start();
|
73
|
+
});
|
74
|
+
}
|
75
|
+
}
|
76
|
+
function stopSentinel() {
|
77
|
+
if (settings.getKeepClientAlive() && !!serviceClientSentinel$1) {
|
78
|
+
serviceClientSentinel$1.stop();
|
79
|
+
}
|
80
|
+
}
|
81
|
+
function getFormat() {
|
82
|
+
if (viewMode === enums.ViewModes.PRINT_PREVIEW) {
|
83
|
+
return "HTML5";
|
84
|
+
}
|
85
|
+
return "HTML5Interactive";
|
86
|
+
}
|
87
|
+
function handleRequestError(xhrData, localizedMessage, suppressErrorBubbling) {
|
88
|
+
var errorMessage = "";
|
89
|
+
if (!xhrData.xhr) {
|
90
|
+
errorMessage = xhrData;
|
91
|
+
controller.raiseError(formatXhrError({ "responseText": errorMessage }, null, null, null));
|
92
|
+
throw errorMessage;
|
93
|
+
}
|
94
|
+
var xhr = xhrData.xhr;
|
95
|
+
if (utils.isInvalidClientException(xhr)) {
|
96
|
+
onClientExpired();
|
97
|
+
}
|
98
|
+
var formattedError = formatXhrError(
|
99
|
+
xhr,
|
100
|
+
xhrData.status,
|
101
|
+
utils.isInternalServerError(xhrData.error) ? "" : xhrData.error,
|
102
|
+
localizedMessage
|
103
|
+
);
|
104
|
+
controller.raiseError(formattedError);
|
105
|
+
if (!suppressErrorBubbling) {
|
106
|
+
if (utils.isApplicationException(xhr)) {
|
107
|
+
var exception = utils.getExceptionInstance(xhr);
|
108
|
+
if (exception) {
|
109
|
+
throw exception;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
throw xhr.responseJSON && xhr.responseJSON.exceptionMessage ? xhr.responseJSON.exceptionMessage : stringResources.stringResources.promisesChainStopError;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
function initializeClientAsync() {
|
116
|
+
if (!registerClientPromise) {
|
117
|
+
registerClientPromise = client.registerClient().catch(function(xhrErrorData) {
|
118
|
+
handleRequestError(xhrErrorData, stringResources.stringResources.errorRegisteringViewer);
|
119
|
+
}).then(function(clientId2) {
|
120
|
+
setClientId(clientId2);
|
121
|
+
}).catch(clearClientId);
|
122
|
+
}
|
123
|
+
return registerClientPromise;
|
124
|
+
}
|
125
|
+
function registerInstanceAsync() {
|
126
|
+
if (!registerInstancePromise) {
|
127
|
+
registerInstancePromise = createReportInstanceAsync(report, parameterValues).then(function(instanceId) {
|
128
|
+
reportInstanceId = instanceId;
|
129
|
+
});
|
130
|
+
registerInstancePromise.catch(function(errorMessage) {
|
131
|
+
registerInstancePromise = null;
|
132
|
+
});
|
133
|
+
}
|
134
|
+
return registerInstancePromise;
|
135
|
+
}
|
136
|
+
function clearReportState() {
|
137
|
+
reportDocumentId = null;
|
138
|
+
reportInstanceId = null;
|
139
|
+
registerInstancePromise = null;
|
140
|
+
resetPageNumbers();
|
141
|
+
}
|
142
|
+
function resetPageNumbers() {
|
143
|
+
currentPageNumber = pageCount = 0;
|
144
|
+
}
|
145
|
+
function formatError(args) {
|
146
|
+
var len = args.length;
|
147
|
+
if (len === 1) {
|
148
|
+
return args[0];
|
149
|
+
}
|
150
|
+
if (len > 1) {
|
151
|
+
return utils.stringFormat(args[0], Array.prototype.slice.call(args, 1));
|
152
|
+
}
|
153
|
+
return "";
|
154
|
+
}
|
155
|
+
function createReportInstanceAsync(report2, parameterValues2) {
|
156
|
+
throwIfNotInitialized();
|
157
|
+
return client.createReportInstance(clientId, report2, parameterValues2).catch(function(xhrErrorData) {
|
158
|
+
handleRequestError(xhrErrorData, utils.stringFormat(stringResources.stringResources.errorCreatingReportInstance, [utils.escapeHtml(report2)]));
|
159
|
+
});
|
160
|
+
}
|
161
|
+
function registerDocumentAsync(format, deviceInfo, useCache, baseDocumentId, actionId) {
|
162
|
+
throwIfNotInitialized();
|
163
|
+
throwIfNoReportInstance();
|
164
|
+
return client.createReportDocument(clientId, reportInstanceId, format, deviceInfo, useCache, baseDocumentId, actionId).catch(function(xhrErrorData) {
|
165
|
+
handleRequestError(xhrErrorData, utils.stringFormat(stringResources.stringResources.errorCreatingReportDocument, [utils.escapeHtml(report), utils.escapeHtml(format)]));
|
166
|
+
});
|
167
|
+
}
|
168
|
+
function sendDocumentAsync(documentId, args) {
|
169
|
+
throwIfNotInitialized();
|
170
|
+
throwIfNoReportInstance();
|
171
|
+
return client.sendDocument(clientId, reportInstanceId, documentId, args).catch(function(xhrErrorData) {
|
172
|
+
handleRequestError(xhrErrorData, utils.stringFormat(stringResources.stringResources.errorSendingDocument, [utils.escapeHtml(report)]));
|
173
|
+
});
|
174
|
+
}
|
175
|
+
function getDocumentInfoRecursive(clientId2, instanceId, documentId, options2) {
|
176
|
+
if (!options2.isCanceled && instanceId === reportInstanceId) {
|
177
|
+
return client.getDocumentInfo(clientId2, instanceId, documentId).catch(handleRequestError).then(function(info) {
|
178
|
+
if (info && info.documentReady) {
|
179
|
+
return info;
|
180
|
+
} else {
|
181
|
+
info["promise"] = new Promise(function(resolve, reject) {
|
182
|
+
window.setTimeout(resolve, options2.documentInfoPollIntervalMs);
|
183
|
+
}).then(function() {
|
184
|
+
return getDocumentInfoRecursive(clientId2, instanceId, documentId, options2);
|
185
|
+
});
|
186
|
+
return info;
|
187
|
+
}
|
188
|
+
});
|
189
|
+
} else {
|
190
|
+
return Promise.reject();
|
191
|
+
}
|
192
|
+
}
|
193
|
+
function ReportLoader(reportHost, useCache, baseDocumentId, actionId) {
|
194
|
+
var loaderOptions = {};
|
195
|
+
function onReportDocumentRegistered(id) {
|
196
|
+
if (reportHost) {
|
197
|
+
reportDocumentId = id;
|
198
|
+
onBeginLoadReport();
|
199
|
+
getReportDocumentReady();
|
200
|
+
}
|
201
|
+
}
|
202
|
+
function onBeforeLoadReport(args) {
|
203
|
+
loaderOptions.documentInfoPollIntervalMs = options.pagePollIntervalMs;
|
204
|
+
if (reportHost) {
|
205
|
+
reportHost.beforeLoadReport(args);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
function onBeginLoadReport() {
|
209
|
+
if (reportHost) {
|
210
|
+
reportHost.beginLoadReport();
|
211
|
+
}
|
212
|
+
}
|
213
|
+
function onReportLoadComplete(info) {
|
214
|
+
if (reportHost) {
|
215
|
+
reportHost.onReportLoadComplete(info);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
function onReportLoadProgress(info) {
|
219
|
+
if (reportHost) {
|
220
|
+
pageCount = info.pageCount;
|
221
|
+
reportHost.reportLoadProgress(info);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
function getReportDocumentReady() {
|
225
|
+
throwIfNotInitialized();
|
226
|
+
throwIfNoReportInstance();
|
227
|
+
throwIfNoReportDocument();
|
228
|
+
progressReportDocumentReady(getDocumentInfoRecursive(clientId, reportInstanceId, reportDocumentId, loaderOptions));
|
229
|
+
}
|
230
|
+
function progressReportDocumentReady(getDocumentReadyPromise) {
|
231
|
+
getDocumentReadyPromise.then(function(info) {
|
232
|
+
if (info.documentReady) {
|
233
|
+
onReportLoadComplete(info);
|
234
|
+
} else {
|
235
|
+
onReportLoadProgress(info);
|
236
|
+
progressReportDocumentReady(info.promise);
|
237
|
+
}
|
238
|
+
});
|
239
|
+
}
|
240
|
+
function getPageAsync(pageNo) {
|
241
|
+
return new Promise(function(resolve, reject) {
|
242
|
+
var fn = function() {
|
243
|
+
client.getPage(clientId, reportInstanceId, reportDocumentId, pageNo).catch(handleRequestError).then(function(pageInfo) {
|
244
|
+
if (pageInfo.pageReady) {
|
245
|
+
resolve(pageInfo);
|
246
|
+
} else {
|
247
|
+
window.setTimeout(fn, options.pagePollIntervalMs);
|
248
|
+
}
|
249
|
+
});
|
250
|
+
};
|
251
|
+
fn();
|
252
|
+
});
|
253
|
+
}
|
254
|
+
function onBeginLoadPage(pageNo) {
|
255
|
+
if (reportHost) {
|
256
|
+
reportHost.beginLoadPage(pageNo);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
var loadPromise;
|
260
|
+
function loadAsync() {
|
261
|
+
if (!loadPromise) {
|
262
|
+
var format = getFormat();
|
263
|
+
var deviceInfo = createPreviewDeviceInfo();
|
264
|
+
onBeforeLoadReport({ deviceInfo });
|
265
|
+
loadPromise = initializeClientAsync().then(registerInstanceAsync).then(function() {
|
266
|
+
return registerDocumentAsync(format, deviceInfo, useCache, baseDocumentId, actionId);
|
267
|
+
}).then(onReportDocumentRegistered);
|
268
|
+
}
|
269
|
+
return loadPromise;
|
270
|
+
}
|
271
|
+
function createPreviewDeviceInfo() {
|
272
|
+
var deviceInfo = createDeviceInfo();
|
273
|
+
deviceInfo.ContentOnly = true;
|
274
|
+
deviceInfo.UseSVG = utils.isSvgSupported();
|
275
|
+
return deviceInfo;
|
276
|
+
}
|
277
|
+
return {
|
278
|
+
beginLoad: function() {
|
279
|
+
loadAsync();
|
280
|
+
},
|
281
|
+
beginGetPage: function(pageNo) {
|
282
|
+
throwIfNotInitialized();
|
283
|
+
loadAsync().then(function() {
|
284
|
+
onBeginLoadPage(pageNo);
|
285
|
+
return getPageAsync(pageNo);
|
286
|
+
}).then(function(pageInfo) {
|
287
|
+
loaderOptions.documentInfoPollIntervalMs = options.documentInfoPollIntervalMs;
|
288
|
+
if (reportHost) {
|
289
|
+
reportHost.pageReady(pageInfo);
|
290
|
+
}
|
291
|
+
});
|
292
|
+
},
|
293
|
+
getPageData: function(pageNo) {
|
294
|
+
throwIfNotInitialized();
|
295
|
+
return loadAsync().then(function() {
|
296
|
+
return getPageAsync(pageNo);
|
297
|
+
});
|
298
|
+
},
|
299
|
+
dispose: function() {
|
300
|
+
reportHost = null;
|
301
|
+
},
|
302
|
+
cancel: function() {
|
303
|
+
loaderOptions.isCanceled = true;
|
304
|
+
}
|
305
|
+
};
|
306
|
+
}
|
307
|
+
function createDeviceInfo() {
|
308
|
+
var deviceInfo = {};
|
309
|
+
if (settings.getEnableAccessibility()) {
|
310
|
+
deviceInfo.enableAccessibility = true;
|
311
|
+
deviceInfo.contentTabIndex = settings.contentTabIndex;
|
312
|
+
}
|
313
|
+
var args = {};
|
314
|
+
controller.getSearchDialogState(args);
|
315
|
+
var searchInitiated = args.visible;
|
316
|
+
var searchMetadataOnDemand = settings.getSearchMetadataOnDemand();
|
317
|
+
var enableSearch = !searchMetadataOnDemand || searchInitiated;
|
318
|
+
deviceInfo.enableSearch = enableSearch;
|
319
|
+
return deviceInfo;
|
320
|
+
}
|
321
|
+
function tryResolveClientErrorByExceptionType(exceptionType) {
|
322
|
+
var parameterExceptionShortName = "InvalidParameterException";
|
323
|
+
return utils.exceptionTypeNamesMatch(exceptionType, parameterExceptionShortName, "Telerik.Reporting.Services.Engine." + parameterExceptionShortName) ? stringResources.stringResources.missingOrInvalidParameter : "";
|
324
|
+
}
|
325
|
+
function formatXhrError(xhr, status, error, localizedMessage) {
|
326
|
+
var parsedXhr = utils.parseJSON(xhr.responseText);
|
327
|
+
var result = "";
|
328
|
+
if (parsedXhr) {
|
329
|
+
var errorMessage = tryResolveClientErrorByExceptionType(parsedXhr.exceptionType || parsedXhr.error);
|
330
|
+
if (errorMessage) {
|
331
|
+
return errorMessage;
|
332
|
+
}
|
333
|
+
result = utils.escapeHtml(parsedXhr.message);
|
334
|
+
var exceptionMessage = utils.escapeHtml(parsedXhr.exceptionMessage || parsedXhr.error_description);
|
335
|
+
if (exceptionMessage) {
|
336
|
+
if (result) {
|
337
|
+
result += " " + exceptionMessage;
|
338
|
+
} else {
|
339
|
+
result = exceptionMessage;
|
340
|
+
}
|
341
|
+
}
|
342
|
+
} else {
|
343
|
+
result = utils.escapeHtml(xhr.responseText);
|
344
|
+
}
|
345
|
+
if (localizedMessage || error) {
|
346
|
+
if (result) {
|
347
|
+
result = " " + result;
|
348
|
+
}
|
349
|
+
result = utils.escapeHtml(localizedMessage ? localizedMessage : error) + result;
|
350
|
+
}
|
351
|
+
if (utils.isInvalidClientException(xhr)) {
|
352
|
+
result += "<br />" + stringResources.stringResources.clientExpired;
|
353
|
+
}
|
354
|
+
return result;
|
355
|
+
}
|
356
|
+
function getReportPage(pageNo) {
|
357
|
+
if (loader) {
|
358
|
+
loader.beginGetPage(pageNo);
|
359
|
+
}
|
360
|
+
}
|
361
|
+
function loadReportAsync(ignoreCache, baseDocumentId, actionId) {
|
362
|
+
if (!report) {
|
363
|
+
controller.raiseError(stringResources.stringResources.noReport);
|
364
|
+
return;
|
365
|
+
}
|
366
|
+
if (loader) {
|
367
|
+
loader.dispose();
|
368
|
+
loader = null;
|
369
|
+
}
|
370
|
+
clearReportState();
|
371
|
+
loader = new ReportLoader(controller, !ignoreCache, baseDocumentId, actionId);
|
372
|
+
loader.beginLoad();
|
373
|
+
}
|
374
|
+
function printReport() {
|
375
|
+
throwIfNoReport();
|
376
|
+
var deviceInfo = {
|
377
|
+
ImmediatePrint: true
|
378
|
+
};
|
379
|
+
var printStartArgs = {
|
380
|
+
deviceInfo,
|
381
|
+
handled: false
|
382
|
+
};
|
383
|
+
controller.printStarted(printStartArgs);
|
384
|
+
if (!printStartArgs.handled) {
|
385
|
+
controller.setUIState({
|
386
|
+
operationName: "PrintInProgress",
|
387
|
+
inProgress: true
|
388
|
+
});
|
389
|
+
controller.showNotification({ stringResources: "preparingPrint" });
|
390
|
+
var canUsePlugin = getCanUsePlugin();
|
391
|
+
var contentDisposition = canUsePlugin ? "inline" : "attachment";
|
392
|
+
var queryString = "response-content-disposition=" + contentDisposition;
|
393
|
+
exportAsync("PDF", deviceInfo).then(
|
394
|
+
function(info) {
|
395
|
+
var url = client.formatDocumentUrl(info.clientId, info.instanceId, info.documentId, queryString);
|
396
|
+
var printEndArgs = {
|
397
|
+
url,
|
398
|
+
handled: false
|
399
|
+
};
|
400
|
+
controller.printReady(printEndArgs);
|
401
|
+
controller.hideNotification();
|
402
|
+
controller.setUIState({
|
403
|
+
operationName: "PrintInProgress",
|
404
|
+
inProgress: false
|
405
|
+
});
|
406
|
+
if (!printEndArgs.handled) {
|
407
|
+
print.PrintManager.print(url);
|
408
|
+
}
|
409
|
+
}
|
410
|
+
);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
function getCanUsePlugin() {
|
414
|
+
switch (printMode) {
|
415
|
+
case enums.PrintModes.FORCE_PDF_FILE:
|
416
|
+
case false:
|
417
|
+
return false;
|
418
|
+
case enums.PrintModes.FORCE_PDF_PLUGIN:
|
419
|
+
case true:
|
420
|
+
return true;
|
421
|
+
default:
|
422
|
+
return print.PrintManager.getDirectPrintState();
|
423
|
+
}
|
424
|
+
}
|
425
|
+
function exportReport(format, deviceInfo) {
|
426
|
+
throwIfNoReport();
|
427
|
+
if (!deviceInfo) {
|
428
|
+
deviceInfo = createDeviceInfo();
|
429
|
+
}
|
430
|
+
var exportStartArgs = {
|
431
|
+
format,
|
432
|
+
deviceInfo,
|
433
|
+
handled: false
|
434
|
+
};
|
435
|
+
controller.exportStarted(exportStartArgs);
|
436
|
+
if (!exportStartArgs.handled) {
|
437
|
+
var queryString = "response-content-disposition=attachment";
|
438
|
+
controller.setUIState({
|
439
|
+
operationName: "ExportInProgress",
|
440
|
+
inProgress: true
|
441
|
+
});
|
442
|
+
controller.showNotification({ stringResources: "preparingDownload" });
|
443
|
+
exportAsync(format, exportStartArgs.deviceInfo).then(
|
444
|
+
function(info) {
|
445
|
+
var url = client.formatDocumentUrl(info.clientId, info.instanceId, info.documentId, queryString);
|
446
|
+
var exportEndArgs = {
|
447
|
+
url,
|
448
|
+
format,
|
449
|
+
handled: false,
|
450
|
+
windowOpenTarget: "_self"
|
451
|
+
};
|
452
|
+
controller.exportReady(exportEndArgs);
|
453
|
+
controller.hideNotification();
|
454
|
+
controller.setUIState({
|
455
|
+
operationName: "ExportInProgress",
|
456
|
+
inProgress: false
|
457
|
+
});
|
458
|
+
if (!exportEndArgs.handled) {
|
459
|
+
window.open(url, exportEndArgs.windowOpenTarget);
|
460
|
+
}
|
461
|
+
}
|
462
|
+
);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
function sendReport(args) {
|
466
|
+
throwIfNoReport();
|
467
|
+
if (!args.deviceInfo) {
|
468
|
+
args.deviceInfo = createDeviceInfo();
|
469
|
+
}
|
470
|
+
var sendEmailStartArgs = {
|
471
|
+
deviceInfo: args.deviceInfo,
|
472
|
+
handled: false,
|
473
|
+
format: args.format
|
474
|
+
};
|
475
|
+
controller.sendEmailStarted(sendEmailStartArgs);
|
476
|
+
var queryString = "response-content-disposition=attachment";
|
477
|
+
if (!sendEmailStartArgs.handled) {
|
478
|
+
exportAsync(args.format, args.deviceInfo).then(
|
479
|
+
function(info) {
|
480
|
+
var url = client.formatDocumentUrl(info.clientId, info.instanceId, info.documentId, queryString);
|
481
|
+
args["url"] = url;
|
482
|
+
args["handled"] = false;
|
483
|
+
controller.sendEmailReady(args);
|
484
|
+
delete args.deviceInfo;
|
485
|
+
if (!args.handled) {
|
486
|
+
sendDocumentAsync(info.documentId, args);
|
487
|
+
}
|
488
|
+
}
|
489
|
+
);
|
490
|
+
}
|
491
|
+
}
|
492
|
+
function exportAsync(format, deviceInfo) {
|
493
|
+
throwIfNoReport();
|
494
|
+
return initializeClientAsync().then(registerInstanceAsync).then(function() {
|
495
|
+
return registerDocumentAsync(format, deviceInfo, true, reportDocumentId);
|
496
|
+
}).then(function(documentId) {
|
497
|
+
return waitReportDocumentReady(clientId, reportInstanceId, documentId, options);
|
498
|
+
});
|
499
|
+
}
|
500
|
+
function waitReportDocumentReady(clientId2, reportInstanceId2, documentId, options2) {
|
501
|
+
return new Promise(function(resolve, reject) {
|
502
|
+
var fn = function(promise) {
|
503
|
+
promise.then(function(info) {
|
504
|
+
if (info.documentReady) {
|
505
|
+
resolve({
|
506
|
+
clientId: clientId2,
|
507
|
+
instanceId: reportInstanceId2,
|
508
|
+
documentId
|
509
|
+
});
|
510
|
+
} else {
|
511
|
+
fn(info.promise);
|
512
|
+
}
|
513
|
+
});
|
514
|
+
};
|
515
|
+
fn(getDocumentInfoRecursive(clientId2, reportInstanceId2, documentId, options2));
|
516
|
+
});
|
517
|
+
}
|
518
|
+
function execServerAction(actionId) {
|
519
|
+
throwIfNoReport();
|
520
|
+
throwIfNoReportInstance();
|
521
|
+
throwIfNoReportDocument();
|
522
|
+
onServerActionStarted();
|
523
|
+
controller.refreshReportCore(false, reportDocumentId, actionId);
|
524
|
+
}
|
525
|
+
function throwIfNotInitialized() {
|
526
|
+
if (!clientId) {
|
527
|
+
throw stringResources.stringResources.controllerNotInitialized;
|
528
|
+
}
|
529
|
+
}
|
530
|
+
function throwIfNoReportInstance() {
|
531
|
+
if (!reportInstanceId) {
|
532
|
+
throw stringResources.stringResources.noReportInstance;
|
533
|
+
}
|
534
|
+
}
|
535
|
+
function throwIfNoReportDocument() {
|
536
|
+
if (!reportDocumentId) {
|
537
|
+
throw stringResources.stringResources.noReportDocument;
|
538
|
+
}
|
539
|
+
}
|
540
|
+
function throwIfNoReport() {
|
541
|
+
if (!report) {
|
542
|
+
throw stringResources.stringResources.noReport;
|
543
|
+
}
|
544
|
+
}
|
545
|
+
function eventFactory(event, args) {
|
546
|
+
if (typeof args[0] === "function") {
|
547
|
+
eventEmitter$1.on(event, args[0]);
|
548
|
+
} else {
|
549
|
+
eventEmitter$1.trigger(event, args);
|
550
|
+
}
|
551
|
+
return controller;
|
552
|
+
}
|
553
|
+
function loadParametersAsync(report2, paramValues) {
|
554
|
+
return initializeClientAsync().then(function() {
|
555
|
+
return client.getParameters(clientId, report2, paramValues || parameterValues || {}).catch(function(xhrErrorData) {
|
556
|
+
handleRequestError(xhrErrorData, stringResources.stringResources.unableToGetReportParameters);
|
557
|
+
});
|
558
|
+
});
|
559
|
+
}
|
560
|
+
function getDocumentFormatsAsync() {
|
561
|
+
if (renderingExtensions) {
|
562
|
+
return Promise.resolve(renderingExtensions);
|
563
|
+
}
|
564
|
+
if (!documentFormatsPromise) {
|
565
|
+
documentFormatsPromise = client.getDocumentFormats().catch(handleRequestError);
|
566
|
+
}
|
567
|
+
return documentFormatsPromise;
|
568
|
+
}
|
569
|
+
function getServiceVersionAsync() {
|
570
|
+
return client.getServiceVersion().catch(handleRequestError);
|
571
|
+
}
|
572
|
+
function getPageForBookmark(nodes, id) {
|
573
|
+
if (nodes) {
|
574
|
+
for (var i = 0, len = nodes.length; i < len; i++) {
|
575
|
+
var node = nodes[i];
|
576
|
+
if (node.id === id) {
|
577
|
+
return node.page;
|
578
|
+
} else {
|
579
|
+
var page = getPageForBookmark(node.items, id);
|
580
|
+
if (page) {
|
581
|
+
return page;
|
582
|
+
}
|
583
|
+
}
|
584
|
+
}
|
585
|
+
}
|
586
|
+
return null;
|
587
|
+
}
|
588
|
+
function fixDataContractJsonSerializer(arr) {
|
589
|
+
var dict = {};
|
590
|
+
if (Array.isArray(arr)) {
|
591
|
+
arr.forEach(function(pair) {
|
592
|
+
dict[pair.Key] = pair.Value;
|
593
|
+
});
|
594
|
+
}
|
595
|
+
return dict;
|
596
|
+
}
|
597
|
+
function changeReportSource(rs) {
|
598
|
+
setStateReportSource(rs);
|
599
|
+
controller.reportSourceChanged();
|
600
|
+
}
|
601
|
+
function setStateReportSource(rs) {
|
602
|
+
if (typeof settings.setReportSource === "function") {
|
603
|
+
settings.setReportSource(rs);
|
604
|
+
}
|
605
|
+
}
|
606
|
+
function changePageNumber(pageNr) {
|
607
|
+
settings.setPageNumber(pageNr);
|
608
|
+
controller.currentPageChanged();
|
609
|
+
}
|
610
|
+
var actionHandlers = {
|
611
|
+
"sorting": function(action) {
|
612
|
+
execServerAction(action.Id);
|
613
|
+
},
|
614
|
+
"toggleVisibility": function(action) {
|
615
|
+
execServerAction(action.Id);
|
616
|
+
},
|
617
|
+
"navigateToReport": function(action) {
|
618
|
+
var args = action.Value;
|
619
|
+
onServerActionStarted();
|
620
|
+
controller.setReportSource({
|
621
|
+
report: args.Report,
|
622
|
+
parameters: fixDataContractJsonSerializer(args.ParameterValues)
|
623
|
+
});
|
624
|
+
controller.refreshReport(false);
|
625
|
+
},
|
626
|
+
"navigateToUrl": function(action) {
|
627
|
+
var args = action.Value;
|
628
|
+
window.open(args.Url, args.Target);
|
629
|
+
},
|
630
|
+
"navigateToBookmark": function(action) {
|
631
|
+
var id = action.Value;
|
632
|
+
var page = getPageForBookmark(bookmarkNodes, id);
|
633
|
+
controller.navigateToPage(page, {
|
634
|
+
type: "bookmark",
|
635
|
+
id
|
636
|
+
});
|
637
|
+
},
|
638
|
+
"customAction": function(action) {
|
639
|
+
}
|
640
|
+
};
|
641
|
+
function onInteractiveActionExecuting(interactiveActionArgs) {
|
642
|
+
controller.interactiveActionExecuting(interactiveActionArgs);
|
643
|
+
}
|
644
|
+
function executeReportAction(interactiveActionArgs) {
|
645
|
+
var action = interactiveActionArgs.action;
|
646
|
+
var handler = actionHandlers[action.Type];
|
647
|
+
if (typeof handler === "function") {
|
648
|
+
window.setTimeout(function() {
|
649
|
+
onInteractiveActionExecuting(interactiveActionArgs);
|
650
|
+
if (!interactiveActionArgs.cancel) {
|
651
|
+
handler(action);
|
652
|
+
}
|
653
|
+
}, 0);
|
654
|
+
}
|
655
|
+
}
|
656
|
+
function onServerActionStarted() {
|
657
|
+
controller.serverActionStarted();
|
658
|
+
}
|
659
|
+
function onReportActionEnter(args) {
|
660
|
+
controller.interactiveActionEnter({
|
661
|
+
action: args.action,
|
662
|
+
element: args.element
|
663
|
+
});
|
664
|
+
}
|
665
|
+
function onReportActionLeave(args) {
|
666
|
+
controller.interactiveActionLeave({
|
667
|
+
action: args.action,
|
668
|
+
element: args.element
|
669
|
+
});
|
670
|
+
}
|
671
|
+
function onClientExpired() {
|
672
|
+
clientHasExpired = true;
|
673
|
+
controller.clientExpired();
|
674
|
+
}
|
675
|
+
function onReportToolTipOpening(args) {
|
676
|
+
controller.toolTipOpening(args);
|
677
|
+
}
|
678
|
+
function getSearchResultsAsync(args) {
|
679
|
+
if (!args.searchToken || args.searchToken === "") {
|
680
|
+
return Promise.resolve(null);
|
681
|
+
}
|
682
|
+
return client.getSearchResults(clientId, reportInstanceId, reportDocumentId, args.searchToken, args.matchCase, args.matchWholeWord, args.useRegex).catch(handleSearchResultsError);
|
683
|
+
}
|
684
|
+
function handleSearchResultsError(xhrData) {
|
685
|
+
if (!utils.isSystemArgumentException(xhrData.xhr)) {
|
686
|
+
handleRequestError(xhrData, null, true);
|
687
|
+
throw null;
|
688
|
+
}
|
689
|
+
var exceptionDetails = utils.parseJSON(xhrData.xhr.responseText);
|
690
|
+
throw exceptionDetails.exceptionMessage;
|
691
|
+
}
|
692
|
+
function appendInvalidReportParameterNames(invalidParameters) {
|
693
|
+
var errorElement = document.querySelector(".trv-pages-area .trv-error-message");
|
694
|
+
var invalidParametersHolder = document.createElement("ul");
|
695
|
+
for (var index = 0; index < invalidParameters.length; index++) {
|
696
|
+
var invalidParameterText = document.createElement("li");
|
697
|
+
invalidParameterText.classList.add(invalidParameters[index].name);
|
698
|
+
invalidParameterText.innerText = utils.stringFormat("{0} ({1})", [invalidParameters[index].text, invalidParameters[index].name]);
|
699
|
+
invalidParametersHolder.appendChild(invalidParameterText);
|
700
|
+
}
|
701
|
+
errorElement.appendChild(invalidParametersHolder);
|
702
|
+
}
|
703
|
+
controller.Events = {
|
704
|
+
ERROR: "error",
|
705
|
+
EXPORT_STARTED: "exportStarted",
|
706
|
+
EXPORT_DOCUMENT_READY: "exportDocumentReady",
|
707
|
+
PRINT_STARTED: "printStarted",
|
708
|
+
PRINT_DOCUMENT_READY: "printDocumentReady",
|
709
|
+
BEFORE_LOAD_PARAMETERS: "beforeLoadParameters",
|
710
|
+
LOADED_REPORT_CHANGE: "loadedReportChange",
|
711
|
+
BEFORE_LOAD_REPORT: "beforeLoadReport",
|
712
|
+
BEGIN_LOAD_REPORT: "beginLoadReport",
|
713
|
+
REPORT_LOAD_COMPLETE: "reportLoadComplete",
|
714
|
+
REPORT_LOAD_PROGRESS: "reportLoadProgress",
|
715
|
+
REPORT_LOAD_FAIL: "reportLoadFail",
|
716
|
+
BEGIN_LOAD_PAGE: "beginLoadPage",
|
717
|
+
PAGE_READY: "pageReady",
|
718
|
+
VIEW_MODE_CHANGED: "viewModeChanged",
|
719
|
+
PAGE_MODE_CHANGED: "pageModeChanged",
|
720
|
+
PRINT_MODE_CHANGED: "printModeChanged",
|
721
|
+
REPORT_SOURCE_CHANGED: "reportSourceChanged",
|
722
|
+
NAVIGATE_TO_PAGE: "navigateToPage",
|
723
|
+
CURRENT_PAGE_CHANGED: "currentPageChanged",
|
724
|
+
GET_DOCUMENT_MAP_STATE: "trv.GET_DOCUMENT_MAP_STATE",
|
725
|
+
SET_DOCUMENT_MAP_VISIBLE: "trv.SET_DOCUMENT_MAP_VISIBLE",
|
726
|
+
GET_PARAMETER_AREA_STATE: "trv.GET_PARAMETER_AREA_STATE",
|
727
|
+
SET_PARAMETER_AREA_VISIBLE: "trv.SET_PARAMETER_AREA_VISIBLE",
|
728
|
+
SCALE_CHANGED: "scaleChanged",
|
729
|
+
SCALE_MODE_CHANGED: "scaleModeChanged",
|
730
|
+
SERVER_ACTION_STARTED: "serverActionStarted",
|
731
|
+
SET_TOGGLE_SIDE_MENU: "trv.SET_TOGGLE_SIDE_MENU",
|
732
|
+
GET_TOGGLE_SIDE_MENU: "trv.GET_TOGGLE_SIDE_MENU",
|
733
|
+
UPDATE_UI: "trv.UPDATE_UI",
|
734
|
+
CSS_LOADED: "cssLoaded",
|
735
|
+
RELOAD_PARAMETERS: "reloadParameters",
|
736
|
+
INTERACTIVE_ACTION_EXECUTING: "interactiveActionExecuting",
|
737
|
+
INTERACTIVE_ACTION_ENTER: "interactiveActionEnter",
|
738
|
+
INTERACTIVE_ACTION_LEAVE: "interactiveActionLeave",
|
739
|
+
UPDATE_UI_INTERNAL: "trv.UPDATE_UI_INTERNAL",
|
740
|
+
CLIENT_EXPIRED: "clientExpired",
|
741
|
+
TOOLTIP_OPENING: "tooltipOpening",
|
742
|
+
TOOLTIP_CLOSING: "tooltipClosing",
|
743
|
+
PAGE_NUMBER: "trv.PAGE_NUMBER",
|
744
|
+
PAGE_COUNT: "trv.PAGE_COUNT",
|
745
|
+
GET_SEARCH_DIALOG_STATE: "trv.GET_SEARCH_DIALOG_STATE",
|
746
|
+
GET_SEND_EMAIL_DIALOG_STATE: "trv.GET_SEND_EMAIL_DIALOG_STATE",
|
747
|
+
SET_SEARCH_DIALOG_VISIBLE: "trv.SET_SEARCH_DIALOG_VISIBLE",
|
748
|
+
SET_SEND_EMAIL_DIALOG_VISIBLE: "trv.SET_SEND_EMAIL_DIALOG_VISIBLE",
|
749
|
+
SEND_EMAIL_STARTED: "sendEmailStarted",
|
750
|
+
SEND_EMAIL_READY: "sendEmailDocumentReady",
|
751
|
+
SHOW_NOTIFICATION: "trv.SHOW_NOTIFICATION",
|
752
|
+
HIDE_NOTIFICATION: "trv.HIDE_NOTIFICATION",
|
753
|
+
UI_STATE: "trv.UI_STATE",
|
754
|
+
SCROLL_PAGE_READY: "scrollPageReady",
|
755
|
+
UPDATE_SCROLL_PAGE_DIMENSIONS_READY: "trv.UPDATE_SCROLL_PAGE_DIMENSIONS_READY",
|
756
|
+
MISSING_OR_INVALID_PARAMETERS: "missingOrInvalidParameters",
|
757
|
+
RENDERING_STOPPED: "renderingStopped"
|
758
|
+
};
|
759
|
+
utils.extend(
|
760
|
+
controller,
|
761
|
+
{
|
762
|
+
getPageData: function(pageNumber) {
|
763
|
+
if (loader) {
|
764
|
+
return loader.getPageData(pageNumber);
|
765
|
+
}
|
766
|
+
return;
|
767
|
+
},
|
768
|
+
getReportSource: function() {
|
769
|
+
if (report === null) {
|
770
|
+
return null;
|
771
|
+
}
|
772
|
+
return {
|
773
|
+
report,
|
774
|
+
parameters: utils.extend({}, parameterValues)
|
775
|
+
};
|
776
|
+
},
|
777
|
+
setReportSource: function(rs) {
|
778
|
+
if (rs === null) {
|
779
|
+
report = parameterValues = null;
|
780
|
+
clearReportState();
|
781
|
+
changeReportSource(rs);
|
782
|
+
return this;
|
783
|
+
}
|
784
|
+
report = rs.report;
|
785
|
+
parameterValues = rs.parameters;
|
786
|
+
changeReportSource(rs);
|
787
|
+
return this;
|
788
|
+
},
|
789
|
+
updateSettings: function(settings2) {
|
790
|
+
options.settings = utils.extend({}, settings2, options.settings);
|
791
|
+
},
|
792
|
+
clearReportSource: function() {
|
793
|
+
report = parameterValues = null;
|
794
|
+
clearReportState();
|
795
|
+
changeReportSource(void 0);
|
796
|
+
return this;
|
797
|
+
},
|
798
|
+
getReportDocumentId: function() {
|
799
|
+
return reportDocumentId;
|
800
|
+
},
|
801
|
+
setReportDocumentId: function(documentId) {
|
802
|
+
reportDocumentId = documentId;
|
803
|
+
},
|
804
|
+
setParameters: function(paramValues) {
|
805
|
+
parameterValues = paramValues;
|
806
|
+
},
|
807
|
+
setProcessedParameter: function(processedParamValues) {
|
808
|
+
processedParameterValues = processedParamValues;
|
809
|
+
},
|
810
|
+
getPageCount: function() {
|
811
|
+
return pageCount;
|
812
|
+
},
|
813
|
+
getCurrentPageNumber: function() {
|
814
|
+
return currentPageNumber;
|
815
|
+
},
|
816
|
+
setCurrentPageNumber: function(pageNo) {
|
817
|
+
var num = utils.tryParseInt(pageNo);
|
818
|
+
if (num !== currentPageNumber) {
|
819
|
+
currentPageNumber = num;
|
820
|
+
changePageNumber(num);
|
821
|
+
}
|
822
|
+
return this;
|
823
|
+
},
|
824
|
+
getScale: function() {
|
825
|
+
return settings.getScale();
|
826
|
+
},
|
827
|
+
setScale: function(scale) {
|
828
|
+
if (settings.getScale() !== scale) {
|
829
|
+
settings.setScale(scale);
|
830
|
+
controller.scaleChanged(scale);
|
831
|
+
controller.setScaleMode(enums.ScaleModes.SPECIFIC);
|
832
|
+
}
|
833
|
+
return controller;
|
834
|
+
},
|
835
|
+
getScaleMode: function() {
|
836
|
+
return settings.getScaleMode();
|
837
|
+
},
|
838
|
+
setScaleMode: function(scaleMode) {
|
839
|
+
if (settings.getScaleMode() !== scaleMode) {
|
840
|
+
settings.setScaleMode(scaleMode);
|
841
|
+
controller.scaleModeChanged(scaleMode);
|
842
|
+
}
|
843
|
+
return controller;
|
844
|
+
},
|
845
|
+
getViewMode: function() {
|
846
|
+
return viewMode;
|
847
|
+
},
|
848
|
+
setViewMode: function(vm) {
|
849
|
+
if (viewMode !== vm) {
|
850
|
+
viewMode = vm;
|
851
|
+
controller.viewModeChanged(vm);
|
852
|
+
if (report) {
|
853
|
+
controller.refreshReportCore(false, reportDocumentId);
|
854
|
+
}
|
855
|
+
}
|
856
|
+
return controller;
|
857
|
+
},
|
858
|
+
getPageMode: function() {
|
859
|
+
return pageMode;
|
860
|
+
},
|
861
|
+
setPageMode: function(psm) {
|
862
|
+
if (pageMode !== psm) {
|
863
|
+
pageMode = psm;
|
864
|
+
controller.pageModeChanged(psm);
|
865
|
+
if (report) {
|
866
|
+
controller.refreshReportCore(false, reportDocumentId);
|
867
|
+
}
|
868
|
+
}
|
869
|
+
return controller;
|
870
|
+
},
|
871
|
+
getPrintMode: function() {
|
872
|
+
return printMode;
|
873
|
+
},
|
874
|
+
setPrintMode: function(pm) {
|
875
|
+
if (printMode !== pm) {
|
876
|
+
printMode = pm;
|
877
|
+
controller.printModeChanged(pm);
|
878
|
+
}
|
879
|
+
return controller;
|
880
|
+
},
|
881
|
+
previewReport: function(ignoreCache, baseDocumentId, actionId) {
|
882
|
+
controller.loadedReportChange();
|
883
|
+
controller.refreshReportCore(ignoreCache, baseDocumentId, actionId);
|
884
|
+
},
|
885
|
+
refreshReportCore: function(ignoreCache, baseDocumentId, actionId) {
|
886
|
+
loadReportAsync(ignoreCache, baseDocumentId, actionId);
|
887
|
+
},
|
888
|
+
stopRendering: function() {
|
889
|
+
throwIfNoReport();
|
890
|
+
throwIfNoReportInstance();
|
891
|
+
throwIfNoReportDocument();
|
892
|
+
client.deleteReportDocument(clientId, reportInstanceId, reportDocumentId).catch(handleRequestError).then(function() {
|
893
|
+
if (loader) {
|
894
|
+
loader.cancel();
|
895
|
+
}
|
896
|
+
resetPageNumbers();
|
897
|
+
controller.renderingStopped();
|
898
|
+
});
|
899
|
+
},
|
900
|
+
getReportParameters: function() {
|
901
|
+
var paramsToBeExposed = {};
|
902
|
+
for (var key in processedParameterValues) {
|
903
|
+
var processedParam = processedParameterValues[key];
|
904
|
+
var paramValue = parameterValues[key];
|
905
|
+
if (processedParam && processedParam.availableValues) {
|
906
|
+
if (processedParam.multivalue) {
|
907
|
+
paramsToBeExposed[key] = addMultiComboParam(processedParam, paramValue, key);
|
908
|
+
} else {
|
909
|
+
paramsToBeExposed[key] = addSingleComboParam(processedParam, paramValue, key);
|
910
|
+
}
|
911
|
+
} else {
|
912
|
+
paramsToBeExposed[key] = paramValue;
|
913
|
+
}
|
914
|
+
}
|
915
|
+
return paramsToBeExposed;
|
916
|
+
},
|
917
|
+
refreshReport: function(ignoreCache, baseDocumentId, actionId) {
|
918
|
+
controller.loadedReportChange();
|
919
|
+
if (clientHasExpired) {
|
920
|
+
clientHasExpired = false;
|
921
|
+
clearClientId();
|
922
|
+
}
|
923
|
+
if (!report) {
|
924
|
+
controller.raiseError(stringResources.stringResources.noReport);
|
925
|
+
return;
|
926
|
+
}
|
927
|
+
var loadParametersPromise = controller.loadParameters(null);
|
928
|
+
loadParametersPromise.then(function(parameters) {
|
929
|
+
var parameterValues2 = {};
|
930
|
+
var invalidParameters = [];
|
931
|
+
var hasError = false;
|
932
|
+
utils.each(parameters || [], function() {
|
933
|
+
try {
|
934
|
+
var value = parameterValidators$1.validate(this, this.value);
|
935
|
+
parameterValues2[this.id] = value;
|
936
|
+
} catch (e) {
|
937
|
+
hasError = true;
|
938
|
+
invalidParameters.push(this);
|
939
|
+
return;
|
940
|
+
}
|
941
|
+
});
|
942
|
+
if (hasError) {
|
943
|
+
controller.raiseError(stringResources.stringResources.missingOrInvalidParameter);
|
944
|
+
appendInvalidReportParameterNames(invalidParameters);
|
945
|
+
controller.missingOrInvalidParameters();
|
946
|
+
} else {
|
947
|
+
controller.setParameters(parameterValues2);
|
948
|
+
controller.refreshReportCore(ignoreCache, baseDocumentId, actionId);
|
949
|
+
}
|
950
|
+
});
|
951
|
+
controller.reloadParameters(loadParametersPromise);
|
952
|
+
},
|
953
|
+
exportReport: function(format, deviceInfo) {
|
954
|
+
exportReport(format, deviceInfo);
|
955
|
+
},
|
956
|
+
sendReport: function(args) {
|
957
|
+
sendReport(args);
|
958
|
+
},
|
959
|
+
printReport: function() {
|
960
|
+
printReport();
|
961
|
+
},
|
962
|
+
getReportPage: function(pageNumber) {
|
963
|
+
getReportPage(pageNumber);
|
964
|
+
},
|
965
|
+
executeReportAction: function(interactiveActionArgs) {
|
966
|
+
executeReportAction(interactiveActionArgs);
|
967
|
+
},
|
968
|
+
reportActionEnter: function(args) {
|
969
|
+
onReportActionEnter(args);
|
970
|
+
},
|
971
|
+
reportActionLeave: function(args) {
|
972
|
+
onReportActionLeave(args);
|
973
|
+
},
|
974
|
+
reportToolTipOpening: function(args) {
|
975
|
+
onReportToolTipOpening(args);
|
976
|
+
},
|
977
|
+
loadParameters: function(paramValues) {
|
978
|
+
if (report === null) {
|
979
|
+
return {};
|
980
|
+
}
|
981
|
+
controller.beforeLoadParameters(paramValues === null);
|
982
|
+
return loadParametersAsync(report, paramValues);
|
983
|
+
},
|
984
|
+
getDocumentFormats: function() {
|
985
|
+
return getDocumentFormatsAsync();
|
986
|
+
},
|
987
|
+
getServiceVersion: function() {
|
988
|
+
return getServiceVersionAsync();
|
989
|
+
},
|
990
|
+
setAuthenticationToken: function(token) {
|
991
|
+
client.setAccessToken(token);
|
992
|
+
},
|
993
|
+
clientId: function() {
|
994
|
+
return clientId;
|
995
|
+
},
|
996
|
+
onReportLoadComplete: function(info) {
|
997
|
+
pageCount = info.pageCount;
|
998
|
+
bookmarkNodes = info.bookmarkNodes;
|
999
|
+
renderingExtensions = info.renderingExtensions;
|
1000
|
+
setStateReportSource(controller.getReportSource());
|
1001
|
+
controller.reportLoadComplete(info);
|
1002
|
+
},
|
1003
|
+
raiseError: function(...args) {
|
1004
|
+
var errorMessage = formatError(args);
|
1005
|
+
controller.error(errorMessage);
|
1006
|
+
},
|
1007
|
+
getSearchResults: function(args, results) {
|
1008
|
+
return getSearchResultsAsync(args);
|
1009
|
+
},
|
1010
|
+
// --- E V E N T S ---
|
1011
|
+
on: function(eventName, handler) {
|
1012
|
+
eventEmitter$1.on(eventName, handler);
|
1013
|
+
return controller;
|
1014
|
+
},
|
1015
|
+
trigger: function(eventName, args) {
|
1016
|
+
eventEmitter$1.trigger(eventName, args);
|
1017
|
+
return controller;
|
1018
|
+
},
|
1019
|
+
showNotification: function(...args) {
|
1020
|
+
return eventFactory(controller.Events.SHOW_NOTIFICATION, args);
|
1021
|
+
},
|
1022
|
+
hideNotification: function(...args) {
|
1023
|
+
return eventFactory(controller.Events.HIDE_NOTIFICATION, args);
|
1024
|
+
},
|
1025
|
+
setUIState: function(...args) {
|
1026
|
+
return eventFactory(controller.Events.UI_STATE, args);
|
1027
|
+
},
|
1028
|
+
error: function(...args) {
|
1029
|
+
return eventFactory(controller.Events.ERROR, args);
|
1030
|
+
},
|
1031
|
+
reloadParameters: function(...args) {
|
1032
|
+
return eventFactory(controller.Events.RELOAD_PARAMETERS, args);
|
1033
|
+
},
|
1034
|
+
exportStarted: function(...args) {
|
1035
|
+
return eventFactory(controller.Events.EXPORT_STARTED, args);
|
1036
|
+
},
|
1037
|
+
exportReady: function(...args) {
|
1038
|
+
return eventFactory(controller.Events.EXPORT_DOCUMENT_READY, args);
|
1039
|
+
},
|
1040
|
+
sendEmailStarted: function(...args) {
|
1041
|
+
return eventFactory(controller.Events.SEND_EMAIL_STARTED, args);
|
1042
|
+
},
|
1043
|
+
sendEmailReady: function(...args) {
|
1044
|
+
return eventFactory(controller.Events.SEND_EMAIL_READY, args);
|
1045
|
+
},
|
1046
|
+
printStarted: function(...args) {
|
1047
|
+
return eventFactory(controller.Events.PRINT_STARTED, args);
|
1048
|
+
},
|
1049
|
+
printReady: function(...args) {
|
1050
|
+
return eventFactory(controller.Events.PRINT_DOCUMENT_READY, args);
|
1051
|
+
},
|
1052
|
+
beforeLoadParameters: function(...args) {
|
1053
|
+
return eventFactory(controller.Events.BEFORE_LOAD_PARAMETERS, args);
|
1054
|
+
},
|
1055
|
+
loadedReportChange: function(...args) {
|
1056
|
+
return eventFactory(controller.Events.LOADED_REPORT_CHANGE, args);
|
1057
|
+
},
|
1058
|
+
beforeLoadReport: function(...args) {
|
1059
|
+
return eventFactory(controller.Events.BEFORE_LOAD_REPORT, args);
|
1060
|
+
},
|
1061
|
+
beginLoadReport: function(...args) {
|
1062
|
+
return eventFactory(controller.Events.BEGIN_LOAD_REPORT, args);
|
1063
|
+
},
|
1064
|
+
reportLoadComplete: function(...args) {
|
1065
|
+
return eventFactory(controller.Events.REPORT_LOAD_COMPLETE, args);
|
1066
|
+
},
|
1067
|
+
reportLoadProgress: function(...args) {
|
1068
|
+
return eventFactory(controller.Events.REPORT_LOAD_PROGRESS, args);
|
1069
|
+
},
|
1070
|
+
reportLoadFail: function(...args) {
|
1071
|
+
return eventFactory(controller.Events.REPORT_LOAD_FAIL, args);
|
1072
|
+
},
|
1073
|
+
beginLoadPage: function(...args) {
|
1074
|
+
return eventFactory(controller.Events.BEGIN_LOAD_PAGE, args);
|
1075
|
+
},
|
1076
|
+
pageReady: function(...args) {
|
1077
|
+
return eventFactory(controller.Events.PAGE_READY, args);
|
1078
|
+
},
|
1079
|
+
viewModeChanged: function(...args) {
|
1080
|
+
return eventFactory(controller.Events.VIEW_MODE_CHANGED, args);
|
1081
|
+
},
|
1082
|
+
pageModeChanged: function(...args) {
|
1083
|
+
return eventFactory(controller.Events.PAGE_MODE_CHANGED, args);
|
1084
|
+
},
|
1085
|
+
printModeChanged: function(...args) {
|
1086
|
+
return eventFactory(controller.Events.PRINT_MODE_CHANGED, args);
|
1087
|
+
},
|
1088
|
+
reportSourceChanged: function(...args) {
|
1089
|
+
return eventFactory(controller.Events.REPORT_SOURCE_CHANGED, args);
|
1090
|
+
},
|
1091
|
+
navigateToPage: function(...args) {
|
1092
|
+
return eventFactory(controller.Events.NAVIGATE_TO_PAGE, args);
|
1093
|
+
},
|
1094
|
+
currentPageChanged: function(...args) {
|
1095
|
+
return eventFactory(controller.Events.CURRENT_PAGE_CHANGED, args);
|
1096
|
+
},
|
1097
|
+
getDocumentMapState: function(...args) {
|
1098
|
+
return eventFactory(controller.Events.GET_DOCUMENT_MAP_STATE, args);
|
1099
|
+
},
|
1100
|
+
setDocumentMapVisible: function(...args) {
|
1101
|
+
return eventFactory(controller.Events.SET_DOCUMENT_MAP_VISIBLE, args);
|
1102
|
+
},
|
1103
|
+
getParametersAreaState: function(...args) {
|
1104
|
+
return eventFactory(controller.Events.GET_PARAMETER_AREA_STATE, args);
|
1105
|
+
},
|
1106
|
+
setParametersAreaVisible: function(...args) {
|
1107
|
+
return eventFactory(controller.Events.SET_PARAMETER_AREA_VISIBLE, args);
|
1108
|
+
},
|
1109
|
+
setSideMenuVisible: function(...args) {
|
1110
|
+
return eventFactory(controller.Events.SET_TOGGLE_SIDE_MENU, args);
|
1111
|
+
},
|
1112
|
+
getSideMenuVisible: function(...args) {
|
1113
|
+
return eventFactory(controller.Events.GET_TOGGLE_SIDE_MENU, args);
|
1114
|
+
},
|
1115
|
+
scaleChanged: function(...args) {
|
1116
|
+
return eventFactory(controller.Events.SCALE_CHANGED, args);
|
1117
|
+
},
|
1118
|
+
scaleModeChanged: function(...args) {
|
1119
|
+
return eventFactory(controller.Events.SCALE_MODE_CHANGED, args);
|
1120
|
+
},
|
1121
|
+
serverActionStarted: function(...args) {
|
1122
|
+
return eventFactory(controller.Events.SERVER_ACTION_STARTED, args);
|
1123
|
+
},
|
1124
|
+
cssLoaded: function(...args) {
|
1125
|
+
return eventFactory(controller.Events.CSS_LOADED, args);
|
1126
|
+
},
|
1127
|
+
interactiveActionExecuting: function(...args) {
|
1128
|
+
return eventFactory(controller.Events.INTERACTIVE_ACTION_EXECUTING, args);
|
1129
|
+
},
|
1130
|
+
interactiveActionEnter: function(...args) {
|
1131
|
+
return eventFactory(controller.Events.INTERACTIVE_ACTION_ENTER, args);
|
1132
|
+
},
|
1133
|
+
interactiveActionLeave: function(...args) {
|
1134
|
+
return eventFactory(controller.Events.INTERACTIVE_ACTION_LEAVE, args);
|
1135
|
+
},
|
1136
|
+
updateUI: function(...args) {
|
1137
|
+
return eventFactory(controller.Events.UPDATE_UI, args);
|
1138
|
+
},
|
1139
|
+
updateUIInternal: function(...args) {
|
1140
|
+
return eventFactory(controller.Events.UPDATE_UI_INTERNAL, args);
|
1141
|
+
},
|
1142
|
+
toolTipOpening: function(...args) {
|
1143
|
+
return eventFactory(controller.Events.TOOLTIP_OPENING, args);
|
1144
|
+
},
|
1145
|
+
pageNumberChange: function(...args) {
|
1146
|
+
return eventFactory(controller.Events.PAGE_NUMBER, args);
|
1147
|
+
},
|
1148
|
+
pageCountChange: function(...args) {
|
1149
|
+
return eventFactory(controller.Events.PAGE_COUNT, args);
|
1150
|
+
},
|
1151
|
+
getSearchDialogState: function(...args) {
|
1152
|
+
return eventFactory(controller.Events.GET_SEARCH_DIALOG_STATE, args);
|
1153
|
+
},
|
1154
|
+
getSendEmailDialogState: function(...args) {
|
1155
|
+
return eventFactory(controller.Events.GET_SEND_EMAIL_DIALOG_STATE, args);
|
1156
|
+
},
|
1157
|
+
setSearchDialogVisible: function(...args) {
|
1158
|
+
return eventFactory(controller.Events.SET_SEARCH_DIALOG_VISIBLE, args);
|
1159
|
+
},
|
1160
|
+
setSendEmailDialogVisible: function(...args) {
|
1161
|
+
return eventFactory(controller.Events.SET_SEND_EMAIL_DIALOG_VISIBLE, args);
|
1162
|
+
},
|
1163
|
+
scrollPageReady: function(...args) {
|
1164
|
+
return eventFactory(controller.Events.SCROLL_PAGE_READY, args);
|
1165
|
+
},
|
1166
|
+
updatePageDimensionsReady: function(...args) {
|
1167
|
+
return eventFactory(controller.Events.UPDATE_SCROLL_PAGE_DIMENSIONS_READY, args);
|
1168
|
+
},
|
1169
|
+
missingOrInvalidParameters: function(...args) {
|
1170
|
+
return eventFactory(controller.Events.MISSING_OR_INVALID_PARAMETERS, args);
|
1171
|
+
},
|
1172
|
+
renderingStopped: function(...args) {
|
1173
|
+
return eventFactory(controller.Events.RENDERING_STOPPED, args);
|
1174
|
+
},
|
1175
|
+
clientExpired: function(...args) {
|
1176
|
+
return eventFactory(controller.Events.CLIENT_EXPIRED, args);
|
1177
|
+
},
|
1178
|
+
dispose: function() {
|
1179
|
+
stopSentinel();
|
1180
|
+
this.serviceClientSentinel = null;
|
1181
|
+
}
|
1182
|
+
}
|
1183
|
+
);
|
1184
|
+
return controller;
|
1185
|
+
}
|
1186
|
+
function addSingleComboParam(processedParam, paramValue, key) {
|
1187
|
+
try {
|
1188
|
+
var nameValuePair = processedParam.availableValues.find((obj) => {
|
1189
|
+
return obj["value"] === paramValue;
|
1190
|
+
});
|
1191
|
+
if (!nameValuePair) {
|
1192
|
+
throw new Error(`The available values of parameter ${key} do not contain Value property that equals ${paramValue}`);
|
1193
|
+
}
|
1194
|
+
return { valueMember: paramValue, displayMember: nameValuePair["name"] };
|
1195
|
+
} catch (e) {
|
1196
|
+
utils.logError(e);
|
1197
|
+
}
|
1198
|
+
}
|
1199
|
+
function addMultiComboParam(processedParam, paramValue, key) {
|
1200
|
+
var paramArr = [];
|
1201
|
+
for (var i in paramValue) {
|
1202
|
+
paramArr.push(addSingleComboParam(processedParam, paramValue[i], key));
|
1203
|
+
}
|
1204
|
+
return paramArr;
|
1205
|
+
}
|
1206
|
+
|
1207
|
+
exports.ReportViewerController = ReportViewerController;
|