Просмотр исходного кода

Trying to restore broken features and some polishing

Torkel Ödegaard 11 лет назад
Родитель
Сommit
12e2bf2f85

+ 12 - 14
src/app/controllers/dashboardCtrl.js

@@ -48,28 +48,22 @@ function (angular, $, config, _) {
       $scope.dashboard = dashboardSrv.create(dashboardData);
       $scope.dashboardViewState = dashboardViewStateSrv.create($scope);
 
-      $scope.grafana.style = $scope.dashboard.style;
-
+      // init services
       timeSrv.init($scope.dashboard);
       templateValuesSrv.init($scope.dashboard);
+      panelMoveSrv.init($scope.dashboard, $scope);
 
-      $scope.submenuEnabled = $scope.dashboard.templating.enable || $scope.dashboard.annotations.enable;
-
-      var panelMove = panelMoveSrv.create($scope.dashboard);
-
-      $scope.panelMoveDrop = panelMove.onDrop;
-      $scope.panelMoveStart = panelMove.onStart;
-      $scope.panelMoveStop = panelMove.onStop;
-      $scope.panelMoveOver = panelMove.onOver;
-      $scope.panelMoveOut = panelMove.onOut;
-
-      window.document.title = config.window_title_prefix + $scope.dashboard.title;
-
+      $scope.checkFeatureToggles();
       dashboardKeybindings.shortcuts($scope);
 
       $scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
     };
 
