diff --git a/frontend/app/scripts/controllers/dashboard/DashboardsCtrl.js b/frontend/app/scripts/controllers/dashboard/DashboardsCtrl.js index 53fa3a851a..307c17ba0b 100644 --- a/frontend/app/scripts/controllers/dashboard/DashboardsCtrl.js +++ b/frontend/app/scripts/controllers/dashboard/DashboardsCtrl.js @@ -51,20 +51,54 @@ return $uibModalInstance.close(dashboard); }; }) - .controller('DashboardsCtrl', function($scope, $state, $uibModal, PSearchSrv, ModalUtilsSrv, NotificationSrv, DashboardSrv, AuthenticationSrv) { + .controller('DashboardsCtrl', function($scope, $state, $uibModal, PaginatedQuerySrv, FilteringSrv, ModalUtilsSrv, NotificationSrv, DashboardSrv, AuthenticationSrv) { this.dashboards = []; var self = this; + this.$onInit = function() { + self.filtering = new FilteringSrv('dashboard', 'dashboard.list', { + version: 'v0', + defaults: { + showFilters: true, + showStats: false, + pageSize: 15, + sort: ['+title'] + }, + defaultFilter: [] + }); + + self.filtering.initContext('list') + .then(function() { + self.load(); + + $scope.$watch('$vm.list.pageSize', function (newValue) { + self.filtering.setPageSize(newValue); + }); + }); + } + this.load = function() { - DashboardSrv.list().then(function(response) { - self.dashboards = response.data; - }, function(err){ - NotificationSrv.error('DashboardsCtrl', err.data, err.status); + + self.list = new PaginatedQuerySrv({ + name: 'dashboard-list', + version: 'v0', + skipStream: true, + sort: self.filtering.context.sort, + loadAll: false, + pageSize: self.filtering.context.pageSize, + filter: this.filtering.buildQuery(), + operations: [ + {'_name': 'listDashboard'} + ], + onFailure: function(err) { + if(err && err.status === 400) { + self.filtering.resetContext(); + self.load(); + } + } }); }; - this.load(); - this.openDashboardModal = function(dashboard) { return $uibModal.open({ templateUrl: 'views/partials/dashboard/create.dialog.html', @@ -186,5 +220,62 @@ } }); } + + // Filtering + this.toggleFilters = function () { + this.filtering.toggleFilters(); + }; + + this.filter = function () { + self.filtering.filter().then(this.applyFilters); + }; + + this.clearFilters = function () { + this.filtering.clearFilters() + .then(self.search); + }; + + this.removeFilter = function (index) { + self.filtering.removeFilter(index) + .then(self.search); + }; + + this.search = function () { + self.load(); + self.filtering.storeContext(); + }; + this.addFilterValue = function (field, value) { + this.filtering.addFilterValue(field, value); + this.search(); + }; + + this.filterBy = function(field, value) { + self.filtering.clearFilters() + .then(function(){ + self.addFilterValue(field, value); + }); + }; + + this.sortBy = function(sort) { + self.list.sort = sort; + self.list.update(); + self.filtering.setSort(sort); + }; + + this.sortByField = function(field) { + var context = this.filtering.context; + var currentSort = Array.isArray(context.sort) ? context.sort[0] : context.sort; + var sort = null; + + if(currentSort.substr(1) !== field) { + sort = ['+' + field]; + } else { + sort = [(currentSort === '+' + field) ? '-'+field : '+'+field]; + } + + self.list.sort = sort; + self.list.update(); + self.filtering.setSort(sort); + }; }); })(); diff --git a/frontend/app/styles/main.css b/frontend/app/styles/main.css index 0fa8ac1fa0..0966ce592f 100644 --- a/frontend/app/styles/main.css +++ b/frontend/app/styles/main.css @@ -58,7 +58,7 @@ body { } .container-main { - padding-top: 60px; + padding-top: 80px; } .marked>table, .markdown>table { diff --git a/frontend/app/views/partials/case/case.list.html b/frontend/app/views/partials/case/case.list.html index 82fcc09e32..87082cb127 100644 --- a/frontend/app/views/partials/case/case.list.html +++ b/frontend/app/views/partials/case/case.list.html @@ -75,7 +75,7 @@
+ + Status + + + + + | ++ + Title + + + + + | ++ + By + + + + + | ++ Dates + + C. + + + + + + U. + + + + + | ++ |
---|---|---|---|---|
+ {{item.status}} + | + +
+
+ {{item.title}}
+
+ {{item.description}}
+ |
+
+ |
+ + + + | +
+
+ Edit
+
+
+ Delete
+
+
+ Duplicate
+
+
+ Export
+
+ |
+