From 148c24aa18008fd9ddfe434fc01539e383229b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 3 Aug 2017 10:35:27 +0200 Subject: [PATCH] ux: tweaks to new panel menu --- public/app/features/panel/panel_ctrl.ts | 2 +- public/app/features/panel/panel_header.ts | 5 - public/app/features/panel/panel_menu.js | 164 ---------------------- public/sass/pages/_dashboard.scss | 53 +++++-- 4 files changed, 41 insertions(+), 183 deletions(-) delete mode 100644 public/app/features/panel/panel_menu.js diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index b02520f4c41..b506581e562 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -145,7 +145,7 @@ export class PanelCtrl { menu.push({text: 'Share', click: 'ctrl.sharePanel();', icon: "fa fa-fw fa-share", shortcut: "p s"}); let extendedMenu = this.getExtendedMenu(); - menu.push({text: 'Actions', click: 'ctrl.removePanel();', icon: "fa fa-fw fa-cube", submenu: extendedMenu}); + menu.push({text: 'More ...', click: 'ctrl.removePanel();', icon: "fa fa-fw fa-cube", submenu: extendedMenu}); if (!this.fullscreen) { menu.push({ text: 'Duplicate', click: 'ctrl.duplicate()', role: 'Editor', icon: "fa fa-fw fa-copy" }); diff --git a/public/app/features/panel/panel_header.ts b/public/app/features/panel/panel_header.ts index 1c45367235c..322954be7a1 100644 --- a/public/app/features/panel/panel_header.ts +++ b/public/app/features/panel/panel_header.ts @@ -103,11 +103,6 @@ function panelHeader($compile) { evt.stopPropagation(); elem.find('[data-toggle=dropdown]').dropdown('toggle'); } - - // var toggleAttribute = evt.getAttribute('data-toggle'); - // if (!toggleAttribute) { - // elem.find('[data-toggle=dropdown]').click(); - // } }); } }; diff --git a/public/app/features/panel/panel_menu.js b/public/app/features/panel/panel_menu.js deleted file mode 100644 index d6e414610d4..00000000000 --- a/public/app/features/panel/panel_menu.js +++ /dev/null @@ -1,164 +0,0 @@ -define([ - 'angular', - 'jquery', - 'lodash', - 'tether', -], -function (angular, $, _, Tether) { - 'use strict'; - - angular - .module('grafana.directives') - .directive('panelMenu', function($compile) { - var linkTemplate = - '' + - '' + - '{{ctrl.panel.title | interpolateTemplateVars:this}}' + - '' + - ' {{ctrl.timeInfo}}' + - ''; - - function createMenuTemplate(ctrl) { - var template = '
'; - - if (ctrl.dashboard.meta.canEdit) { - template += '
'; - template += '
'; - if (!ctrl.dashboard.meta.fullscreen) { - template += ''; - template += ''; - } - template += ''; - template += '
'; - template += '
'; - } - - template += '
'; - template += ''; - - _.each(ctrl.getMenu(), function(item) { - // skip edit actions if not editor - if (item.role === 'Editor' && !ctrl.dashboard.meta.canEdit) { - return; - } - - template += ''; - }); - - template += '
'; - template += '
'; - template += '
'; - return template; - } - - function getExtendedMenu(ctrl) { - return ctrl.getExtendedMenu(); - } - - return { - restrict: 'A', - link: function($scope, elem) { - var $link = $(linkTemplate); - var $panelContainer = elem.parents(".panel-container"); - var menuScope = null; - var ctrl = $scope.ctrl; - var timeout = null; - var $menu = null; - var teather; - - elem.append($link); - - function dismiss(time, force) { - clearTimeout(timeout); - timeout = null; - - if (time) { - timeout = setTimeout(dismiss, time); - return; - } - - // if hovering or draging pospone close - if (force !== true) { - if ($menu.is(':hover') || $scope.ctrl.dashboard.$$panelDragging) { - dismiss(2200); - return; - } - } - - if (menuScope) { - teather.destroy(); - $menu.unbind(); - $menu.remove(); - menuScope.$destroy(); - menuScope = null; - $menu = null; - $panelContainer.removeClass('panel-highlight'); - } - } - - var showMenu = function(e) { - if (true) { - return; - } - // if menu item is clicked and menu was just removed from dom ignore this event - if (!$.contains(document, e.target)) { - return; - } - - if ($menu) { - dismiss(); - return; - } - - var menuTemplate; - menuTemplate = createMenuTemplate(ctrl); - - $menu = $(menuTemplate); - $menu.mouseleave(function() { - dismiss(1000); - }); - - menuScope = $scope.$new(); - menuScope.extendedMenu = getExtendedMenu(ctrl); - menuScope.dismiss = function() { - dismiss(null, true); - }; - - $(".panel-container").removeClass('panel-highlight'); - $panelContainer.toggleClass('panel-highlight'); - - $('.panel-menu').remove(); - - elem.append($menu); - - $scope.$apply(function() { - $compile($menu.contents())(menuScope); - - teather = new Tether({ - element: $menu, - target: $panelContainer, - attachment: 'bottom center', - targetAttachment: 'top center', - constraints: [ - { - to: 'window', - attachment: 'together', - pin: true - } - ] - }); - }); - - dismiss(2200); - }; - - elem.click(showMenu); - $compile(elem.contents())($scope); - } - }; - }); -}); diff --git a/public/sass/pages/_dashboard.scss b/public/sass/pages/_dashboard.scss index 67c7dd48a25..bfde03af170 100644 --- a/public/sass/pages/_dashboard.scss +++ b/public/sass/pages/_dashboard.scss @@ -41,7 +41,6 @@ div.flot-text { .panel-container { background-color: $panel-bg; position: relative; - border: $panel-border; &.panel-transparent { background-color: transparent; @@ -55,7 +54,6 @@ div.flot-text { .panel-title-container { min-height: 9px; - padding: 2px 0; cursor: move; word-wrap: break-word; display: block; @@ -67,6 +65,15 @@ div.flot-text { position: relative; width: 100%; display: block; + padding-bottom: 2px; +} + +.panel-title-text { + cursor: pointer; + + &:hover { + color: $link-hover-color; + } } .panel-menu-container { @@ -77,6 +84,17 @@ div.flot-text { color: $text-color-weak; cursor: pointer; padding: 3px 5px; + visibility: hidden; + opacity: 0; + position: absolute; + width: 16px; + height: 16px; + left: 0; + top: 0; + + &:hover { + color: $link-hover-color; + } } .panel-loading { @@ -84,19 +102,16 @@ div.flot-text { top: -3px; right: 0px; z-index: 800; + font-size: $font-size-sm; + color: $text-color-weak; } .panel-header { text-align: center; &:hover { - background: $panel-header-hover-bg; - - .panel-menu-toggle { - color: $text-color; - background: $panel-header-menu-hover-bg; - } - + transition: background-color 0.1s ease-in-out; + background-color: $panel-header-hover-bg; } } @@ -178,9 +193,19 @@ div.flot-text { box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 5px rgba(82,168,236,10.8) } -// .panel-hover-highlight { -// box-shadow: inset 0 1px 1px rgba(0,0,0,0.025), 0 0 1px rgba(82,168,236,0.5) -// } +.panel-hover-highlight { + .panel-menu-toggle { + visibility: visible; + transition: opacity 0.1s ease-in 0.2s; + opacity: 1; + } + + .resize-panel-handle { + visibility: visible; + transition: opacity 0.1s ease-in 0.2s; + opacity: 1; + } +} .on-drag-hover { .panel-container { @@ -190,6 +215,7 @@ div.flot-text { .panel-drop-zone { display: none; + .panel-container { border: $panel-border; display: flex; @@ -227,7 +253,8 @@ div.flot-text { right: 0; width: 15px; height: 15px; - display: block; + visibility: hidden; + opacity: 0; color: $text-color-faint; &:before {