From 2b1dcaf5e38a1e912236b2ec78822021991169aa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Aug 2014 11:25:30 +0200 Subject: [PATCH 001/127] added global page title prefix setting --- src/app/components/settings.js | 1 + src/app/controllers/dash.js | 2 +- src/config.sample.js | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/components/settings.js b/src/app/components/settings.js index 165bbc6c476..9601d80de79 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -14,6 +14,7 @@ function (_, crypto) { */ var defaults = { datasources : {}, + title : 'Grafana - ', panels : ['graph', 'text'], plugins : {}, default_route : '/dashboard/file/default.json', diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index e40db93fd7e..55f19905192 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -40,7 +40,7 @@ function (angular, $, config, _) { $scope.panelMoveOver = panelMove.onOver; $scope.panelMoveOut = panelMove.onOut; - window.document.title = 'Grafana - ' + $scope.dashboard.title; + window.document.title = (config.title ? config.title : '') + $scope.dashboard.title; // start auto refresh if($scope.dashboard.refresh) { diff --git a/src/config.sample.js b/src/config.sample.js index 9bce1540fa4..4bc6864e442 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -73,6 +73,17 @@ function (Settings) { * ======================================================== */ + /* title: + * The global page title prefix that is prepended before the specific dashboard titles. + * Defaults to 'Grafana - '. + * + * title: undefined, // default prefix, page title = 'Grafana - ' + * title: null, // no prefix, page title = + * title: '', // no prefix, page title = + * title: 'Custom | ', // custom prefix, page title = 'Custom | ' + */ + title: undefined, + // specify the limit for dashboard search results search: { max_results: 20 From 5c0d1355a5911c28141be54eb9fe83b9792e2383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 18 Aug 2014 19:33:38 +0200 Subject: [PATCH 002/127] Second take on dashboard tags search result colors --- src/app/controllers/search.js | 26 ++++++++++++++++++++++++++ src/app/partials/search.html | 4 ++-- src/css/less/grafana.less | 3 +++ src/css/less/overrides.less | 3 +++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index de0ec44045a..6e9de7ba585 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -9,6 +9,32 @@ function (angular, _, config, $) { var module = angular.module('grafana.controllers'); + function djb2(str) { + var hash = 5381; + for (var i = 0; i < str.length; i++) { + hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */ + } + return hash; + } + + module.directive('tagColorFromName', function() { + return function (scope, element) { + var name = _.isString(scope.tag) ? scope.tag : scope.tag.term; + var hash = djb2(name.toLowerCase()); + var colors = [ + "#E24D42","#1F78C1","#BA43A9","#705DA0", + "#508642","#447EBC","#C15C17","#890F02", + "#0A437C","#6D1F62","#584477","#629E51", + "#BF1B00","#EA6460","#D683CE","#806EB7", + "#3F6833","#2F575E","#99440A","#E0752D", + "#58140C","#052B51","#511749","#3F2B5B", + ]; + var color = colors[Math.abs(hash % colors.length)]; + console.log("namei " + name + " color: " + color, hash % 4); + element.css("background-color", color); + }; + }); + module.controller('SearchCtrl', function($scope, $rootScope, $element, $location, datasourceSrv) { $scope.init = function() { diff --git a/src/app/partials/search.html b/src/app/partials/search.html index e1c9f158e0b..297edadedfc 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -54,7 +54,7 @@ ng-click="filterByTag(tag.term, $event)"> - {{tag.term}}  ({{tag.count}}) + {{tag.term}}  ({{tag.count}}) @@ -79,7 +79,7 @@ diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index 0fc9c72bf2f..9ddc8568258 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -86,6 +86,9 @@ .search-result-tags { float: right; + .label { + margin-left: 6px; + } } .search-result-actions { diff --git a/src/css/less/overrides.less b/src/css/less/overrides.less index 7615f35d6f8..dd806cb46ca 100644 --- a/src/css/less/overrides.less +++ b/src/css/less/overrides.less @@ -589,6 +589,9 @@ div.flot-text { .label-tag { background-color: @purple; color: darken(@white, 5%); + text-shadow: none; + font-size: 13px; + padding: 3px 6px; } .label-tag:hover { From 36882ea2a42e705e3d250e2d455fea19f7bc49b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 22 Aug 2014 09:04:28 +0200 Subject: [PATCH 003/127] More work on dashboard tag colors --- src/app/controllers/search.js | 54 ++++++++++++++++--------------- src/app/partials/search.html | 6 ++-- src/css/less/grafana.less | 19 +++++------ src/css/less/overrides.less | 10 ++++-- src/css/less/variables.light.less | 6 ++-- 5 files changed, 52 insertions(+), 43 deletions(-) diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 6e9de7ba585..a32aa64acf0 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -9,32 +9,6 @@ function (angular, _, config, $) { var module = angular.module('grafana.controllers'); - function djb2(str) { - var hash = 5381; - for (var i = 0; i < str.length; i++) { - hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */ - } - return hash; - } - - module.directive('tagColorFromName', function() { - return function (scope, element) { - var name = _.isString(scope.tag) ? scope.tag : scope.tag.term; - var hash = djb2(name.toLowerCase()); - var colors = [ - "#E24D42","#1F78C1","#BA43A9","#705DA0", - "#508642","#447EBC","#C15C17","#890F02", - "#0A437C","#6D1F62","#584477","#629E51", - "#BF1B00","#EA6460","#D683CE","#806EB7", - "#3F6833","#2F575E","#99440A","#E0752D", - "#58140C","#052B51","#511749","#3F2B5B", - ]; - var color = colors[Math.abs(hash % colors.length)]; - console.log("namei " + name + " color: " + color, hash % 4); - element.css("background-color", color); - }; - }); - module.controller('SearchCtrl', function($scope, $rootScope, $element, $location, datasourceSrv) { $scope.init = function() { @@ -177,4 +151,32 @@ function (angular, _, config, $) { }; }); + module.directive('tagColorFromName', function() { + + function djb2(str) { + var hash = 5381; + for (var i = 0; i < str.length; i++) { + hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */ + } + return hash; + } + + return function (scope, element) { + var name = _.isString(scope.tag) ? scope.tag : scope.tag.term; + var hash = djb2(name.toLowerCase()); + var colors = [ + "#E24D42","#1F78C1","#BA43A9","#705DA0","#466803", + "#508642","#447EBC","#C15C17","#890F02","#757575", + "#0A437C","#6D1F62","#584477","#629E51","#2F4F4F", + "#BF1B00","#806EB7","#8a2eb8", "#699e00","#000000", + "#3F6833","#2F575E","#99440A","#E0752D","#0E4AB4", + "#58140C","#052B51","#511749","#3F2B5B", + ]; + var color = colors[Math.abs(hash % colors.length)]; + console.log("namei " + name + " color: " + color, hash % 4); + element.css("background-color", color); + }; + + }); + }); diff --git a/src/app/partials/search.html b/src/app/partials/search.html index ce987759999..b9974207d3b 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -52,9 +52,9 @@ class="search-result-item pointer" ng-class="{'selected': $index === selectedIndex }" ng-click="filterByTag(tag.term, $event)"> - + - {{tag.term}}  ({{tag.count}}) + {{tag.term}}  ({{tag.count}}) @@ -64,7 +64,7 @@ bindonce ng-repeat="row in results.dashboards" ng-class="{'selected': $index === selectedIndex }" ng-click="goToDashboard(row.id)"> -
+
share     diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index e13d9f16a5b..ca006b2b015 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -55,19 +55,18 @@ max-height: 600px; overflow: auto; display: block; - .search-result-item a { - } + line-height: 28px; .search-result-item:hover, .search-result-item.selected { - .search-result-link, .icon { + .search-result-link, .search-result-link > .icon { color: @grafanaListHighlight; } - .search-result-link .label { - background-color: @blue; + .search-result-tag { + opacity: 0.70; + color: white; } } - .search-result-link { color: @grafanaListMainLinkColor; .icon { @@ -81,7 +80,7 @@ } .search-result-item { - padding: 6px 10px; + padding: 0px 10px; white-space: nowrap; border-top: 1px solid @grafanaListBorderTop; border-bottom: 1px solid @grafanaListBorderBottom; @@ -89,14 +88,16 @@ .search-result-tags { float: right; - .label { + .label-tag { margin-left: 6px; + font-size: 11px; + padding: 2px 6px; } } .search-result-actions { float: right; - padding-left: 10px; + padding-left: 20px; } } diff --git a/src/css/less/overrides.less b/src/css/less/overrides.less index dd806cb46ca..35db9356279 100644 --- a/src/css/less/overrides.less +++ b/src/css/less/overrides.less @@ -589,14 +589,20 @@ div.flot-text { .label-tag { background-color: @purple; color: darken(@white, 5%); + border-radius: 2px; text-shadow: none; font-size: 13px; - padding: 3px 6px; + padding: 4px 6px; + .icon-tag { + position: relative; + top: 1px; + padding-right: 4px; + } } .label-tag:hover { + opacity: 0.85; background-color: darken(@purple, 10%); - color: @white; } .annotation-editor-table { diff --git a/src/css/less/variables.light.less b/src/css/less/variables.light.less index 562114a9e54..1e0b38413fb 100644 --- a/src/css/less/variables.light.less +++ b/src/css/less/variables.light.less @@ -61,8 +61,8 @@ // Links // ------------------------- -@linkColor: @blue; -@linkColorHover: darken(@linkColor, 10%); +@linkColor: @textColor; +@linkColorHover: @blue; // Typography @@ -219,7 +219,7 @@ @navbarText: #666; @navbarLinkColor: #666; -@navbarLinkColorHover: #333; +@navbarLinkColorHover: @blue; @navbarLinkColorActive: #555; @navbarLinkBackgroundHover: transparent; @navbarLinkBackgroundActive: darken(@navbarBackground, 6.5%); From 3579a18da834a5b998508e465771e41cc2ab258b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 22 Aug 2014 09:34:05 +0200 Subject: [PATCH 004/127] Css fix for panel-error position --- src/css/less/overrides.less | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/css/less/overrides.less b/src/css/less/overrides.less index 7615f35d6f8..eddf9c6e4f9 100644 --- a/src/css/less/overrides.less +++ b/src/css/less/overrides.less @@ -74,6 +74,7 @@ code, pre { padding: 0px 0px 0px 0px; background: @grafanaPanelBackground; margin: 5px; + position: relative; } .panel-content { @@ -112,9 +113,8 @@ code, pre { .panel-error { color: @white; - //padding: 5px 10px 0px 10px; position: absolute; - left: 5px; + left: 0; padding: 0px 17px 6px 5px; top: 0; i { @@ -585,7 +585,6 @@ div.flot-text { // Labels & Badges - .label-tag { background-color: @purple; color: darken(@white, 5%); @@ -603,7 +602,6 @@ div.flot-text { } // Top menu - .save-dashboard-dropdown { padding: 10px; li>a { From 8a80623d0c3b114308a5cd1c15f7ef5a86d883b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 22 Aug 2014 09:40:11 +0200 Subject: [PATCH 005/127] Merged dashboard tag colors feature branch, updated changelog #634 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c6d39929f8..e53e93f0ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [Issue #672](https://github.com/grafana/grafana/issues/672). Dashboard: panel fullscreen & edit state is present in url, can now link to graph in edit & fullscreen mode. - [Issue #709](https://github.com/grafana/grafana/issues/709). Dashboard: Small UI look polish to search results, made dashboard title link are larger - [Issue #425](https://github.com/grafana/grafana/issues/425). Graph: New section in 'Display Styles' tab to override any display setting on per series bases (mix and match lines, bars, points, fill, stack, line width etc) +- [Issue #634](https://github.com/grafana/grafana/issues/634). Dashboard: Dashboard tags now in different colors (from fixed palette) determined by tag name. **Fixes** - [Issue #696](https://github.com/grafana/grafana/issues/696). Graph: Fix for y-axis format 'none' when values are in scientific notation (ex 2.3e-13) From 47a20e6a2f3379ddf5e4c0e93316eadcd400a89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 23 Aug 2014 10:43:37 +0200 Subject: [PATCH 006/127] Dashboard: fix for adding rows from dashboard settings modal, Closes #699 --- CHANGELOG.md | 3 ++- src/app/controllers/dashboardCtrl.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e53e93f0ae3..61b7aea105e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ **Fixes** - [Issue #696](https://github.com/grafana/grafana/issues/696). Graph: Fix for y-axis format 'none' when values are in scientific notation (ex 2.3e-13) - [Issue #697](https://github.com/grafana/grafana/issues/697). Graphite: Fix for Glob syntax in graphite queries ([1-9] and ?) that made the query editor / parser bail and fallback to a text box. -- [Issue #277](https://github.com/grafana/grafana/issues/277). Dashboard: Fix for timepicker date & tooltip when UTC timezone selected. Closes #277 +- [Issue #277](https://github.com/grafana/grafana/issues/277). Dashboard: Fix for timepicker date & tooltip when UTC timezone selected. +- [Issue #699](https://github.com/grafana/grafana/issues/699). Dashboard: Fix for bug when adding rows from dashboard settings dialog. **Tech** - Upgraded from angularjs 1.1.5 to 1.3 beta 17; diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index 7132ca8a571..052ad540a8c 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -28,6 +28,7 @@ function (angular, $, config, _) { }); }); + $scope.reset_row(); }; $scope.setupDashboard = function(event, dashboardData) { From ffbdea78ee0cc287549458c046f1858b65f221bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 23 Aug 2014 20:23:33 +0200 Subject: [PATCH 007/127] Fix for plot dimension error when resizing window --- src/app/controllers/dashboardCtrl.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index 052ad540a8c..34af5718072 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -17,18 +17,20 @@ function (angular, $, config, _) { $scope.editor = { index: 0 }; $scope.panelNames = config.panels; + var resizeEventTimeout; $scope.init = function() { $scope.availablePanels = config.panels; $scope.onAppEvent('setup-dashboard', $scope.setupDashboard); - - angular.element(window).bind('resize', function() { - $timeout(function() { - $scope.$broadcast('render'); - }); - }); - $scope.reset_row(); + $scope.registerWindowResizeEvent(); + }; + + $scope.registerWindowResizeEvent = function() { + angular.element(window).bind('resize', function() { + $timeout.cancel(resizeEventTimeout); + resizeEventTimeout = $timeout(function() { $scope.$broadcast('render'); }, 200); + }); }; $scope.setupDashboard = function(event, dashboardData) { From 6f80862517c0db225b720a4d1299885bc49150a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 24 Aug 2014 14:45:00 +0200 Subject: [PATCH 008/127] Dashboard: new config.js option to change/remove window title prefix from 'Grafana -' to anything, PR #685 --- CHANGELOG.md | 1 + src/app/components/settings.js | 2 +- src/app/controllers/dashboardCtrl.js | 2 +- src/config.sample.js | 16 ++++------------ 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61b7aea105e..c1b37967ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [Issue #709](https://github.com/grafana/grafana/issues/709). Dashboard: Small UI look polish to search results, made dashboard title link are larger - [Issue #425](https://github.com/grafana/grafana/issues/425). Graph: New section in 'Display Styles' tab to override any display setting on per series bases (mix and match lines, bars, points, fill, stack, line width etc) - [Issue #634](https://github.com/grafana/grafana/issues/634). Dashboard: Dashboard tags now in different colors (from fixed palette) determined by tag name. +- [Issue #685](https://github.com/grafana/grafana/issues/685). Dashboard: New config.js option to change/remove window title prefix. **Fixes** - [Issue #696](https://github.com/grafana/grafana/issues/696). Graph: Fix for y-axis format 'none' when values are in scientific notation (ex 2.3e-13) diff --git a/src/app/components/settings.js b/src/app/components/settings.js index fff5d9dd4a4..6afba222b4b 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -14,7 +14,7 @@ function (_, crypto) { */ var defaults = { datasources : {}, - title : 'Grafana - ', + window_title_prefix : 'Grafana - ', panels : ['graph', 'text'], plugins : {}, default_route : '/dashboard/file/default.json', diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index 33a190273d7..694fe59a319 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -56,7 +56,7 @@ function (angular, $, config, _) { $scope.panelMoveOver = panelMove.onOver; $scope.panelMoveOut = panelMove.onOut; - window.document.title = (config.title ? config.title : '') + $scope.dashboard.title; + window.document.title = config.window_title_prefix + $scope.dashboard.title; // start auto refresh if($scope.dashboard.refresh) { diff --git a/src/config.sample.js b/src/config.sample.js index aa7341085d7..6046a753d5a 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -73,23 +73,12 @@ function (Settings) { * ======================================================== */ - /* title: - * The global page title prefix that is prepended before the specific dashboard titles. - * Defaults to 'Grafana - '. - * - * title: undefined, // default prefix, page title = 'Grafana - ' - * title: null, // no prefix, page title = - * title: '', // no prefix, page title = - * title: 'Custom | ', // custom prefix, page title = 'Custom | ' - */ - title: undefined, - // specify the limit for dashboard search results search: { max_results: 20 }, - // default start dashboard + // default home dashboard default_route: '/dashboard/file/default.json', // set to false to disable unsaved changes warning @@ -105,6 +94,9 @@ function (Settings) { password: '' }, + // Change window title prefix from 'Grafana - ' + window_title_prefix: 'Grafana - ', + // Add your own custom pannels plugins: { // list of plugin panels From 4f8b2ad245a3f9185ef8c94a5a0758e7be237321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 12:55:42 +0200 Subject: [PATCH 009/127] began work on filtering overhaul --- src/app/panels/filtering/editor.html | 0 src/app/panels/filtering/module.html | 62 +++++++++++----------- src/app/services/annotationsSrv.js | 6 +-- src/app/services/dashboard/dashboardSrv.js | 31 ++++++----- src/test/specs/dashboardSrv-specs.js | 21 +++++++- 5 files changed, 70 insertions(+), 50 deletions(-) create mode 100644 src/app/panels/filtering/editor.html diff --git a/src/app/panels/filtering/editor.html b/src/app/panels/filtering/editor.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/panels/filtering/module.html b/src/app/panels/filtering/module.html index 96b5751ce7d..40f4379a98d 100755 --- a/src/app/panels/filtering/module.html +++ b/src/app/panels/filtering/module.html @@ -1,14 +1,6 @@
-
-
-
- - -
- -
-
+
+ + -
-
    -
  • - name:
    - -
  • -
  • - filter.query:
    - -
  • -
  • - - -
  • -
-
- - -
-
-
- -
+
+ + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/app/services/annotationsSrv.js b/src/app/services/annotationsSrv.js index a219caa5d66..a59eae4cf07 100644 --- a/src/app/services/annotationsSrv.js +++ b/src/app/services/annotationsSrv.js @@ -9,7 +9,6 @@ define([ module.service('annotationsSrv', function(datasourceSrv, $q, alertSrv, $rootScope) { var promiseCached; - var annotationPanel; var list = []; var timezone; @@ -23,8 +22,7 @@ define([ }; this.getAnnotations = function(filterSrv, rangeUnparsed, dashboard) { - annotationPanel = _.findWhere(dashboard.pulldowns, { type: 'annotations' }); - if (!annotationPanel.enable) { + if (!dashboard.annotations.enable) { return $q.when(null); } @@ -33,7 +31,7 @@ define([ } timezone = dashboard.timezone; - var annotations = _.where(annotationPanel.annotations, { enable: true }); + var annotations = _.where(dashboard.annotations.list, { enable: true }); var promises = _.map(annotations, function(annotation) { var datasource = datasourceSrv.get(annotation.datasource); diff --git a/src/app/services/dashboard/dashboardSrv.js b/src/app/services/dashboard/dashboardSrv.js index 6a363837bc3..6139a41f83e 100644 --- a/src/app/services/dashboard/dashboardSrv.js +++ b/src/app/services/dashboard/dashboardSrv.js @@ -27,10 +27,10 @@ function (angular, $, kbn, _, moment) { this.timezone = data.timezone || 'browser'; this.editable = data.editble || true; this.rows = data.rows || []; - this.pulldowns = data.pulldowns || []; this.nav = data.nav || []; this.time = data.time || { from: 'now-6h', to: 'now' }; - this.templating = data.templating || { list: [] }; + this.templating = data.templating || { list: [], enable: false }; + this.annotations = data.annotations || { list: [], enable: false}; this.refresh = data.refresh; this.version = data.version || 0; @@ -38,14 +38,6 @@ function (angular, $, kbn, _, moment) { this.nav.push({ type: 'timepicker' }); } - if (!_.findWhere(this.pulldowns, {type: 'filtering'})) { - this.pulldowns.push({ type: 'filtering', enable: false }); - } - - if (!_.findWhere(this.pulldowns, {type: 'annotations'})) { - this.pulldowns.push({ type: 'annotations', enable: false }); - } - this.updateSchema(data); } @@ -147,9 +139,9 @@ function (angular, $, kbn, _, moment) { p.updateSchema = function(old) { var oldVersion = this.version; var panelUpgrades = []; - this.version = 4; + this.version = 5; - if (oldVersion === 4) { + if (oldVersion === 5) { return; } @@ -224,6 +216,21 @@ function (angular, $, kbn, _, moment) { }); } + if (oldVersion < 5) { + // move pulldowns to new schema + var filtering = _.findWhere(old.pulldowns, { type: 'filtering' }); + var annotations = _.findWhere(old.pulldowns, { type: 'annotations' }); + if (filtering) { + this.templating.enable = filtering.enable; + } + if (annotations) { + this.annotations = { + list: annotations.annotations, + enable: annotations.enable + }; + } + } + if (panelUpgrades.length === 0) { return; } diff --git a/src/test/specs/dashboardSrv-specs.js b/src/test/specs/dashboardSrv-specs.js index a2c7c1772f6..c141b746cd3 100644 --- a/src/test/specs/dashboardSrv-specs.js +++ b/src/test/specs/dashboardSrv-specs.js @@ -18,7 +18,6 @@ define([ it('should have default properties', function() { expect(model.rows.length).to.be(0); expect(model.nav.length).to.be(1); - expect(model.pulldowns.length).to.be(2); }); }); @@ -91,6 +90,17 @@ define([ beforeEach(inject(function(dashboardSrv) { model = dashboardSrv.create({ services: { filter: { time: { from: 'now-1d', to: 'now'}, list: [1] }}, + pulldowns: [ + { + type: 'filtering', + enable: true + }, + { + type: 'annotations', + enable: true, + annotations: [{name: 'old'}] + } + ], rows: [ { panels: [ @@ -140,8 +150,15 @@ define([ expect(graph.seriesOverrides[0].yaxis).to.be(2); }); + it('should move pulldowns to new schema', function() { + expect(model.templating.enable).to.be(true); + expect(model.annotations.enable).to.be(true); + expect(model.annotations.list[0].name).to.be('old'); + }); + + it('dashboard schema version should be set to latest', function() { - expect(model.version).to.be(4); + expect(model.version).to.be(5); }); }); From 6969a4121c7f1370764897eba4979df7fe5394bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 13:31:31 +0200 Subject: [PATCH 010/127] removing pulldowns and simplifying submenu controls code --- src/app/controllers/dashboardCtrl.js | 3 +++ src/app/controllers/submenuCtrl.js | 2 +- src/app/partials/dashboard.html | 11 +------- src/app/partials/submenu.html | 38 ++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 src/app/partials/submenu.html diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index 694fe59a319..4b6bdb76382 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -48,6 +48,9 @@ function (angular, $, config, _) { $scope.filter = filterSrv; $scope.filter.init($scope.dashboard); + $scope.submenuEnabled = $scope.dashboard.templating.enable || + $scope.dashboard.annotations.enable; + var panelMove = panelMoveSrv.create($scope.dashboard); $scope.panelMoveDrop = panelMove.onDrop; diff --git a/src/app/controllers/submenuCtrl.js b/src/app/controllers/submenuCtrl.js index b75fab56043..beefcf15ff0 100644 --- a/src/app/controllers/submenuCtrl.js +++ b/src/app/controllers/submenuCtrl.js @@ -24,4 +24,4 @@ function (angular, app, _) { }); -}); \ No newline at end of file +}); diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 368583cb5c5..95c22b574d8 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -3,16 +3,7 @@
- diff --git a/src/app/partials/submenu.html b/src/app/partials/submenu.html index e1fba4a8bdf..ab432753bc0 100644 --- a/src/app/partials/submenu.html +++ b/src/app/partials/submenu.html @@ -5,29 +5,40 @@ diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index ca006b2b015..7773d4b31b9 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -284,6 +284,14 @@ &a:hover { background: @grafanaTargetFuncBackground; } + + &.template-param-name { + border-right: none; + padding-right: 3px; + } + &.annotation-segment { + padding: 8px 15px; + } } .grafana-target-function { @@ -405,7 +413,6 @@ select.grafana-target-segment-input { } } - .scrollable { max-height: 300px; overflow: auto; From 8b3c89e2676a743247d2a77c8a3db8bf27c45778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 15:55:42 +0200 Subject: [PATCH 012/127] Starting work on new templating editor --- src/app/partials/submenu.html | 6 +++--- src/app/partials/templating_editor.html | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/app/partials/templating_editor.html diff --git a/src/app/partials/submenu.html b/src/app/partials/submenu.html index ab432753bc0..a9b2230237e 100644 --- a/src/app/partials/submenu.html +++ b/src/app/partials/submenu.html @@ -10,8 +10,8 @@ @@ -35,7 +35,7 @@ -
  • +
  • {{annotation.name}}
  • diff --git a/src/app/partials/templating_editor.html b/src/app/partials/templating_editor.html new file mode 100644 index 00000000000..0282ea26ade --- /dev/null +++ b/src/app/partials/templating_editor.html @@ -0,0 +1,15 @@ +
    + + + +
    From 061d1262d4a405ad2ed392fc6f0b7b942f290d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 16:14:47 +0200 Subject: [PATCH 013/127] Small html markup/css simplification --- src/app/partials/dashboard.html | 196 ++++++++++++++++---------------- src/css/less/grafana.less | 2 +- src/css/less/overrides.less | 2 +- 3 files changed, 98 insertions(+), 102 deletions(-) diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 95c22b574d8..b2857205fa7 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -7,112 +7,108 @@
    -
    -
    -
    - -
    -
    -
    -
    -
    - - - - - - -
    - -
    -
    -
    - - - -
    - -
    -
    -
    -
    -
    +
    + +
    +
    +
    +
    +
    + + + + + + +
    + +
    +
    +
    + + + +
    + +
    +
    - -
    - -
    +
    +
    +
    -
    -
    + +
    + +
    -
    -
    -
    -
    -
    +
    +
    +
    +
    +
    +
    +
    -
    -
    - - ADD A ROW - -
    -
    -
    -
    +
    +
    + + ADD A ROW + +
    +
    diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index 7773d4b31b9..77381a4ebf5 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -179,7 +179,7 @@ } } -.dashboard-fullscreen .container-fluid.main { +.dashboard-fullscreen .main-view-container { height: 0px; width: 0px; position: fixed; diff --git a/src/css/less/overrides.less b/src/css/less/overrides.less index eeff1ef0087..14c1fabf9b8 100644 --- a/src/css/less/overrides.less +++ b/src/css/less/overrides.less @@ -14,7 +14,7 @@ padding-right: 0px; } -.container.grafana-container { +.main-view-container { padding: 5px 10px; width: 100%; box-sizing: border-box; From b506e7c26711082e8ca540070735355e7d4a3ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 16:44:33 +0200 Subject: [PATCH 014/127] fixed submenu in fullscreen mode --- src/app/directives/bodyClass.js | 10 +-- src/app/panels/filtering/module.js | 57 --------------- src/css/less/submenu.less | 110 +---------------------------- 3 files changed, 3 insertions(+), 174 deletions(-) diff --git a/src/app/directives/bodyClass.js b/src/app/directives/bodyClass.js index 6d3c6d32e15..86ff598d69e 100644 --- a/src/app/directives/bodyClass.js +++ b/src/app/directives/bodyClass.js @@ -12,20 +12,14 @@ function (angular, app, _) { return { link: function($scope, elem) { - var lastPulldownVal; var lastHideControlsVal; - $scope.$watchCollection('dashboard.pulldowns', function() { + $scope.$watch('submenuEnabled', function() { if (!$scope.dashboard) { return; } - var panel = _.find($scope.dashboard.pulldowns, function(pulldown) { return pulldown.enable; }); - var panelEnabled = panel ? panel.enable : false; - if (lastPulldownVal !== panelEnabled) { - elem.toggleClass('submenu-controls-visible', panelEnabled); - lastPulldownVal = panelEnabled; - } + elem.toggleClass('submenu-controls-visible', $scope.submenuEnabled); }); $scope.$watch('dashboard.hideControls', function() { diff --git a/src/app/panels/filtering/module.js b/src/app/panels/filtering/module.js index a8f64cad6ed..eb89cebafa0 100644 --- a/src/app/panels/filtering/module.js +++ b/src/app/panels/filtering/module.js @@ -34,63 +34,6 @@ function (angular, app, _) { $scope.filter.removeTemplateParameter(templateParameter); }; - $scope.filterOptionSelected = function(templateParameter, option, recursive) { - templateParameter.current = option; - - $scope.filter.updateTemplateData(); - - return $scope.applyFilterToOtherFilters(templateParameter) - .then(function() { - // only refresh in the outermost call - if (!recursive) { - $scope.dashboard.emit_refresh(); - } - }); - }; - - $scope.applyFilterToOtherFilters = function(updatedTemplatedParam) { - var promises = _.map($scope.filter.templateParameters, function(templateParam) { - if (templateParam === updatedTemplatedParam) { - return; - } - if (templateParam.query.indexOf('[[' + updatedTemplatedParam.name + ']]') !== -1) { - return $scope.applyFilter(templateParam); - } - }); - - return $q.all(promises); - }; - - $scope.applyFilter = function(templateParam) { - return datasourceSrv.default.metricFindQuery($scope.filter, templateParam.query) - .then(function (results) { - templateParam.editing = undefined; - templateParam.options = _.map(results, function(node) { - return { text: node.text, value: node.text }; - }); - - if (templateParam.includeAll) { - var allExpr = '{'; - _.each(templateParam.options, function(option) { - allExpr += option.text + ','; - }); - allExpr = allExpr.substring(0, allExpr.length - 1) + '}'; - templateParam.options.unshift({text: 'All', value: allExpr}); - } - - // if parameter has current value - // if it exists in options array keep value - if (templateParam.current) { - var currentExists = _.findWhere(templateParam.options, { value: templateParam.current.value }); - if (currentExists) { - return $scope.filterOptionSelected(templateParam, templateParam.current, true); - } - } - - return $scope.filterOptionSelected(templateParam, templateParam.options[0], true); - }); - }; - $scope.add = function() { $scope.filter.addTemplateParameter({ type : 'filter', diff --git a/src/css/less/submenu.less b/src/css/less/submenu.less index 514ccf6e29b..247ffda5175 100644 --- a/src/css/less/submenu.less +++ b/src/css/less/submenu.less @@ -1,118 +1,10 @@ -.submenu-controls { - background: @submenuBackground; - font-size: inherit; - label { - margin: 0; - padding-right: 4px; - display: inline; - } - input[type=checkbox] { - margin: 0; - } -} - .submenu-controls-visible:not(.hide-controls) { .panel-fullscreen { - top: 82px; + top: 90px; } } -.submenu-panel { - padding: 0 4px 0 8px; - border-right: 1px solid @submenuBorder; - float: left; -} - -.submenu-panel:first-child { - padding-left: 17px; -} - -.submenu-panel-title { - float: left; - text-transform: uppercase; - padding: 4px 10px 3px 0; -} - -.submenu-panel-wrapper { - float: left; -} - -.submenu-toggle { - padding: 4px 0 3px 8px; - float: left; - .annotation-color-icon { - position: relative; - top: 2px; - } -} - -.submenu-toggle:first-child { - padding-left: 0; -} - -.submenu-control-edit { - padding: 4px 4px 3px 8px; - float: right; - border-left: 1px solid @submenuBorder; - margin-left: 8px; -} - .annotation-disabled, .annotation-disabled a { color: darken(@textColor, 25%); } - -// Filter submenu -.filtering-container { - float: left; -} - -.filtering-container label { - float: left; -} - -.filtering-container input[type=checkbox] { - margin: 0; -} - -.filter-panel-filter { - display:inline-block; - vertical-align: top; - padding: 4px 10px 3px 10px; - border-right: 1px solid @submenuBorder; -} - -.filter-panel-filter:first-child { - padding-left: 0; -} - -.filter-panel-filter ul { - margin-bottom: 0px; -} - -.filter-deselected { - opacity: 0.5; -} - -.filtering-container .filter-action { - float:right; - padding-right: 2px; - margin-bottom: 0px !important; - margin-left: 0px; - margin-top: 4px; -} - -.add-filter-action { - padding: 3px 5px 0px 5px; - position: relative; - top: 4px; -} - -.filter-mandate { - text-decoration: underline; - cursor: pointer; -} - -.filter-apply { - float:right; -} \ No newline at end of file From 00e5bb61fc9f597ebc688c8a23d37842c3a2fb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 17:27:19 +0200 Subject: [PATCH 015/127] Trying out an alternative to modals --- src/app/controllers/annotationsEditorCtrl.js | 14 ++++++++++++++ src/app/controllers/search.js | 1 - src/app/directives/configModal.js | 6 ++++++ src/app/partials/dashboard.html | 19 ++++++++++++------- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/app/controllers/annotationsEditorCtrl.js b/src/app/controllers/annotationsEditorCtrl.js index 65561643896..ce832eee1d4 100644 --- a/src/app/controllers/annotationsEditorCtrl.js +++ b/src/app/controllers/annotationsEditorCtrl.js @@ -61,4 +61,18 @@ function (angular, app, _) { }; }); + + module.controller('EditViewCtrl', function($scope) { + //$scope.editPanelSrc = 'app/partials/test.html'; + + $scope.onAppEvent('show-edit-panel', function(evt, payload) { + $scope.editPanelSrc = payload.src; + }); + + $scope.dismiss = function() { + $scope.editPanelSrc = null; + }; + + }); + }); diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index a32aa64acf0..3d11bc68750 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -173,7 +173,6 @@ function (angular, _, config, $) { "#58140C","#052B51","#511749","#3F2B5B", ]; var color = colors[Math.abs(hash % colors.length)]; - console.log("namei " + name + " color: " + color, hash % 4); element.css("background-color", color); }; diff --git a/src/app/directives/configModal.js b/src/app/directives/configModal.js index b7e579e7026..6ca19cef435 100644 --- a/src/app/directives/configModal.js +++ b/src/app/directives/configModal.js @@ -16,6 +16,12 @@ function (angular, _, $) { var id = '#' + partial.replace('.html', '').replace(/[\/|\.|:]/g, '-') + '-' + scope.$id; elem.bind('click',function() { + $timeout(function() { + scope.exitFullscreen(); + scope.emitAppEvent('show-edit-panel', {src: partial}); + }); + return; + if ($(id).length) { elem.attr('data-target', id).attr('data-toggle', 'modal'); scope.$apply(function() { scope.$broadcast('modal-opened'); }); diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index b2857205fa7..73b23ed12a4 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -8,8 +8,12 @@
    +
    +
    +
    +
    +
    -
    @@ -100,14 +104,15 @@
    -
    -
    -
    - - ADD A ROW - +
    +
    + + ADD A ROW + +
    +
    From 6342571afebcbb1dc198519a906a825e82db3a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Aug 2014 22:39:40 +0200 Subject: [PATCH 016/127] Trying get rid of modals, new better design for dashboard settings and modals --- src/app/controllers/annotationsEditorCtrl.js | 6 +- src/app/directives/bodyClass.js | 2 +- src/app/directives/configModal.js | 2 +- src/app/panels/filtering/editor.html | 0 src/app/panels/filtering/module.html | 48 ----- src/app/panels/filtering/module.js | 47 ----- src/app/partials/dashboard.html | 2 +- src/app/partials/dasheditor.html | 209 ++++++++++--------- src/app/partials/import.html | 4 +- src/app/partials/templating_editor.html | 58 ++++- src/css/less/bootswatch.dark.less | 5 +- src/css/less/grafana.less | 48 +++++ src/css/less/variables.dark.less | 10 +- 13 files changed, 222 insertions(+), 219 deletions(-) delete mode 100644 src/app/panels/filtering/editor.html delete mode 100755 src/app/panels/filtering/module.html delete mode 100644 src/app/panels/filtering/module.js diff --git a/src/app/controllers/annotationsEditorCtrl.js b/src/app/controllers/annotationsEditorCtrl.js index ce832eee1d4..13cf4d29087 100644 --- a/src/app/controllers/annotationsEditorCtrl.js +++ b/src/app/controllers/annotationsEditorCtrl.js @@ -63,9 +63,13 @@ function (angular, app, _) { }); module.controller('EditViewCtrl', function($scope) { - //$scope.editPanelSrc = 'app/partials/test.html'; + $scope.editPanelSrc = 'app/partials/dasheditor.html'; $scope.onAppEvent('show-edit-panel', function(evt, payload) { + if (payload.src === $scope.editPanelSrc) { + $scope.dismiss(); + return; + } $scope.editPanelSrc = payload.src; }); diff --git a/src/app/directives/bodyClass.js b/src/app/directives/bodyClass.js index 86ff598d69e..0b1cac65614 100644 --- a/src/app/directives/bodyClass.js +++ b/src/app/directives/bodyClass.js @@ -3,7 +3,7 @@ define([ 'app', 'lodash' ], -function (angular, app, _) { +function (angular) { 'use strict'; angular diff --git a/src/app/directives/configModal.js b/src/app/directives/configModal.js index 6ca19cef435..9e65f6cb07c 100644 --- a/src/app/directives/configModal.js +++ b/src/app/directives/configModal.js @@ -20,7 +20,7 @@ function (angular, _, $) { scope.exitFullscreen(); scope.emitAppEvent('show-edit-panel', {src: partial}); }); - return; + //return; if ($(id).length) { elem.attr('data-target', id).attr('data-toggle', 'modal'); diff --git a/src/app/panels/filtering/editor.html b/src/app/panels/filtering/editor.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/app/panels/filtering/module.html b/src/app/panels/filtering/module.html deleted file mode 100755 index 40f4379a98d..00000000000 --- a/src/app/panels/filtering/module.html +++ /dev/null @@ -1,48 +0,0 @@ -
    - -
    - -
    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/src/app/panels/filtering/module.js b/src/app/panels/filtering/module.js deleted file mode 100644 index eb89cebafa0..00000000000 --- a/src/app/panels/filtering/module.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - - ## filtering - -*/ -define([ - 'angular', - 'app', - 'lodash' -], -function (angular, app, _) { - 'use strict'; - - var module = angular.module('grafana.panels.filtering', []); - app.useModule(module); - - module.controller('filtering', function($scope, datasourceSrv, $rootScope, $timeout, $q) { - - $scope.panelMeta = { - status : "Stable", - description : "graphite target filters" - }; - - // Set and populate defaults - var _d = { - }; - _.defaults($scope.panel,_d); - - $scope.init = function() { - // empty. Don't know if I need the function then. - }; - - $scope.remove = function(templateParameter) { - $scope.filter.removeTemplateParameter(templateParameter); - }; - - $scope.add = function() { - $scope.filter.addTemplateParameter({ - type : 'filter', - name : 'filter name', - editing : true, - query : 'metric.path.query.*', - }); - }; - - }); -}); diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 73b23ed12a4..b528c1e1016 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -9,7 +9,7 @@
    -
    +
    diff --git a/src/app/partials/dasheditor.html b/src/app/partials/dasheditor.html index 5179893ea75..3169859da01 100644 --- a/src/app/partials/dasheditor.html +++ b/src/app/partials/dasheditor.html @@ -1,108 +1,119 @@ -