1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- "use strict";
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: admin
- * Copyright IBM Corp. 2015, 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['bacontentnav/common/ContentListPageView', 'underscore', 'bi/admin/nls/StringResource', 'bi/admin/multitenancy/services/TenantsCustomizationService'], function (ContentListPageView, _, StringResource, TenantsController) {
- 'use strict'; //NOSONAR: meant to be strict
- var LicenseByUserView = ContentListPageView.extend({
- init: function init(options) {
- LicenseByUserView.inherited('init', this, arguments);
- $.extend(this, options);
- this.tenantsController = this._getNewTenantsController({
- glassContext: this.glassContext
- });
- },
- _getNewTenantsController: function _getNewTenantsController(spec) {
- return new TenantsController(spec);
- },
- _getContentBarAccesibleLabel: function _getContentBarAccesibleLabel() {
- return StringResource.get('licenseUsageByUser');
- },
- _buildColumns: function _buildColumns(AdminRoles) {
- var isSysAdmin = AdminRoles[0];
- var isTenantAdmin = AdminRoles[1];
- var haveTenants = AdminRoles[2] && AdminRoles[2].length > 0;
- var columns = [{
- 'type': 'Text',
- 'name': 'userName',
- 'label': StringResource.get('userName'),
- 'scope': 'row',
- 'getDataFn': function getDataFn(oRowData) {
- return _.escape(oRowData.name);
- }
- }, {
- 'type': 'Text',
- 'name': 'userID',
- 'label': StringResource.get('userId'),
- 'scope': 'row',
- 'getDataFn': function getDataFn(oRowData) {
- return _.escape(oRowData.userId);
- }
- }, {
- 'type': 'Time',
- 'name': 'lastLogin',
- 'label': StringResource.get('lastLogin'),
- 'scope': 'row',
- 'getDataFn': function getDataFn(oRowData) {
- return oRowData.lastLogon;
- }
- }];
- var tenantColumn = {
- 'type': 'Text',
- 'name': 'tenant',
- 'label': StringResource.get('type_tenant'),
- 'scope': 'row',
- 'getDataFn': function getDataFn(oRowData) {
- return oRowData.tenant;
- }
- };
- if ((isSysAdmin || isTenantAdmin) && haveTenants) {
- columns.push(tenantColumn);
- }
- return columns;
- },
- _checkColumnsToRender: function _checkColumnsToRender(AdminRoles) {
- return this.renderContentList({
- 'el': this.$el,
- 'ajaxProp': 'users',
- 'multiSelect': false,
- 'columns': this._buildColumns(AdminRoles),
- 'minHeight': 50,
- 'url': 'v1/licenses/details?level=' + this.licenseInfo.level
- });
- },
- renderContent: function renderContent() {
- return Promise.all([this.parentPane.isSysAdmin(), this.parentPane.isTenantAdmin(), this.tenantsController.getTenantsList()]).catch(function (err) {
- this.logger.error(err);
- return [false, false, []];
- }.bind(this)).then(function (results) {
- return this._checkColumnsToRender(results);
- }.bind(this));
- }
- });
- return LicenseByUserView;
- });
|