"use strict"; /** * Licensed Materials - Property of IBM * IBM Cognos Products: Cognos Analytics * Copyright IBM Corp. 2017, 2018 * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['bi/admin/datasource/slideout/ConnectionStringEditorPane', 'bi/admin/datasource/services/ConnectionUtils', 'bi/admin/nls/StringResource', 'jquery', 'text!bi/admin/datasource/services/datasources.json', 'react-dom', 'react', 'mobx', 'ba-react-admin/ba-react-admin.min', 'baglass/core-client/js/core-client/utils/BidiUtil'], function (ConnectionStringEditorPane, ConnectionUtils, StringResource, $, datasources, ReactDOM, React, mobx, AdminReact, BidiUtil) { /** * Sample content view that extends the glass View class */ var JdbcConnectionStringPane = ConnectionStringEditorPane.extend({ _connectParametersHelpLink: 'https://www.ibm.com/support/knowledgecenter/SSEP7J_11.1.0/com.ibm.swg.ba.cognos.ag_manage.doc/c_connection_properties.html', _secureGatewayHelpLink: 'https://www.ibm.com/support/knowledgecenter/SSEP7J_11.1.0/com.ibm.swg.ba.cognos.ag_manage.doc/c_ca_manage_secure_gateway_connecting_destination.html', _secretKeyHelpLink: 'https://www.ibm.com/support/knowledgecenter/SSEP7J_11.1.0/com.ibm.swg.ba.cognos.ag_manage.doc/c_ca_manage_data_source_secret_key.html', init: function init(options) { JdbcConnectionStringPane.inherited('init', this, arguments); $.extend(this, options); this.objectInfo = options.objectInfo; }, refresh: function refresh() { this.$body.empty(); this.renderBody(); }, renderBody: function renderBody() { var options = { 'el': this.$el.find(".bi-admin-pane-body"), 'glassContext': this.glassContext, 'items': [] }; options.items.push({ 'id': 'adminJdbcUrl', 'name': 'jdbcUrl', 'label': StringResource.get('jdbcUrl'), 'type': 'TextArea', 'multiline': true, 'editable': this.isEditable(), 'onChange': function (name, value) { this.parseInfo.jdbcURL = value; }.bind(this), 'value': this.parseInfo.jdbcURL }); options.items.push({ 'id': 'adminDriverClass', 'name': 'driverClass', 'label': StringResource.get('driverClassName'), 'type': 'TextArea', 'multiline': true, 'editable': this.isEditable(), 'onChange': function (name, value) { this.parseInfo.metadata.driverName = value; }.bind(this), 'value': this.parseInfo.metadata.driverName }); if (this.isEditable()) { options.items.push({ 'id': 'admindriverClassRestore', 'name': 'driverClassRestore', 'label': StringResource.get('restore'), 'type': 'Button', 'onSelect': function () { try { var ds = JSON.parse(datasources).data; for (var i = 0; i < ds.length; i++) { if (this.parseInfo.metadata.code === ds[i].code) { //NOSONAR this.parseInfo.metadata.driverName = ds[i].driverName; this.refresh(); break; } } } catch (err) { this.logger.error("Could not load datasource metadata: " + err); } }.bind(this) }); } options.items.push({ 'type': 'CollapsibleSection', 'label': StringResource.get('exampleURL'), 'name': 'exampleURLCol', 'styleAsSimpleRow': true, 'items': [] }); options.items.push({ 'id': 'adminConnectionParameters', 'name': 'connectionParameters', 'label': StringResource.get('connectionParameters'), 'type': 'TextArea', 'multiline': true, 'editable': this.isEditable(), 'onChange': function (name, value) { this.parseInfo.connectionProperties = value; }.bind(this), 'value': this.parseInfo.connectionProperties }); if (this._showSecretKeyOptions()) { options.items.push({ 'id': 'adminAuthKey', 'name': 'key', 'label': StringResource.get('key'), 'value': this.parseInfo.apiToken && this.parseInfo.apiToken.authKey ? 'secret' : '', 'type': 'SingleLineValue', 'multiline': true, 'editable': this.isEditable(), 'inputType': 'password', 'onChange': function (name, value) { if (!this.parseInfo.apiToken) { this.parseInfo.apiToken = {}; } this.parseInfo.apiToken.authKey = value.toString(); }.bind(this) }); options.items.push({ 'id': 'adminSecretKey', 'name': 'secretKey', 'label': StringResource.get('secretKey'), 'type': 'SingleLineValue', 'value': this.parseInfo.apiToken && this.parseInfo.apiToken.secretKey ? 'secret' : '', 'multiline': true, 'editable': this.isEditable(), 'inputType': 'password', 'onChange': function (name, value) { if (!this.parseInfo.apiToken) { this.parseInfo.apiToken = {}; } this.parseInfo.apiToken.secretKey = value.toString(); }.bind(this) }); } return ConnectionUtils.checkForSecuredGatewayExtension(this.glassContext).then(function (resp) { if (resp === null || resp === undefined) { this.isSecureGateway = false; } else { this.isSecureGateway = true; options.items.push({ 'id': 'secureGatewayInfo', 'name': 'secureGatewayInfo', 'label': StringResource.get('secureGatewayDestination'), 'type': 'SectionLabel' }); options.items.push({ 'type': 'Separator' }); } return this._renderBody(options); }.bind(this)); }, _showSecretKeyOptions: function _showSecretKeyOptions() { if (this.objectInfo.vendor && this.objectInfo.vendor.authKey || this.objectInfo.connectionString.indexOf('ibmcognos.subcode=AUTOREST') > -1) { return true; } return false; }, _postRender: function _postRender() { if (this.isSecureGateway) { this._addSecuredGateway(); this._addSecureGatewayHelp(); } if (this._showSecretKeyOptions()) { this._addSecretKeyHelp(); } this._addConnectionParamsHelp(); this._addSampleText(); return this.$el; }, _addSecretKeyHelp: function _addSecretKeyHelp() { var $secHelp = $(this.$el.find('.property_adminAuthKey .l_key')); $secHelp.css('display', 'inline-flex'); var $helpEl = $('
'); $helpEl.on('primaryaction', function () { window.open(this._secretKeyHelpLink, '_blank'); }.bind(this)); $secHelp.append($helpEl); }, _addSecureGatewayHelp: function _addSecureGatewayHelp() { var $secGWHelp = $(this.$el.find('.property_secureGatewayInfo')); $secGWHelp.css('display', 'inline-flex'); var $helpEl = $(''); $helpEl.on('primaryaction', function () { window.open(this._secureGatewayHelpLink, '_blank'); }.bind(this)); $secGWHelp.append($helpEl); }, _addSecuredGateway: function _addSecuredGateway() { $(this.$el.find('.separator')[0]).after($('