mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
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"></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);
|
|
}
|
|
};
|
|
});
|
|
|
|
});
|