fix target duplication in query editor

This commit is contained in:
Alexander Zobnin
2017-12-21 12:17:49 +03:00
parent 45430a6f2a
commit 69bc415fd9
5 changed files with 35 additions and 35 deletions

View File

@@ -6,7 +6,7 @@
</div> </div>
<div class="gf-form"> <div class="gf-form">
<datasource-selector <datasource-selector
datasources="editor.panel.datasources" datasources="ctrl.panel.datasources"
options="editor.panelCtrl.available_datasources" options="editor.panelCtrl.available_datasources"
on-change="editor.datasourcesChanged()"> on-change="editor.datasourcesChanged()">
</datasource-selector> </datasource-selector>
@@ -15,36 +15,36 @@
</div> </div>
</div> </div>
<div class="editor-row" ng-repeat="ds in editor.panel.datasources"> <div class="editor-row" ng-repeat="ds in ctrl.panel.datasources">
<div class="section gf-form-group"> <div class="section gf-form-group">
<h5 class="section-heading">{{ ds }}</h5> <h5 class="section-heading">{{ ds }}</h5>
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form max-width-20"> <div class="gf-form max-width-20">
<label class="gf-form-label query-keyword width-7">Group</label> <label class="gf-form-label query-keyword width-7">Group</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].group.filter" ng-model="ctrl.panel.targets[ds].group.filter"
bs-typeahead="editor.getGroupNames[ds]" bs-typeahead="editor.getGroupNames[ds]"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
data-min-length=0 data-min-length=0
data-items=100 data-items=100
class="gf-form-input" class="gf-form-input"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].group.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].group.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].group.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].group.filter)
}"> }">
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-7">Host</label> <label class="gf-form-label query-keyword width-7">Host</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].host.filter" ng-model="ctrl.panel.targets[ds].host.filter"
bs-typeahead="editor.getHostNames[ds]" bs-typeahead="editor.getHostNames[ds]"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
data-min-length=0 data-min-length=0
data-items=100 data-items=100
class="gf-form-input" class="gf-form-input"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].host.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].host.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].host.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].host.filter)
}"> }">
</div> </div>
</div> </div>
@@ -53,35 +53,35 @@
<div class="gf-form max-width-20"> <div class="gf-form max-width-20">
<label class="gf-form-label query-keyword width-7">Application</label> <label class="gf-form-label query-keyword width-7">Application</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].application.filter" ng-model="ctrl.panel.targets[ds].application.filter"
bs-typeahead="editor.getApplicationNames[ds]" bs-typeahead="editor.getApplicationNames[ds]"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
data-min-length=0 data-min-length=0
data-items=100 data-items=100
class="gf-form-input" class="gf-form-input"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].application.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].application.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].application.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].application.filter)
}"> }">
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-7">Trigger</label> <label class="gf-form-label query-keyword width-7">Trigger</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].trigger.filter" ng-model="ctrl.panel.targets[ds].trigger.filter"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
placeholder="trigger name" placeholder="trigger name"
class="gf-form-input" class="gf-form-input"
ng-style="editor.panel.targets[ds].trigger.style" ng-style="ctrl.panel.targets[ds].trigger.style"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].trigger.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].trigger.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].trigger.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].trigger.filter)
}" }"
empty-to-null> empty-to-null>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-7">Tags</label> <label class="gf-form-label query-keyword width-7">Tags</label>
<input type="text" class="gf-form-input" <input type="text" class="gf-form-input"
ng-model="editor.panel.targets[ds].tags.filter" ng-model="ctrl.panel.targets[ds].tags.filter"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
placeholder="tag1:value1, tag2:value2"> placeholder="tag1:value1, tag2:value2">
</div> </div>

View File

