Skip to content

Commit 0a44add

Browse files
committed
feat(adhoc fiters): began work on ad-hoc filters, refactored submenu filters to use gf-form styles, grafana#6038
1 parent babab76 commit 0a44add

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

public/app/features/dashboard/submenu/submenu.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
<div class="submenu-controls">
1+
<div class="submenu-controls gf-form-query">
22
<ul ng-if="ctrl.dashboard.templating.list.length > 0">
33
<li ng-repeat="variable in ctrl.variables" ng-hide="variable.hide === 2" class="submenu-item">
4-
<span class="submenu-item-label template-variable " ng-hide="variable.hide === 1">
5-
{{variable.label || variable.name}}:
4+
<div class="gf-form">
5+
<label class="gf-form-label template-variable " ng-hide="variable.hide === 1">
6+
{{variable.label || variable.name}}:
7+
</label>
8+
<value-select-dropdown ng-if="variable.type !== 'adhoc'" variable="variable" on-updated="ctrl.variableUpdated(variable)" get-values-for-tag="ctrl.getValuesForTag(variable, tagKey)"></value-select-dropdown>
9+
</div>
10+
<span ng-if="variable.type === 'adhoc'">
11+
<div class="gf-form">
12+
<label class="gf-form-label">hostname</label>
13+
<label class="gf-form-label query-operator">=</label>
14+
<label class="gf-form-label">server1</label>
15+
</div>
616
</span>
7-
<value-select-dropdown variable="variable" on-updated="ctrl.variableUpdated(variable)" get-values-for-tag="ctrl.getValuesForTag(variable, tagKey)"></value-select-dropdown>
817
</li>
918
</ul>
1019

public/app/features/templating/editorCtrl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function (angular, _) {
2323

2424
$scope.variableTypes = [
2525
{value: "query", text: "Query"},
26+
{value: "adhoc", text: "Ad hoc filters"},
2627
{value: "interval", text: "Interval"},
2728
{value: "datasource", text: "Data source"},
2829
{value: "custom", text: "Custom"},

public/app/features/templating/templateValuesSrv.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ function (angular, _, $, kbn) {
188188
return;
189189
}
190190

191+
if (variable.type === 'adhoc') {
192+
variable.options = [];
193+
return;
194+
}
195+
191196
// extract options in comma separated string
192197
variable.options = _.map(variable.query.split(/[,]+/), function(text) {
193198
return { text: text.trim(), value: text.trim() };
@@ -271,7 +276,7 @@ function (angular, _, $, kbn) {
271276

272277
this.validateVariableSelectionState = function(variable) {
273278
if (!variable.current) {
274-
if (!variable.options.length) { return; }
279+
if (!variable.options.length) { return $q.when(); }
275280
return self.setVariableValue(variable, variable.options[0], false);
276281
}
277282

public/app/partials/valueSelectDropdown.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="variable-link-wrapper">
2-
<a ng-click="vm.show()" class="variable-value-link">
2+
<a ng-click="vm.show()" class="gf-form-label variable-value-link">
33
{{vm.linkText}}
44
<span ng-repeat="tag in vm.selectedTags" bs-tooltip='tag.valuesText' data-placement="bottom">
55
<span class="label-tag"tag-color-from-name="tag.text">
@@ -10,7 +10,7 @@
1010
<i class="fa fa-caret-down"></i>
1111
</a>
1212

13-
<input type="text" class="hidden-input input-small" style="display: none" ng-keydown="vm.keyDown($event)" ng-model="vm.search.query" ng-change="vm.queryChanged()" ></input>
13+
<input type="text" class="hidden-input input-small gf-form-input" style="display: none" ng-keydown="vm.keyDown($event)" ng-model="vm.search.query" ng-change="vm.queryChanged()" ></input>
1414

1515
<div class="variable-value-dropdown" ng-if="vm.dropdownVisible" ng-class="{'multi': vm.variable.multi, 'single': !vm.variable.multi}">
1616
<div class="variable-options-wrapper">

public/sass/components/_submenu.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
.submenu-item {
1919
margin-right: 20px;
2020
display: inline-block;
21-
border-radius: 3px;
22-
background-color: $panel-bg;
23-
border: $panel-border;
24-
margin-right: 10px;
21+
margin-right: 15px;
2522
display: inline-block;
2623
float: left;
2724

0 commit comments

Comments
 (0)