From cb522d58cd896b316994c56707215a83acc17c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 19 Sep 2016 18:41:42 +0200 Subject: [PATCH] feat(templating): back to be able to continue work on ad hoc filters, #6048 --- .../app/features/templating/adhoc_variable.ts | 52 +++++++++++++++++++ public/app/features/templating/all.ts | 2 + 2 files changed, 54 insertions(+) create mode 100644 public/app/features/templating/adhoc_variable.ts diff --git a/public/app/features/templating/adhoc_variable.ts b/public/app/features/templating/adhoc_variable.ts new file mode 100644 index 00000000000..579b0268efa --- /dev/null +++ b/public/app/features/templating/adhoc_variable.ts @@ -0,0 +1,52 @@ +/// + +import _ from 'lodash'; +import kbn from 'app/core/utils/kbn'; +import {Variable, assignModelProperties, variableTypes} from './variable'; +import {VariableSrv} from './variable_srv'; + +export class AdhocVariable implements Variable { + + defaults = { + type: 'adhoc', + name: '', + label: '', + hide: 0, + datasource: null, + options: [], + current: {}, + tags: {}, + }; + + /** @ngInject **/ + constructor(private model, private timeSrv, private templateSrv, private variableSrv) { + assignModelProperties(this, model, this.defaults); + } + + setValue(option) { + return Promise.resolve(); + } + + getModel() { + assignModelProperties(this.model, this, this.defaults); + return this.model; + } + + updateOptions() { + return Promise.resolve(); + } + + dependsOn(variable) { + return false; + } + + setValueFromUrl(urlValue) { + return Promise.resolve(); + } +} + +variableTypes['adhoc'] = { + name: 'Ad hoc', + ctor: AdhocVariable, + description: 'Ad hoc filters', +}; diff --git a/public/app/features/templating/all.ts b/public/app/features/templating/all.ts index 3b36f18b9b0..7205da52d19 100644 --- a/public/app/features/templating/all.ts +++ b/public/app/features/templating/all.ts @@ -7,6 +7,7 @@ import {QueryVariable} from './query_variable'; import {DatasourceVariable} from './datasource_variable'; import {CustomVariable} from './custom_variable'; import {ConstantVariable} from './constant_variable'; +import {AdhocVariable} from './adhoc_variable'; export { VariableSrv, @@ -15,4 +16,5 @@ export { DatasourceVariable, CustomVariable, ConstantVariable, + AdhocVariable, }