iss #71 - Added text metrics editor.

This commit is contained in:
Alexander Zobnin
2015-08-18 20:39:01 +03:00
parent 5961978828
commit 9ec32b26e8
3 changed files with 50 additions and 33 deletions

View File

@@ -94,7 +94,7 @@ function (angular, _, kbn) {
// Create request for each target
var promises = _.map(options.targets, function(target) {
if (!target.ITService) {
if (!target.mode || target.mode === 0) {
// Don't show undefined and hidden targets
if (target.hide || !target.group || !target.host
|| !target.application || !target.item) {
@@ -199,7 +199,10 @@ function (angular, _, kbn) {
});
}
});
} else {
}
// IT services mode
else if (target.mode === 1) {
// Don't show undefined and hidden targets
if (target.hide || !target.itservice || !target.slaProperty) {
return [];
@@ -208,6 +211,11 @@ function (angular, _, kbn) {
.then(_.bind(zabbixHelperSrv.handleSLAResponse, zabbixHelperSrv, target.itservice, target.slaProperty));
}
}
// Text metrics mode
else if (target.mode === 2) {
return [];
}
}, this);
return $q.all(_.flatten(promises)).then(function (results) {

View File

@@ -16,14 +16,18 @@
<i class="fa fa-bars"></i>
</a>
<ul class="dropdown-menu pull-right" role="menu">
<!-- Switch to IT Services editor -->
<li role="menuitem" ng-hide="target.mode == 1">
<!-- Switch editor mode -->
<li role="menuitem" ng-show="target.mode">
<a class="pointer" tabindex="1"
ng-click="switchEditorMode(0)">Numeric metrics</a>
</li>
<li role="menuitem" ng-show="target.mode != 1">
<a class="pointer" tabindex="1"
ng-click="switchEditorMode(1)">IT services</a>
</li>
<li role="menuitem" ng-show="target.mode">
<li role="menuitem" ng-show="target.mode != 2">
<a class="pointer" tabindex="1"
ng-click="switchEditorMode(0)">Items</a>
ng-click="switchEditorMode(2)">Text metrics</a>
</li>
<li class="divider" role="menuitem"></li>
<li role="menuitem"><a tabindex="1" ng-click="duplicate()">Duplicate</a></li>
@@ -75,7 +79,7 @@
</li>
</ul>
<ul class="tight-form-list" role="menu" ng-hide="target.mode">
<ul class="tight-form-list" role="menu" ng-hide="target.mode == 1">
<!-- Alias -->
<li>
<input type="text"
@@ -118,12 +122,12 @@
</a>
</li>
<!-- Host filter -->
<li class="tight-form-item">
<li class="tight-form-item" ng-hide="target.mode == 2">
Filter
<i class="fa fa-question-circle"
bs-tooltip="'Filtering hosts by regex. Select All in items and specify regex for host names.'"></i>
</li>
<li>
<li ng-hide="target.mode == 2">
<input type="text"
class="tight-form-input input-large"
ng-model="target.hostFilter"
@@ -132,8 +136,10 @@
ng-blur="targetBlur()">
</li>
<!-- Downsampling function -->
<li class="tight-form-item input-medium">Downsampling</li>
<li>
<li class="tight-form-item input-medium" ng-hide="target.mode == 2">
Downsampling
</li>
<li ng-hide="target.mode == 2">
<select class="tight-form-input input-small"
ng-change="targetBlur()"
ng-model="target.downsampleFunction"
@@ -151,7 +157,7 @@
<div class="clearfix"></div>
</div>
<div class="tight-form" ng-hide="target.mode">
<div class="tight-form" ng-hide="target.mode == 1">
<ul class="tight-form-list" role="menu">
<li class="tight-form-item" style="min-width: 15px; text-align: center">&nbsp</li>
<li class="tight-form-item">
@@ -192,12 +198,12 @@
</a>
</li>
<!-- Item filter -->
<li class="tight-form-item">
<li class="tight-form-item" ng-hide="target.mode == 2">
Filter
<i class="fa fa-question-circle"
bs-tooltip="'Filtering items by regex. Select All in items and specify regex for item names.'"></i>
</li>
<li>
<li ng-hide="target.mode == 2">
<input type="text"
class="tight-form-input input-large"
ng-model="target.itemFilter"
@@ -206,12 +212,12 @@
ng-blur="targetBlur()">
</li>
<!-- Scale -->
<li class="tight-form-item">
<li class="tight-form-item" ng-hide="target.mode == 2">
Scale
<i class="fa fa-question-circle"
bs-tooltip="'Set a custom multiplier for series values, for example -1 to invert series'"></i>
</li>
<li>
<li ng-hide="target.mode == 2">
<input type="text"
class="tight-form-input input-small"
ng-model="target.scale"

View File

@@ -13,17 +13,7 @@ define([
$scope.init = function () {
$scope.targetLetters = targetLetters;
if ($scope.target.mode === 1) {
$scope.slaPropertyList = [
{name: "Status", property: "status"},
{name: "SLA", property: "sla"},
{name: "OK time", property: "okTime"},
{name: "Problem time", property: "problemTime"},
{name: "Down time", property: "downtimeTime"}
];
$scope.itserviceList = [{name: "test"}];
$scope.updateITServiceList();
} else {
if (!$scope.target.mode || $scope.target.mode === 0) {
$scope.downsampleFunctionList = [
{name: "avg", value: "avg"},
{name: "min", value: "min"},
@@ -34,12 +24,14 @@ define([
if (!$scope.target.downsampleFunction) {
$scope.target.downsampleFunction = $scope.downsampleFunctionList[0];
}
$scope.metric = {
hostGroupList: [],
hostList: [{name: '*', visible_name: 'All'}],
applicationList: [{name: '*', visible_name: 'All'}],
itemList: [{name: 'All'}]
};
if (!$scope.metric) {
$scope.metric = {
hostGroupList: [],
hostList: [{name: '*', visible_name: 'All'}],
applicationList: [{name: '*', visible_name: 'All'}],
itemList: [{name: 'All'}]
};
}
// Update host group, host, application and item lists
$scope.updateGroupList();
@@ -49,6 +41,17 @@ define([
setItemAlias();
}
else if ($scope.target.mode === 1) {
$scope.slaPropertyList = [
{name: "Status", property: "status"},
{name: "SLA", property: "sla"},
{name: "OK time", property: "okTime"},
{name: "Problem time", property: "problemTime"},
{name: "Down time", property: "downtimeTime"}
];
$scope.itserviceList = [{name: "test"}];
$scope.updateITServiceList();
}
$scope.target.errors = validateTarget($scope.target);
};