@@ -125,7 +125,7 @@ System.register(['lodash', '../datasource-zabbix/utils', './triggers_panel_ctrl'
_.each(this.panel.datasources, function (ds) { _.each(this.panel.datasources, function (ds) {
if (!_this2.panel.targets[ds]) { if (!_this2.panel.targets[ds]) {
_this2.panel.targets[ds] = DEFAULT_TARGET; _this2.panel.targets[ds] = _.cloneDeep(DEFAULT_TARGET);
} }
}); });
this.parseTarget(); this.parseTarget();

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
</div> </div>
<div class="gf-form"> <div class="gf-form">
<datasource-selector <datasource-selector
datasources="editor.panel.datasources" datasources="ctrl.panel.datasources"
options="editor.panelCtrl.available_datasources" options="editor.panelCtrl.available_datasources"
on-change="editor.datasourcesChanged()"> on-change="editor.datasourcesChanged()">
</datasource-selector> </datasource-selector>
@@ -15,36 +15,36 @@
</div> </div>
</div> </div>
<div class="editor-row" ng-repeat="ds in editor.panel.datasources"> <div class="editor-row" ng-repeat="ds in ctrl.panel.datasources">
<div class="section gf-form-group"> <div class="section gf-form-group">
<h5 class="section-heading">{{ ds }}</h5> <h5 class="section-heading">{{ ds }}</h5>
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form max-width-20"> <div class="gf-form max-width-20">
<label class="gf-form-label query-keyword width-7">Group</label> <label class="gf-form-label query-keyword width-7">Group</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].group.filter" ng-model="ctrl.panel.targets[ds].group.filter"
bs-typeahead="editor.getGroupNames[ds]" bs-typeahead="editor.getGroupNames[ds]"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
data-min-length=0 data-min-length=0
data-items=100 data-items=100
class="gf-form-input" class="gf-form-input"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].group.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].group.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].group.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].group.filter)
}"> }">
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-7">Host</label> <label class="gf-form-label query-keyword width-7">Host</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].host.filter" ng-model="ctrl.panel.targets[ds].host.filter"
bs-typeahead="editor.getHostNames[ds]" bs-typeahead="editor.getHostNames[ds]"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
data-min-length=0 data-min-length=0
data-items=100 data-items=100
class="gf-form-input" class="gf-form-input"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].host.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].host.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].host.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].host.filter)
}"> }">
</div> </div>
</div> </div>
@@ -53,35 +53,35 @@
<div class="gf-form max-width-20"> <div class="gf-form max-width-20">
<label class="gf-form-label query-keyword width-7">Application</label> <label class="gf-form-label query-keyword width-7">Application</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].application.filter" ng-model="ctrl.panel.targets[ds].application.filter"
bs-typeahead="editor.getApplicationNames[ds]" bs-typeahead="editor.getApplicationNames[ds]"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
data-min-length=0 data-min-length=0
data-items=100 data-items=100
class="gf-form-input" class="gf-form-input"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].application.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].application.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].application.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].application.filter)
}"> }">
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-7">Trigger</label> <label class="gf-form-label query-keyword width-7">Trigger</label>
<input type="text" <input type="text"
ng-model="editor.panel.targets[ds].trigger.filter" ng-model="ctrl.panel.targets[ds].trigger.filter"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
placeholder="trigger name" placeholder="trigger name"
class="gf-form-input" class="gf-form-input"
ng-style="editor.panel.targets[ds].trigger.style" ng-style="ctrl.panel.targets[ds].trigger.style"
ng-class="{ ng-class="{
'zbx-variable': editor.isVariable(editor.panel.targets[ds].trigger.filter), 'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].trigger.filter),
'zbx-regex': editor.isRegex(editor.panel.targets[ds].trigger.filter) 'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].trigger.filter)
}" }"
empty-to-null> empty-to-null>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-7">Tags</label> <label class="gf-form-label query-keyword width-7">Tags</label>
<input type="text" class="gf-form-input" <input type="text" class="gf-form-input"
ng-model="editor.panel.targets[ds].tags.filter" ng-model="ctrl.panel.targets[ds].tags.filter"
ng-blur="editor.parseTarget()" ng-blur="editor.parseTarget()"
placeholder="tag1:value1, tag2:value2"> placeholder="tag1:value1, tag2:value2">
</div> </div>

View File

@@ -72,7 +72,7 @@ class TriggersTabCtrl {
datasourcesChanged() { datasourcesChanged() {
_.each(this.panel.datasources, (ds) => { _.each(this.panel.datasources, (ds) => {
if (!this.panel.targets[ds]) { if (!this.panel.targets[ds]) {
this.panel.targets[ds] = DEFAULT_TARGET; this.panel.targets[ds] = _.cloneDeep(DEFAULT_TARGET);
} }
}); });
this.parseTarget(); this.parseTarget();