+    $scope.setWindowTitleAndTheme = function() {
+      window.document.title = config.window_title_prefix + $scope.dashboard.title;
+      $scope.grafana.style = $scope.dashboard.style;
+    };
+
     $scope.isPanel = function(obj) {
       if(!_.isNull(obj) && !_.isUndefined(obj) && !_.isUndefined(obj.type)) {
         return true;
@@ -113,6 +107,10 @@ function (angular, $, config, _) {
       }
     };
 
+    $scope.checkFeatureToggles = function() {
+      $scope.submenuEnabled = $scope.dashboard.templating.enable || $scope.dashboard.annotations.enable;
+    };
+
     $scope.setEditorTabs = function(panelMeta) {
       $scope.editorTabs = ['General','Panel'];
       if(!_.isUndefined(panelMeta.editorTabs)) {

+ 22 - 12
src/app/partials/annotations_editor.html

@@ -14,20 +14,30 @@
 	</div>
 
 	<div class="dashboard-editor-body">
-		<div class="editor-row" ng-if="editor.index == 0">
-			<table class="table table-striped annotation-editor-table" style="width: 700px">
-				<tr ng-repeat="annotation in annotations">
-					<td style="width:90%">
-						<a ng-click="edit(annotation)" bs-tooltip="'Click to edit'" data-placement="right">
+		<div class="editor-row row" ng-if="editor.index == 0">
+			<div class="span6">
+				<table class="grafana-options-table">
+					<tr ng-repeat="annotation in annotations">
+						<td style="width:90%">
 							<i class="icon-bolt"></i>
 							{{annotation.name}}
-						</a>
-					</td>
-					<td><i ng-click="_.move(annotations,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
-					<td><i ng-click="_.move(annotations,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
-					<td><i ng-click="removeAnnotation(annotation)" class="pointer icon-remove"></i></td>
-				</tr>
-			</table>
+						</td>
+						<td style="width: 1%">
+							<a ng-click="edit(annotation)" class="btn btn-success btn-mini">
+								<i class="icon-edit"></i>
+								Edit
+							</a>
+						</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%">
+							<a ng-click="removeVariable(variable)" class="btn btn-danger btn-mini">
+								<i class="icon-remove"></i>
+							</a>
+						</td>
+					</tr>
+				</table>
+			</div>
 		</div>
 
 		<div ng-if="editor.index == 1 || (editor.index == 2 && !currentIsNew)">

+ 17 - 8
src/app/partials/dasheditor.html

@@ -49,14 +49,19 @@
 
 		<div ng-if="editor.index == 1">
 			<div class="editor-row">
-				<div class="span8">
-					<h5>Rows</h5>
-					<table class="table table-striped">
+				<div class="span6">
+					<table class="grafana-options-table">
 						<tr ng-repeat="row in dashboard.rows">
+							<td style="width: 97%">
+								{{row.title}}
+							</td>
 							<td><i ng-click="_.move(dashboard.rows,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
 							<td><i ng-click="_.move(dashboard.rows,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
-							<td><i ng-click="dashboard.rows = _.without(dashboard.rows,row)" class="pointer icon-remove"></i></td>
-							<td style="width: 97%">{{row.title}}</td>
+							<td>
+								<a ng-click="dashboard.rows = _.without(dashboard.rows,row)" class="btn btn-danger btn-mini">
+									<i class="icon-remove"></i>
+								</a>
+							</td>
 						</tr>
 					</table>
 				</div>
@@ -66,9 +71,13 @@
 		<div ng-if="editor.index == 2">
 			<div class="editor-row">
 				<div class="section">
-					<h5>Feature toggles</h5>
-					<div class="editor-option" ng-repeat="pulldown in dashboard.pulldowns">
-						<label class="small" style="text-transform:capitalize;">{{pulldown.type}}</label><input type="checkbox" ng-model="pulldown.enable" ng-checked="pulldown.enable">
+					<div class="editor-option">
+						<label class="small">Templating</label>
+						<input type="checkbox" ng-model="dashboard.templating.enable" ng-checked="dashboard.templating.enable" ng-change="checkFeatureToggles()"x >
+					</div>
+					<div class="editor-option">
+						<label class="small">Annotations</label>
+						<input type="checkbox" ng-model="dashboard.annotations.enable" ng-checked="dashboard.annotations.enable" ng-change="checkFeatureToggles()">
 					</div>
 					<div class="editor-option" ng-repeat="pulldown in dashboard.nav">
 						<label class="small" style="text-transform:capitalize;">{{pulldown.type}}</label><input type="checkbox" ng-model="pulldown.enable" ng-checked="pulldown.enable">

+ 3 - 2
src/app/partials/submenu.html

@@ -17,7 +17,7 @@
 						</li>
 					</ul>
 
-					<ul class="grafana-segment-list">
+					<ul class="grafana-segment-list" ng-if="dashboard.templating.enable">
 						<li class="small grafana-target-segment">
 							<strong>VARIABLES</strong>
 						</li>
@@ -27,7 +27,9 @@
 
 						<li ng-repeat-end template-param-selector>
 						</li>
+					</ul>
 
+					<ul class="grafana-segment-list" ng-if="dashboard.annotations.enable">
 						<li class="small grafana-target-segment">
 							<strong>ANNOTATIONS</strong>
 						</li>
@@ -38,7 +40,6 @@
 								{{annotation.name}}
 							</a>
 						</li>
-
 					</ul>
 
 					<div class="clearfix"></div>

+ 2 - 0
src/app/partials/templating_editor.html

@@ -34,6 +34,8 @@
 									Edit
 								</a>
 							</td>
+							<td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
+							<td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
 							<td style="width: 1%">
 								<a ng-click="removeVariable(variable)" class="btn btn-danger btn-mini">
 									<i class="icon-remove"></i>

+ 8 - 2
src/app/services/panelMove.js

@@ -69,8 +69,14 @@ function (angular, _) {
     };
 
     return {
-      create: function(dashboard) {
-        return new PanelMoveSrv(dashboard);
+      init: function(dashboard, scope) {
+        var panelMove = new PanelMoveSrv(dashboard);
+
+        scope.panelMoveDrop = panelMove.onDrop;
+        scope.panelMoveStart = panelMove.onStart;
+        scope.panelMoveStop = panelMove.onStop;
+        scope.panelMoveOver = panelMove.onOver;
+        scope.panelMoveOut = panelMove.onOut;
       }
     };
 

+ 1 - 4
src/app/services/templateSrv.js

@@ -1,16 +1,13 @@
 define([
   'angular',
   'lodash',
-  'kbn',
-  'config'
 ],
-function (angular, _, kbn, config) {
+function (angular, _) {
   'use strict';
 
   var module = angular.module('grafana.services');
 
   module.service('templateSrv', function($q, $routeParams) {
-    var self = this;
 
     this.init = function(variables) {
       this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };