123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- "use strict";
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Cognos Analytics
- * Copyright IBM Corp. 2015, 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['jquery', 'bi/admin/common/slideout/BasePane', 'bi/admin/datasource/App', 'bi/admin/common/utils/AJAXUtils', 'bi/admin/datasource/ui/VendorListView', 'bi/admin/nls/StringResource', 'text!bi/admin/datasource/services/datasources.json'], function ($, BasePane, App, AJAXUtils, VendorListView, StringResource, datasources) {
- /**
- * Sample content view that extends the glass View class
- *
- */
- var VendorListPane = BasePane.extend({
- title: StringResource.get('vendorListPaneTitle'),
- init: function init(options) {
- VendorListPane.inherited('init', this, arguments);
- $.extend(this, options);
- this._stringResource = StringResource;
- this.slideout.$el.addClass('vendor-list-panel');
- },
- _openNewConnectionDialog: function _openNewConnectionDialog(selectedVendor) {
- var connection = {
- defaultName: StringResource.get('newDataServerConnection'),
- type: 'dataSourceConnection',
- permissions: ["execute", "read", "setPolicy", "traverse", "write"],
- disabled: false,
- hidden: false,
- isNew: true,
- dataSourceId: this.objectInfo.id,
- newConnection: true,
- signonOption: "anon",
- vendor: selectedVendor,
- connectionString: ""
- };
- return this._openConnectionDialog(connection);
- },
- _openNewDataServerConnectionDialog: function _openNewDataServerConnectionDialog(selectedVendor) {
- var dataSourceConnection = {
- defaultName: StringResource.get('newDataServerConnection'),
- type: 'dataSourceConnection',
- permissions: ["execute", "read", "setPolicy", "traverse", "write"],
- disabled: false,
- hidden: false,
- isNew: true,
- signonOption: "anon",
- vendor: selectedVendor,
- connectionString: ""
- };
- return this._openConnectionDialog(dataSourceConnection);
- },
- _openConnectionDialog: function _openConnectionDialog(connection) {
- var slideout = this.glassContext.appController.showSlideOut({
- 'parent': this.slideout,
- 'width': "400px",
- 'content': {
- 'module': 'bi/admin/common/PropertiesPageView',
- 'parentView': this,
- 'objectInfo': connection,
- 'glassContext': this._glassContext,
- 'selectedTabModule': 'bi/admin/datasource/ui/PropertiesConnectionTab',
- 'type': 'connection'
- }
- });
- slideout.onHide = function () {
- if (slideout && slideout.contentView && slideout.contentView.onHide) {
- return slideout.contentView.onHide();
- }
- }.bind(this);
- return slideout;
- },
- renderBody: function renderBody($body) {
- var listView = this._getNewVendorListView($body);
- listView.on('selected', function (item) {
- if (this.slideout.child) {
- this.slideout.child.hide();
- }
- var detailsPane;
- if (this.objectInfo && this.objectInfo.newConnection) {
- detailsPane = this._openNewConnectionDialog(item);
- } else {
- detailsPane = this._openNewDataServerConnectionDialog(item);
- }
- $(detailsPane).on("updateObject", function (e, updatedItem) {
- $(this.slideout).trigger("datasourceUpdate", updatedItem);
- }.bind(this));
- }.bind(this));
- var $spanEl = this.$el.find('div.goback .goback-icon');
- $spanEl.attr('role', 'button');
- $spanEl.attr('title', StringResource.get('goBack')).on('primaryaction', function () {
- if (this.slideout.child) {
- this.slideout.child.hide();
- }
- App.SlideOutDataSourceList(this.glassContext);
- }.bind(this));
- return this._getSortedItems().then(function (sortedItems) {
- listView.items = sortedItems;
- return listView.render(sortedItems);
- }.bind(this));
- },
- _getMtCloudConfigStatus: function _getMtCloudConfigStatus() {
- return this.glassContext.services.ajax.ajax({
- 'type': 'GET',
- 'url': AJAXUtils.getPath('getMtCloudBuild')
- }).then(function (response) {
- return response;
- });
- },
- _getSortedItems: function _getSortedItems() {
- var ds;
- try {
- ds = JSON.parse(datasources);
- } catch (err) {
- this.logger.error("could not load datasource metadata " + err);
- }
- return this._getMtCloudConfigStatus().then(function (response) {
- // only show supported data server connections if environment is multitenant cloud
- if (response && response.mtCloudBuild === 'true') {
- ds.data = ds.data.filter(function (item) {
- return item.multitenantCloud === true;
- });
- }
- ds.data.forEach(function (item, index) {
- if (item.versions) {
- item.code = item.versions[0].code;
- }
- item.id = item.code;
- });
- return _.sortBy(ds.data, function (item) {
- return item.title.toLowerCase();
- });
- });
- },
- _getNewVendorListView: function _getNewVendorListView($el) {
- return new VendorListView({
- $el: $el,
- glassContext: this.glassContext
- });
- },
- setFocus: function setFocus() {
- var $firstFocus = this.$el.find(":input[type=search]:first");
- if ($firstFocus.length > 0) {
- $firstFocus.focus();
- }
- }
- });
- return VendorListPane;
- });
|