From cacbcb9c99a92ae583ac93193d3e7c401f7ef9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 13 Dec 2017 11:29:29 +0100 Subject: [PATCH] ux: added search box to ds list page, closes #10106 --- public/app/features/plugins/ds_list_ctrl.ts | 22 ++++++++----------- .../features/plugins/partials/ds_list.html | 10 +++++++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/public/app/features/plugins/ds_list_ctrl.ts b/public/app/features/plugins/ds_list_ctrl.ts index ce9047166ef..a6f3333a15b 100644 --- a/public/app/features/plugins/ds_list_ctrl.ts +++ b/public/app/features/plugins/ds_list_ctrl.ts @@ -1,35 +1,31 @@ -/// - import coreModule from '../../core/core_module'; -import {appEvents} from 'app/core/core'; +import _ from 'lodash'; export class DataSourcesCtrl { datasources: any; + unfiltered: any; navModel: any; + searchQuery: string; /** @ngInject */ constructor( private $scope, private backendSrv, private datasourceSrv, - private $location, private navModelSrv) { this.navModel = this.navModelSrv.getNav('cfg', 'datasources', 0); - this.navigateToUrl = this.navigateToUrl.bind(this); backendSrv.get('/api/datasources').then(result => { this.datasources = result; - }); - - appEvents.on('location-change', payload => { - this.navigateToUrl(payload.href); + this.unfiltered = result; }); } - navigateToUrl(url) { - // debugger; - this.$location.path(url); - this.$location.replace(); + onQueryUpdated() { + let regex = new RegExp(this.searchQuery, 'ig'); + this.datasources = _.filter(this.unfiltered, item => { + return regex.test(item.name) || regex.test(item.type); + }); } removeDataSourceConfirmed(ds) { diff --git a/public/app/features/plugins/partials/ds_list.html b/public/app/features/plugins/partials/ds_list.html index b645096960c..401eb4eac6c 100644 --- a/public/app/features/plugins/partials/ds_list.html +++ b/public/app/features/plugins/partials/ds_list.html @@ -1,9 +1,15 @@