|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | 3 | class DomainsCtrl |
4 | | - constructor: (@scope, @window, @interval, @DomainsFcty, @MostCommonViolationsFcty, @WebSocketFcty, @NamedRouteService, @localStorage, @gettextCatalog) -> |
| 4 | + constructor: (@scope, @window, @interval, @filter, @DomainsFcty, @MostCommonViolationsFcty, @WebSocketFcty, @NamedRouteService, @localStorage, @gettextCatalog) -> |
5 | 5 | @domainsVisible = false |
6 | 6 | @groupsVisible = true |
7 | 7 | @mostFrequentVisible = false |
8 | 8 |
|
9 | 9 | @storage = @localStorage |
10 | 10 | @prefsFilter = @storage.prefsFilter |
11 | | - @order = 'is_active' |
| 11 | + @order = '-is_active' |
12 | 12 | @order_options = [ |
13 | | - {text: @gettextCatalog.getString('sort by'), order:'is_active'}, |
14 | | - {text: @gettextCatalog.getString('pages'), order:'details.pageCount'}, |
15 | | - {text: @gettextCatalog.getString('violations'), order:'details.violationCount'}, |
16 | | - {text: @gettextCatalog.getString('error %'), order:'details.errorPercentage'}, |
17 | | - {text: @gettextCatalog.getString('avg resp time'), order:'details.averageResponseTime'}] |
18 | | - @order_select = @order_options[0] |
| 13 | + {text: @gettextCatalog.getString('is active'), order:'-is_active'}, |
| 14 | + {text: @gettextCatalog.getString('pages'), order:'-details.pageCount'}, |
| 15 | + {text: @gettextCatalog.getString('violations'), order:'-details.violationCount'}, |
| 16 | + {text: @gettextCatalog.getString('error %'), order:'-details.errorPercentage'}, |
| 17 | + {text: @gettextCatalog.getString('avg resp time'), order:'-details.averageResponseTime'}] |
| 18 | + @order_select = {text: @gettextCatalog.getString('is active'), order:'-is_active'} |
19 | 19 |
|
20 | 20 | @getDomainData() |
21 | 21 | @getMostCommonViolations() |
@@ -56,12 +56,7 @@ class DomainsCtrl |
56 | 56 | for domain in @domainList |
57 | 57 | domain.details = _.find domainsDetails, {id: domain.id} |
58 | 58 |
|
59 | | - @domains = _.sortBy @domainList, (domain) => |
60 | | - order_splitted = @order.split '.' |
61 | | - if order_splitted.length == 2 |
62 | | - domain[order_splitted[0]][order_splitted[1]] |
63 | | - else |
64 | | - domain[order_splitted[0]] |
| 59 | + @domains = @filter('orderBy')(@domainList, @order) |
65 | 60 |
|
66 | 61 | @loadedDomains = @domains.length |
67 | 62 |
|
@@ -116,6 +111,6 @@ class DomainsCtrl |
116 | 111 |
|
117 | 112 |
|
118 | 113 | angular.module('holmesApp') |
119 | | - .controller 'DomainsCtrl', ($scope, $window, $interval, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog) -> |
| 114 | + .controller 'DomainsCtrl', ($scope, $window, $interval, $filter, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog) -> |
120 | 115 |
|
121 | | - $scope.model = new DomainsCtrl($scope, $window, $interval, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog) |
| 116 | + $scope.model = new DomainsCtrl($scope, $window, $interval, $filter, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog) |
0 commit comments