Преглед на файлове

Merge branch 'master' into valuepanel

Torkel Ödegaard преди 11 години
родител
ревизия
bbbcba8b98

+ 0 - 84
'

@@ -1,84 +0,0 @@
-/* global _ */
-
-/*
- * Complex scripted dashboard
- * This script generates a dashboard object that Grafana can load. It also takes a number of user
- * supplied URL parameters (int ARGS variable)
- *
- * Return a dashboard object, or a function
- *
- * For async scripts, return a function, this function must take a single callback function as argument,
- * call this callback function with the dashboard object (look at scripted_async.js for an example)
- */
-
-'use strict';
-
-// accessable variables in this scope
-var window, document, ARGS, $, jQuery, moment, kbn, services, _;
-
-// default datasource
-var datasource = services.datasourceSrv.default;
-// get datasource used for saving dashboards
-var dashboardDB = services.datasourceSrv.getGrafanaDB();
-
-var targets = [];
-
-function getTargets(path) {
-  return datasource.metricFindQuery(path + '.*').then(function(result) {
-    if (!result) {
-      return null;
-    }
-
-    if (targets.length === 10) {
-      return null;
-    }
-
-    var promises = _.map(result, function(metric) {
-      if (metric.expandable) {
-        return getTargets(path + "." + metric.text);
-      }
-      else {
-        targets.push(path + '.' + metric.text);
-      }
-      return null;
-    });
-
-    return services.$q.when(promises);
-  });
-}
-
-function createDashboard(target, index) {
-  // Intialize a skeleton with nothing but a rows array and service object
-  var dashboard = { rows : [] };
-  dashboard.title = 'Scripted dash ' + index;
-  dashboard.time = {
-    from: "now-6h",
-    to: "now"
-  };
-
-  dashboard.rows.push({
-    title: 'Chart',
-    height: '300px',
-    panels: [
-    {
-      title: 'Events',
-      type: 'graph',
-      span: 12,
-      targets: [ {target: target} ]
-    }
-  ]
-  });
-
-}
-
-return function(callback)  {
-
-  getTargets('apps').then(function(results) {
-    console.log('targets: ', targets);
-    _.each(targets, function(target, index) {
-      var dashboard = createDashboard(target);
-    });
-  });
-
-};
-

+ 3 - 0
CHANGELOG.md

