Problems: fix proxy filter

This commit is contained in:
Alexander Zobnin
2020-05-08 17:09:18 +03:00
parent 0916f2eff7
commit 29acf951b2
2 changed files with 34 additions and 3 deletions

View File

@@ -86,6 +86,21 @@
}"> }">
</div> </div>
<div class="gf-form" ng-show="ctrl.target.queryType == editorMode.PROBLEMS">
<label class="gf-form-label query-keyword width-7">Proxy</label>
<input type="text"
ng-model="ctrl.target.proxy.filter"
bs-typeahead="ctrl.getProxyNames"
ng-blur="ctrl.onTargetBlur()"
data-min-length=0
data-items=100
class="gf-form-input width-14"
ng-class="{
'zbx-variable': ctrl.isVariable(ctrl.target.proxy.filter),
'zbx-regex': ctrl.isRegex(ctrl.target.proxy.filter)
}">
</div>
<div class="gf-form gf-form--grow"> <div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div> <div class="gf-form-label gf-form-label--grow"></div>
</div> </div>

View File

@@ -106,6 +106,7 @@ export class ZabbixQueryController extends QueryCtrl {
this.getApplicationNames = _.bind(this.getMetricNames, this, 'appList'); this.getApplicationNames = _.bind(this.getMetricNames, this, 'appList');
this.getItemNames = _.bind(this.getMetricNames, this, 'itemList'); this.getItemNames = _.bind(this.getMetricNames, this, 'itemList');
this.getITServices = _.bind(this.getMetricNames, this, 'itServiceList'); this.getITServices = _.bind(this.getMetricNames, this, 'itServiceList');
this.getProxyNames = _.bind(this.getMetricNames, this, 'proxyList');
this.getVariables = _.bind(this.getTemplateVariables, this); this.getVariables = _.bind(this.getTemplateVariables, this);
// Update metric suggestion when template variable was changed // Update metric suggestion when template variable was changed
@@ -161,12 +162,18 @@ export class ZabbixQueryController extends QueryCtrl {
initFilters() { initFilters() {
let itemtype = _.find(this.editorModes, {'queryType': this.target.queryType}); let itemtype = _.find(this.editorModes, {'queryType': this.target.queryType});
itemtype = itemtype ? itemtype.value : null; itemtype = itemtype ? itemtype.value : null;
return Promise.all([ const promises = [
this.suggestGroups(), this.suggestGroups(),
this.suggestHosts(), this.suggestHosts(),
this.suggestApps(), this.suggestApps(),
this.suggestItems(itemtype) this.suggestItems(itemtype),
]); ];
if (this.target.queryType === c.MODE_PROBLEMS) {
promises.push(this.suggestProxies());
}
return Promise.all(promises);
} }
// Get list of metric names for bs-typeahead directive // Get list of metric names for bs-typeahead directive
@@ -243,6 +250,15 @@ export class ZabbixQueryController extends QueryCtrl {
}); });
} }
suggestProxies() {
return this.zabbix.getProxies()
.then(response => {
const proxies = _.map(response, 'host');
this.metric.proxyList = proxies;
return proxies;
});
}
isRegex(str) { isRegex(str) {
return utils.isRegex(str); return utils.isRegex(str);
} }