From cae852a1a2def127724ea61306eb86f2cac1fb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 27 Oct 2017 08:33:04 +0200 Subject: [PATCH 1/4] updated icons --- pkg/api/index.go | 12 ++--- .../dashboard/dashgrid/AddPanelPanel.tsx | 2 +- public/img/icn-row.svg | 25 ++++++++++ .../img/icons_dark_theme/icon_add_folder.svg | 17 +++---- .../icons_dark_theme/icon_data_sources.svg | 15 ++++++ .../icon_import_dashboard.svg | 46 +++++++++---------- .../icons_dark_theme/icon_new_dashboard.svg | 41 ++++++++--------- .../icons_light_theme/icon_data_sources.svg | 15 ++++++ .../icon_import_dashboard.svg | 44 +++++++++--------- .../icons_light_theme/icon_new_dashboard.svg | 41 ++++++++--------- public/sass/base/_icons.scss | 4 ++ 11 files changed, 156 insertions(+), 106 deletions(-) create mode 100644 public/img/icn-row.svg create mode 100644 public/img/icons_dark_theme/icon_data_sources.svg create mode 100644 public/img/icons_light_theme/icon_data_sources.svg diff --git a/pkg/api/index.go b/pkg/api/index.go index 01e85f92654..4a94a418c8e 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -104,6 +104,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { {Text: "Home", Url: setting.AppSubUrl + "/", Icon: "fa fa-fw fa-home"}, {Text: "Playlists", Id: "playlists", Url: setting.AppSubUrl + "/playlists", Icon: "fa fa-fw fa-film"}, {Text: "Snapshots", Id: "snapshots", Url: setting.AppSubUrl + "/dashboard/snapshots", Icon: "icon-gf icon-gf-fw icon-gf-snapshot"}, + {Text: "Dashboard List", Description: "Manage Dashboards And Folders", Id: "dashboards", Url: setting.AppSubUrl + "/dashboards", Icon: "fa fa-fw fa-bars"}, } data.NavTree = append(data.NavTree, &dtos.NavLink{ @@ -208,21 +209,16 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { Children: []*dtos.NavLink{ { Text: "Data Sources", - Icon: "icon-gf icon-gf-fw icon-gf-datasources", + Icon: "gicon gicon-datasources", Description: "Add and configure data sources", Id: "datasources", Url: setting.AppSubUrl + "/datasources", Children: []*dtos.NavLink{ - {Text: "List", Url: setting.AppSubUrl + "/datasources", Icon: "icon-gf icon-gf-datasources"}, + {Text: "List", Url: setting.AppSubUrl + "/datasources", Icon: "gicon gicon-datasources"}, {Text: "New", Url: setting.AppSubUrl + "/datasources", Icon: "fa fa-fw fa-plus"}, }, }, - { - Text: "Dashboard List", - Description: "Manage Dashboards And Folders", - Id: "dashboards", - Url: setting.AppSubUrl + "/dashboards", - }, + { Text: "Preferences", Id: "org", diff --git a/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx b/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx index 5b03cb8af54..8415d9c14b2 100644 --- a/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx +++ b/public/app/features/dashboard/dashgrid/AddPanelPanel.tsx @@ -34,7 +34,7 @@ export class AddPanelPanel extends React.Component + + + + + + + + + + + + + + + + + + + diff --git a/public/img/icons_dark_theme/icon_add_folder.svg b/public/img/icons_dark_theme/icon_add_folder.svg index 3eddd5ddc5d..0e3357d1086 100644 --- a/public/img/icons_dark_theme/icon_add_folder.svg +++ b/public/img/icons_dark_theme/icon_add_folder.svg @@ -7,11 +7,12 @@ .st1{fill:url(#SVGID_1_);} - - - + + + @@ -21,8 +22,8 @@ - + diff --git a/public/img/icons_dark_theme/icon_data_sources.svg b/public/img/icons_dark_theme/icon_data_sources.svg new file mode 100644 index 00000000000..5cce28eb217 --- /dev/null +++ b/public/img/icons_dark_theme/icon_data_sources.svg @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/public/img/icons_dark_theme/icon_import_dashboard.svg b/public/img/icons_dark_theme/icon_import_dashboard.svg index 20b3e6c27e8..d21511c31c5 100644 --- a/public/img/icons_dark_theme/icon_import_dashboard.svg +++ b/public/img/icons_dark_theme/icon_import_dashboard.svg @@ -3,30 +3,28 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/public/img/icons_dark_theme/icon_new_dashboard.svg b/public/img/icons_dark_theme/icon_new_dashboard.svg index a7927425ba5..33f116dcab1 100644 --- a/public/img/icons_dark_theme/icon_new_dashboard.svg +++ b/public/img/icons_dark_theme/icon_new_dashboard.svg @@ -7,27 +7,26 @@ .st1{fill:url(#SVGID_1_);} - - - - - - - - - - - - - + + + + + + + + + + + + + - + diff --git a/public/img/icons_light_theme/icon_data_sources.svg b/public/img/icons_light_theme/icon_data_sources.svg new file mode 100644 index 00000000000..3a6e65e8761 --- /dev/null +++ b/public/img/icons_light_theme/icon_data_sources.svg @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/public/img/icons_light_theme/icon_import_dashboard.svg b/public/img/icons_light_theme/icon_import_dashboard.svg index 3a83c0fe829..d1b5f2fe17e 100644 --- a/public/img/icons_light_theme/icon_import_dashboard.svg +++ b/public/img/icons_light_theme/icon_import_dashboard.svg @@ -6,27 +6,25 @@ .st0{fill:#555555;} .st1{fill:url(#SVGID_1_);} - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/public/img/icons_light_theme/icon_new_dashboard.svg b/public/img/icons_light_theme/icon_new_dashboard.svg index 68c24e648d4..9ed93e4732b 100644 --- a/public/img/icons_light_theme/icon_new_dashboard.svg +++ b/public/img/icons_light_theme/icon_new_dashboard.svg @@ -7,27 +7,26 @@ .st1{fill:url(#SVGID_1_);} - - - - - - - - - - - - - + + + + + + + + + + + + + - + diff --git a/public/sass/base/_icons.scss b/public/sass/base/_icons.scss index e3361e9e9e5..3769ea4ff92 100644 --- a/public/sass/base/_icons.scss +++ b/public/sass/base/_icons.scss @@ -15,6 +15,10 @@ background-image: url('../img/icons_#{$theme-name}_theme/icon_alert.svg'); } +.gicon-datasources { + background-image: url('../img/icons_#{$theme-name}_theme/icon_data_sources.svg'); +} + .gicon-dashboard { background-image: url('../img/icons_#{$theme-name}_theme/icon_dashboard.svg'); } From 752453f204420e4fcfcd756ca5b911ec9ed4ecfd Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Sun, 29 Oct 2017 20:20:51 +0100 Subject: [PATCH 2/4] dashboards: fix link to bulk edit --- pkg/api/index.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/api/index.go b/pkg/api/index.go index 4a94a418c8e..41fff516f2d 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -218,7 +218,12 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { {Text: "New", Url: setting.AppSubUrl + "/datasources", Icon: "fa fa-fw fa-plus"}, }, }, - + { + Text: "Dashboard List", + Description: "Manage Dashboards And Folders", + Id: "dashboards", + Url: setting.AppSubUrl + "/dashboards", + }, { Text: "Preferences", Id: "org", From e85abf681083b54aa9db4040c95b27b1719412d2 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Sun, 29 Oct 2017 22:08:26 +0100 Subject: [PATCH 3/4] dashboards: bulk edit delete If both a parent folder and a child is chosen then only sends the parent folder for deletion as the child folder will be deleted anyway. --- .../features/dashboard/dashboard_list_ctrl.ts | 22 ++++++++++++++++++- .../specs/dashboard_list_ctrl.jest.ts | 22 +++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard/dashboard_list_ctrl.ts b/public/app/features/dashboard/dashboard_list_ctrl.ts index 232d8d7bb22..4522a53e81d 100644 --- a/public/app/features/dashboard/dashboard_list_ctrl.ts +++ b/public/app/features/dashboard/dashboard_list_ctrl.ts @@ -81,8 +81,28 @@ export class DashboardListCtrl { this.canMove = selectedDashboards > 0 && selectedFolders === 0; } + getDashboardsToDelete() { + const selectedFolderIds = this.getFolderIds(this.dashboards); + return _.filter(this.dashboards, o => { + return o.checked && ( + o.type !== 'dash-child' || + (o.type === 'dash-child' && !_.includes(selectedFolderIds, o.folderId)) + ); + }); + } + + getFolderIds(dashboards) { + const ids = []; + for (let dash of dashboards) { + if (dash.type === 'dash-folder') { + ids.push(dash.id); + } + } + return ids; + } + delete() { - const selectedDashboards = _.filter(this.dashboards, {checked: true}); + const selectedDashboards = this.getDashboardsToDelete(); appEvents.emit('confirm-modal', { title: 'Delete', diff --git a/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts b/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts index ad85c8d319c..9a0218a2a4b 100644 --- a/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts +++ b/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts @@ -2,9 +2,9 @@ import {DashboardListCtrl} from '../dashboard_list_ctrl'; import q from 'q'; describe('DashboardListCtrl', () => { - describe('when fetching dashboards', () => { - let ctrl; + let ctrl; + describe('when fetching dashboards', () => { describe('and dashboard has parent that is not in search result', () => { beforeEach(() => { const response = [ @@ -171,4 +171,22 @@ describe('DashboardListCtrl', () => { }); }); }); + + describe('when deleting dashboards', () => { + beforeEach(() => { + ctrl = new DashboardListCtrl({get: () => q.resolve([])}, {getNav: () => {}}, q); + ctrl.dashboards = [ + {id: 1, type: 'dash-folder', checked: true}, + {id: 2, type: 'dash-child', checked: true, folderId: 1}, + {id: 3, type: 'dash-db', checked: true} + ]; + }); + + it('should filter out children if parent is selected', () => { + const toBeDeleted = ctrl.getDashboardsToDelete(); + expect(toBeDeleted.length).toEqual(2); + expect(toBeDeleted[0].id).toEqual(1); + expect(toBeDeleted[1].id).toEqual(3); + }); + }); }); From a366b137a29d4869e692d30618d2d44f7803d48b Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Mon, 30 Oct 2017 19:34:55 +0100 Subject: [PATCH 4/4] dashfolders: bulk edit tag filtering Still ugly though --- .../features/dashboard/dashboard_list_ctrl.ts | 22 ++++++++++++++-- .../dashboard/partials/dashboardList.html | 25 ++++++++++++++----- .../specs/dashboard_list_ctrl.jest.ts | 8 +++--- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/public/app/features/dashboard/dashboard_list_ctrl.ts b/public/app/features/dashboard/dashboard_list_ctrl.ts index 4522a53e81d..a8479de92e0 100644 --- a/public/app/features/dashboard/dashboard_list_ctrl.ts +++ b/public/app/features/dashboard/dashboard_list_ctrl.ts @@ -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(); + } + } } diff --git a/public/app/features/dashboard/partials/dashboardList.html b/public/app/features/dashboard/partials/dashboardList.html index aca798ebf32..313ec2337b7 100644 --- a/public/app/features/dashboard/partials/dashboardList.html +++ b/public/app/features/dashboard/partials/dashboardList.html @@ -14,11 +14,24 @@ Create Folder -
- - - +
+
+
+ + + +
+
+ Filtered by Tags: + + + + {{tagName}} + + +
+
@@ -68,7 +81,7 @@ - + diff --git a/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts b/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts index 9a0218a2a4b..c4cd538b6ac 100644 --- a/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts +++ b/public/app/features/dashboard/specs/dashboard_list_ctrl.jest.ts @@ -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},