123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- "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 = $('<div tabindex="0" style="padding-left: 10px;" role="img" title="' + StringResource.get('adminAuthKeyHelpInfo') + '"><svg class="svgIcon dsSvgInfoIcon" role="presentation"><text>' + StringResource.get('adminAuthKeyHelpInfo') + '</text><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#common-titan_help"></use></svg></div>');
- $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 = $('<div tabindex="0" style="padding-left: 10px;" role="img" title="' + StringResource.get('sgGatewayHelpInfo') + '"><svg class="svgIcon dsSvgInfoIcon" role="presentation"><text>' + StringResource.get('sgGatewayHelpInfo') + '</text><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#common-titan_help"></use></svg></div>');
- $helpEl.on('primaryaction', function () {
- window.open(this._secureGatewayHelpLink, '_blank');
- }.bind(this));
- $secGWHelp.append($helpEl);
- },
- _addSecuredGateway: function _addSecuredGateway() {
- $(this.$el.find('.separator')[0]).after($('<div id=secGatewayElement>'));
- if (this.$el.find('#secGatewayElement')[0]) {
- ReactDOM.unmountComponentAtNode(this.$el.find('#secGatewayElement')[0]);
- }
- var secureGatewayElement = React.createElement(AdminReact.DSSecureGatewayElementView, {
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'StringResource': StringResource,
- 'ConnectionUtils': ConnectionUtils,
- 'objectInfo': this.objectInfo,
- 'textDir': BidiUtil.userPreferredTextDir,
- 'parent': this
- });
- this.secureGateway = ReactDOM.render(secureGatewayElement, this.$el.find('#secGatewayElement')[0]);
- },
- _addConnectionParamsHelp: function _addConnectionParamsHelp() {
- var $connParamsSec = $(this.$el.find(".l_connectionParameters"));
- $connParamsSec.css("display", "inline-flex");
- var $helpEl = $('<div tabindex="0" style="padding-left: 10px;" role="img" title="' + StringResource.get('connectionPropertiesHelp') + '"><svg class="svgIcon dsSvgInfoIcon" role="presentation"><text>' + StringResource.get('connectionPropertiesHelp') + '</text><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#common-titan_help"></use></svg></div>');
- $helpEl.on("primaryaction", function () {
- window.open(this._connectParametersHelpLink, '_blank');
- }.bind(this));
- $connParamsSec.append($helpEl);
- },
- _addSampleText: function _addSampleText() {
- var jdbcCollSec = this.$el.find(".collapsibleSection");
- var exampleText = $('<div><div style="padding-left: 25px" class="jdbcSampleText"></div></div>');
- exampleText.find('.jdbcSampleText').text(this.parseInfo.metadata.urlTemplate);
- $(jdbcCollSec).append(exampleText);
- var colSectEl = this.$el.find(".rightAlign");
- $(colSectEl).removeClass("rightAlign");
- },
- setFocus: function setFocus() {
- var textArea = this.$el.find(".v_jdbcUrl");
- $(textArea).focus();
- $(textArea).select();
- },
- closeClick: function closeClick() {
- JdbcConnectionStringPane.inherited('closeClick', this, arguments);
- if (this.$el.find('#secGatewayElement')[0]) {
- ReactDOM.unmountComponentAtNode(this.$el.find('#secGatewayElement')[0]);
- }
- },
- updateSecureGWConnectionString: function updateSecureGWConnectionString(connString, gwId, gatewayDestinationId, destinationKey) {
- this.parseInfo.gwConnStr = connString;
- var jdbcString = ConnectionUtils.buildConnection(this.parseInfo, this.objectInfo);
- this.objectInfo.connectionString = ConnectionUtils.getUpdatedConnectionString(this.parseInfo, jdbcString);
- this.parseInfo.gwStringUpdated = true;
- if (gatewayDestinationId && destinationKey) {
- this.objectInfo.gatewayDestination = [{
- type: 'gatewayDestination',
- gwParentId: gwId,
- id: gatewayDestinationId,
- searchPath: "storeID('" + gatewayDestinationId + "')"
- }];
- this.objectInfo.secureKey = [{
- type: 'secureKey',
- searchPath: "storeID('" + destinationKey + "')"
- }];
- } else {
- this.objectInfo.gatewayDestination = null;
- this.objectInfo.secureKey = null;
- }
- }
- });
- return JdbcConnectionStringPane;
- });
|