Zabbix plugin refactor.
This commit is contained in:
@@ -89,7 +89,6 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
ng-model="ctrl.target.group.filter"
|
ng-model="ctrl.target.group.filter"
|
||||||
bs-typeahead="ctrl.getGroupNames"
|
bs-typeahead="ctrl.getGroupNames"
|
||||||
ng-change="ctrl.onTargetPartChange(ctrl.target.group)"
|
|
||||||
ng-blur="ctrl.onTargetBlur()"
|
ng-blur="ctrl.onTargetBlur()"
|
||||||
data-min-length=0
|
data-min-length=0
|
||||||
data-items=100
|
data-items=100
|
||||||
@@ -106,7 +105,6 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
ng-model="ctrl.target.host.filter"
|
ng-model="ctrl.target.host.filter"
|
||||||
bs-typeahead="ctrl.getHostNames"
|
bs-typeahead="ctrl.getHostNames"
|
||||||
ng-change="ctrl.onTargetPartChange(ctrl.target.host)"
|
|
||||||
ng-blur="ctrl.onTargetBlur()"
|
ng-blur="ctrl.onTargetBlur()"
|
||||||
data-min-length=0
|
data-min-length=0
|
||||||
data-items=100
|
data-items=100
|
||||||
@@ -123,26 +121,7 @@
|
|||||||
change="ctrl.onTargetBlur()">
|
change="ctrl.onTargetBlur()">
|
||||||
</editor-checkbox>
|
</editor-checkbox>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<!-- Downsampling function -->
|
|
||||||
<!-- <li class="tight-form-item input-medium" ng-hide="ctrl.target.mode == 2">
|
|
||||||
Downsampling
|
|
||||||
</li>
|
|
||||||
<li ng-hide="ctrl.target.mode == 2">
|
|
||||||
<select class="tight-form-input input-small"
|
|
||||||
ng-change="ctrl.targetBlur()"
|
|
||||||
ng-model="ctrl.target.downsampleFunction"
|
|
||||||
bs-tooltip="'Downsampling function'"
|
|
||||||
ng-options="func.name for func in downsampleFunctionList track by func.name">
|
|
||||||
</select>
|
|
||||||
<a bs-tooltip="ctrl.target.errors.metric"
|
|
||||||
style="color: rgb(229, 189, 28)"
|
|
||||||
ng-show="ctrl.target.errors.metric">
|
|
||||||
<i class="icon-warning-sign"></i>
|
|
||||||
</a>
|
|
||||||
</li> -->
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -156,7 +135,6 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
ng-model="ctrl.target.application.filter"
|
ng-model="ctrl.target.application.filter"
|
||||||
bs-typeahead="ctrl.getApplicationNames"
|
bs-typeahead="ctrl.getApplicationNames"
|
||||||
ng-change="ctrl.onTargetPartChange(ctrl.target.application)"
|
|
||||||
ng-blur="ctrl.onTargetBlur()"
|
ng-blur="ctrl.onTargetBlur()"
|
||||||
data-min-length=0
|
data-min-length=0
|
||||||
data-items=100
|
data-items=100
|
||||||
@@ -173,7 +151,6 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
ng-model="ctrl.target.item.filter"
|
ng-model="ctrl.target.item.filter"
|
||||||
bs-typeahead="ctrl.getItemNames"
|
bs-typeahead="ctrl.getItemNames"
|
||||||
ng-change="ctrl.onTargetPartChange(ctrl.target.item)"
|
|
||||||
ng-blur="ctrl.onTargetBlur()"
|
ng-blur="ctrl.onTargetBlur()"
|
||||||
data-min-length=0
|
data-min-length=0
|
||||||
data-items=100
|
data-items=100
|
||||||
|
|||||||
@@ -178,26 +178,12 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onTargetPartChange(targetPart) {
|
|
||||||
/*var regexStyle = {'color': '#CCA300'};
|
|
||||||
targetPart.isRegex = utils.isRegex(targetPart.filter);
|
|
||||||
targetPart.style = targetPart.isRegex ? regexStyle : {};*/
|
|
||||||
}
|
|
||||||
|
|
||||||
isRegex(str) {
|
isRegex(str) {
|
||||||
return utils.isRegex(str);
|
return utils.isRegex(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
isVariable(str) {
|
isVariable(str) {
|
||||||
var variablePattern = /^\$\w+/;
|
return utils.isTemplateVariable(str, this.templateSrv.variables);
|
||||||
if (variablePattern.test(str)) {
|
|
||||||
var variables = _.map(this.templateSrv.variables, variable => {
|
|
||||||
return '$' + variable.name;
|
|
||||||
});
|
|
||||||
return _.contains(variables, str);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTargetBlur() {
|
onTargetBlur() {
|
||||||
|
|||||||
@@ -29,6 +29,18 @@ export function isRegex(str) {
|
|||||||
return regexPattern.test(str);
|
return regexPattern.test(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isTemplateVariable(str, templateVariables) {
|
||||||
|
var variablePattern = /^\$\w+/;
|
||||||
|
if (variablePattern.test(str)) {
|
||||||
|
var variables = _.map(templateVariables, variable => {
|
||||||
|
return '$' + variable.name;
|
||||||
|
});
|
||||||
|
return _.contains(variables, str);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function buildRegex(str) {
|
export function buildRegex(str) {
|
||||||
var matches = str.match(regexPattern);
|
var matches = str.match(regexPattern);
|
||||||
var pattern = matches[1];
|
var pattern = matches[1];
|
||||||
|
|||||||
@@ -141,15 +141,7 @@ class TriggerPanelEditorCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isVariable(str) {
|
isVariable(str) {
|
||||||
var variablePattern = /^\$\w+/;
|
return utils.isTemplateVariable(str, this.templateSrv.variables);
|
||||||
if (variablePattern.test(str)) {
|
|
||||||
var variables = _.map(this.templateSrv.variables, variable => {
|
|
||||||
return '$' + variable.name;
|
|
||||||
});
|
|
||||||
return _.contains(variables, str);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user