From bd3bae3af0ef5e40b997e004cfdc1f1791fa982f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 23 Sep 2014 10:52:31 +0200 Subject: [PATCH] another attempt at improving panel edit menu --- ' | 79 ++++++++++++++++++++++++++++++ src/app/controllers/row.js | 5 ++ src/app/directives/grafanaPanel.js | 33 ++++++++----- src/app/partials/dashboard.html | 9 ++++ src/css/less/panel.less | 6 ++- 5 files changed, 120 insertions(+), 12 deletions(-) create mode 100644 ' diff --git a/' b/' new file mode 100644 index 00000000000..b22d59592f8 --- /dev/null +++ b/' @@ -0,0 +1,79 @@ +.panel { + display: inline-block; + float: left; + vertical-align: top; +} + +.panel-container { + padding: 0px 0px 0px 0px; + background: @grafanaPanelBackground; + margin: 5px; + position: relative; +} + +.panel-content { + padding: 0px 10px 5px 10px; +} + +.panel-title { + border: 0px; + font-weight: bold; + position: relative; +} + +.panel-loading { + position:absolute; + top: 0px; + right: 4px; + z-index: 800; +} + +.panel-header { + text-align: center; +} + + +.panel-error { + color: @white; + position: absolute; + left: 0; + padding: 0px 17px 6px 5px; + top: 0; + i { + position: relative; + top: -2px; + } +} + +.panel-error-arrow { + width: 0; + height: 0; + position: absolute; + border-left: 31px solid transparent; + border-right: 30px solid transparent; + border-bottom: 27px solid @grafanaPanelBackground; + left: 0; + bottom: 0; +} + +.panel-menu { + display: inline-block; + vertical-align: top; + a { + font-size: 1.2em; + float: left; + padding: 7px 10px; + border-top: 1px solid black; + border-right: 1px solid black; + border-bottom: 1px solid black; + background: @grayDark; + } + a:first-child { + border-left: 1px solid black; + } +} + +.panel-highlight { + border: 1px solid @blue; + .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)"); +} diff --git a/src/app/controllers/row.js b/src/app/controllers/row.js index 621c3eddda5..45287d85e48 100644 --- a/src/app/controllers/row.js +++ b/src/app/controllers/row.js @@ -22,6 +22,11 @@ function (angular, app, _) { $scope.reset_panel(); }; + $scope.togglePanelMenu = function(posX) { + $scope.showPanelMenu = !$scope.showPanelMenu; + $scope.panelMenuPos = posX; + }; + $scope.toggle_row = function(row) { row.collapse = row.collapse ? false : true; if (!row.collapse) { diff --git a/src/app/directives/grafanaPanel.js b/src/app/directives/grafanaPanel.js index ec6048609ea..22c5f539664 100644 --- a/src/app/directives/grafanaPanel.js +++ b/src/app/directives/grafanaPanel.js @@ -27,20 +27,31 @@ function (angular, $) { var $link = $(linkTemplate); elem.append($link); - $link.click(function() { - var $menu = $(menuTemplate); - var menuScope = $scope.$new(); + $link.click(function(e) { + var menuWidth = 452; + var windowWidth = $(window).width(); + var maxPos = windowWidth - menuWidth - 20; + var leftPos = e.screenX - (menuWidth / 2); + leftPos = Math.min(leftPos, maxPos); - elem.append($menu); - $compile($menu.contents())(menuScope); + $scope.$apply(function() { + $scope.togglePanelMenu(leftPos); + }); + elem.parents(".panel-container").toggleClass('panel-highlight'); + console.log(e); +// var $menu = $(menuTemplate); +// var menuScope = $scope.$new(); +// +// elem.append($menu); +// $compile($menu.contents())(menuScope); - setTimeout(function() { - $menu.remove(); - menuScope.$destroy(); - $link.show(); - }, 8000); + // setTimeout(function() { + // $menu.remove(); + // menuScope.$destroy(); + // $link.show(); + // }, 8000); - $link.hide(); + //$link.hide(); }); $compile(elem.contents())($scope); diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 8afe5d40824..2c2ed566c66 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -74,6 +74,15 @@ +
+ view + edit + span + duplicate + share + remove +
+
diff --git a/src/css/less/panel.less b/src/css/less/panel.less index 85f65cd5f16..4dbfb321224 100644 --- a/src/css/less/panel.less +++ b/src/css/less/panel.less @@ -62,7 +62,7 @@ a { font-size: 1.2em; float: left; - padding: 2px 10px; + padding: 7px 10px; border-top: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; @@ -72,3 +72,7 @@ border-left: 1px solid black; } } + +.panel-highlight { + .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236, 0.9)"); +}