Skip to content

Commit

Permalink
fix(graphite): raw query mode (disable graphite query editor mode) is…
Browse files Browse the repository at this point in the history
… now persisted property on the query, Fixes grafana#2328, Fixes grafana#2307
  • Loading branch information
torkelo committed Jul 12, 2015
1 parent ca1cd89 commit 9f6c9cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
15 changes: 11 additions & 4 deletions public/app/plugins/datasource/graphite/queryCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit 9f6c9cd

Please sign in to comment.