1 | var powerbi;
|
2 |
|
3 | !function(powerbi) {
|
4 | var visuals;
|
5 | !function(visuals) {
|
6 | var telemetry;
|
7 | !function(telemetry) {
|
8 | function generateGuid() {
|
9 | var guid = "", idx = 0;
|
10 | for (idx = 0; 32 > idx; idx += 1) {
|
11 | var guidDigitsItem = 16 * Math.random() | 0;
|
12 | switch (idx) {
|
13 | case 8:
|
14 | case 12:
|
15 | case 16:
|
16 | case 20:
|
17 | guid += "-";
|
18 | }
|
19 | guid += guidDigitsItem.toString(16);
|
20 | }
|
21 | return guid;
|
22 | }
|
23 | telemetry.generateGuid = generateGuid;
|
24 | }(telemetry = visuals.telemetry || (visuals.telemetry = {}));
|
25 | }(visuals = powerbi.visuals || (powerbi.visuals = {}));
|
26 | }(powerbi || (powerbi = {}));
|
27 |
|
28 | var powerbi;
|
29 |
|
30 | !function(powerbi) {
|
31 | var visuals;
|
32 | !function(visuals) {
|
33 | var telemetry;
|
34 | !function(telemetry) {
|
35 | telemetry.ExtensibilityVisualApiUsage = function(name, apiVersion, custom, parentId, isError, errorSource, errorCode) {
|
36 | void 0 === isError && (isError = !1), void 0 === errorSource && (errorSource = void 0),
|
37 | void 0 === errorCode && (errorCode = void 0);
|
38 | var info = {
|
39 | name: name,
|
40 | apiVersion: apiVersion,
|
41 | custom: custom,
|
42 | parentId: parentId,
|
43 | isError: isError,
|
44 | errorSource: errorSource,
|
45 | errorCode: errorCode
|
46 | }, event = {
|
47 | name: "PBI.Extensibility.VisualApiUsage",
|
48 | category: 1,
|
49 | time: Date.now(),
|
50 | id: telemetry.generateGuid(),
|
51 | getFormattedInfoObject: function() {
|
52 | var formattedObject = {
|
53 | name: info.name,
|
54 | apiVersion: info.apiVersion,
|
55 | custom: info.custom,
|
56 | parentId: info.parentId,
|
57 | isError: info.isError
|
58 | };
|
59 | return "undefined" != typeof info.errorSource && (formattedObject.errorSource = telemetry.ErrorSource[info.errorSource]),
|
60 | "undefined" != typeof info.errorCode && (formattedObject.errorCode = info.errorCode),
|
61 | formattedObject;
|
62 | },
|
63 | info: info,
|
64 | privateFields: [],
|
65 | orgInfoFields: []
|
66 | };
|
67 | return "undefined" != typeof telemetry.ExtensibilityVisualApiUsageLoggers && (event.loggers = telemetry.ExtensibilityVisualApiUsageLoggers),
|
68 | event;
|
69 | }, telemetry.VisualException = function(visualType, isCustom, apiVersion, source, lineNumber, columnNumber, stack, message) {
|
70 | var info = {
|
71 | visualType: visualType,
|
72 | isCustom: isCustom,
|
73 | apiVersion: apiVersion,
|
74 | source: source,
|
75 | lineNumber: lineNumber,
|
76 | columnNumber: columnNumber,
|
77 | stack: stack,
|
78 | message: message
|
79 | }, event = {
|
80 | name: "PBI.VisualException",
|
81 | category: 2,
|
82 | time: Date.now(),
|
83 | id: telemetry.generateGuid(),
|
84 | getFormattedInfoObject: function() {
|
85 | var formattedObject = {
|
86 | visualType: info.visualType,
|
87 | isCustom: info.isCustom,
|
88 | apiVersion: info.apiVersion,
|
89 | source: info.source,
|
90 | lineNumber: info.lineNumber,
|
91 | columnNumber: info.columnNumber,
|
92 | stack: info.stack,
|
93 | message: info.message
|
94 | };
|
95 | return formattedObject;
|
96 | },
|
97 | info: info,
|
98 | privateFields: [],
|
99 | orgInfoFields: []
|
100 | };
|
101 | return "undefined" != typeof telemetry.VisualExceptionLoggers && (event.loggers = telemetry.VisualExceptionLoggers),
|
102 | event;
|
103 | };
|
104 | }(telemetry = visuals.telemetry || (visuals.telemetry = {}));
|
105 | }(visuals = powerbi.visuals || (powerbi.visuals = {}));
|
106 | }(powerbi || (powerbi = {}));
|
107 |
|
108 | var powerbi;
|
109 |
|
110 | !function(powerbi) {
|
111 | var extensibility;
|
112 | !function(extensibility) {
|
113 | function VisualPlugin(options) {
|
114 | return function(constructor) {
|
115 | constructor.__capabilities__ = options.capabilities;
|
116 | };
|
117 | }
|
118 | extensibility.VisualPlugin = VisualPlugin;
|
119 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
120 | }(powerbi || (powerbi = {}));
|
121 |
|
122 | var powerbi;
|
123 |
|
124 | !function(powerbi) {
|
125 | var extensibility;
|
126 | !function(extensibility) {
|
127 | var SelectionManager = function() {
|
128 | function SelectionManager(options) {
|
129 | this.hostServices = options.hostServices, this.selectedIds = [], this.promiseFactory = this.hostServices.promiseFactory();
|
130 | }
|
131 | return SelectionManager.prototype.select = function(selectionId, multiSelect) {
|
132 | void 0 === multiSelect && (multiSelect = !1);
|
133 | var deferred = this.promiseFactory.defer();
|
134 | return this.hostServices.shouldRetainSelection() ? this.sendSelectionToHost([ selectionId ]) : (this.selectInternal(selectionId, multiSelect),
|
135 | this.sendSelectionToHost(this.selectedIds)), deferred.resolve(this.selectedIds),
|
136 | deferred.promise;
|
137 | }, SelectionManager.prototype.showContextMenu = function(selectionId, position) {
|
138 | var deferred = this.promiseFactory.defer();
|
139 | return this.sendContextMenuToHost(selectionId, position), deferred.resolve(null),
|
140 | deferred.promise;
|
141 | }, SelectionManager.prototype.hasSelection = function() {
|
142 | return this.selectedIds.length > 0;
|
143 | }, SelectionManager.prototype.clear = function() {
|
144 | var deferred = this.promiseFactory.defer();
|
145 | return this.selectedIds = [], this.sendSelectionToHost([]), deferred.resolve(null),
|
146 | deferred.promise;
|
147 | }, SelectionManager.prototype.getSelectionIds = function() {
|
148 | return this.selectedIds;
|
149 | }, SelectionManager.prototype.sendSelectionToHost = function(ids) {
|
150 | var selectArgs = {
|
151 | data: ids.filter(function(value) {
|
152 | return value.hasIdentity();
|
153 | }).map(function(value) {
|
154 | return value.getSelector();
|
155 | })
|
156 | }, data2 = this.getSelectorsByColumn(ids);
|
157 | _.isEmpty(data2) || (selectArgs.data2 = data2), this.hostServices.onSelect(selectArgs);
|
158 | }, SelectionManager.prototype.sendContextMenuToHost = function(selectionId, position) {
|
159 | var selectors = this.getSelectorsByColumn([ selectionId ]);
|
160 | if (!_.isEmpty(selectors)) {
|
161 | var args = {
|
162 | data: selectors,
|
163 | position: position
|
164 | };
|
165 | this.hostServices.onContextMenu(args);
|
166 | }
|
167 | }, SelectionManager.prototype.getSelectorsByColumn = function(selectionIds) {
|
168 | return _(selectionIds).filter(function(value) {
|
169 | return value.hasIdentity;
|
170 | }).map(function(value) {
|
171 | return value.getSelectorsByColumn();
|
172 | }).compact().value();
|
173 | }, SelectionManager.prototype.selectInternal = function(selectionId, multiSelect) {
|
174 | SelectionManager.containsSelection(this.selectedIds, selectionId) ? this.selectedIds = multiSelect ? this.selectedIds.filter(function(d) {
|
175 | return !selectionId.equals(d);
|
176 | }) : this.selectedIds.length > 1 ? [ selectionId ] : [] : multiSelect ? this.selectedIds.push(selectionId) : this.selectedIds = [ selectionId ];
|
177 | }, SelectionManager.containsSelection = function(list, id) {
|
178 | return list.some(function(d) {
|
179 | return id.equals(d);
|
180 | });
|
181 | }, SelectionManager;
|
182 | }();
|
183 | extensibility.SelectionManager = SelectionManager;
|
184 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
185 | }(powerbi || (powerbi = {}));
|
186 |
|
187 | var powerbi;
|
188 |
|
189 | !function(powerbi) {
|
190 | var extensibility;
|
191 | !function(extensibility) {
|
192 | var SelectionIdBuilder = function() {
|
193 | function SelectionIdBuilder() {}
|
194 | return SelectionIdBuilder.prototype.withCategory = function(categoryColumn, index) {
|
195 | return categoryColumn && categoryColumn.source && categoryColumn.source.queryName && categoryColumn.identity && (this.ensureDataMap()[categoryColumn.source.queryName] = categoryColumn.identity[index]),
|
196 | this;
|
197 | }, SelectionIdBuilder.prototype.withSeries = function(seriesColumn, valueColumn) {
|
198 | return seriesColumn && seriesColumn.source && seriesColumn.source.queryName && valueColumn && (this.ensureDataMap()[seriesColumn.source.queryName] = valueColumn.identity),
|
199 | this;
|
200 | }, SelectionIdBuilder.prototype.withMeasure = function(measureId) {
|
201 | return this.measure = measureId, this;
|
202 | }, SelectionIdBuilder.prototype.createSelectionId = function() {
|
203 | return powerbi.visuals.SelectionId.createWithSelectorForColumnAndMeasure(this.ensureDataMap(), this.measure);
|
204 | }, SelectionIdBuilder.prototype.ensureDataMap = function() {
|
205 | return this.dataMap || (this.dataMap = {}), this.dataMap;
|
206 | }, SelectionIdBuilder;
|
207 | }();
|
208 | extensibility.SelectionIdBuilder = SelectionIdBuilder;
|
209 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
210 | }(powerbi || (powerbi = {}));
|
211 |
|
212 | var powerbi;
|
213 |
|
214 | !function(powerbi) {
|
215 | var extensibility;
|
216 | !function(extensibility) {
|
217 | function createVisualAdapter(visualPlugin, telemetryService) {
|
218 | var visualTelemetryInfo = {
|
219 | name: visualPlugin.name,
|
220 | apiVersion: visualPlugin.apiVersion,
|
221 | custom: !!visualPlugin.custom
|
222 | };
|
223 | return new extensibility.VisualSafeExecutionWrapper(new VisualAdapter(visualPlugin, telemetryService), visualTelemetryInfo, telemetryService);
|
224 | }
|
225 | var ExtensibilityVisualApiUsage = powerbi.visuals.telemetry.ExtensibilityVisualApiUsage;
|
226 | extensibility.visualApiVersions = [], extensibility.createVisualAdapter = createVisualAdapter;
|
227 | var VisualAdapter = function() {
|
228 | function VisualAdapter(visualPlugin, telemetryService) {
|
229 | this.telemetryService = telemetryService, this.plugin = visualPlugin;
|
230 | var version = visualPlugin.apiVersion, versionIndex = this.getVersionIndex(version), isError = !1;
|
231 | version ? versionIndex > -1 ? (this.apiVersionIndex = versionIndex, this.legacy = !1) : isError = !0 : this.legacy = !0,
|
232 | this.telemetryService && this.telemetryService.logEvent(ExtensibilityVisualApiUsage, this.plugin.name, this.plugin.apiVersion, !!this.plugin.custom, void 0, isError, powerbi.visuals.telemetry.ErrorSource.User);
|
233 | }
|
234 | return VisualAdapter.prototype.init = function(options) {
|
235 | if (options.element.empty(), this.legacy) this.visual = this.plugin.create(), this.visualLegacy.init(options); else {
|
236 | var host = extensibility.visualApiVersions[this.apiVersionIndex].hostAdapter(options.host);
|
237 | this.visual = this.plugin.create({
|
238 | element: options.element.get(0),
|
239 | host: host
|
240 | }), this.overloadMethods();
|
241 | }
|
242 | }, VisualAdapter.prototype.update = function(options) {
|
243 | options.type & powerbi.VisualUpdateType.Resize && this.visualHasMethod("onResizing") ? this.onResizing(options.viewport, options.resizeMode) : this.visualHasMethod("update") ? this.visualLegacy.update(options) : ((!options.type || options.type & powerbi.VisualUpdateType.Data) && this.onDataChanged(_.pick(options, [ "dataViews", "operationKind" ])),
|
244 | options.type & powerbi.VisualUpdateType.ViewMode && this.onViewModeChanged(options.viewMode));
|
245 | }, VisualAdapter.prototype.destroy = function() {
|
246 | this.visualHasMethod("destroy") && this.visualLegacy.destroy();
|
247 | }, VisualAdapter.prototype.enumerateObjectInstances = function(options) {
|
248 | return this.visualHasMethod("enumerateObjectInstances") ? this.visualLegacy.enumerateObjectInstances(options) : void 0;
|
249 | }, VisualAdapter.prototype.enumerateObjectRepetition = function() {
|
250 | return this.visualHasMethod("enumerateObjectRepetition") ? this.visualLegacy.enumerateObjectRepetition() : void 0;
|
251 | }, VisualAdapter.prototype.onResizing = function(finalViewport, resizeMode) {
|
252 | this.visualHasMethod("onResizing") && this.visualLegacy.onResizing(finalViewport, resizeMode);
|
253 | }, VisualAdapter.prototype.onDataChanged = function(options) {
|
254 | this.visualHasMethod("onDataChanged") && this.visualLegacy.onDataChanged(options);
|
255 | }, VisualAdapter.prototype.onViewModeChanged = function(viewMode) {
|
256 | this.visualHasMethod("onViewModeChanged") && this.visualLegacy.onViewModeChanged(viewMode);
|
257 | }, VisualAdapter.prototype.onClearSelection = function() {
|
258 | this.visualHasMethod("onClearSelection") && this.visualLegacy.onClearSelection();
|
259 | }, VisualAdapter.prototype.canResizeTo = function(viewport) {
|
260 | return this.visualHasMethod("canResizeTo") ? this.visualLegacy.canResizeTo(viewport) : void 0;
|
261 | }, VisualAdapter.prototype.unwrap = function() {
|
262 | return this.visual;
|
263 | }, Object.defineProperty(VisualAdapter.prototype, "visualNew", {
|
264 | get: function() {
|
265 | return this.legacy ? void 0 : this.visual;
|
266 | },
|
267 | enumerable: !0,
|
268 | configurable: !0
|
269 | }), Object.defineProperty(VisualAdapter.prototype, "visualLegacy", {
|
270 | get: function() {
|
271 | return this.legacy ? this.visual : void 0;
|
272 | },
|
273 | enumerable: !0,
|
274 | configurable: !0
|
275 | }), VisualAdapter.prototype.visualHasMethod = function(methodName) {
|
276 | var visual = this.legacy ? this.visualLegacy : this.visualNew;
|
277 | return visual && _.isFunction(visual[methodName]);
|
278 | }, VisualAdapter.prototype.getVersionIndex = function(version) {
|
279 | if (version) for (var versionCount = extensibility.visualApiVersions.length, i = 0; versionCount > i; i++) if (extensibility.visualApiVersions[i].version === version) return i;
|
280 | return -1;
|
281 | }, VisualAdapter.prototype.overloadMethods = function() {
|
282 | var overloads = this.getCompiledOverloads();
|
283 | for (var key in overloads) this[key] = overloads[key];
|
284 | }, VisualAdapter.prototype.getCompiledOverloads = function() {
|
285 | for (var overloads = {}, versionIndex = this.apiVersionIndex, visualNew = this.visualNew, i = 0; versionIndex >= i; i++) {
|
286 | var overloadFactory = extensibility.visualApiVersions[i].overloads;
|
287 | _.isFunction(overloadFactory) && _.assign(overloads, overloadFactory(visualNew));
|
288 | }
|
289 | return overloads;
|
290 | }, VisualAdapter;
|
291 | }();
|
292 | extensibility.VisualAdapter = VisualAdapter;
|
293 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
294 | }(powerbi || (powerbi = {}));
|
295 |
|
296 | var powerbi;
|
297 |
|
298 | !function(powerbi) {
|
299 | var extensibility;
|
300 | !function(extensibility) {
|
301 | var VisualException = powerbi.visuals.telemetry.VisualException, VisualSafeExecutionWrapper = function() {
|
302 | function VisualSafeExecutionWrapper(wrappedVisual, visualInfo, telemetryService, silent) {
|
303 | this.wrappedVisual = wrappedVisual, this.visualInfo = visualInfo, this.telemetryService = telemetryService,
|
304 | this.silent = silent;
|
305 | }
|
306 | return VisualSafeExecutionWrapper.prototype.init = function(options) {
|
307 | var _this = this;
|
308 | this.wrappedVisual.init && this.executeSafely(function() {
|
309 | return _this.wrappedVisual.init(options);
|
310 | });
|
311 | }, VisualSafeExecutionWrapper.prototype.destroy = function() {
|
312 | var _this = this;
|
313 | this.wrappedVisual.destroy && this.executeSafely(function() {
|
314 | return _this.wrappedVisual.destroy();
|
315 | });
|
316 | }, VisualSafeExecutionWrapper.prototype.update = function(options) {
|
317 | var _this = this;
|
318 | this.wrappedVisual.update && this.executeSafely(function() {
|
319 | return _this.wrappedVisual.update(options);
|
320 | });
|
321 | }, VisualSafeExecutionWrapper.prototype.onResizing = function(finalViewport, resizeMode) {
|
322 | var _this = this;
|
323 | this.wrappedVisual.onResizing && this.executeSafely(function() {
|
324 | return _this.wrappedVisual.onResizing(finalViewport, resizeMode);
|
325 | });
|
326 | }, VisualSafeExecutionWrapper.prototype.onDataChanged = function(options) {
|
327 | var _this = this;
|
328 | this.wrappedVisual.onDataChanged && this.executeSafely(function() {
|
329 | return _this.wrappedVisual.onDataChanged(options);
|
330 | });
|
331 | }, VisualSafeExecutionWrapper.prototype.onViewModeChanged = function(viewMode) {
|
332 | var _this = this;
|
333 | this.wrappedVisual.onViewModeChanged && this.executeSafely(function() {
|
334 | return _this.wrappedVisual.onViewModeChanged(viewMode);
|
335 | });
|
336 | }, VisualSafeExecutionWrapper.prototype.onClearSelection = function() {
|
337 | var _this = this;
|
338 | this.wrappedVisual.onClearSelection && this.executeSafely(function() {
|
339 | return _this.wrappedVisual.onClearSelection();
|
340 | });
|
341 | }, VisualSafeExecutionWrapper.prototype.canResizeTo = function(viewport) {
|
342 | var _this = this;
|
343 | return this.wrappedVisual.canResizeTo ? this.executeSafely(function() {
|
344 | return _this.wrappedVisual.canResizeTo(viewport);
|
345 | }) : void 0;
|
346 | }, VisualSafeExecutionWrapper.prototype.enumerateObjectInstances = function(options) {
|
347 | var _this = this;
|
348 | return this.wrappedVisual.enumerateObjectInstances ? this.executeSafely(function() {
|
349 | return _this.wrappedVisual.enumerateObjectInstances(options);
|
350 | }) : void 0;
|
351 | }, VisualSafeExecutionWrapper.prototype.enumerateObjectRepetition = function() {
|
352 | var _this = this;
|
353 | return this.wrappedVisual.enumerateObjectRepetition ? this.executeSafely(function() {
|
354 | return _this.wrappedVisual.enumerateObjectRepetition();
|
355 | }) : void 0;
|
356 | }, VisualSafeExecutionWrapper.prototype.unwrap = function() {
|
357 | var visual = this.wrappedVisual;
|
358 | return visual.unwrap ? visual.unwrap() : visual;
|
359 | }, VisualSafeExecutionWrapper.prototype.isCustomVisual = function() {
|
360 | return this.visualInfo.custom;
|
361 | }, VisualSafeExecutionWrapper.prototype.executeSafely = function(callback) {
|
362 | try {
|
363 | return callback();
|
364 | } catch (exception) {
|
365 | !this.silent, this.telemetryService && this.telemetryService.logEvent(VisualException, this.visualInfo.name, this.visualInfo.custom, this.visualInfo.apiVersion, exception.fileName, exception.lineNumber, exception.columnNumber, exception.stack, exception.message);
|
366 | }
|
367 | }, VisualSafeExecutionWrapper;
|
368 | }();
|
369 | extensibility.VisualSafeExecutionWrapper = VisualSafeExecutionWrapper;
|
370 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
371 | }(powerbi || (powerbi = {}));
|
372 |
|
373 | var powerbi;
|
374 |
|
375 | !function(powerbi) {
|
376 | var extensibility;
|
377 | !function(extensibility) {
|
378 | var v100;
|
379 | !function(v100) {
|
380 | var overloadFactory = function(visual) {
|
381 | return {
|
382 | update: function(options) {
|
383 | if (visual.update) {
|
384 | var type = options.type || powerbi.VisualUpdateType.Data;
|
385 | type & powerbi.VisualUpdateType.Resize && 2 === options.resizeMode && (type |= powerbi.VisualUpdateType.ResizeEnd),
|
386 | visual.update({
|
387 | viewport: options.viewport,
|
388 | dataViews: options.dataViews,
|
389 | type: type
|
390 | });
|
391 | }
|
392 | },
|
393 | destroy: function() {
|
394 | visual.destroy && visual.destroy();
|
395 | },
|
396 | enumerateObjectInstances: function(options) {
|
397 | return visual.enumerateObjectInstances ? visual.enumerateObjectInstances(options) : void 0;
|
398 | }
|
399 | };
|
400 | }, hostAdapter = function(host) {
|
401 | return {};
|
402 | };
|
403 | extensibility.visualApiVersions.push({
|
404 | version: "1.0.0",
|
405 | overloads: overloadFactory,
|
406 | hostAdapter: hostAdapter
|
407 | });
|
408 | }(v100 = extensibility.v100 || (extensibility.v100 = {}));
|
409 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
410 | }(powerbi || (powerbi = {}));
|
411 |
|
412 | var powerbi;
|
413 |
|
414 | !function(powerbi) {
|
415 | var extensibility;
|
416 | !function(extensibility) {
|
417 | var v110;
|
418 | !function(v110) {
|
419 | var hostAdapter = function(host) {
|
420 | return {
|
421 | createSelectionIdBuilder: function() {
|
422 | return new powerbi.visuals.SelectionIdBuilder();
|
423 | },
|
424 | createSelectionManager: function() {
|
425 | return new extensibility.SelectionManager({
|
426 | hostServices: host
|
427 | });
|
428 | }
|
429 | };
|
430 | };
|
431 | extensibility.visualApiVersions.push({
|
432 | version: "1.1.0",
|
433 | hostAdapter: hostAdapter
|
434 | });
|
435 | }(v110 = extensibility.v110 || (extensibility.v110 = {}));
|
436 | }(extensibility = powerbi.extensibility || (powerbi.extensibility = {}));
|
437 | }(powerbi || (powerbi = {})); |
\ | No newline at end of file |