{"size": 2426, "ext": "js", "max_stars_repo_path": "public/app.js", "max_stars_repo_name": "leadwire-apm/kibana-own-home", "max_stars_repo_stars_event_min_datetime": "2017-01-04T06:51:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T05:04:32.000Z", "max_issues_repo_path": "public/app.js", "max_issues_repo_name": "leadwire-apm/kibana-own-home", "max_issues_repo_issues_event_min_datetime": "2017-01-25T08:17:11.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-14T10:59:51.000Z", "max_forks_repo_path": "public/app.js", "max_forks_repo_name": "leadwire-apm/kibana-own-home", "max_forks_repo_forks_event_min_datetime": "2017-02-21T19:41:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-17T02:24:18.000Z"}
{"max_stars_count": 277, "max_issues_count": 151, "max_forks_count": 94, "avg_line_length": 31.1025641026, "max_line_length": 106, "alphanum_fraction": 0.6541632317}
import chrome from 'ui/chrome';
import uiRoutes from 'ui/routes';

import 'ui/autoload/styles';
import './less/main.less';
import template from './templates/index.html';

function generateUserInfo(resp, tab, object, reload) {
  return {
    currentKibanaIndex: resp.data.currentKibanaIndex,
    kibanaIndexPrefix: resp.data.kibanaIndexPrefix,
    username: resp.data.username,
    groups: resp.data.groups,
    moveTo: tab ? {tab: tab, object: object || ''} : null,
    reload: reload,
    backHref: resp.data.backHref
  }
}

uiRoutes.enable();
uiRoutes
.when('/:suffix', {
  template,
  resolve: {
    userInfo($route, $http) {
      return $http.get('../api/own_home/selection/' + $route.current.params.suffix).then(function (resp) {
        return generateUserInfo(resp, null, null, resp.data.explicitMode == 'true' ? true : false);
      });
    }
  }
}).when('/:suffix/:tab', {
  template,
  resolve: {
    userInfo($route, $http) {
      return $http.get('../api/own_home/selection/' + $route.current.params.suffix).then(function (resp) {
        return generateUserInfo(resp, $route.current.params.tab, null, false);
      });
    }
  }
}).when('/:suffix/:tab/:object', {
  template,
  resolve: {
    userInfo($route, $http) {
      return $http.get('../api/own_home/selection/' + $route.current.params.suffix).then(function (resp) {
        return generateUserInfo(resp, $route.current.params.tab, $route.current.params.object, false);
      });
    }
  }
}).otherwise({
  template,
  resolve: {
    userInfo($route, $http) {
      return $http.get('../api/own_home/selection').then(function (resp) {
        return generateUserInfo(resp, null, null, false);
      });
    }
  }
});

require('ui/modules')
.get('app/own_home', [])
.controller('ownHome', function ($scope, $route, $location) {
  const userInfo = $route.current.locals.userInfo;
  $scope.currentKibanaIndex = userInfo.currentKibanaIndex;
  $scope.kibanaIndexPrefix = userInfo.kibanaIndexPrefix;
  $scope.username = userInfo.username;
  $scope.groups = userInfo.groups;
  $scope.backHref = userInfo.backHref;
  $location.path('').replace();
  if (userInfo.moveTo && ['discover', 'visualize', 'dashboard'].indexOf(userInfo.moveTo.tab) > -1) {
    window.location = './own_home';
    window.location.replace('./kibana#/' + userInfo.moveTo.tab + '/' + userInfo.moveTo.object);
  }
  if (userInfo.reload) {
    window.location.replace('./own_home');
  }
});
