{"size": 2170, "ext": "js", "max_stars_repo_path": "src/ui/src/js/controllers/system_index.js", "max_stars_repo_name": "ExpressHermes/beer-garden", "max_stars_repo_stars_event_min_datetime": "2018-02-03T01:33:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-20T22:07:25.000Z", "max_issues_repo_path": "src/ui/src/js/controllers/system_index.js", "max_issues_repo_name": "ExpressHermes/beer-garden", "max_issues_repo_issues_event_min_datetime": "2018-02-06T11:22:40.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T15:22:33.000Z", "max_forks_repo_path": "src/ui/src/js/controllers/system_index.js", "max_forks_repo_name": "ExpressHermes/beer-garden", "max_forks_repo_forks_event_min_datetime": "2018-02-04T18:00:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-15T13:07:22.000Z"}
{"max_stars_count": 230, "max_issues_count": 961, "max_forks_count": 33, "avg_line_length": 34.4444444444, "max_line_length": 111, "alphanum_fraction": 0.6506912442}

systemIndexController.$inject = [
  '$scope',
  '$rootScope',
  'localStorageService',
  'UtilityService',
  'DTOptionsBuilder',
];

/**
 * systemIndexController - Controller for the system index page.
 * @param  {Object} $scope         Angular's $scope object.
 * @param  {Object} $rootScope     Angular's $rootScope object.
 * @param  {Object} localStorageService  Storage service
 * @param  {Object} UtilityService Beer-Garden's utility service.
 */
export default function systemIndexController(
    $scope,
    $rootScope,
    localStorageService,
    UtilityService,
    DTOptionsBuilder
    ) {
  $scope.setWindowTitle();

  $scope.util = UtilityService;

  $scope.dtOptions = DTOptionsBuilder.newOptions()
    .withOption('autoWidth', false)
    .withOption('pageLength', localStorageService.get('_system_index_length') || 10)
    .withOption('order', [[0, 'asc'], [1, 'asc'], [2, 'asc'], [3, 'asc']])
    .withLightColumnFilter({
      0: {html: 'input', type: 'text', attr: {class: 'form-inline form-control', title: 'Namespace Filter'}},
      1: {html: 'input', type: 'text', attr: {class: 'form-inline form-control', title: 'System Filter'}},
      2: {html: 'input', type: 'text', attr: {class: 'form-inline form-control', title: 'Version Filter'}},
      3: {html: 'input', type: 'text', attr: {class: 'form-inline form-control', title: 'Description Filter'}},
      4: {html: 'input', type: 'number', attr: {class: 'form-inline form-control', title: 'Commands Filter'}},
      5: {html: 'input', type: 'number', attr: {class: 'form-inline form-control', title: 'Instances Filter'}},
    })
    .withBootstrap();

  $scope.instanceCreated = function(_instance) {
    $scope.dtInstance = _instance;

    $('#systemIndexTable').on('length.dt', (event, settings, len) => {
      localStorageService.set('_system_index_length', len);
    });
  };

  $scope.successCallback = function(response) {
    $scope.response = response;
    $scope.data = response.data;
  };

  $scope.failureCallback = function(response) {
    $scope.response = response;
    $scope.data = {};
  };

  $scope.response = $rootScope.sysResponse;
  $scope.data = $rootScope.systems;
};
