123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['jquery', './CustomUtil'], function ($, CustomUtil) {
- var INPUT_FILE_BROWSE_DIALOG = '<input type="file" id="custom-vis-uploadfiles" style="display: none;" accept="application/zip,application/x-zip-compressed,multipart/x-zip,application/x-compressed" onclick="this.value=null;">';
- return function () {
- function CustomVisAction(options) {
- _classCallCheck(this, CustomVisAction);
- this.dashboardApi = options.dashboardApi;
- this.refreshCustomVis = options.refreshCustomVis;
- this.enabled = this.dashboardApi.getConfiguration('enableCustomVisualizations') === true;
- this._loadUserCapabilities();
- }
- CustomVisAction.prototype.openSelectBundleFileDialog = function openSelectBundleFileDialog(item) {
- this.item = item;
- this.$uploadFileButton.click();
- };
- CustomVisAction.prototype.bundleFileSelected = function bundleFileSelected(event, refreshCustomVisDefinitionsCallback) {
- var _this = this;
- var viprBundleMethod = this.item ? CustomUtil.updateCustomVis : CustomUtil.addCustomVis;
- return viprBundleMethod(event, this.dashboardApi, refreshCustomVisDefinitionsCallback, this.item).then(function (items) {
- if (items) {
- _this.setItems(items);
- }
- });
- };
- CustomVisAction.prototype.setItems = function setItems() {
- var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- //First clear the items
- this.customVisualsContentComponent.setState({
- items: []
- });
- //Now re-render with new list
- this.customVisualsContentComponent.setState({
- items: items
- });
- };
- CustomVisAction.prototype.shouldRefreshCustomPanel = function shouldRefreshCustomPanel() {
- return this.canDevelop() || this.canManage();
- };
- CustomVisAction.prototype.createUploadFileNode = function createUploadFileNode(refreshCustomVisDefinitionsCallback) {
- var _this2 = this;
- //Ensure the existing got removed before creating new one
- this.removeUploadFileNode();
- this.$uploadFileButton = $(INPUT_FILE_BROWSE_DIALOG);
- $('body').append(this.$uploadFileButton);
- this.$uploadFileButton.on('change', function (event) {
- _this2.bundleFileSelected(event, refreshCustomVisDefinitionsCallback);
- });
- this.$uploadFileButton.on('onClick', function () {
- _this2.$uploadFileButton.value = null;
- });
- };
- CustomVisAction.prototype.removeUploadFileNode = function removeUploadFileNode() {
- if (this.$uploadFileButton && this.$uploadFileButton.length > 0) {
- this.$uploadFileButton.remove();
- this.$uploadFileButton = null;
- }
- };
- CustomVisAction.prototype.setCustomVisualsContentComponent = function setCustomVisualsContentComponent(component) {
- this.customVisualsContentComponent = component;
- };
- CustomVisAction.prototype.destroy = function destroy() {
- this.removeUploadFileNode();
- this.customVisualsContentComponent = null;
- this.dashboardApi = null;
- this.refreshCustomVis = null;
- };
- CustomVisAction.prototype.canDevelop = function canDevelop() {
- return this.capabilities.canDevelop;
- };
- CustomVisAction.prototype.canManage = function canManage() {
- return this.capabilities.canManage;
- };
- CustomVisAction.prototype.canManageOnly = function canManageOnly() {
- return this.capabilities.canManageOnly;
- };
- CustomVisAction.prototype.canUseOnly = function canUseOnly() {
- return this.capabilities.canUseOnly;
- };
- CustomVisAction.prototype.isEnabled = function isEnabled() {
- return this.enabled;
- };
- CustomVisAction.prototype._loadUserCapabilities = function _loadUserCapabilities() {
- // __glassAppController.glassContext.getCoreSvc('.FeatureChecker').addRules({'dashboard':{'canDevelopVisualizations': 'enabled'}})
- //__glassAppController.glassContext.getCoreSvc('.FeatureChecker').addRules({'dashboard':{'canManageVisualizations': 'enabled'}})
- var userCapabilities = this.dashboardApi.getGlassCoreSvc('.UserProfile').capabilities;
- var canDevelop = userCapabilities.indexOf('canDevelopVisualizations') !== -1 || this.dashboardApi.getGlassCoreSvc('.FeatureChecker').checkValue('dashboard', 'canDevelopVisualizations', 'enabled');
- var canManage = userCapabilities.indexOf('canManageVisualizations') !== -1 || this.dashboardApi.getGlassCoreSvc('.FeatureChecker').checkValue('dashboard', 'canManageVisualizations', 'enabled');
- this.capabilities = {
- canDevelop: canDevelop,
- canManage: canManage,
- canManageOnly: !canDevelop && canManage,
- canUseOnly: !canDevelop && !canManage
- };
- };
- return CustomVisAction;
- }();
- });
- //# sourceMappingURL=CustomVisAction.js.map
|