"use strict"; /** * Licensed Materials - Property of IBM * IBM Cognos Products: Cognos Analytics * Copyright IBM Corp. 2016, 2019 * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['underscore', 'q', 'jquery', 'bi/admin/common/slideout/BasePane', 'bi/commons/ui/properties/PropertyUIControl', 'bi/admin/common/utils/CapabilityHelper', 'bi/admin/multitenancy/services/TenantsCustomizationService', 'bi/admin/common/utils/parameters/GlobalParameters', 'bi/admin/system/slideout/PluginsDefinition'], function (_, Q, $, BasePane, PropertyUIControl, CapabilityHelper, TenantsCustomizationService, GlobalParameters, PluginsDefinition) { var PluginsPane = BasePane.extend({ init: function init(options) { PluginsPane.inherited('init', this, arguments); $.extend(this, options); this.glassContext = options.glassContext; CapabilityHelper.glassContext = this.glassContext; this.isPortalAdmin = false; this.canUseUsersGroupsAndRoles = false; this.canManageVisualizations = false; this.tenantID = null; this.listController = new TenantsCustomizationService({ glassContext: this.glassContext }); this.globalParametersController = new GlobalParameters({ 'glassContext': this.glassContext }); }, _getNewPropertyUIControl: function _getNewPropertyUIControl(spec) { return new PropertyUIControl(spec); }, renderBody: function renderBody() { return this.listController.getTenantIDForUser(this.glassContext.profile.account.id).then(function (data) { this.tenantID = data.data[0].tenantID; this.isSysAdmin().then(function (isSysAdmin) { // get all the plugin definition - with full info var tabControlItems = PluginsDefinition.getPlugins(isSysAdmin, this.tenantID, this.glassContext, { // definition used in all tabs slideout: this.slideout, // callbacks for theme tab getDefaultTheme: this.getDefaultTheme.bind(this), setDefaultTheme: this.setDefaultTheme.bind(this), // callbacks for parameters tab getParameters: function (isSystemAdmin, isPortalAdmin, tenantID) { return this.globalParametersController.getParameters(isSystemAdmin, isPortalAdmin, tenantID); }.bind(this), updateParameters: function (parameters, isSystemAdmin, isPortalAdmin, tenantID) { return this.globalParametersController.updateParameters(parameters, isSystemAdmin, isPortalAdmin, tenantID); }.bind(this), listController: this.listController }); this.$body.addClass('bi-admin-plugins-pane'); this._oPropertyUIControl = this._getNewPropertyUIControl({ 'glassContext': this.glassContext, 'el': this.$body, 'items': [{ 'type': 'TabControl', 'items': tabControlItems }] }); return this._oPropertyUIControl.render(); }.bind(this)); }.bind(this)); }, setDefaultTheme: function setDefaultTheme(defaultTheme) { var ui_theme = { 'ui_theme': defaultTheme }; var options = { 'contentType': 'application/json', 'url': 'v1/system_profile_settings', 'type': 'PUT', 'data': JSON.stringify(ui_theme) }; return this.glassContext.services.ajax.ajax(options); }, remove: function remove() { this._oPropertyUIControl.remove(); }, getDefaultTheme: function getDefaultTheme() { return this.glassContext.services.ajax.ajax({ 'type': 'GET', 'url': 'v1/system_profile_settings' }).then(function (response) { return response.ui_theme; }); } }); return PluginsPane; });