Commit 0b03ca15 by Torkel Ödegaard

final touches to aliasByNode automatic stuff

parent d9e6fcd7
......@@ -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;
}
}
};
......
<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>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment