From 465c71ab117419b00b51616ed068a74e06d32c9a Mon Sep 17 00:00:00 2001 From: rozetko Date: Mon, 4 Mar 2019 16:44:28 +0300 Subject: [PATCH] Set default access method --- src/datasource/config_ctrl.ts | 32 ++++++++++++++++++++++++++++++++ src/datasource/module.ts | 31 +------------------------------ 2 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 src/datasource/config_ctrl.ts diff --git a/src/datasource/config_ctrl.ts b/src/datasource/config_ctrl.ts new file mode 100644 index 0000000..265ec13 --- /dev/null +++ b/src/datasource/config_ctrl.ts @@ -0,0 +1,32 @@ +import { normalizeUrl } from '../utlis'; +import configTemplate from './partials/config.html'; + + +export class HasticConfigCtrl { + public static template = configTemplate; + public ACCESS_OPTIONS = [ + { key: 'proxy', value: 'Server (Default)' }, + { key: 'direct', value: 'Browser' } + ]; + + private showAccessHelp: boolean = false; + + constructor(private $scope: any) { + if(this.$scope.current === undefined) { + this.$scope.current = { + access: 'proxy' + }; + } + } + + normalizeUrl() { + if(this.$scope.current.url === '') { + return; + } + this.$scope.current.url = normalizeUrl(this.$scope.current.url); + } + + toggleAccessHelp() { + this.showAccessHelp = !this.showAccessHelp; + } +} diff --git a/src/datasource/module.ts b/src/datasource/module.ts index 3b01f9e..e3767cd 100644 --- a/src/datasource/module.ts +++ b/src/datasource/module.ts @@ -1,36 +1,7 @@ import { HasticDatasource } from './datasource'; import { HasticQueryCtrl } from './query_ctrl'; +import { HasticConfigCtrl } from './config_ctrl'; -import { normalizeUrl } from '../utlis'; - -import configTemplate from './partials/config.html'; - - -class HasticConfigCtrl { - public static template = configTemplate; - public ACCESS_OPTIONS = [ - { key: 'proxy', value: 'Server (Default)' }, - { key: 'direct', value: 'Browser'} - ]; - - public current: any; - private showAccessHelp: boolean = false; - - constructor(private $scope) { - } - - normalizeUrl() { - if(this.$scope.current.url === "") { - return; - } - this.$scope.current.url = normalizeUrl(this.$scope.current.url); - } - - toggleAccessHelp() { - this.showAccessHelp = !this.showAccessHelp; - } - -} export { HasticDatasource as Datasource,