 
 
 angular.module('holmesApp')
-  .controller 'DomainsCtrl', ($scope, $window, $interval, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog) ->
+  .controller 'DomainsCtrl', ($scope, $window, $interval,  $filter, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog) ->
 
-    $scope.model = new DomainsCtrl($scope, $window, $interval, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog)
+    $scope.model = new DomainsCtrl($scope, $window, $interval, $filter, DomainsFcty, MostCommonViolationsFcty, WebSocketFcty, $NamedRouteService, $localStorage, gettextCatalog)

'use strict'

class DomainsCtrl
  constructor: (@scope, @window, @interval, @DomainsFcty, @MostCommonViolationsFcty, @WebSocketFcty, @NamedRouteService, @localStorage, @gettextCatalog) ->
    @domainsVisible = false
    @groupsVisible = true
    @mostFrequentVisible = false

    @storage = @localStorage
    @prefsFilter = @storage.prefsFilter
    @order = 'is_active'
    @order_options = [
      {text: @gettextCatalog.getString('sort by'), order:'is_active'},
      {text: @gettextCatalog.getString('pages'), order:'details.pageCount'},
      {text: @gettextCatalog.getString('violations'), order:'details.violationCount'},
      {text: @gettextCatalog.getString('error %'), order:'details.errorPercentage'},
      {text: @gettextCatalog.getString('avg resp time'), order:'details.averageResponseTime'}]
    @order_select = @order_options[0]

    @getDomainData()
    @getMostCommonViolations()

    for domain in @domainList
      domain.details = _.find domainsDetails, {id: domain.id}

    @domains = @filter('orderBy')(@domainList,  @order)

    @loadedDomains = @domains.length

