final touches to aliasByNode automatic stuff

This commit is contained in:
Torkel Ödegaard 2014-03-07 15:07:02 +01:00
parent d9e6fcd730
commit 0b03ca158b
5 changed files with 26 additions and 78 deletions

View File

@ -227,17 +227,38 @@ function (angular, _, config, gfunc, Parser) {
newFunc.added = true;
$scope.functions.push(newFunc);
$scope.moveAliasFuncLast();
$scope.smartlyHandleNewAliasByNode(newFunc);
if (!funcDef.params && newFunc.added) {
$scope.targetChanged();
}
};
$scope.moveAliasFuncLast = function() {
var aliasFunc = _.find($scope.functions, function(func) {
return func.def.name === 'alias';
return func.def.name === 'alias' ||
func.def.name === 'aliasByNode' ||
func.def.name === 'aliasByMetric';
});
if (aliasFunc) {
$scope.functions = _.without($scope.functions, aliasFunc);
$scope.functions.push(aliasFunc);
}
};
if (!funcDef.params) {
$scope.targetChanged();
$scope.smartlyHandleNewAliasByNode = function(func) {
if (func.def.name !== 'aliasByNode') {
return;
}
for(var i = 0; i < $scope.segments.length; i++) {
if ($scope.segments[i].val.indexOf('*') >= 0) {
func.params[0] = i;
func.added = false;
$scope.targetChanged();
return;
}
}
};

View File

@ -1,51 +0,0 @@
<div class="grafana-func-editor">
<div class="grafana-func-editor-header">
<a ng-click="removeFunction(func)">
Remove
</a>
&nbsp;&nbsp;
<a ng-click="helpFunction(func)">
Help
</a>
&nbsp;&nbsp;
<a class="close" ng-click="dismiss();" href="">×</a>
</div>
<div class="editor-row" ng-if="func.def.params.length">
<div class="section">
<div class="editor-option" ng-repeat="param in func.def.params">
<label class="small">{{param.name}}</label>
<div ng-switch on="param.type">
<div ng-switch-when="int">
<input
type="number"
step="any"
focus-me="true"
class="input-mini"
ng-change="functionParamsChanged(func)" ng-model-onblur
ng-model="func.params[$index]" />
</div>
<div ng-switch-when="string">
<input
type="text"
focus-me="true"
class="input-small"
ng-change="functionParamsChanged(func)" ng-model-onblur
ng-model="func.params[$index]" />
</div>
<div ng-switch-when="select">
<select
class="input-mini"
ng-model="func.params[$index]"
ng-change="functionParamsChanged(func)"
focus-me="true"
ng-options="f for f in param.options">
</select>
</div>
</div>
</div>
</div>
</div>
</div>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -383,34 +383,12 @@ select.grafana-target-segment-input {
}
}
input[type=text].func-param {
border: none;
background: inherit;
width: 30px;
border-radius: none;
padding: 0;
margin: 0;
}
.grafana-target {
.popover-content {
padding: 0;
}
}
.grafana-func-editor {
min-width: 140px;
.grafana-func-editor-header {
background: @grafanaTargetFuncHightlight;
text-align: center;
border-bottom: 1px solid @grafanaTargetFuncBackground;
padding: 3px 5px;
white-space: nowrap;
}
.editor-row {
padding: 5px;
}
}
.scrollable {
max-height: 300px;