dashfolders: bulk edit tag filtering

Still ugly though
This commit is contained in:
Daniel Lee
2017-10-30 19:34:55 +01:00
parent e85abf6810
commit a366b137a2
3 changed files with 43 additions and 12 deletions
@@ -11,12 +11,12 @@ export class DashboardListCtrl {
/** @ngInject */
constructor(private backendSrv, navModelSrv, private $q) {
this.navModel = navModelSrv.getNav('cfg', 'dashboards');
this.query = '';
this.query = {query: '', mode: 'tree', tag: []};
this.getDashboards();
}
getDashboards() {
return this.backendSrv.get(`/api/search?query=${this.query}&mode=tree`).then((result) => {
return this.backendSrv.search(this.query).then((result) => {
this.dashboards = this.groupDashboardsInFolders(result);
@@ -134,4 +134,22 @@ export class DashboardListCtrl {
model: {dashboards: selectedDashboards, afterSave: this.getDashboards.bind(this)}
});
}
filterByTag(tag, evt) {
this.query.tag.push(tag);
this.getDashboards();
if (evt) {
evt.stopPropagation();
evt.preventDefault();
}
}
removeTag(tag, evt) {
this.query.tag = _.without(this.query.tag, tag);
this.getDashboards();
if (evt) {
evt.stopPropagation();
evt.preventDefault();
}
}
}
@@ -14,11 +14,24 @@
Create Folder
</a>
</div>
<div class="gf-form width-15 gf-form-group">
<span style="position: relative;">
<input type="text" class="gf-form-input" placeholder="Find Dashboard by name" tabindex="1" give-focus="true"
ng-model="ctrl.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="ctrl.getDashboards()" />
</span>
<div class="gf-form-group">
<div class="gf-form-inline">
<div class="gf-form width-15">
<span style="position: relative;">
<input type="text" class="gf-form-input" placeholder="Find Dashboard by name" tabindex="1" give-focus="true"
ng-model="ctrl.query.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="ctrl.getDashboards()" />
</span>
</div>
<div class="gf-form" ng-if="ctrl.query.tag.length">
Filtered by Tags:
<span ng-repeat="tagName in ctrl.query.tag">
<a ng-click="ctrl.removeTag(tagName, $event)" tag-color-from-name="tagName" class="label label-tag">
<i class="fa fa-remove"></i>
{{tagName}}
</a>
</span>
</div>
</div>
</div>
<div class="gf-form-group" ng-if="ctrl.dashboards.length > 1">
@@ -68,7 +81,7 @@
</span>
<span class="search-result-link">
<i class="fa search-result-icon"></i>
<span bo-text="dashboard.title"></span>
<span bo-text="dashboard.title" />
</span>
</a>
</td>
@@ -21,7 +21,7 @@ describe('DashboardListCtrl', () => {
}
];
ctrl = new DashboardListCtrl({get: () => q.resolve(response)}, {getNav: () => {}}, q);
ctrl = new DashboardListCtrl({search: () => q.resolve(response)}, {getNav: () => {}}, q);
return ctrl.getDashboards();
});
@@ -62,7 +62,7 @@ describe('DashboardListCtrl', () => {
folderSlug: "afolder"
}
];
ctrl = new DashboardListCtrl({get: () => q.resolve(response)}, {getNav: () => {}}, null);
ctrl = new DashboardListCtrl({search: () => q.resolve(response)}, {getNav: () => {}}, null);
return ctrl.getDashboards();
});
@@ -78,7 +78,7 @@ describe('DashboardListCtrl', () => {
let ctrl;
beforeEach(() => {
ctrl = new DashboardListCtrl({get: () => q.resolve([])}, {getNav: () => {}}, null);
ctrl = new DashboardListCtrl({search: () => q.resolve([])}, {getNav: () => {}}, null);
});
describe('and no dashboards are selected', () => {
@@ -174,7 +174,7 @@ describe('DashboardListCtrl', () => {
describe('when deleting dashboards', () => {
beforeEach(() => {
ctrl = new DashboardListCtrl({get: () => q.resolve([])}, {getNav: () => {}}, q);
ctrl = new DashboardListCtrl({search: () => q.resolve([])}, {getNav: () => {}}, q);
ctrl.dashboards = [
{id: 1, type: 'dash-folder', checked: true},
{id: 2, type: 'dash-child', checked: true, folderId: 1},