Merge branch 'master' into playlist_tags
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
<span ng-if="ctrl.query.tag.length">
|
<span ng-if="ctrl.query.tag.length">
|
||||||
|
|
|
|
||||||
<span ng-repeat="tagName in ctrl.query.tag">
|
<span ng-repeat="tagName in ctrl.query.tag">
|
||||||
<a ng-click="ctrl.removeTag(tagName, $event)" tag-color-from-name="ctrl.tagName" class="label label-tag">
|
<a ng-click="ctrl.removeTag(tagName, $event)" tag-color-from-name="tagName" class="label label-tag">
|
||||||
<i class="fa fa-remove"></i>
|
<i class="fa fa-remove"></i>
|
||||||
{{tagName}}
|
{{tagName}}
|
||||||
</a>
|
</a>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<div class="search-results-container" ng-if="ctrl.tagsMode">
|
<div class="search-results-container" ng-if="ctrl.tagsMode">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span6 offset1">
|
<div class="span6 offset1">
|
||||||
<div ng-repeat="tag in 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 === 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">
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
ng-class="{'selected': $index == selectedIndex}" ng-href="{{row.url}}">
|
ng-class="{'selected': $index == 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 ctrl.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">
|
||||||
{{tag}}
|
{{tag}}
|
||||||
</span>
|
</span>
|
||||||
<i class="fa" ng-class="{'fa-star': row.isStarred, 'fa-star-o': !row.isStarred}"></i>
|
<i class="fa" ng-class="{'fa-star': row.isStarred, 'fa-star-o': !row.isStarred}"></i>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export class SearchCtrl {
|
|||||||
currentSearchId: number;
|
currentSearchId: number;
|
||||||
tagsMode: boolean;
|
tagsMode: boolean;
|
||||||
showImport: boolean;
|
showImport: boolean;
|
||||||
|
dismiss: 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) {
|
||||||
@@ -32,7 +33,7 @@ export class SearchCtrl {
|
|||||||
|
|
||||||
keyDown(evt) {
|
keyDown(evt) {
|
||||||
if (evt.keyCode === 27) {
|
if (evt.keyCode === 27) {
|
||||||
this.$scope.dismiss();
|
this.dismiss();
|
||||||
}
|
}
|
||||||
if (evt.keyCode === 40) {
|
if (evt.keyCode === 40) {
|
||||||
this.moveSelection(1);
|
this.moveSelection(1);
|
||||||
@@ -107,9 +108,12 @@ export class SearchCtrl {
|
|||||||
|
|
||||||
getTags() {
|
getTags() {
|
||||||
return this.backendSrv.get('/api/dashboards/tags').then((results) => {
|
return this.backendSrv.get('/api/dashboards/tags').then((results) => {
|
||||||
this.tagsMode = true;
|
this.tagsMode = !this.tagsMode;
|
||||||
this.results = results;
|
this.results = results;
|
||||||
this.giveSearchFocus = this.giveSearchFocus + 1;
|
this.giveSearchFocus = this.giveSearchFocus + 1;
|
||||||
|
if ( !this.tagsMode ) {
|
||||||
|
this.search();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,7 +141,9 @@ export function searchDirective() {
|
|||||||
controller: SearchCtrl,
|
controller: SearchCtrl,
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: 'ctrl',
|
controllerAs: 'ctrl',
|
||||||
scope: {},
|
scope: {
|
||||||
|
dismiss: '&'
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
define([
|
define([
|
||||||
'./search_ctrl',
|
|
||||||
'./inspect_ctrl',
|
'./inspect_ctrl',
|
||||||
'./json_editor_ctrl',
|
'./json_editor_ctrl',
|
||||||
'./login_ctrl',
|
'./login_ctrl',
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
define([
|
|
||||||
'angular',
|
|
||||||
'lodash',
|
|
||||||
'../core_module',
|
|
||||||
'app/core/config',
|
|
||||||
],
|
|
||||||
function (angular, _, coreModule, config) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
coreModule.default.controller('SearchCtrl', function($scope, $location, $timeout, backendSrv) {
|
|
||||||
|
|
||||||
$scope.init = function() {
|
|
||||||
$scope.giveSearchFocus = 0;
|
|
||||||
$scope.selectedIndex = -1;
|
|
||||||
$scope.results = [];
|
|
||||||
$scope.query = { query: '', tag: [], starred: false };
|
|
||||||
$scope.currentSearchId = 0;
|
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
||||||
$scope.query.query = '';
|
|
||||||
$scope.search();
|
|
||||||
}, 100);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.keyDown = function (evt) {
|
|
||||||
if (evt.keyCode === 27) {
|
|
||||||
$scope.dismiss();
|
|
||||||
}
|
|
||||||
if (evt.keyCode === 40) {
|
|
||||||
$scope.moveSelection(1);
|
|
||||||
}
|
|
||||||
if (evt.keyCode === 38) {
|
|
||||||
$scope.moveSelection(-1);
|
|
||||||
}
|
|
||||||
if (evt.keyCode === 13) {
|
|
||||||
if ($scope.tagMode) {
|
|
||||||
var tag = $scope.results[$scope.selectedIndex];
|
|
||||||
if (tag) {
|
|
||||||
$scope.filterByTag(tag.term);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectedDash = $scope.results[$scope.selectedIndex];
|
|
||||||
if (selectedDash) {
|
|
||||||
$location.search({});
|
|
||||||
$location.path(selectedDash.url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.moveSelection = function(direction) {
|
|
||||||
var max = ($scope.results || []).length;
|
|
||||||
var newIndex = $scope.selectedIndex + direction;
|
|
||||||
$scope.selectedIndex = ((newIndex %= max) < 0) ? newIndex + max : newIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.searchDashboards = function() {
|
|
||||||
$scope.tagsMode = false;
|
|
||||||
$scope.currentSearchId = $scope.currentSearchId + 1;
|
|
||||||
var localSearchId = $scope.currentSearchId;
|
|
||||||
|
|
||||||
return backendSrv.search($scope.query).then(function(results) {
|
|
||||||
if (localSearchId < $scope.currentSearchId) { return; }
|
|
||||||
|
|
||||||
$scope.results = _.map(results, function(dash) {
|
|
||||||
dash.url = 'dashboard/' + dash.uri;
|
|
||||||
return dash;
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($scope.queryHasNoFilters()) {
|
|
||||||
$scope.results.unshift({ title: 'Home', url: config.appSubUrl + '/', type: 'dash-home' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.queryHasNoFilters = function() {
|
|
||||||
var query = $scope.query;
|
|
||||||
return query.query === '' && query.starred === false && query.tag.length === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.filterByTag = function(tag, evt) {
|
|
||||||
$scope.query.tag.push(tag);
|
|
||||||
$scope.search();
|
|
||||||
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
||||||
if (evt) {
|
|
||||||
evt.stopPropagation();
|
|
||||||
evt.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.removeTag = function(tag, evt) {
|
|
||||||
$scope.query.tag = _.without($scope.query.tag, tag);
|
|
||||||
$scope.search();
|
|
||||||
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
||||||
evt.stopPropagation();
|
|
||||||
evt.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.getTags = function() {
|
|
||||||
return backendSrv.get('/api/dashboards/tags').then(function(results) {
|
|
||||||
$scope.tagsMode = true;
|
|
||||||
$scope.results = results;
|
|
||||||
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.showStarred = function() {
|
|
||||||
$scope.query.starred = !$scope.query.starred;
|
|
||||||
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
||||||
$scope.search();
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.search = function() {
|
|
||||||
$scope.showImport = false;
|
|
||||||
$scope.selectedIndex = 0;
|
|
||||||
$scope.searchDashboards();
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.newDashboard = function() {
|
|
||||||
$location.url('dashboard/new');
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -29,7 +29,7 @@ function (angular, $) {
|
|||||||
editorScope = null;
|
editorScope = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
var view = $('<search class="search-container"></search>');
|
var view = $('<search class="search-container" dismiss="dismiss()"></search>');
|
||||||
|
|
||||||
elem.append(view);
|
elem.append(view);
|
||||||
$compile(elem.contents())(editorScope);
|
$compile(elem.contents())(editorScope);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
|
|||||||
return { status: "success", message: "Data source is working", title: "Success" };
|
return { status: "success", message: "Data source is working", title: "Success" };
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.data && err.data.error) {
|
if (err.data && err.data.error) {
|
||||||
return { status: "error", message: err.data.error, title: "Error" };
|
return { status: "error", message: angular.toJson(err.data.error), title: "Error" };
|
||||||
} else {
|
} else {
|
||||||
return { status: "error", message: err.status, title: "Error" };
|
return { status: "error", message: err.status, title: "Error" };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user