mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixed dashboard search dropdown issue where it closes dashboard settings view if open, also fixed so that clicking outside dashboard search will close it, Fixes #1489
This commit is contained in:
@@ -2,9 +2,8 @@ define([
|
|||||||
'angular',
|
'angular',
|
||||||
'lodash',
|
'lodash',
|
||||||
'config',
|
'config',
|
||||||
'jquery'
|
|
||||||
],
|
],
|
||||||
function (angular, _, config, $) {
|
function (angular, _, config) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
@@ -29,7 +28,7 @@ function (angular, _, config, $) {
|
|||||||
|
|
||||||
$scope.keyDown = function (evt) {
|
$scope.keyDown = function (evt) {
|
||||||
if (evt.keyCode === 27) {
|
if (evt.keyCode === 27) {
|
||||||
$scope.appEvent('hide-dash-editor');
|
$scope.dismiss();
|
||||||
}
|
}
|
||||||
if (evt.keyCode === 40) {
|
if (evt.keyCode === 40) {
|
||||||
$scope.moveSelection(1);
|
$scope.moveSelection(1);
|
||||||
@@ -50,9 +49,6 @@ function (angular, _, config, $) {
|
|||||||
if (selectedDash) {
|
if (selectedDash) {
|
||||||
$location.search({});
|
$location.search({});
|
||||||
$location.path("/dashboard/db/" + selectedDash.slug);
|
$location.path("/dashboard/db/" + selectedDash.slug);
|
||||||
setTimeout(function() {
|
|
||||||
$('body').click(); // hack to force dropdown to close;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -118,5 +118,4 @@ function (angular, $) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ define([
|
|||||||
'./playlistSrv',
|
'./playlistSrv',
|
||||||
'./timeSrv',
|
'./timeSrv',
|
||||||
'./unsavedChangesSrv',
|
'./unsavedChangesSrv',
|
||||||
|
'./directives/dashSearchView',
|
||||||
], function () {});
|
], function () {});
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function (angular, _, moment, config, store) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.openSearch = function() {
|
$scope.openSearch = function() {
|
||||||
$scope.appEvent('show-dash-editor', { src: 'app/partials/search.html', cssClass: 'search-container' });
|
$scope.appEvent('show-dash-search');
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.saveDashboard = function() {
|
$scope.saveDashboard = function() {
|
||||||
|
|||||||
62
src/app/features/dashboard/directives/dashSearchView.js
Normal file
62
src/app/features/dashboard/directives/dashSearchView.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
define([
|
||||||
|
'angular',
|
||||||
|
'jquery'
|
||||||
|
],
|
||||||
|
function (angular, $) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular
|
||||||
|
.module('grafana.directives')
|
||||||
|
.directive('dashSearchView', function($compile, $timeout) {
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
link: function(scope, elem) {
|
||||||
|
var editorScope;
|
||||||
|
|
||||||
|
function hookUpHideWhenClickedOutside() {
|
||||||
|
$timeout(function() {
|
||||||
|
$(document).bind('click.hide-search', function(evt) {
|
||||||
|
// some items can be inside container
|
||||||
|
// but then removed
|
||||||
|
if ($(evt.target).parents().length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(evt.target).parents('.search-container').length === 0) {
|
||||||
|
if (editorScope) {
|
||||||
|
editorScope.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSearch() {
|
||||||
|
if (editorScope) {
|
||||||
|
editorScope.dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
editorScope = scope.$new();
|
||||||
|
editorScope.dismiss = function() {
|
||||||
|
editorScope.$destroy();
|
||||||
|
elem.empty();
|
||||||
|
elem.unbind();
|
||||||
|
editorScope = null;
|
||||||
|
$(document).unbind('click.hide-search');
|
||||||
|
};
|
||||||
|
|
||||||
|
var view = $('<div class="search-container" ng-include="\'app/partials/search.html\'"></div>');
|
||||||
|
|
||||||
|
elem.append(view);
|
||||||
|
$compile(elem.contents())(editorScope);
|
||||||
|
|
||||||
|
hookUpHideWhenClickedOutside();
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.onAppEvent('show-dash-search', showSearch);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -40,7 +40,7 @@ function(angular, $) {
|
|||||||
}, { inputDisabled: true });
|
}, { inputDisabled: true });
|
||||||
|
|
||||||
keyboardManager.bind('ctrl+f', function() {
|
keyboardManager.bind('ctrl+f', function() {
|
||||||
scope.appEvent('show-dash-editor', { src: 'app/partials/search.html', cssClass: 'search-container' });
|
scope.appEvent('show-dash-search');
|
||||||
}, { inputDisabled: true });
|
}, { inputDisabled: true });
|
||||||
|
|
||||||
keyboardManager.bind('ctrl+o', function() {
|
keyboardManager.bind('ctrl+o', function() {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
<div dash-editor-view>
|
<div dash-editor-view></div>
|
||||||
</div>
|
<div dash-search-view></div>
|
||||||
|
|
||||||
<div class="main-view-container">
|
<div class="main-view-container">
|
||||||
<div class="grafana-row" ng-controller="RowCtrl" ng-repeat="(row_name, row) in dashboard.rows" row-height>
|
<div class="grafana-row" ng-controller="RowCtrl" ng-repeat="(row_name, row) in dashboard.rows" row-height>
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
</span>
|
</span>
|
||||||
<div class="search-switches">
|
<div class="search-switches">
|
||||||
<i class="fa fa-filter"></i>
|
<i class="fa fa-filter"></i>
|
||||||
<a class="pointer" href="javascript:void();" ng-click="showStarred()" tabindex="2">
|
<a class="pointer" href="javascript:void 0;" ng-click="showStarred()" tabindex="2">
|
||||||
<i class="fa fa-remove" ng-show="query.starred"></i>
|
<i class="fa fa-remove" ng-show="query.starred"></i>
|
||||||
starred
|
starred
|
||||||
</a> |
|
</a> |
|
||||||
<a class="pointer" href="javascript:void();" ng-click="showTags()" tabindex="3">
|
<a class="pointer" href="javascript:void 0;" ng-click="showTags()" tabindex="3">
|
||||||
<i class="fa fa-remove" ng-show="query.tagcloud"></i>
|
<i class="fa fa-remove" ng-show="query.tagcloud"></i>
|
||||||
tags
|
tags
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ blockquote {
|
|||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
||||||
html {
|
html {
|
||||||
min-height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
min-height: 100%;
|
height: 100%;
|
||||||
//#gradient > .vertical (@bodyBackground, #252A30);
|
//#gradient > .vertical (@bodyBackground, #252A30);
|
||||||
//background: @bodyBackground;
|
//background: @bodyBackground;
|
||||||
background: @bodyBackground;
|
background: @bodyBackground;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.gf-box.search-container {
|
.search-container {
|
||||||
left: 52px;
|
left: 52px;
|
||||||
top: 33px;
|
top: 33px;
|
||||||
margin: 15px;
|
margin: 15px;
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
width: 700px;
|
width: 700px;
|
||||||
box-shadow: 0px 0px 55px 0px black;
|
box-shadow: 0px 0px 55px 0px black;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
background-color: @grafanaPanelBackground;
|
||||||
|
border: 1px solid @grafanaTargetFuncBackground;
|
||||||
|
|
||||||
.label-tag {
|
.label-tag {
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
|
|||||||
Reference in New Issue
Block a user