Commit f9b0ce0f by Torkel Ödegaard

Fixes to annotations editor

parent 20607c00
...@@ -20,15 +20,10 @@ function (angular, _, $) { ...@@ -20,15 +20,10 @@ function (angular, _, $) {
}; };
$scope.init = function() { $scope.init = function() {
$scope.currentAnnotation = angular.copy(annotationDefaults);
$scope.currentIsNew = true;
$scope.editor = { index: 0 }; $scope.editor = { index: 0 };
$scope.datasources = datasourceSrv.getAnnotationSources(); $scope.datasources = datasourceSrv.getAnnotationSources();
$scope.annotations = $scope.dashboard.annotations.list; $scope.annotations = $scope.dashboard.annotations.list;
$scope.reset();
if ($scope.datasources.length > 0) {
$scope.currentDatasource = $scope.datasources[0];
}
$scope.$watch('editor.index', function(newVal) { $scope.$watch('editor.index', function(newVal) {
if (newVal !== 2) { if (newVal !== 2) {
...@@ -37,18 +32,17 @@ function (angular, _, $) { ...@@ -37,18 +32,17 @@ function (angular, _, $) {
}); });
}; };
$scope.setDatasource = function() { $scope.datasourceChanged = function() {
$scope.currentAnnotation.datasource = $scope.currentDatasource.name; $scope.currentDatasource = _.findWhere($scope.datasources, { name: $scope.currentAnnotation.datasource });
if (!$scope.currentDatasource) {
$scope.currentDatasource = $scope.datasources[0];
}
}; };
$scope.edit = function(annotation) { $scope.edit = function(annotation) {
$scope.currentAnnotation = annotation; $scope.currentAnnotation = annotation;
$scope.currentIsNew = false; $scope.currentIsNew = false;
$scope.currentDatasource = _.findWhere($scope.datasources, { name: annotation.datasource }); $scope.datasourceChanged();
if (!$scope.currentDatasource) {
$scope.currentDatasource = $scope.datasources[0];
}
$scope.editor.index = 2; $scope.editor.index = 2;
$(".tooltip.in").remove(); $(".tooltip.in").remove();
...@@ -57,6 +51,13 @@ function (angular, _, $) { ...@@ -57,6 +51,13 @@ function (angular, _, $) {
$scope.reset = function() { $scope.reset = function() {
$scope.currentAnnotation = angular.copy(annotationDefaults); $scope.currentAnnotation = angular.copy(annotationDefaults);
$scope.currentIsNew = true; $scope.currentIsNew = true;
$scope.datasourceChanged();
$scope.currentAnnotation.datasource = $scope.currentDatasource.name;
};
$scope.update = function() {
$scope.reset();
$scope.editor.index = 0;
}; };
$scope.add = function() { $scope.add = function() {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<table class="grafana-options-table"> <table class="grafana-options-table">
<tr ng-repeat="annotation in annotations"> <tr ng-repeat="annotation in annotations">
<td style="width:90%"> <td style="width:90%">
<i class="icon-bolt"></i> <i class="icon-bolt"></i> &nbsp;
{{annotation.name}} {{annotation.name}}
</td> </td>
<td style="width: 1%"> <td style="width: 1%">
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<td style="width: 1%"><i ng-click="_.move(annotations,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td> <td style="width: 1%"><i ng-click="_.move(annotations,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
<td style="width: 1%"><i ng-click="_.move(annotations,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td> <td style="width: 1%"><i ng-click="_.move(annotations,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
<td style="width: 1%"> <td style="width: 1%">
<a ng-click="removeVariable(variable)" class="btn btn-danger btn-mini"> <a ng-click="removeAnnotation(annotation)" class="btn btn-danger btn-mini">
<i class="icon-remove"></i> <i class="icon-remove"></i>
</a> </a>
</td> </td>
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Datasource</label> <label class="small">Datasource</label>
<select ng-model="currentDatasource" ng-options="f.name for f in datasources" ng-change="setDatasource()"></select> <select ng-model="currentAnnotation.datasource" ng-options="f.name as f.name for f in datasources" ng-change="datasourceChanged()"></select>
</div> </div>
<div class="editor-option"> <div class="editor-option">
<label class="small">Icon color</label> <label class="small">Icon color</label>
...@@ -71,11 +71,12 @@ ...@@ -71,11 +71,12 @@
<div ng-include src="currentDatasource.editorSrc"> <div ng-include src="currentDatasource.editorSrc">
</div> </div>
<button ng-show="currentIsNew" type="button" class="btn btn-success" ng-click="add()">Add annotation</button>
</div> </div>
</div> </div>
<div class="dashboard-editor-footer"> <div class="dashboard-editor-footer">
<button ng-show="editor.index === 1" type="button" class="btn btn-success" ng-click="add()">Add</button>
<button ng-show="editor.index === 2" type="button" class="btn btn-success pull-left" ng-click="update();">Update</button>
<button type="button" class="btn btn-success pull-right" ng-click="close_edit();dismiss();dashboard.refresh();">Close</button> <button type="button" class="btn btn-success pull-right" ng-click="close_edit();dismiss();dashboard.refresh();">Close</button>
</div> </div>
</div> </div>
...@@ -29,29 +29,32 @@ ...@@ -29,29 +29,32 @@
</div> </div>
<div class="row-fluid" ng-if="editor.index == 1"> <div class="row-fluid" ng-if="editor.index == 1">
<div class="span12"> <div class="span12">
<h4>Panels</h4> <table class="grafana-options-table" style="max-width: 400px; width: auto">
<table class="table table-condensed table-striped">
<thead> <thead>
<th>Title</th> <th>Title</th>
<th>Type</th> <th>Type</th>
<th>Span <span class="small">({{dashboard.rowSpan(row)}}/12)</span></th> <th>Span</span></th>
<th>Delete</th>
<th>Move</th>
<th></th> <th></th>
<th></th>
<th></th>
</thead> </thead>
<tr ng-repeat="panel in row.panels"> <tr ng-repeat="panel in row.panels">
<td>{{panel.title}}</td> <td style="width: 95%">{{panel.title}}</td>
<td>{{panel.type}}</td> <td>{{panel.type}}</td>
<td><select ng-hide="panel.sizeable == false" class="input-mini" ng-model="panel.span" ng-options="size for size in [1,2,3,4,5,6,7,8,9,10,11,12]"></select></td> <td><select ng-hide="panel.sizeable == false" class="input-mini" style="margin-bottom: 0;" ng-model="panel.span" ng-options="size for size in [1,2,3,4,5,6,7,8,9,10,11,12]"></select></td>
<td><i ng-click="row.panels = _.without(row.panels,panel)" class="pointer icon-remove"></i></td> <td><i ng-click="_.move(row.panels,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
<td><i ng-click="_.move(row.panels,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td> <td><i ng-click="_.move(row.panels,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
<td><i ng-click="_.move(row.panels,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td> <td>
</tr> <a ng-click="row.panels = _.without(row.panels,panel)" class="btn btn-danger btn-mini">
</table> <i class="icon-remove"></i>
</div> </a>
</div> </td>
</tr>
</table>
</div>
</div>
</div> </div>
<div class="dashboard-editor-footer"> <div class="dashboard-editor-footer">
<button type="button" class="btn btn-success pull-right" ng-click="editor.index=0;dismiss();reset_panel();close_edit()">Close</button> <button type="button" class="btn btn-success pull-right" ng-click="editor.index=0;dismiss();reset_panel();close_edit()">Close</button>
</div> </div>
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