grafana/public/app/features/playlist/playlist_search.ts
Tobias Skarhed c8498461a5 noImplicitAny: Down approx 200 errors (#18143)
* noImplicitAny playlist approx 200

* Add AngularPanelMenuItem interface

* Roughly 100 noImplicitAny
2019-07-18 08:03:04 +02:00

80 lines
1.7 KiB
TypeScript

import coreModule from '../../core/core_module';
import { BackendSrv } from 'app/core/services/backend_srv';
export class PlaylistSearchCtrl {
query: any;
tagsMode: boolean;
searchStarted: any;
/** @ngInject */
constructor($timeout: any, private backendSrv: BackendSrv) {
this.query = { query: '', tag: [], starred: false, limit: 20 };
$timeout(() => {
this.query.query = '';
this.query.type = 'dash-db';
this.searchDashboards();
}, 100);
}
searchDashboards() {
this.tagsMode = false;
const prom: any = {};
prom.promise = this.backendSrv.search(this.query).then(result => {
return {
dashboardResult: result,
tagResult: [],
};
});
this.searchStarted(prom);
}
showStarred() {
this.query.starred = !this.query.starred;
this.searchDashboards();
}
queryHasNoFilters() {
return this.query.query === '' && this.query.starred === false && this.query.tag.length === 0;
}
filterByTag(tag: any, evt: any) {
this.query.tag.push(tag);
this.searchDashboards();
if (evt) {
evt.stopPropagation();
evt.preventDefault();
}
}
getTags() {
const prom: any = {};
prom.promise = this.backendSrv.get('/api/dashboards/tags').then((result: any) => {
return {
dashboardResult: [],
tagResult: result,
} as any;
});
this.searchStarted(prom);
}
}
export function playlistSearchDirective() {
return {
restrict: 'E',
templateUrl: 'public/app/features/playlist/partials/playlist_search.html',
controller: PlaylistSearchCtrl,
bindToController: true,
controllerAs: 'ctrl',
scope: {
searchStarted: '&',
},
};
}
coreModule.directive('playlistSearch', playlistSearchDirective);