mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(search); fixes to dashboard search (using keyboard), and fix for singlestat in snapshot view
This commit is contained in:
@@ -187,13 +187,17 @@ export function grafanaAppDirective(playlistSrv) {
|
|||||||
// hide search
|
// hide search
|
||||||
if (elem.find('.search-container').length > 0) {
|
if (elem.find('.search-container').length > 0) {
|
||||||
if (target.parents('.search-container').length === 0) {
|
if (target.parents('.search-container').length === 0) {
|
||||||
scope.appEvent('hide-dash-search');
|
scope.$apply(function() {
|
||||||
|
scope.appEvent('hide-dash-search');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// hide sidemenu
|
// hide sidemenu
|
||||||
if (!ignoreSideMenuHide && !scope.contextSrv.pinned && elem.find('.sidemenu').length > 0) {
|
if (!ignoreSideMenuHide && !scope.contextSrv.pinned && elem.find('.sidemenu').length > 0) {
|
||||||
if (target.parents('.sidemenu').length === 0) {
|
if (target.parents('.sidemenu').length === 0) {
|
||||||
scope.$apply(() => scope.contextSrv.toggleSideMenu());
|
scope.$apply(function() {
|
||||||
|
scope.contextSrv.toggleSideMenu();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<div class="search-container" ng-if="ctrl.isOpen">
|
||||||
<div class="search-field-wrapper">
|
<div class="search-field-wrapper">
|
||||||
<span style="position: relative;">
|
<span style="position: relative;">
|
||||||
<input type="text" placeholder="Find dashboards by name" give-focus="ctrl.giveSearchFocus" tabindex="1"
|
<input type="text" placeholder="Find dashboards by name" give-focus="ctrl.giveSearchFocus" tabindex="1"
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span6 offset1">
|
<div class="span6 offset1">
|
||||||
<div ng-repeat="tag in ctrl.results" class="pointer" style="width: 180px; float: left;"
|
<div ng-repeat="tag in ctrl.results" class="pointer" style="width: 180px; float: left;"
|
||||||
ng-class="{'selected': $index === selectedIndex }"
|
ng-class="{'selected': $index === ctrl.selectedIndex }"
|
||||||
ng-click="ctrl.filterByTag(tag.term, $event)">
|
ng-click="ctrl.filterByTag(tag.term, $event)">
|
||||||
<a class="search-result-tag label label-tag" tag-color-from-name="tag.term">
|
<a class="search-result-tag label label-tag" tag-color-from-name="tag.term">
|
||||||
<i class="fa fa-tag"></i>
|
<i class="fa fa-tag"></i>
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>
|
<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>
|
||||||
|
|
||||||
<a class="search-item pointer search-item-{{row.type}}" bindonce ng-repeat="row in ctrl.results"
|
<a class="search-item pointer search-item-{{row.type}}" bindonce ng-repeat="row in ctrl.results"
|
||||||
ng-class="{'selected': $index == selectedIndex}" ng-href="{{row.url}}">
|
ng-class="{'selected': $index == ctrl.selectedIndex}" ng-href="{{row.url}}">
|
||||||
|
|
||||||
<span class="search-result-tags">
|
<span class="search-result-tags">
|
||||||
<span ng-click="ctrl.filterByTag(tag, $event)" ng-repeat="tag in row.tags" tag-color-from-name="tag" class="label label-tag">
|
<span ng-click="ctrl.filterByTag(tag, $event)" ng-repeat="tag in row.tags" tag-color-from-name="tag" class="label label-tag">
|
||||||
@@ -71,4 +72,4 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import $ from 'jquery';
|
|||||||
import coreModule from '../../core_module';
|
import coreModule from '../../core_module';
|
||||||
|
|
||||||
export class SearchCtrl {
|
export class SearchCtrl {
|
||||||
|
isOpen: boolean;
|
||||||
query: any;
|
query: any;
|
||||||
giveSearchFocus: number;
|
giveSearchFocus: number;
|
||||||
selectedIndex: number;
|
selectedIndex: number;
|
||||||
@@ -15,16 +16,34 @@ export class SearchCtrl {
|
|||||||
tagsMode: boolean;
|
tagsMode: boolean;
|
||||||
showImport: boolean;
|
showImport: boolean;
|
||||||
dismiss: any;
|
dismiss: any;
|
||||||
|
ignoreClose: any;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
constructor(private $scope, private $location, private $timeout, private backendSrv, private contextSrv) {
|
constructor(private $scope, private $location, private $timeout, private backendSrv, private contextSrv, private $rootScope) {
|
||||||
|
$rootScope.onAppEvent('show-dash-search', this.openSearch.bind(this), $scope);
|
||||||
|
$rootScope.onAppEvent('hide-dash-search', this.closeSearch.bind(this), $scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeSearch() {
|
||||||
|
this.isOpen = this.ignoreClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
openSearch() {
|
||||||
|
if (this.isOpen) {
|
||||||
|
this.isOpen = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isOpen = true;
|
||||||
this.giveSearchFocus = 0;
|
this.giveSearchFocus = 0;
|
||||||
this.selectedIndex = -1;
|
this.selectedIndex = -1;
|
||||||
this.results = [];
|
this.results = [];
|
||||||
this.query = { query: '', tag: [], starred: false };
|
this.query = { query: '', tag: [], starred: false };
|
||||||
this.currentSearchId = 0;
|
this.currentSearchId = 0;
|
||||||
|
this.ignoreClose = true;
|
||||||
|
|
||||||
$timeout(() => {
|
this.$timeout(() => {
|
||||||
|
this.ignoreClose = false;
|
||||||
this.giveSearchFocus = this.giveSearchFocus + 1;
|
this.giveSearchFocus = this.giveSearchFocus + 1;
|
||||||
this.query.query = '';
|
this.query.query = '';
|
||||||
this.search();
|
this.search();
|
||||||
@@ -33,7 +52,7 @@ export class SearchCtrl {
|
|||||||
|
|
||||||
keyDown(evt) {
|
keyDown(evt) {
|
||||||
if (evt.keyCode === 27) {
|
if (evt.keyCode === 27) {
|
||||||
this.dismiss();
|
this.closeSearch();
|
||||||
}
|
}
|
||||||
if (evt.keyCode === 40) {
|
if (evt.keyCode === 40) {
|
||||||
this.moveSelection(1);
|
this.moveSelection(1);
|
||||||
@@ -141,10 +160,7 @@ export function searchDirective() {
|
|||||||
controller: SearchCtrl,
|
controller: SearchCtrl,
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: 'ctrl',
|
controllerAs: 'ctrl',
|
||||||
scope: {
|
|
||||||
dismiss: '&'
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
coreModule.directive('search', searchDirective);
|
coreModule.directive('dashboardSearch', searchDirective);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ define([
|
|||||||
'./viewStateSrv',
|
'./viewStateSrv',
|
||||||
'./timeSrv',
|
'./timeSrv',
|
||||||
'./unsavedChangesSrv',
|
'./unsavedChangesSrv',
|
||||||
'./directives/dashSearchView',
|
|
||||||
'./timepicker/timepicker',
|
'./timepicker/timepicker',
|
||||||
'./graphiteImportCtrl',
|
'./graphiteImportCtrl',
|
||||||
'./dynamicDashboardSrv',
|
'./dynamicDashboardSrv',
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
define([
|
|
||||||
'angular',
|
|
||||||
'jquery'
|
|
||||||
],
|
|
||||||
function (angular, $) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
angular
|
|
||||||
.module('grafana.directives')
|
|
||||||
.directive('dashSearchView', function($compile) {
|
|
||||||
return {
|
|
||||||
restrict: 'A',
|
|
||||||
link: function(scope, elem) {
|
|
||||||
var editorScope;
|
|
||||||
var ignoreHide;
|
|
||||||
|
|
||||||
function showSearch() {
|
|
||||||
if (editorScope) {
|
|
||||||
editorScope.dismiss();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ignoreHide = true;
|
|
||||||
editorScope = scope.$new();
|
|
||||||
editorScope.dismiss = function() {
|
|
||||||
editorScope.$destroy();
|
|
||||||
elem.empty();
|
|
||||||
elem.unbind();
|
|
||||||
editorScope = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
var view = $('<search class="search-container" dismiss="dismiss()"></search>');
|
|
||||||
|
|
||||||
elem.append(view);
|
|
||||||
$compile(elem.contents())(editorScope);
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
ignoreHide = false;
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideSearch() {
|
|
||||||
if (editorScope && !ignoreHide) {
|
|
||||||
editorScope.dismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scope.onAppEvent('show-dash-search', showSearch);
|
|
||||||
scope.onAppEvent('hide-dash-search', hideSearch);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="main-view-container">
|
<div class="main-view-container">
|
||||||
|
|
||||||
<div dash-editor-view></div>
|
<div dash-editor-view></div>
|
||||||
<div dash-search-view></div>
|
<dashboard-search></dashboard-search>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
<dashboard-submenu ng-if="submenuEnabled" dashboard="dashboard"></dashboard-submenu>
|
<dashboard-submenu ng-if="submenuEnabled" dashboard="dashboard"></dashboard-submenu>
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadSnapshot(snapshotData) {
|
loadSnapshot(snapshotData) {
|
||||||
this.dataHandler(snapshotData);
|
// give element time to get attached and get dimensions
|
||||||
|
this.$timeout(() => this.dataHandler(snapshotData), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataHandler(results) {
|
dataHandler(results) {
|
||||||
@@ -239,22 +240,13 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
|||||||
var $timeout = this.$timeout;
|
var $timeout = this.$timeout;
|
||||||
var panel = ctrl.panel;
|
var panel = ctrl.panel;
|
||||||
var templateSrv = this.templateSrv;
|
var templateSrv = this.templateSrv;
|
||||||
var data, linkInfo, $panelContainer;
|
var data, linkInfo;
|
||||||
var firstRender = true;
|
var $panelContainer = elem.parents('.panel-container');
|
||||||
|
// change elem to singlestat panel
|
||||||
|
elem = elem.find('.singlestat-panel');
|
||||||
|
hookupDrilldownLinkTooltip();
|
||||||
|
|
||||||
scope.$on('render', function() {
|
scope.$on('render', function() {
|
||||||
if (firstRender) {
|
|
||||||
var inner = elem.find('.singlestat-panel');
|
|
||||||
if (inner.length) {
|
|
||||||
elem = inner;
|
|
||||||
$panelContainer = elem.parents('.panel-container');
|
|
||||||
firstRender = false;
|
|
||||||
hookupDrilldownLinkTooltip();
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render();
|
render();
|
||||||
ctrl.renderingCompleted();
|
ctrl.renderingCompleted();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,6 +70,11 @@
|
|||||||
top: 20%;
|
top: 20%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.grafana-app {
|
||||||
|
display: block;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.histogram-chart {
|
.histogram-chart {
|
||||||
position:relative;
|
position:relative;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body ng-cloak>
|
<body ng-cloak>
|
||||||
<grafana-app>
|
<grafana-app class="grafana-app">
|
||||||
|
|
||||||
<aside class="sidemenu-wrapper">
|
<aside class="sidemenu-wrapper">
|
||||||
<sidemenu ng-if="contextSrv.sidemenu"></sidemenu>
|
<sidemenu ng-if="contextSrv.sidemenu"></sidemenu>
|
||||||
|
|||||||
Reference in New Issue
Block a user