From e0a58dd1fec419d60251c96da2623d2955f24832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 27 Aug 2014 10:41:27 +0200 Subject: [PATCH] More work on template editor --- src/app/controllers/annotationsEditorCtrl.js | 1 - src/app/controllers/templateEditorCtrl.js | 19 ++++- src/app/directives/grafanaVersionCheck.js | 2 +- src/app/partials/annotations_editor.html | 1 - src/app/partials/search.html | 3 +- src/app/partials/submenu.html | 6 +- src/app/partials/templating_editor.html | 32 +++++--- src/css/less/grafana.less | 81 +------------------ src/css/less/search.less | 83 ++++++++++++++++++++ src/css/less/tables_lists.less | 29 +++++++ 10 files changed, 155 insertions(+), 102 deletions(-) create mode 100644 src/css/less/search.less create mode 100644 src/css/less/tables_lists.less diff --git a/src/app/controllers/annotationsEditorCtrl.js b/src/app/controllers/annotationsEditorCtrl.js index 371bbad5838..5234e429206 100644 --- a/src/app/controllers/annotationsEditorCtrl.js +++ b/src/app/controllers/annotationsEditorCtrl.js @@ -60,7 +60,6 @@ function (angular, _, $) { }; $scope.add = function() { - $scope.currentAnnotation.datasource = $scope.currentDatasource.name; $scope.annotations.push($scope.currentAnnotation); $scope.reset(); $scope.editor.index = 0; diff --git a/src/app/controllers/templateEditorCtrl.js b/src/app/controllers/templateEditorCtrl.js index 8b9db552625..b81d553eb09 100644 --- a/src/app/controllers/templateEditorCtrl.js +++ b/src/app/controllers/templateEditorCtrl.js @@ -23,6 +23,10 @@ function (angular, _) { $scope.currentDatasource = _.findWhere($scope.datasources, { default: true }); $scope.templateParameters = $scope.filter.templateParameters; $scope.reset(); + + $scope.$watch('editor.index', function(newVal) { + if (newVal !== 2) { $scope.reset(); } + }); }; $scope.add = function() { @@ -31,6 +35,18 @@ function (angular, _) { $scope.reset(); }; + $scope.edit = function(param) { + $scope.current = param; + $scope.currentIsNew = false; + $scope.currentDatasource = _.findWhere($scope.datasources, { name: param.datasource }); + + if (!$scope.currentDatasource) { + $scope.currentDatasource = $scope.datasources[0]; + } + + $scope.editor.index = 2; + }; + $scope.reset = function() { $scope.currentIsNew = true; $scope.current = angular.copy(replacementDefaults); @@ -42,9 +58,6 @@ function (angular, _) { $scope.templateParameters.splice(index, 1); }; - $scope.setDatasource = function() { - }; - }); }); diff --git a/src/app/directives/grafanaVersionCheck.js b/src/app/directives/grafanaVersionCheck.js index cce6d2ea816..487265e26af 100644 --- a/src/app/directives/grafanaVersionCheck.js +++ b/src/app/directives/grafanaVersionCheck.js @@ -11,7 +11,7 @@ function (angular) { restrict: 'A', link: function(scope, elem) { if (grafanaVersion[0] === '@') { - // return; + return; } $http({ method: 'GET', url: 'https://grafanarel.s3.amazonaws.com/latest.json' }) diff --git a/src/app/partials/annotations_editor.html b/src/app/partials/annotations_editor.html index e921354bc72..f6aca707f46 100644 --- a/src/app/partials/annotations_editor.html +++ b/src/app/partials/annotations_editor.html @@ -14,7 +14,6 @@
-
diff --git a/src/app/partials/search.html b/src/app/partials/search.html index c1a030f713d..ad47e68a336 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -49,8 +49,7 @@
No dashboards matching your query were found.
-
diff --git a/src/app/partials/submenu.html b/src/app/partials/submenu.html index 6ed1552db15..4d9d6b10125 100644 --- a/src/app/partials/submenu.html +++ b/src/app/partials/submenu.html @@ -36,8 +36,10 @@
  • - - {{annotation.name}} + + + {{annotation.name}} +
  • diff --git a/src/app/partials/templating_editor.html b/src/app/partials/templating_editor.html index 40864ab5df8..ef91bcf285d 100644 --- a/src/app/partials/templating_editor.html +++ b/src/app/partials/templating_editor.html @@ -15,23 +15,28 @@
    -
    -
    +
    +
    No replacements defined
    -
    +
    - - + + - @@ -41,7 +46,7 @@ -
    +
    @@ -53,7 +58,7 @@
    - +
    @@ -64,13 +69,14 @@
    - diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index fcb8380e565..e9184ac41c2 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -2,6 +2,8 @@ @import "graph.less"; @import "console.less"; @import "bootstrap-tagsinput.less"; +@import "tables_lists.less"; +@import "search.less"; .hide-controls { padding: 0; @@ -32,85 +34,6 @@ } } -// Search -.grafana-search-panel { - .search-field-wrapper { - padding: 6px 10px; - input { - width: 100%; - } - button { - margin: 0 4px 0 0; - } - > span { - display: block; - overflow: hidden; - padding-right: 25px; - } - } -} - -.search-results-container { - height: 500px; - overflow: auto; - display: block; - line-height: 28px; - - .search-result-item:hover, .search-result-item.selected { - .search-result-link, .search-result-link > .icon { - color: @grafanaListHighlight; - } - .search-result-tag { - opacity: 0.70; - color: white; - } - } - - .search-result-link { - color: @grafanaListMainLinkColor; - .icon { - padding-right: 10px; - color: @grafanaListHighlightContrast; - } - } - - .search-result-item:nth-child(odd) { - background-color: lighten(@grayDarker, 2%); - } - - .search-result-item { - padding: 0px 10px; - white-space: nowrap; - border-bottom: 1px solid @grafanaListBorderBottom; - border-top: 1px solid @grafanaListBorderTop; - border-left: 1px solid @grafanaListBorderBottom; - } - - .search-result-tags { - float: right; - .label-tag { - margin-left: 6px; - font-size: 11px; - padding: 2px 6px; - } - } - - .search-result-actions { - float: right; - padding-left: 20px; - } -} - -.search-tagview-switch { - position: absolute; - top: 6px; - right: 24px; - color: darken(@linkColor, 30%); - &.active { - color: @linkColor; - } -} - .row-button { width: 24px; } diff --git a/src/css/less/search.less b/src/css/less/search.less new file mode 100644 index 00000000000..7302d7ea7a7 --- /dev/null +++ b/src/css/less/search.less @@ -0,0 +1,83 @@ +// Search +.grafana-search-panel { + .search-field-wrapper { + padding: 6px 10px; + input { + width: 100%; + } + button { + margin: 0 4px 0 0; + } + > span { + display: block; + overflow: hidden; + padding-right: 25px; + } + } +} + +.search-results-container { + height: 500px; + overflow: auto; + display: block; + line-height: 28px; + + .search-result-item:hover, .search-result-item.selected { + .search-result-link, .search-result-link > .icon { + color: @grafanaListHighlight; + } + } + + .selected { + .search-result-tag { + opacity: 0.70; + color: white; + } + } + + .search-result-link { + color: @grafanaListMainLinkColor; + .icon { + padding-right: 10px; + color: @grafanaListHighlightContrast; + } + } + + .search-result-item:nth-child(odd) { + background-color: lighten(@grayDarker, 2%); + } + + .search-result-item { + padding: 0px 10px; + white-space: nowrap; + border-bottom: 1px solid @grafanaListBorderBottom; + border-top: 1px solid @grafanaListBorderTop; + border-left: 1px solid @grafanaListBorderBottom; + } + + .search-result-tags { + float: right; + .label-tag { + margin-left: 6px; + font-size: 11px; + padding: 2px 6px; + } + } + + .search-result-actions { + float: right; + padding-left: 20px; + } +} + +.search-tagview-switch { + position: absolute; + top: 6px; + right: 24px; + color: darken(@linkColor, 30%); + &.active { + color: @linkColor; + } +} + + diff --git a/src/css/less/tables_lists.less b/src/css/less/tables_lists.less new file mode 100644 index 00000000000..29896b02e47 --- /dev/null +++ b/src/css/less/tables_lists.less @@ -0,0 +1,29 @@ +.grafana-options-table { + width: 100%; + + tr:nth-child(odd) td { + background-color: lighten(@grayDarker, 2%); + } + + td { + padding: 5px 10px; + white-space: nowrap; + border-bottom: 1px solid @grafanaListBorderBottom; + border-top: 1px solid @grafanaListBorderTop; + } + + td:first-child { + border-left: 1px solid @grafanaListBorderBottom; + } + + td:last-child { + border-right: 1px solid @grafanaListBorderBottom; + } + + .max-width { + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + white-space: nowrap; + } +}
    {{templateParam.name}}{{templateParam.query}} - + {{templateParam.name}} + + {{templateParam.query}} + + + Edit - - Remove + + +