123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 'use strict';
- define(['../../lib/@waca/core-client/js/core-client/ui/core/Class', '../nls/StringResources', 'underscore'], function (BaseClass, StringResources, _) {
- 'use strict';
- var AddSourceActionHandler = BaseClass.extend({
- init: function init(options) {
- AddSourceActionHandler.inherited('init', this, arguments);
- this.dashboardApi = options.dashboardApi;
- },
-
- execute: function execute() {
- var enableReportDatasource = this.dashboardApi.getGlassCoreSvc('.FeatureChecker').checkValue('dashboard', 'reportDatasource', 'enabled');
- var typesToOpen = ['module', 'dataSet2', 'uploadedFile', 'package', 'data_asset'];
- if (enableReportDatasource) {
- typesToOpen.push('report');
- }
- var options = {
- 'typesToOpen': typesToOpen,
- 'multiSelect': false,
- 'dialogTitle': StringResources.get('addDataSourceDialogTitle'),
- 'primaryBtnText': StringResources.get('addDataSourceDialogButtonLabel'),
- 'onOpenCallback': this.addDataSource.bind(this)
- };
- this.dashboardApi.prepareGlassOptions(options);
-
- if (this._openDialogInstance) {
- this._openDialogInstance.open(options);
- } else {
- return this.dashboardApi.getGlassSvc('.ContentDialogFactory').then(function (dialogFactory) {
- var openDialog = dialogFactory.createOpenDialog(options);
- openDialog.open();
- });
- }
- },
-
- addDataSource: function addDataSource(selectedItems) {
-
- var selectedItem = selectedItems[0];
- var dataSource = {
- 'assetId': selectedItem.id,
- 'name': selectedItem.defaultName,
- 'type': selectedItem.type,
- 'searchPath': selectedItem.searchPath,
- 'isOlapPackage': selectedItem.userInterfaces && _.indexOf(selectedItem.userInterfaces, 'analysisStudio') >= 0,
- 'modificationTime': selectedItem.modificationTime
- };
- var dataSourcesSvc = this.dashboardApi.getFeature('dataSources.deprecated');
- var dataSourceCollection = dataSourcesSvc.getSourcesCollection();
- var sourceId = dataSourceCollection.addSource(dataSource);
- this.dashboardApi.triggerDashboardEvent('dataSourcePanel:dataSourceAdded', {
- sender: sourceId
- });
- }
- });
- return AddSourceActionHandler;
- });
|