Commit 9f6c9cd6 by Torkel Ödegaard

fix(graphite): raw query mode (disable graphite query editor mode) is now…

fix(graphite): raw query mode (disable graphite query editor mode) is now persisted property on the query, Fixes #2328, Fixes #2307
parent ca1cd891
......@@ -12,7 +12,7 @@
</a>
</li>
<li class="tight-form-item">
<a class="pointer" tabindex="1" ng-click="showTextEditor = !showTextEditor">
<a class="pointer" tabindex="1" ng-click="toggleEditorMode()">
<i class="fa fa-pencil"></i>
</a>
</li>
......@@ -65,15 +65,14 @@
</li>
</ul>
<input type="text"
class="tight-form-clear-input span10"
<input type="text" class="tight-form-clear-input span10"
ng-model="target.target"
focus-me="showTextEditor"
focus-me="target.textEditor"
spellcheck='false'
ng-model-onblur ng-change="targetTextChanged()"
ng-show="showTextEditor" />
ng-model-onblur ng-change="get_data()"
ng-show="target.textEditor" />
<ul class="tight-form-list" role="menu" ng-hide="showTextEditor">
<ul class="tight-form-list" role="menu" ng-hide="target.textEditor">
<li ng-repeat="segment in segments" role="menuitem">
<metric-segment segment="segment" get-alt-segments="getAltSegments($index)" on-value-changed="segmentValueChanged(segment, $index)"></metric-segment>
</li>
......
......@@ -20,15 +20,22 @@ function (angular, _, config, gfunc, Parser) {
parseTarget();
};
$scope.toggleEditorMode = function() {
$scope.target.textEditor = !$scope.target.textEditor;
parseTarget();
};
// The way parsing and the target editor works needs
// to be rewritten to handle functions that take multiple series
function parseTarget() {
$scope.functions = [];
$scope.segments = [];
$scope.showTextEditor = false;
delete $scope.parserError;
if ($scope.target.textEditor) {
return;
}
var parser = new Parser($scope.target.target);
var astNode = parser.getAst();
if (astNode === null) {
......@@ -38,7 +45,7 @@ function (angular, _, config, gfunc, Parser) {
if (astNode.type === 'error') {
$scope.parserError = astNode.message + " at position: " + astNode.pos;
$scope.showTextEditor = true;
$scope.target.textEditor = true;
return;
}
......@@ -48,7 +55,7 @@ function (angular, _, config, gfunc, Parser) {
catch (err) {
console.log('error parsing target:', err.message);
$scope.parserError = err.message;
$scope.showTextEditor = true;
$scope.target.textEditor = true;
}
checkOtherSegments($scope.segments.length - 1);
......
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