"use strict"; /** * Licensed Materials - Property of IBM * IBM Cognos Products: Cognos Analytics * Copyright IBM Corp. 2015, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['q', 'underscore', 'doT', 'bi/commons/utils/Utils', 'bi/admin/account/AccountExplorer', 'bi/admin/common/ui/MagicWand', 'bacontentnav/common/ui/Breadcrumbs', 'bi/commons/ui/AccessibleView', 'bi/admin/common/ui/listview/ListView', 'bi/admin/nls/StringResource', 'bacontentnav/common/ui/ContentGenericDialog', 'text!bi/admin/account/templates/SecurityObjectExplorerTemplate.html', 'text!bi/admin/account/templates/CreateNewGroupTemplate.html', 'text!bi/admin/account/templates/CreateNewUserTemplate.html', 'bi/admin/common/utils/AJAXUtils', 'bi/commons/utils/BidiUtil', 'bi/commons/utils/ContentFormatter', 'bi/commons/ui/properties/PropertyUIControl', 'bacontentnav/common/ui/contentbar_components/Button', 'react-dom', 'react', 'ba-react-admin/ba-react-admin.min', 'bi/admin/common/Uploader'], function (Q, _, dot, Utils, AccountExplorer, MagicWand, Breadcrumbs, View, ListView, StringResource, ContentGenericDialog, SecurityObjectExplorerTemplate, CreateNewGroupTemplate, CreateNewUserTemplate, AJAXUtils, BidiUtil, ContentFormatter, PropertyUIControl, Button, ReactDOM, React, AdminReact, Uploader) { 'use strict'; //NOSONAR: meant to be strict var SecurityObjectExplorerView = View.extend({ showBreadcrumbs: true, defaultTypes: ['namespaceFolder', 'group', 'role', 'account'], _breadCrumbs: null, _accountExplorer: null, listAdaptor: null, init: function init(options) { SecurityObjectExplorerView.inherited('init', this, arguments); this.glassContext = options.glassContext; if (!this._accountExplorer && options.accountExplorer) { this._accountExplorer = options.accountExplorer; } else { this._accountExplorer = this._getNewAccountExplorer({ glassContext: options.glassContext }); } this.listAdaptor = options.listAdaptor; this.parent = options.parent; this.includeToolbar = options.includeToolbar ? options.includeToolbar : false; this.hideSearch = options.hideSearch; this.filterPushed = false; this.hidePaging = options.hidePaging; this.pagingEnabled = false; this.filterStringValue = { 'group': true, 'account': true, 'role': true }; }, _getNewAccountExplorer: function _getNewAccountExplorer(options) { return new AccountExplorer(options); }, _getLdapStatus: function _getLdapStatus() { var options = { dataType: 'json', type: 'GET', data: {}, url: AJAXUtils.getAJAXURL("ldapStatus"), cache: false }; return this.glassContext.services.ajax.ajax(options); }, _showPaging: function _showPaging() { // this checks if we want to show paging in a component. For example we want to hide it in accounts copy/move view. return _.isUndefined(this.hidePaging) || !this.hidePaging; }, _populatePagingStatusAndValue: function _populatePagingStatusAndValue() { var pagingEnabled = this._checkIfPagingIsEnabled(); var pagingValue = this._getPagingValue(); return Promise.all([pagingEnabled, pagingValue]).then(function (responses) { this.pagingEnabled = responses[1] === 'true'; this.pagingValueSet = parseInt(responses[0]); }.bind(this)); }, _renderPagingWidget: function _renderPagingWidget() { if (this.pagingEnabled && this._showPaging()) { this._accountExplorer.pagingEnabled = this.pagingEnabled; this._accountExplorer.pagingValueSet = this.pagingValueSet; this._accountExplorer.searchPageSize = this.pagingValueSet; var pagingBar = React.createElement(AdminReact.Pagination, { 'glassContext': this.glassContext, 'StringResource': StringResource, 'accountExplorer': this._accountExplorer, 'listView': this.listView, 'defaultPagingValue': this.pagingValueSet, 'listAdaptor': this.listAdaptor }); this.pagerControl = ReactDOM.render(pagingBar, this.$el.find('.bi-admin-account-pagingBar')[0]); this._accountExplorer.pagerControl = this.pagerControl; this.$el.find('.bi-admin-account-pagingBar').hide(); $(this.listAdaptor).on("ldapBrowsingEvent", function (event, type) { this._updatePagingBar(type); }.bind(this)); } }, _checkIfPagingIsEnabled: function _checkIfPagingIsEnabled() { var endpoint = "v1/configuration/keys/Admin.namespaceChildrenPerPage"; var pagingSettingsPromise = this.glassContext.services.fetch.get(endpoint); return pagingSettingsPromise.then(function (response) { return response.data['Admin.namespaceChildrenPerPage']; }); }, _getPagingValue: function _getPagingValue() { var endpoint = "v1/configuration/keys/Admin.enableNamespaceChildrenPaging"; var pagingValuePromise = this.glassContext.services.fetch.get(endpoint); return pagingValuePromise.then(function (response) { return response.data['Admin.enableNamespaceChildrenPaging']; }); }, _renderTemplate: function _renderTemplate() { var paneInfo = { 'strings': { 'type': StringResource.get('type'), 'addNewUser': StringResource.get('addNewUser'), 'addNewGroup': StringResource.get('addNewGroup'), 'addNewRole': StringResource.get('addNewRole'), 'addNewFolder': StringResource.get('addNewFolder'), 'import': StringResource.get('import') }, showFilter: this.listAdaptor.shouldShowFilter() }; var sHtml = dot.template(SecurityObjectExplorerTemplate)(paneInfo); this.$el.html(sHtml); BidiUtil.initElementForBidi(this.$el.find(".bi-admin-input.bi-admin-input-search")[0]); this.myAccount = React.createElement(AdminReact.UserWidget, { 'parent': this, 'glassContext': this.glassContent, 'StringResource': StringResource, 'clickFunc': this._createObj.bind(this), 'importOpenIdFunc': this.importOpenId.bind(this), 'importFunc': this.importFunc.bind(this), 'label': 'First Label' }); ReactDOM.render(this.myAccount, this.$el.find('.bi-admin-account-createNewBar')[0]); //init to hide create bar before get ldap status and checking permissions this.$el.find('.bi-admin-account-createNewBar').hide(); this.$el.find('.multiUploadText').text(StringResource.get('importText')); }, importFunc: function importFunc(selectedOption) { if (selectedOption === 'importUsers') { //import users this.importOpenId('users'); } else if (selectedOption === 'importGroups') { //import groups this.importOpenId('groups'); } }, _updateOrUploadUsers: function _updateOrUploadUsers(options) { var pid = this._accountExplorer.getCurrentPath().id; var requestOptions = { 'headers': { 'Content-Type': 'text/csv' }, 'url': 'v1/users?pid=' + pid, 'type': 'POST', 'data': options.data, 'Content-Length': options.byteLength, 'processData': false }; return this.glassContext.services.ajax.ajax(requestOptions); }, _updateOrUploadGroups: function _updateOrUploadGroups(options) { var pid = this._accountExplorer.getCurrentPath().id; var requestOptions = { 'headers': { 'Content-Type': 'text/csv' }, 'url': 'v1/groups?pid=' + pid, 'type': 'POST', 'data': options.data, 'Content-Length': options.byteLength, 'processData': false }; return this.glassContext.services.ajax.ajax(requestOptions); }, _createUploader: function _createUploader(type) { if (type === 'users') { return new Uploader({ 'glassContext': this.glassContext, '$el': this.$el, 'fileType': 'csv', 'ajax': this._updateOrUploadUsers.bind(this), 'ajaxOptions': {} }); } else if (type === 'groups') { return new Uploader({ 'glassContext': this.glassContext, '$el': this.$el, 'fileType': 'csv', 'ajax': this._updateOrUploadGroups.bind(this), 'ajaxOptions': {} }); } }, _refreshAccountListPane: function _refreshAccountListPane(isCreatingObject) { if (this.pagingEnabled) { this.listAdaptor.sortChanged = false; AdminReact.PaginationHelper.reloadListViewinPagingContext(this.glassContext, this._accountExplorer, this.listView, this.listAdaptor, isCreatingObject); } else { this.listAdaptor.sortChanged = true; this.listView.reload(false); } }, importOpenId: function importOpenId(type) { var fileUploader = this._createUploader(type); return fileUploader.doUpload().then(function () { this._refreshAccountListPane(true); }.bind(this), function (err) { this.glassContext.appController.showErrorMessage(StringResource.get('OIDCErrorSuggestion', { serverError: err.responseJSON.messages }), StringResource.get('error')); }.bind(this)); }, changeBrowseSearch: function changeBrowseSearch(isBrowsing) { var elList = this.$el.find('.bi-admin-account-list'); if (isBrowsing) { this._accountExplorer.newSearch(); this.listView.setPaging(true); elList.addClass("security-browsing"); } else { this.listView.setPaging(true); elList.removeClass("security-browsing"); } }, _renderSearch: function _renderSearch() { var rSearch = this.$el.find(".bi-admin-filterbar-leading"); var searchComp = React.createElement(AdminReact.AdminSearchInput, { 'parent': this, StringResource: StringResource, placeholder: StringResource.get('filterTips'), onSearch: function (evt, newValue, searchType) { var isBrowsing = newValue === ""; this.listView.setPaging(false); this.listAdaptor.searchText = encodeURIComponent(newValue.trim()); this.listAdaptor.searchType = searchType; this.listAdaptor.isSearching = true; this._accountExplorer.clearGroupedContent(); this.listView._clearTable(); this.listView.showWorking(); if (!isBrowsing) { this.listView.reload(false).then(function () { this.changeBrowseSearch(isBrowsing); if (this.pagingEnabled && this.pagerControl) { this.pagerControl.store.updatePager(this._accountExplorer, this.listView, this.listAdaptor); } }.bind(this)); } else { this._accountExplorer.selectCurrentPath().then(function () { this.listView.reload(false).then(function () { this.changeBrowseSearch(isBrowsing); this._clearSearch(); }.bind(this)); }.bind(this)); } }.bind(this), ref: function (searchInput) { this._searchInput = searchInput; }.bind(this), onClear: function (e) { var isBrowsing = true; this.listView.setPaging(false); this.listAdaptor.searchText = ""; this._accountExplorer.clearGroupedContent(); this._accountExplorer.selectCurrentPath().then(function () { this.listView.reload(false).then(function () { this.changeBrowseSearch(isBrowsing); }.bind(this)); if (this.pagingEnabled && this.pagerControl) { this._clearSearch(); } }.bind(this)); }.bind(this) }); ReactDOM.render(searchComp, rSearch[0]); $(this.listAdaptor).on("ldapBrowsingEvent", function (event, type) { this._updateFilterBar(type); }.bind(this)); }, _clearSearch: function _clearSearch() { this.pagerControl.store.updatePager(this._accountExplorer, this.listView, this.listAdaptor); this.listAdaptor.isSearching = undefined; }, _initializeAccountExplorer: function _initializeAccountExplorer() { var deferred = Q.defer(); this._accountExplorer._defaultTypes = this.defaultTypes; this._accountExplorer.startUp().done(function () { if (this.listAdaptor.cognosNamespaceOnly) { this._accountExplorer.selectNamespace("Cognos").done(function () { this._updateAccountExplorerInit().done(function () { this.filterStringValue.account = false; this.filterStringValue.role = true; if (this.listAdaptor.allowedSelectionTypes === "role") { this.filterStringValue.group = false; } else { this.filterStringValue.group = true; } deferred.resolve(); }.bind(this)); }.bind(this)); } else { this._updateAccountExplorerInit().done(function () { this.filterStringValue.account = true; this.filterStringValue.role = true; this.filterStringValue.group = true; deferred.resolve(); }.bind(this)); } }.bind(this)); return deferred.promise; }, _updateAccountExplorerInit: function _updateAccountExplorerInit() { var deferred = Q.defer(); this._getLdapStatus().done(function (result) { this._ldapStatus = !!result['ads-state']; this._configToolBar(); deferred.resolve(); }.bind(this)); this.listAdaptor._accountExplorer = this._accountExplorer; this.listAdaptor.on('pathChanged', function (path) { this._updateBreadcrumb(path); this.listAdaptor.off('locationChanged'); this.listAdaptor.on("locationChanged", function (obj) { this._navigate(obj.data); }.bind(this)); }.bind(this)); return deferred.promise; }, _renderListView: function _renderListView() { var deferred = Q.defer(); var elList = this.$el.find('.bi-admin-account-list'); elList.addClass("security-browsing"); elList.empty(); this.listView = this._getNewListView({ el: elList, dataAdaptor: this.listAdaptor, glassContext: this.glassContext, accessibleLabel: this.title, activeInputForm: null, multiSelect: true, onSelectionChange: this.onSelectionChange }); this.listView.singleSelectCallback = this._rowClickHandler.bind(this); if (this.listAdaptor.contextMenuHandler) { this.listView.contextMenuCallback = this.listAdaptor.contextMenuHandler.bind(this.listAdaptor, this); } this.listView.render().then(function () { if (!this.pagingEnabled) { this._bindListViewEvents(); } }.bind(this)).then(deferred.resolve, deferred.reject); return deferred.promise; }, refresh: function refresh() { this._refreshAccountListPane(); }, _getNewListView: function _getNewListView(options) { return new ListView(options); }, _bindListViewEvents: function _bindListViewEvents() { $(this.listView).on("previousPage", function () { if (!this._accountExplorer.isTopOfPage()) { this.listView.setPaging(false); this._accountExplorer.cacheOldContent(); this._accountExplorer.clearGroupedContent(); this._accountExplorer.selectCurrentPath().then(function () { this.listAdaptor.isGetLessData = true; this.listView.reload(false).then(function () { this.changeBrowseSearch(false); this.listAdaptor.isGetLessData = false; this.listView.setPaging(true); }.bind(this)); }.bind(this)); } }.bind(this)); $(this.listView).on("nextPage", function () { if (!this.scrollCausedByRowClick && !this._accountExplorer.noMoreData) { this.listView.setPaging(false); this._accountExplorer.cacheOldContent(); this._accountExplorer.clearGroupedContent(); this._accountExplorer.selectCurrentPath().then(function () { this.listAdaptor.isGetMoreData = true; this.listView.reload(false).then(function () { this.changeBrowseSearch(false); this.listAdaptor.isGetMoreData = false; this.listView.adjustScrollForPageDown(); this.listView.setPaging(true); }.bind(this)); }.bind(this)); } else { delete this.scrollCausedByRowClick; } }.bind(this)); }, clearShowWorking: function clearShowWorking() { this.$el.find(".adminAccountsShowWorking").remove(); }, showWorking: function showWorking() { var loadingAnimation = Utils.getLoadingAnimation(1); var $container = $('
'); $container.append(loadingAnimation); this.$el.append($container); }, render: function render() { var deferred = Q.defer(); this._renderTemplate(); this.showWorking(); var accountsPagingStatus = this._populatePagingStatusAndValue().catch(function (err) { this.pagingEnabled = false; this.logger.error(err); }.bind(this)); this._renderSearch(); this._initializeAccountExplorer().then(function () { return accountsPagingStatus; }).then(this._renderListView.bind(this)).then(function () { this._bindEvents(); this._renderPagingWidget(); this.clearShowWorking(); }.bind(this)).then(deferred.resolve, deferred.reject); return deferred.promise; }, _bindFilter: function _bindFilter() { if (!this.filterPushed) { this.filterPushed = true; this.glassContext.appController.showSlideOut({ 'parent': this.parent.slideout, 'position': 'left', 'width': '200px', 'content': { 'parentView': this, 'glassContext': this.glassCtxt, 'showSwitchButton': true, 'module': 'bi/admin/account/slideout/UserGroupSelectorPane', 'view': this, 'callback': this } }).on('hide', function () { this.filterPushed = false; }.bind(this)); } }, getSelectedObjects: function getSelectedObjects() { return this.listView.getSelectedObjects(); }, _getFilterBar: function _getFilterBar() { return this.$el.find(".bi-admin-filterbar.folderpane-filterbar"); }, _getPaginBar: function _getPaginBar() { return this.$el.find(".bi-admin-account-pagingBar"); }, _updateFilterBar: function _updateFilterBar(type) { var filterBar = this._getFilterBar(); this._hideBar(filterBar, type); }, _updatePagingBar: function _updatePagingBar(type) { var pagingBar = this._getPaginBar(); this._hideBar(pagingBar, type); }, _hideBar: function _hideBar(bar, type) { if (type === "directory") { bar.css("display", "none"); } else { bar.css("display", "block"); } }, _bindEvents: function _bindEvents() { this.$el.find('.multiUploadBtn').on('primaryaction', function () {}.bind(this)); var $filterButton = this.$el.find('#filterDef').on('primaryaction', function () { this._bindFilter(); }.bind(this)); var $label = $(''); $label.text(this._filterString(this.filterStringValue)); ContentFormatter.middleShortenString($label); $label.appendTo($filterButton); }, setFocus: function setFocus() { this.$el.find('.bi-admin-filterbar-leading input').focus(); }, setFocusOnAccountList: function setFocusOnAccountList() { if (!this.listView.setFocus()) { this.setFocus(); } }, _filterString: function _filterString(filterString) { var types = ['account', 'role', 'group']; var filters = 0; var labelString; for (var i = 0; i < types.length; i++) { if (filterString[types[i]]) { if (filters === 0) { labelString = StringResource.get(types[i]); } else { labelString = labelString.concat(',').concat(' ').concat(StringResource.get(types[i])); } filters++; } } if (filters === 0) { labelString = StringResource.get('none'); } else if (filters === types.length) { labelString = StringResource.get('allMember'); } return labelString; }, _filter: function _filter(filterStr) { var $label = this.$el.find('.bi-admin-filter-icon'); if ($label) { $label[0].title = ''; } var labelString = this._filterString(filterStr); $label.text(labelString); ContentFormatter.middleShortenString($label[0]); this.listAdaptor._filterType = filterStr || ''; this._accountExplorer._filterType = this.listAdaptor._filterType; this.listAdaptor._filterString = ''; if (!this.pagingEnabled) { this.listView.reload(false); } else { AdminReact.PaginationHelper.reloadListViewinFilteredContext(this.glassContext, this._accountExplorer, this.listView, this.listAdaptor); } ; }, updateForNavigate: function updateForNavigate(data) { if (!this.hideSearch) { this._searchInput.clearSearch(); } this.changeBrowseSearch(true); this.listView.setPaging(false); this._accountExplorer.updateHasMoreData(); this.listView.reload(false).done(function () { this.setFocusOnAccountList(); this.listView.setPaging(true); if (this.pagingEnabled && this.pagerControl) { this.pagerControl.store.updatePager(this._accountExplorer, this.listView, this.listAdaptor); } }.bind(this)); this._configToolBar(data); }, _navigate: function _navigate(item) { this.listAdaptor.searchText = undefined; this._accountExplorer.selectPath(item).done(function () { this.updateForNavigate(item); }.bind(this, item)); }, _onNavigate: function _onNavigate(index) { var bc = this._breadCrumbs.ancestors; if (index >= bc.length - 1) { return; } var item = bc[index]; this.scrollCausedByRowClick = true; this._navigate(item); }, _checkCapabilities: function _checkCapabilities(capabilityName) { return _.find(this.glassContext.services.userProfile.capabilities, function (capability) { return capability === capabilityName; }); }, _canShowToolbar: function _canShowToolbar(ns) { return this._checkCapabilities('canUseUsersGroupsAndRolesTool') && (ns.defaultName === 'Cognos' || ns.defaultName === 'Cognos Users' || this._isNonBrowsableNamespace()); }, _isWriteable: function _isWriteable(permissions) { var retVal = false; _.find(permissions, function (permission) { retVal = permission === 'write'; }); return retVal; }, _configToolBar: function _configToolBar(data) { //NOSONAR var createNewBar = this.$el.find('.bi-admin-account-createNewBar'); createNewBar.css("padding", "initial"); createNewBar.css("paddingTop", "5px"); var filter = this.$el.find('.dropdown-toggle'); var ns = this._accountExplorer.getCurrentNamespace(); if (this._accountExplorer.tenantNsFolderId && this._accountExplorer.tenantNsFolderId !== 'xOg__' && this._accountExplorer.currentRequest === 'v1/namespaces/xOg__/items?') { this._accountExplorer.getFolderPermission(this._accountExplorer.tenantNsFolderId).then(function (tenantNsFolderPermissions) { this._renderConfigToolBar(data, createNewBar, filter, ns, tenantNsFolderPermissions); }.bind(this)).catch(function (e) { this.tenantNsFolderPermissions = null; this._renderConfigToolBar(data, createNewBar, filter, ns); }.bind(this)); } else { this._renderConfigToolBar(data, createNewBar, filter, ns); } return Promise.resolve(); }, _renderConfigToolBar: function _renderConfigToolBar(data, createNewBar, filter, ns, tenantNsFolderPermissions) { createNewBar.find('.admin-import-dropdown').hide(); if (!ns) { createNewBar.hide(); filter.hide(); } else if (this.type === 'copyMoveDialog') { if (ns.defaultName === 'Cognos') { createNewBar.find('#newGroup').hide(); createNewBar.find('#newUser').hide(); createNewBar.find('#newRole').hide(); createNewBar.find('#newFolder').show(); createNewBar.find('.admin-import-dropdown').hide(); } else { createNewBar.find('#newGroup').hide(); createNewBar.find('#newUser').hide(); createNewBar.find('#newFolder').hide(); createNewBar.find('#newRole').hide(); createNewBar.find('.admin-import-dropdown').hide(); } if (this._canShowToolbar(ns)) { createNewBar.show(); } else { createNewBar.hide(); } if (!this.includeToolbar) { createNewBar.hide(); } filter.show(); } else { //Check if non browsable namespace and is not a cloud evironment (doesn't have a tenented cognos ns folder) if (_.contains(ns.capabilities, 'notBrowsable') && this._isNotCloudEnviroment()) { createNewBar.find('#newUser').show(); createNewBar.find('#newGroup').show(); createNewBar.find('#newFolder').hide(); createNewBar.find('#newRole').hide(); createNewBar.find('.admin-import-dropdown').show(); } else if (data && data.type === 'namespaceFolder' && this._isWriteable(data.permissions) || ns.defaultName === 'Cognos' && this._accountExplorer.tenantNsFolderId === 'xOg__' && this._isWriteable(ns.permissions) || ns.defaultName === 'Cognos' && this._accountExplorer.tenantNsFolderId !== 'xOg__' && this._isWriteable(tenantNsFolderPermissions)) { this._hideButtonBasedOnTargetType('group', createNewBar.find('#newGroup')); this._hideButtonBasedOnTargetType('folder', createNewBar.find('#newFolder')); this._hideButtonBasedOnTargetType('role', createNewBar.find('#newRole')); createNewBar.find('#newUser').hide(); } else if (ns.defaultName === 'Cognos Users') { createNewBar.find('#newUser').show(); createNewBar.find('#newGroup').hide(); createNewBar.find('#newFolder').hide(); createNewBar.find('#newRole').hide(); } else { createNewBar.find('#newGroup').hide(); createNewBar.find('#newUser').hide(); createNewBar.find('#newFolder').hide(); createNewBar.find('#newRole').hide(); } if (this._canShowToolbar(ns)) { createNewBar.show(); } else { createNewBar.hide(); } filter.show(); } }, _isNotCloudEnviroment: function _isNotCloudEnviroment() { return this._accountExplorer.tenantNsFolderId === 'xOg__'; }, _hideButtonBasedOnTargetType: function _hideButtonBasedOnTargetType(buttonType, button) { if (!this.targetType || this.targetType.indexOf(buttonType) !== -1) { button.show(); } else { button.hide(); } }, reloadList: function reloadList() { return this.listView.reload(false); }, _rowClickHandler: function _rowClickHandler(oData) { this.scrollCausedByRowClick = true; if (this.listAdaptor.rowClickHandler) { this.listAdaptor.rowClickHandler(this, oData); } }, _updateBreadcrumb: function _updateBreadcrumb(path) { var $breadcrumbs = this.$el.find('#breadcrumbs'); if (this.showBreadcrumbs) { if (this._breadCrumbs) { this._breadCrumbs.updateBreadcrumb(path); } else { //render Breadcrumbs this._breadCrumbs = new Breadcrumbs({ 'el': $breadcrumbs, 'label': StringResource.get('breadCrumbsAccessibleLabel'), 'breadcrumbs': [{ defaultName: '', url: '' }], 'navigateCallback': this._onNavigate.bind(this) }); this._breadCrumbs.ancestors = this._breadCrumbs.breadcrumbs; this._breadCrumbs.render(); this._breadCrumbs.updateBreadcrumb(path); } } }, _allowCreateUser: function _allowCreateUser() { var retVal = false; if (this._ldapStatus) { var path = this._accountExplorer.getCurrentPath(); var isSignInCognos = false; _.each(this._accountExplorer.authNamespaces, function (authNamespace) { if (authNamespace.searchPath.split('"')[1] === 'CognosEx') { isSignInCognos = true; } }); retVal = !!path && path.type === 'namespace' && path.defaultName === 'Cognos' && isSignInCognos; } return retVal; }, _isNonBrowsableNamespace: function _isNonBrowsableNamespace() { var ns = this._accountExplorer.getCurrentNamespace(); return _.contains(ns.capabilities, 'notBrowsable'); }, _createObj: function _createObj(type) { var ns = this._accountExplorer.getCurrentNamespace(); type = type || this._filterType; var pid = this._accountExplorer.getCurrentPath().id; if (_.contains(ns.capabilities, 'notBrowsable') && type === 'account') { this.glassContext.appController.showSlideOut({ 'parent': this.parent.slideout, 'width': "400px", 'content': { 'showGobackButton': false, 'module': 'bi/admin/account/slideout/AddOpenIdPane', 'parentView': this, 'objectInfo': ns, 'pid': pid, 'glassContext': this.glassContext } }); } else if (type === "account") { var userPrototype = { businessPhone: "", contentLocale: "", faxPhone: "", homePhone: "", mobilePhone: "", pagerPhone: "", postalAddress: "", productLocale: "", userName: "", hidden: false, shown: false, password: "", description: "", type: "account" }; this.newGroupSlideout = this.glassContext.appController.showSlideOut({ 'parent': this.parent.slideout, 'width': "400px", 'content': { 'module': 'bi/admin/account/slideout/CreateNewPane', 'parentView': this, 'template': type === 'account' ? CreateNewUserTemplate : CreateNewGroupTemplate, 'objectInfo': type === 'account' ? userPrototype : {}, 'pid': pid, 'type': type, 'glassContext': this.glassContext } }); } else if (this._isNonBrowsableNamespace() && type === 'group') { this.listView.addInput('nonBrowsableGroup', pid, this._accountExplorer, this.listAdaptor); } else { this.listView.addInput(type, pid, this._accountExplorer, this.listAdaptor); } }, showProperties: function showProperties(item, tabModule) { this.propertySlideout = this.glassContext.appController.showSlideOut({ 'parent': this.parent.slideout, 'launchPoint': this.parent.slideout.$el.find('span.goback-icon'), 'width': "400px", 'onHide': function () { if (this.propertySlideout && this.propertySlideout.contentView && this.propertySlideout.contentView.onHide) { this.propertySlideout.contentView.onHide().then(function () { //remove propertiesPageView this.propertySlideout.hide(); }.bind(this)); } }.bind(this), 'content': { 'module': 'bi/admin/common/PropertiesPageView', 'parentView': this, 'objectInfo': item, 'type': item.type, 'selectedTabModule': tabModule || "", 'accountExplorer': this._accountExplorer, 'glassContext': this.glassContext } }); }, _deleteAccountObj: function _deleteAccountObj(data) { require(['bi/admin/account/ui/ConfirmDeleteContentView'], function (ConfirmDeleteContentView) { var dialog = new ContentGenericDialog({ 'title': StringResource.get('confirmDelete'), 'viewClass': ConfirmDeleteContentView, 'viewOptions': { 'accountObj': data, 'accountAdaptor': this.listAdaptor, 'listView': this.listView, 'showCheckbox': false, 'accountExplorer': this._accountExplorer, 'glassContext': this.glassContext } }); dialog.setLaunchPoint(this.$el.find('.bi-admin-filterbar-leading input')); dialog.open(); }.bind(this)); }, _deleteUserProfileObj: function _deleteUserProfileObj(data) { require(['bi/admin/account/ui/ConfirmDeleteContentView'], function (ConfirmDeleteContentView) { var dialog = new ContentGenericDialog({ 'title': StringResource.get('confirmDelete'), 'viewClass': ConfirmDeleteContentView, 'viewOptions': { 'accountObj': data, 'accountAdaptor': this.listAdaptor, 'listView': this.listView, 'showCheckbox': false, 'accountExplorer': this._accountExplorer, 'glassContext': this.glassContext, 'deleteUserProfile': true } }); dialog.setLaunchPoint(this.$el.find('.bi-admin-filterbar-leading input')); dialog.open(); }.bind(this)); }, createUserProfile: function createUserProfile(data) { var storeId = data[0].id; var url = AJAXUtils.getPath("createUserProfile", storeId); var ajaxOptions = { 'dataType': 'json', 'type': 'GET', 'url': url }; return this.glassContext.getCoreSvc('.Ajax').ajax(ajaxOptions).then(function (data) { this.glassContext.appController.showToast(StringResource.get("userProfileCreationSuccessful")); this._refreshAccountListPane(); }.bind(this), function (ajaxOptions, error) { this.glassContext.appController.showErrorMessage(StringResource.get("userProfileCreationFailed") + ", " + AJAXUtils.buildErrorMessage(error.responseJSON.errors)); }.bind(this)); }, _copyUserProfileObj: function _copyUserProfileObj(data) { this.copyProfileSlideout = this.glassContext.appController.showSlideOut({ 'parent': this.parent.slideout, 'width': "400px", 'onHide': function () { if (this.copyProfileSlideout && this.copyProfileSlideout.contentView && this.copyProfileSlideout.contentView.onHide) { this.copyProfileSlideout.contentView.onHide().then(function () { this.copyProfileSlideout.hide(); }.bind(this)); } }.bind(this), 'content': { 'module': 'bi/admin/account/slideout/CopyUserProfilePane', 'parentView': this, 'data': data, 'accountExplorer': this._accountExplorer, 'glassContext': this.glassContext, listRefresh: this._refreshAccountListPane.bind(this), deleteUserProfile: this._deleteUserProfileObj.bind(this) } }); }, _openSecurityObjectSelectorPane: function _openSecurityObjectSelectorPane(data, targetType) { var res; if (targetType.indexOf(',') > -1) { res = targetType.split(","); } else { res = []; res.push(targetType); } this.memberInfo = data; var self = this; var sTitle = StringResource.get('addMemberTo'); this.addMemberSlideout = this.glassContext.appController.showSlideOut({ 'parent': this.parent.slideout, 'width': "400px", 'content': { 'title': sTitle, 'module': 'bi/admin/account/slideout/SecurityObjectSelectorPane', 'parentView': self, 'objectInfo': self.memberInfo, 'allowedSelectionTypes': res, 'filterType': res, 'multiSelect': self.memberInfo.length > 1 ? false : true, 'defaultTypes': ['namespaceFolder', 'group', 'role', 'account'], 'isAddMemberTo': true, 'cognosNamespaceOnly': true, 'targetType': targetType, 'accountExplorer': this._accountExplorer } }); } }); return SecurityObjectExplorerView; });