From b9a3239edbb379202192b6f14b689935b09c240e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 14 Jan 2019 15:01:47 +0100 Subject: [PATCH] removed old unused angular stuff, rename --- public/app/features/plugins/all.ts | 3 +- .../features/plugins/ds_dashboards_ctrl.ts | 42 ---- public/app/features/plugins/ds_edit_ctrl.ts | 223 ------------------ ...ader.tsx => variableQueryEditorLoader.tsx} | 0 4 files changed, 1 insertion(+), 267 deletions(-) delete mode 100644 public/app/features/plugins/ds_dashboards_ctrl.ts delete mode 100644 public/app/features/plugins/ds_edit_ctrl.ts rename public/app/features/plugins/{VariableQueryComponentLoader.tsx => variableQueryEditorLoader.tsx} (100%) diff --git a/public/app/features/plugins/all.ts b/public/app/features/plugins/all.ts index 757a9a2f491..4845a3a6cb8 100644 --- a/public/app/features/plugins/all.ts +++ b/public/app/features/plugins/all.ts @@ -1,7 +1,6 @@ import './plugin_edit_ctrl'; import './plugin_page_ctrl'; import './import_list/import_list'; -import './ds_edit_ctrl'; import './datasource_srv'; import './plugin_component'; -import './VariableQueryComponentLoader'; +import './variableQueryEditorLoader'; diff --git a/public/app/features/plugins/ds_dashboards_ctrl.ts b/public/app/features/plugins/ds_dashboards_ctrl.ts deleted file mode 100644 index 71639702e41..00000000000 --- a/public/app/features/plugins/ds_dashboards_ctrl.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { coreModule } from 'app/core/core'; -import { store } from 'app/store/store'; -import { getNavModel } from 'app/core/selectors/navModel'; -import { buildNavModel } from './state/navModel'; - -export class DataSourceDashboardsCtrl { - datasourceMeta: any; - navModel: any; - current: any; - - /** @ngInject */ - constructor(private backendSrv, private $routeParams) { - const state = store.getState(); - this.navModel = getNavModel(state.navIndex, 'datasources'); - - if (this.$routeParams.id) { - this.getDatasourceById(this.$routeParams.id); - } - } - - getDatasourceById(id) { - this.backendSrv - .get('/api/datasources/' + id) - .then(ds => { - this.current = ds; - }) - .then(this.getPluginInfo.bind(this)); - } - - updateNav() { - this.navModel = buildNavModel(this.current, this.datasourceMeta, 'datasource-dashboards'); - } - - getPluginInfo() { - return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => { - this.datasourceMeta = pluginInfo; - this.updateNav(); - }); - } -} - -coreModule.controller('DataSourceDashboardsCtrl', DataSourceDashboardsCtrl); diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts deleted file mode 100644 index d8e9f7d8e53..00000000000 --- a/public/app/features/plugins/ds_edit_ctrl.ts +++ /dev/null @@ -1,223 +0,0 @@ -import _ from 'lodash'; -import config from 'app/core/config'; -import { coreModule, appEvents } from 'app/core/core'; -import { store } from 'app/store/store'; -import { getNavModel } from 'app/core/selectors/navModel'; -import { buildNavModel } from './state/navModel'; - -let datasourceTypes = []; - -const defaults = { - name: '', - type: 'graphite', - url: '', - access: 'proxy', - jsonData: {}, - secureJsonFields: {}, - secureJsonData: {}, -}; - -let datasourceCreated = false; - -export class DataSourceEditCtrl { - isNew: boolean; - datasources: any[]; - current: any; - types: any; - testing: any; - datasourceMeta: any; - editForm: any; - gettingStarted: boolean; - navModel: any; - - /** @ngInject */ - constructor(private $q, private backendSrv, private $routeParams, private $location, private datasourceSrv) { - const state = store.getState(); - this.navModel = getNavModel(state.navIndex, 'datasources'); - this.datasources = []; - - this.loadDatasourceTypes().then(() => { - if (this.$routeParams.id) { - this.getDatasourceById(this.$routeParams.id); - } else { - this.initNewDatasourceModel(); - } - }); - } - - initNewDatasourceModel() { - this.isNew = true; - this.current = _.cloneDeep(defaults); - - // We are coming from getting started - if (this.$location.search().gettingstarted) { - this.gettingStarted = true; - this.current.isDefault = true; - } - - this.typeChanged(); - } - - loadDatasourceTypes() { - if (datasourceTypes.length > 0) { - this.types = datasourceTypes; - return this.$q.when(null); - } - - return this.backendSrv.get('/api/plugins', { enabled: 1, type: 'datasource' }).then(plugins => { - datasourceTypes = plugins; - this.types = plugins; - }); - } - - getDatasourceById(id) { - this.backendSrv.get('/api/datasources/' + id).then(ds => { - this.isNew = false; - this.current = ds; - - if (datasourceCreated) { - datasourceCreated = false; - this.testDatasource(); - } - - return this.typeChanged(); - }); - } - - userChangedType() { - // reset model but keep name & default flag - this.current = _.defaults( - { - id: this.current.id, - name: this.current.name, - isDefault: this.current.isDefault, - type: this.current.type, - }, - _.cloneDeep(defaults) - ); - this.typeChanged(); - } - - updateNav() { - this.navModel = buildNavModel(this.current, this.datasourceMeta, 'datasource-settings'); - } - - typeChanged() { - return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => { - this.datasourceMeta = pluginInfo; - this.updateNav(); - }); - } - - updateFrontendSettings() { - return this.backendSrv.get('/api/frontend/settings').then(settings => { - config.datasources = settings.datasources; - config.defaultDatasource = settings.defaultDatasource; - this.datasourceSrv.init(); - }); - } - - testDatasource() { - return this.datasourceSrv.get(this.current.name).then(datasource => { - if (!datasource.testDatasource) { - return; - } - - this.testing = { done: false, status: 'error' }; - - // make test call in no backend cache context - return this.backendSrv - .withNoBackendCache(() => { - return datasource - .testDatasource() - .then(result => { - this.testing.message = result.message; - this.testing.status = result.status; - }) - .catch(err => { - if (err.statusText) { - this.testing.message = 'HTTP Error ' + err.statusText; - } else { - this.testing.message = err.message; - } - }); - }) - .finally(() => { - this.testing.done = true; - }); - }); - } - - saveChanges() { - if (!this.editForm.$valid) { - return; - } - - if (this.current.readOnly) { - return; - } - - if (this.current.id) { - return this.backendSrv.put('/api/datasources/' + this.current.id, this.current).then(result => { - this.current = result.datasource; - this.updateNav(); - return this.updateFrontendSettings().then(() => { - return this.testDatasource(); - }); - }); - } else { - return this.backendSrv.post('/api/datasources', this.current).then(result => { - this.current = result.datasource; - this.updateFrontendSettings(); - - datasourceCreated = true; - this.$location.path('datasources/edit/' + result.id); - }); - } - } - - confirmDelete() { - this.backendSrv.delete('/api/datasources/' + this.current.id).then(() => { - this.$location.path('datasources'); - }); - } - - delete(s) { - appEvents.emit('confirm-modal', { - title: 'Delete', - text: 'Are you sure you want to delete this datasource?', - yesText: 'Delete', - icon: 'fa-trash', - onConfirm: () => { - this.confirmDelete(); - }, - }); - } -} - -coreModule.controller('DataSourceEditCtrl', DataSourceEditCtrl); - -coreModule.directive('datasourceHttpSettings', () => { - return { - scope: { - current: '=', - suggestUrl: '@', - noDirectAccess: '@', - }, - templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html', - link: { - pre: ($scope, elem, attrs) => { - // do not show access option if direct access is disabled - $scope.showAccessOption = $scope.noDirectAccess !== 'true'; - $scope.showAccessHelp = false; - $scope.toggleAccessHelp = () => { - $scope.showAccessHelp = !$scope.showAccessHelp; - }; - - $scope.getSuggestUrls = () => { - return [$scope.suggestUrl]; - }; - }, - }, - }; -}); diff --git a/public/app/features/plugins/VariableQueryComponentLoader.tsx b/public/app/features/plugins/variableQueryEditorLoader.tsx similarity index 100% rename from public/app/features/plugins/VariableQueryComponentLoader.tsx rename to public/app/features/plugins/variableQueryEditorLoader.tsx