target editor is starting to work better, now switch between text edit mode and easy gui version
This commit is contained in:
1 parent
bb6068ac8c
commit
7cbd88f3d8
7 files changed
+47
-29
No files matched your search
@@ -13,22 +13,32 @@ function (angular, _, config, graphiteFunctions, Parser) {
|
||||
module.controller('GraphiteTargetCtrl', function($scope, $http) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.funcDefs = graphiteFunctions;
|
||||
parseTarget();
|
||||
console.log('init:');
|
||||
};
|
||||
|
||||
function parseTarget() {
|
||||
$scope.functions = [];
|
||||
$scope.segments = [];
|
||||
$scope.funcDefs = graphiteFunctions;
|
||||
$scope.showTextEditor = false;
|
||||
|
||||
delete $scope.parserError;
|
||||
|
||||
var parser = new Parser($scope.target.target);
|
||||
var astNode = parser.getAst();
|
||||
|
||||
console.log('GraphiteTargetCtrl:init -> target', $scope.target.target);
|
||||
console.log('GraphiteTargetCtrl:init -> ast', astNode);
|
||||
if (parser.error) {
|
||||
$scope.parserError = parser.error.text + " at position: " + parser.error.pos;
|
||||
$scope.showTextEditor = true;
|
||||
return;
|
||||
}
|
||||
|
||||
parseTargetExpression(astNode);
|
||||
parseTargeRecursive(astNode);
|
||||
checkOtherSegments($scope.segments.length);
|
||||
};
|
||||
}
|
||||
|
||||
function parseTargetExpression(astNode, func, index) {
|
||||
function parseTargeRecursive(astNode, func, index) {
|
||||
if (astNode === null) {
|
||||
return null;
|
||||
}
|
||||
@@ -36,10 +46,10 @@ function (angular, _, config, graphiteFunctions, Parser) {
|
||||
if (astNode.type === 'function') {
|
||||
var innerFunc = {};
|
||||
innerFunc.def = _.findWhere($scope.funcDefs, { name: astNode.name });
|
||||
innerFunc.params = innerFunc.def.defaultParams;
|
||||
innerFunc.params = innerFunc.def.defaultParams.slice(0);
|
||||
|
||||
_.each(astNode.params, function(param, index) {
|
||||
parseTargetExpression(param, innerFunc, index);
|
||||
parseTargeRecursive(param, innerFunc, index);
|
||||
});
|
||||
|
||||
innerFunc.text = getFuncText(innerFunc.def, innerFunc.params);
|
||||
@@ -168,10 +178,18 @@ function (angular, _, config, graphiteFunctions, Parser) {
|
||||
$scope.targetChanged();
|
||||
};
|
||||
|
||||
$scope.targetTextChanged = function() {
|
||||
parseTarget();
|
||||
$scope.$parent.get_data();
|
||||
};
|
||||
|
||||
$scope.targetChanged = function() {
|
||||
if ($scope.parserError) {
|
||||
return;
|
||||
}
|
||||
|
||||
var target = getSegmentPathUpTo($scope.segments.length);
|
||||
target = _.reduce($scope.functions, wrapFunction, target);
|
||||
console.log('target: ', target);
|
||||
$scope.target.target = target;
|
||||
$scope.$parent.get_data();
|
||||
};
|
||||
@@ -189,7 +207,7 @@ function (angular, _, config, graphiteFunctions, Parser) {
|
||||
$scope.addFunction = function(funcDef) {
|
||||
$scope.functions.push({
|
||||
def: funcDef,
|
||||
params: funcDef.defaultParams,
|
||||
params: funcDef.defaultParams.slice(0),
|
||||
text: getFuncText(funcDef, funcDef.defaultParams)
|
||||
});
|
||||
$scope.targetChanged();
|
||||
|
||||
@@ -34,11 +34,6 @@ function (angular) {
|
||||
'<span class="row-text">{{panel.type}}</span>'+
|
||||
'</span>' +
|
||||
|
||||
'<span class="row-button extra" ng-show="panel.editable != false">' +
|
||||
'<span bs-modal="\'app/partials/paneleditor.html\'" class="pointer" ng-click="openConfigureModal($event)" >'+
|
||||
'<i class="icon-cog pointer" bs-tooltip="\'Configure\'"></i></span>'+
|
||||
'</span>' +
|
||||
|
||||
'<span ng-repeat="task in panelMeta.modals" class="row-button extra" ng-show="task.show">' +
|
||||
'<span bs-modal="task.partial" class="pointer"><i ' +
|
||||
'bs-tooltip="task.description" ng-class="task.icon" class="pointer"></i></span>'+
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="grafana-target-inner">
|
||||
<ul class="grafana-target-controls">
|
||||
<li>
|
||||
<a class="pointer" tabindex="1" ng-click="showTextEditor = true">
|
||||
<a class="pointer" tabindex="1" ng-click="showTextEditor = !showTextEditor">
|
||||
<i class="icon-pencil"></i>
|
||||
</a>
|
||||
</li>
|
||||
@@ -22,19 +22,23 @@
|
||||
</ul>
|
||||
|
||||
<ul class="grafana-target-controls-left">
|
||||
<li>
|
||||
<li ng-hide="parserError">
|
||||
<a class="grafana-target-segment" ng-click="hideit()" role="menuitem">
|
||||
<i class="icon-eye-open"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li ng-show="parserError">
|
||||
<a class="grafana-target-segment" bs-tooltip="parserError" style="color: rgb(229, 189, 28)" ng-click="hideit()" role="menuitem">
|
||||
<i class="icon-warning-sign"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<input type="text"
|
||||
class="grafana-target-text-input"
|
||||
ng-model="target.target"
|
||||
focus-me="showTextEditor"
|
||||
ng-blur="showTextEditor = false"
|
||||
ng-model-onblur ng-change="targetChanged()"
|
||||
ng-model-onblur ng-change="targetTextChanged()"
|
||||
ng-show="showTextEditor" />
|
||||
|
||||
<ul class="grafana-segment-list" role="menu" ng-hide="showTextEditor">
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
<div ng-show="editorTabs[editor.index] == 'General'">
|
||||
<div ng-include src="'app/partials/panelgeneral.html'"></div>
|
||||
</div>
|
||||
<div ng-repeat="tab in panelMeta.editorTabs" ng-show="editorTabs[editor.index] == tab.title">
|
||||
<div ng-repeat="tab in panelMeta.fullEditorTabs" ng-show="editorTabs[editor.index] == tab.title">
|
||||
<div ng-include src="tab.src"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -46,7 +46,9 @@ function (angular, app, $, _, kbn, moment, timeSeries, graphiteSrv, RQ) {
|
||||
show: $scope.panel.spyable
|
||||
}
|
||||
],
|
||||
editorTabs : [
|
||||
editorTabs: [],
|
||||
|
||||
fullEditorTabs : [
|
||||
{
|
||||
title:'Targets',
|
||||
src:'app/panels/graphite/editor.html'
|
||||
@@ -433,10 +435,7 @@ function (angular, app, $, _, kbn, moment, timeSeries, graphiteSrv, RQ) {
|
||||
};
|
||||
|
||||
$scope.setEditorTabs = function(panelMeta) {
|
||||
$scope.editorTabs = ['General'];
|
||||
if(!_.isUndefined(panelMeta.editorTabs)) {
|
||||
$scope.editorTabs = _.union($scope.editorTabs,_.pluck(panelMeta.editorTabs,'title'));
|
||||
}
|
||||
$scope.editorTabs = _.union(['General'],_.pluck(panelMeta.fullEditorTabs,'title'));
|
||||
return $scope.editorTabs;
|
||||
};
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -6,4 +6,4 @@
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world by @mdo and @fat.
|
||||
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:31px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;width:auto\9;height:auto;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{text-shadow:none!important;color:#000!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:21px;color:#c8c8c8;background-color:#272b30}a{color:#fff;text-decoration:none}a:hover,a:focus{color:#fff;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-10px;*zoom:1}.row:before,.row:after{display:table;content:"";line-height:0}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:10px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:830px}.span12{width:830px}.span11{width:760px}.span10{width:690px}.span9{width:620px}.span8{width:550px}.span7{width:480px}.span6{width:410px}.span5{width:340px}.span4{width:270px}.span3{width:200px}.span2{width:130px}.span1{width:60px}.offset12{margin-left:850px}.offset11{margin-left:780px}.offset10{margin-left:710px}.offset9{margin-left:640px}.offset8{margin-left:570px}.offset7{margin-left:500px}.offset6{margin-left:430px}.offset5{margin-left:360px}.offset4{margin-left:290px}.offset3{margin-left:220px}.offset2{margin-left:150px}.offset1{margin-left:80px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:"";line-height:0}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;width:100%;min-height:31px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;float:left;margin-left:1.2048192771084338%;*margin-left:1.144578313253012%}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:1.2048192771084338%}.row-fluid .span12{width:100%;*width:99.93975903614458%}.row-fluid .span11{width:91.56626506024097%;*width:91.50602409638554%}.row-fluid .span10{width:83.13253012048192%;*width:83.0722891566265%}.row-fluid .span9{width:74.6987951807229%;*width:74.63855421686748%}.row-fluid .span8{width:66.26506024096385%;*width:66.20481927710843%}.row-fluid .span7{width:57.831325301204814%;*width:57.77108433734939%}.row-fluid .span6{width:49.39759036144578%;*width:49.33734939759036%}.row-fluid .span5{width:40.963855421686745%;*width:40.903614457831324%}.row-fluid .span4{width:32.53012048192771%;*width:32.46987951807229%}.row-fluid .span3{width:24.096385542168676%;*width:24.036144578313255%}.row-fluid .span2{width:15.662650602409638%;*width:15.60240Line truncated
|
||||
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:31px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;width:auto\9;height:auto;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{text-shadow:none!important;color:#000!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:21px;color:#c8c8c8;background-color:#272b30}a{color:#fff;text-decoration:none}a:hover,a:focus{color:#fff;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-10px;*zoom:1}.row:before,.row:after{display:table;content:"";line-height:0}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:10px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:830px}.span12{width:830px}.span11{width:760px}.span10{width:690px}.span9{width:620px}.span8{width:550px}.span7{width:480px}.span6{width:410px}.span5{width:340px}.span4{width:270px}.span3{width:200px}.span2{width:130px}.span1{width:60px}.offset12{margin-left:850px}.offset11{margin-left:780px}.offset10{margin-left:710px}.offset9{margin-left:640px}.offset8{margin-left:570px}.offset7{margin-left:500px}.offset6{margin-left:430px}.offset5{margin-left:360px}.offset4{margin-left:290px}.offset3{margin-left:220px}.offset2{margin-left:150px}.offset1{margin-left:80px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:"";line-height:0}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;width:100%;min-height:31px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;float:left;margin-left:1.2048192771084338%;*margin-left:1.144578313253012%}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:1.2048192771084338%}.row-fluid .span12{width:100%;*width:99.93975903614458%}.row-fluid .span11{width:91.56626506024097%;*width:91.50602409638554%}.row-fluid .span10{width:83.13253012048192%;*width:83.0722891566265%}.row-fluid .span9{width:74.6987951807229%;*width:74.63855421686748%}.row-fluid .span8{width:66.26506024096385%;*width:66.20481927710843%}.row-fluid .span7{width:57.831325301204814%;*width:57.77108433734939%}.row-fluid .span6{width:49.39759036144578%;*width:49.33734939759036%}.row-fluid .span5{width:40.963855421686745%;*width:40.903614457831324%}.row-fluid .span4{width:32.53012048192771%;*width:32.46987951807229%}.row-fluid .span3{width:24.096385542168676%;*width:24.036144578313255%}.row-fluid .span2{width:15.662650602409638%;*width:15.60240Line truncated
|
||||
+5
-3
@@ -182,12 +182,14 @@
|
||||
}
|
||||
|
||||
input[type=text].grafana-target-text-input {
|
||||
padding: 2px 6px;
|
||||
margin: 2px;
|
||||
padding: 5px 7px;
|
||||
border: 1px solid #050505;
|
||||
margin: 0px;
|
||||
background: transparent;
|
||||
width: 80%;
|
||||
float: left;
|
||||
border: none;
|
||||
color: #c8c8c8;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.grafana-target .dropdown {
|
||||
|
||||
Reference in new issue
Block a user