@@ -13,6 +13,9 @@
 - [Issue #952](https://github.com/grafana/grafana/issues/952). Help: Shortcut "?" to open help modal with list of all shortcuts
 - [Issue #991](https://github.com/grafana/grafana/issues/991). ScriptedDashboard: datasource services are now available in scripted dashboards, you can query datasource for metric keys, generate dashboards, and even save them in a scripted dashboard (see scripted_gen_and_save.js for example)
 
+**Changes**
+- [Issue #1007](https://github.com/grafana/grafana/issues/1007). Graph: Series hide/show toggle changed to be default exclusive, so clicking on a series name will show only that series. (SHIFT or meta)+click will toggle hide/show.
+
 **OpenTSDB**
 - [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc
 

+ 4 - 0
src/app/controllers/graphiteTarget.js

@@ -275,6 +275,10 @@ function (angular, _, config, gfunc, Parser) {
       }
     };
 
+    $scope.moveMetricQuery = function(fromIndex, toIndex) {
+      _.move($scope.panel.targets, fromIndex, toIndex);
+    };
+
     $scope.duplicate = function() {
       var clone = angular.copy($scope.target);
       $scope.panel.targets.push(clone);

+ 7 - 2
src/app/controllers/influxTargetCtrl.js

@@ -1,7 +1,8 @@
 define([
-  'angular'
+  'angular',
+  'lodash'
 ],
-function (angular) {
+function (angular, _) {
   'use strict';
 
   var module = angular.module('grafana.controllers');
@@ -96,6 +97,10 @@ function (angular) {
       }
     };
 
+    $scope.moveMetricQuery = function(fromIndex, toIndex) {
+      _.move($scope.panel.targets, fromIndex, toIndex);
+    };
+
     $scope.duplicate = function() {
       var clone = angular.copy($scope.target);
       $scope.panel.targets.push(clone);

+ 7 - 7
src/app/panels/graph/module.js

@@ -275,14 +275,14 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
     };
 
     $scope.toggleSeries = function(serie, event) {
-      if ($scope.hiddenSeries[serie.alias]) {
-        delete $scope.hiddenSeries[serie.alias];
-      }
-      else {
-        $scope.hiddenSeries[serie.alias] = true;
-      }
-
       if (event.ctrlKey || event.metaKey || event.shiftKey) {
+        if ($scope.hiddenSeries[serie.alias]) {
+          delete $scope.hiddenSeries[serie.alias];
+        }
+        else {
+          $scope.hiddenSeries[serie.alias] = true;
+        }
+      } else {
         $scope.toggleSeriesExclusiveMode(serie);
       }
 

+ 13 - 0
src/app/partials/graphite/editor.html

@@ -30,6 +30,19 @@
                   ng-click="duplicate()">
                 Duplicate
               </a>
+            </li>
+						<li role="menuitem">
+              <a  tabindex="1"
+                  ng-click="moveMetricQuery($index, $index-1)">
+                Move up
+              </a>
+            </li>
+						<li role="menuitem">
+							<a  tabindex="1"
+                  ng-click="moveMetricQuery($index, $index+1)">
+                Move down
+              </a>
+            </li>
           </ul>
         </li>
         <li>

+ 19 - 19
src/app/partials/influxdb/editor.html

@@ -15,26 +15,26 @@
                tabindex="1">
               <i class="icon icon-cog"></i>
             </a>
-            <ul class="dropdown-menu pull-right" role="menu">
-              <li role="menuitem">
-                <a tabindex="1" ng-click="duplicate()">Duplicate</a>
-                <a tabindex="2" ng-click="showQuery()" ng-hide="target.rawQuery">Raw query mode</a>
-                <a tabindex="2" ng-click="hideQuery()" ng-show="target.rawQuery">Query editor mode</a>
-              </li>
-           </ul>
-          </li>
-          <li>
-            <a class="pointer" tabindex="1" ng-click="removeDataQuery(target)">
-              <i class="icon icon-remove"></i>
-            </a>
-          </li>
-        </ul>
+						<ul class="dropdown-menu pull-right" role="menu">
+							<li role="menuitem"><a tabindex="1" ng-click="duplicate()">Duplicate</a></li>
+							<li role="menuitem"><a tabindex="1" ng-click="showQuery()" ng-hide="target.rawQuery">Raw query mode</a></li>
+							<li role="menuitem"><a tabindex="1" ng-click="hideQuery()" ng-show="target.rawQuery">Query editor mode</a></li>
+							<li role="menuitem"><a tabindex="1" ng-click="moveMetricQuery($index, $index-1)">Move up </a></li>
+							<li role="menuitem"><a tabindex="1" ng-click="moveMetricQuery($index, $index+1)">Move down</a></li>
+						</ul>
+					</li>
+					<li>
+						<a class="pointer" tabindex="1" ng-click="removeDataQuery(target)">
+							<i class="icon icon-remove"></i>
+						</a>
+					</li>
+				</ul>
 
-        <ul class="grafana-segment-list">
-          <li>
-            <a class="grafana-target-segment" ng-click="target.hide = !target.hide; get_data();" role="menuitem">
-              <i class="icon-eye-open"></i>
-            </a>
+				<ul class="grafana-segment-list">
+					<li>
+						<a class="grafana-target-segment" ng-click="target.hide = !target.hide; get_data();" role="menuitem">
+							<i class="icon-eye-open"></i>
+						</a>
           </li>
         </ul>
 

+ 13 - 12
src/app/services/dashboard/dashboardViewStateSrv.js

@@ -32,26 +32,27 @@ function (angular, _, $) {
       });
 
       this.update(this.getQueryStringState(), true);
+      this.expandRowForPanel();
     }
 
+    DashboardViewState.prototype.expandRowForPanel = function() {
+      if (!this.state.panelId) { return; }
+
+      var panelInfo = this.$scope.dashboard.getPanelInfoById(this.state.panelId);
+      panelInfo.row.collapse = false;
+    };
+
     DashboardViewState.prototype.needsSync = function(urlState) {
       return _.isEqual(this.state, urlState) === false;
     };
 
     DashboardViewState.prototype.getQueryStringState = function() {
-      var queryParams = $location.search();
-      var urlState = {
-        panelId: parseInt(queryParams.panelId) || null,
-        fullscreen: queryParams.fullscreen ? true : false,
-        edit: queryParams.edit ? true : false,
-      };
+      var state = $location.search();
+      state.panelId = parseInt(state.panelId) || null;
+      state.fullscreen = state.fullscreen ? true : false;
+      state.edit = state.edit ? true : false;
 
-      _.each(queryParams, function(value, key) {
-        if (key.indexOf('var-') !== 0) { return; }
-        urlState[key] = value;
-      });
-
-      return urlState;
+      return state;
     };
 
     DashboardViewState.prototype.serializeToUrl = function() {

+ 7 - 3
src/app/services/graphite/gfunc.js

@@ -339,8 +339,12 @@ function (_) {
   addFuncDef({
     name: 'summarize',
     category: categories.Transform,
-    params: [{ name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }],
-    defaultParams: ['1h', 'sum']
+    params: [
+      { name: "interval", type: "string" },
+      { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] },
+      { name: "alignToFrom", type: "boolean", optional: true, options: ['false', 'true'] },
+    ],
+    defaultParams: ['1h', 'sum', 'false']
   });
 
   addFuncDef({
@@ -543,7 +547,7 @@ function (_) {
     var parameters = _.map(this.params, function(value, index) {
 
       var paramType = this.def.params[index].type;
-      if (paramType === 'int' || paramType === 'value_or_series') {
+      if (paramType === 'int' || paramType === 'value_or_series' || paramType === 'boolean') {
         return value;
       }
 

+ 1 - 1
src/test/specs/gfunc-specs.js

@@ -79,7 +79,7 @@ define([
       var func = gfunc.createFuncInstance('summarize', { withDefaultParams: true });
       func.updateParam('1h', 0);
       expect(func.params[0]).to.be('1h');
-      expect(func.text).to.be('summarize(1h, sum)');
+      expect(func.text).to.be('summarize(1h, sum, false)');
     });
 
     it('should parse numbers as float', function() {