/*************************************************
* Copyright (c) 2016 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
var urlPrefix;
if ($basePath) {
urlPrefix = $basePath;
} else {
// required to make tests work
var $basePath = '/static/';
urlPrefix = $basePath;
}
import './helpers';
import './forms';
import './lists';
import './widgets';
import './help';
import './filters';
import {Home, HomeGroups, HomeHosts} from './controllers/Home';
import {SocketsController} from './controllers/Sockets';
import {CredentialsAdd, CredentialsEdit, CredentialsList} from './controllers/Credentials';
import {JobsListController} from './controllers/Jobs';
import portalMode from './portal-mode/main';
import systemTracking from './system-tracking/main';
import inventories from './inventories/main';
import inventoryScripts from './inventory-scripts/main';
import organizations from './organizations/main';
import permissions from './permissions/main';
import managementJobs from './management-jobs/main';
import jobDetail from './job-detail/main';
import notifications from './notifications/main';
import access from './access/main';
// modules
import about from './about/main';
import license from './license/main';
import setupMenu from './setup-menu/main';
import mainMenu from './main-menu/main';
import breadCrumb from './bread-crumb/main';
import browserData from './browser-data/main';
import dashboard from './dashboard/main';
import moment from './shared/moment/main';
import templateUrl from './shared/template-url/main';
import adhoc from './adhoc/main';
import login from './login/main';
import activityStream from './activity-stream/main';
import standardOut from './standard-out/main';
import lookUpHelper from './lookup/main';
import JobTemplates from './job-templates/main';
import {ScheduleEditController} from './controllers/Schedules';
import {ProjectsList, ProjectsAdd, ProjectsEdit} from './controllers/Projects';
import OrganizationsList from './organizations/list/organizations-list.controller';
import OrganizationsAdd from './organizations/add/organizations-add.controller';
import OrganizationsEdit from './organizations/edit/organizations-edit.controller';
import {InventoriesAdd, InventoriesEdit, InventoriesList, InventoriesManage} from './inventories/main';
import {AdminsList} from './controllers/Admins';
import {UsersList, UsersAdd, UsersEdit} from './controllers/Users';
import {TeamsList, TeamsAdd, TeamsEdit} from './controllers/Teams';
import RestServices from './rest/main';
import './shared/api-loader';
import './shared/form-generator';
import './shared/Modal';
import './shared/prompt-dialog';
import './shared/directives';
import './shared/filters';
import './shared/InventoryTree';
import './shared/Socket';
import './shared/features/main';
import './login/authenticationServices/pendo/ng-pendo';
import footer from './footer/main';
import scheduler from './scheduler/main';
/*#if DEBUG#*/
import {__deferLoadIfEnabled} from './debug';
__deferLoadIfEnabled();
/*#endif#*/
var tower = angular.module('Tower', [
//'ngAnimate',
'ngSanitize',
'ngCookies',
about.name,
license.name,
RestServices.name,
browserData.name,
systemTracking.name,
inventories.name,
inventoryScripts.name,
organizations.name,
permissions.name,
managementJobs.name,
setupMenu.name,
mainMenu.name,
breadCrumb.name,
dashboard.name,
moment.name,
templateUrl.name,
adhoc.name,
login.name,
activityStream.name,
footer.name,
jobDetail.name,
notifications.name,
standardOut.name,
access.name,
JobTemplates.name,
portalMode.name,
'templates',
'Utilities',
'OrganizationFormDefinition',
'UserFormDefinition',
'FormGenerator',
'OrganizationListDefinition',
'jobTemplates',
'UserListDefinition',
'UserHelper',
'PromptDialog',
'ApiLoader',
'RelatedSearchHelper',
'SearchHelper',
'PaginationHelpers',
'RefreshHelper',
'AdminListDefinition',
'AWDirectives',
'InventoriesListDefinition',
'InventoryFormDefinition',
'InventoryHelper',
'InventoryGroupsDefinition',
'InventoryHostsDefinition',
'HostsHelper',
'AWFilters',
'ScanJobsListDefinition',
'HostFormDefinition',
'HostListDefinition',
'GroupFormDefinition',
'GroupListDefinition',
'GroupsHelper',
'TeamsListDefinition',
'TeamFormDefinition',
'TeamHelper',
'CredentialsListDefinition',
'CredentialFormDefinition',
'LookUpHelper',
'JobTemplatesListDefinition',
'PortalJobTemplatesListDefinition',
'JobTemplateFormDefinition',
'JobTemplatesHelper',
'JobSubmissionHelper',
'ProjectsListDefinition',
'ProjectFormDefinition',
'ProjectStatusDefinition',
'ProjectsHelper',
'CompletedJobsDefinition',
'AllJobsDefinition',
'JobFormDefinition',
'JobSummaryDefinition',
'ParseHelper',
'ChildrenHelper',
'ProjectPathHelper',
'md5Helper',
'SelectionHelper',
'HostGroupsFormDefinition',
'StreamWidget',
'JobsHelper',
'InventoryGroupsHelpDefinition',
'InventoryTree',
'CredentialsHelper',
'StreamListDefinition',
'HomeGroupListDefinition',
'HomeHostListDefinition',
'ActivityDetailDefinition',
'VariablesHelper',
'SchedulesListDefinition',
'ScheduledJobsDefinition',
'AngularScheduler',
'Timezones',
'SchedulesHelper',
'JobsListDefinition',
'LogViewerStatusDefinition',
'StandardOutHelper',
'LogViewerOptionsDefinition',
'JobDetailHelper',
'SocketIO',
'lrInfiniteScroll',
'LoadConfigHelper',
'SocketHelper',
'PortalJobsListDefinition',
'features',
'longDateFilter',
'pendolytics',
'ui.router',
'ncy-angular-breadcrumb',
'scheduler',
'ApiModelHelper',
'ActivityStreamHelper'
])
.constant('AngularScheduler.partials', urlPrefix + 'lib/angular-scheduler/lib/')
.constant('AngularScheduler.useTimezone', true)
.constant('AngularScheduler.showUTCField', true)
.constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data')
.config(['$pendolyticsProvider', function($pendolyticsProvider) {
$pendolyticsProvider.doNotAutoStart();
}])
.config(['$stateProvider', '$urlRouterProvider', '$breadcrumbProvider', '$urlMatcherFactoryProvider',
function ($stateProvider, $urlRouterProvider, $breadcrumbProvider, $urlMatcherFactoryProvider) {
$urlMatcherFactoryProvider.strictMode(false)
$breadcrumbProvider.setOptions({
templateUrl: urlPrefix + 'partials/breadcrumb.html'
});
// route to the details pane of /job/:id/host-event/:eventId if no other child specified
$urlRouterProvider.when('/jobs/*/host-event/*', '/jobs/*/host-event/*/details')
// $urlRouterProvider.otherwise("/home");
$urlRouterProvider.otherwise(function($injector){
var $state = $injector.get("$state");
$state.go('dashboard');
});
$stateProvider.
state('dashboard', {
url: '/home',
templateUrl: urlPrefix + 'partials/home.html',
controller: Home,
data: {
activityStream: true
},
ncyBreadcrumb: {
label: "DASHBOARD"
},
resolve: {
graphData: ['$q', 'jobStatusGraphData', 'FeaturesService', function($q, jobStatusGraphData, FeaturesService) {
return $q.all({
jobStatus: jobStatusGraphData.get("month", "all"),
features: FeaturesService.get()
});
}]
}
}).
state('dashboardGroups', {
url: '/home/groups?id&name&has_active_failures&status&source&has_external_source&inventory_source__id',
templateUrl: urlPrefix + 'partials/subhome.html',
controller: HomeGroups,
ncyBreadcrumb: {
parent: 'dashboard',
label: "GROUPS"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('dashboardHosts', {
url: '/home/hosts?has_active_failures&name&id',
templateUrl: urlPrefix + 'partials/subhome.html',
controller: HomeHosts,
data: {
activityStream: true,
activityStreamTarget: 'host'
},
ncyBreadcrumb: {
parent: 'dashboard',
label: "HOSTS"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('jobs', {
url: '/jobs',
templateUrl: urlPrefix + 'partials/jobs.html',
controller: JobsListController,
ncyBreadcrumb: {
label: "JOBS"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('projects', {
url: '/projects',
templateUrl: urlPrefix + 'partials/projects.html',
controller: ProjectsList,
data: {
activityStream: true,
activityStreamTarget: 'project'
},
ncyBreadcrumb: {
label: "PROJECTS"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('projects.add', {
url: '/add',
templateUrl: urlPrefix + 'partials/projects.html',
controller: ProjectsAdd,
ncyBreadcrumb: {
parent: "projects",
label: "CREATE PROJECT"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('projects.edit', {
url: '/:id',
templateUrl: urlPrefix + 'partials/projects.html',
controller: ProjectsEdit,
data: {
activityStreamId: 'id'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('projectOrganizations', {
url: '/projects/:project_id/organizations',
templateUrl: urlPrefix + 'partials/projects.html',
controller: OrganizationsList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('projectOrganizationAdd', {
url: '/projects/:project_id/organizations/add',
templateUrl: urlPrefix + 'partials/projects.html',
controller: OrganizationsAdd,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('organizationAdmins', {
url: '/organizations/:organization_id/admins',
templateUrl: urlPrefix + 'partials/organizations.html',
controller: AdminsList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('organizationUsers', {
url:'/organizations/:organization_id/users',
templateUrl: urlPrefix + 'partials/users.html',
controller: UsersList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('organizationUserAdd', {
url: '/organizations/:organization_id/users/add',
templateUrl: urlPrefix + 'partials/users.html',
controller: UsersAdd,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('organizationUserEdit', {
url: '/organizations/:organization_id/users/:user_id',
templateUrl: urlPrefix + 'partials/users.html',
controller: UsersEdit,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teams', {
url: '/teams',
templateUrl: urlPrefix + 'partials/teams.html',
controller: TeamsList,
data: {
activityStream: true,
activityStreamTarget: 'team'
},
ncyBreadcrumb: {
parent: 'setup',
label: 'TEAMS'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teams.add', {
url: '/add',
templateUrl: urlPrefix + 'partials/teams.html',
controller: TeamsAdd,
ncyBreadcrumb: {
parent: "teams",
label: "CREATE TEAM"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teams.edit', {
url: '/:team_id',
templateUrl: urlPrefix + 'partials/teams.html',
controller: TeamsEdit,
data: {
activityStreamId: 'team_id'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamUsers', {
url: '/teams/:team_id/users',
templateUrl: urlPrefix + 'partials/teams.html',
controller: UsersList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamUserEdit', {
url: '/teams/:team_id/users/:user_id',
templateUrl: urlPrefix + 'partials/teams.html',
controller: UsersEdit,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamProjects', {
url: '/teams/:team_id/projects',
templateUrl: urlPrefix + 'partials/teams.html',
controller: ProjectsList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamProjectAdd', {
url: '/teams/:team_id/projects/add',
templateUrl: urlPrefix + 'partials/teams.html',
controller: ProjectsAdd,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamProjectEdit', {
url: '/teams/:team_id/projects/:project_id',
templateUrl: urlPrefix + 'partials/teams.html',
controller: ProjectsEdit,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamCredentials', {
url: '/teams/:team_id/credentials',
templateUrl: urlPrefix + 'partials/teams.html',
controller: CredentialsList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamCredentialAdd', {
url: '/teams/:team_id/credentials/add',
templateUrl: urlPrefix + 'partials/teams.html',
controller: CredentialsAdd,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamCredentialEdit', {
url: '/teams/:team_id/credentials/:credential_id',
templateUrl: urlPrefix + 'partials/teams.html',
controller: CredentialsEdit,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('credentials', {
url: '/credentials',
templateUrl: urlPrefix + 'partials/credentials.html',
controller: CredentialsList,
data: {
activityStream: true,
activityStreamTarget: 'credential'
},
ncyBreadcrumb: {
parent: 'setup',
label: 'CREDENTIALS'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('credentials.add', {
url: '/add',
templateUrl: urlPrefix + 'partials/credentials.html',
controller: CredentialsAdd,
ncyBreadcrumb: {
parent: "credentials",
label: "CREATE CREDENTIAL"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('credentials.edit', {
url: '/:credential_id',
templateUrl: urlPrefix + 'partials/credentials.html',
controller: CredentialsEdit,
data: {
activityStreamId: 'credential_id'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('users', {
url: '/users',
templateUrl: urlPrefix + 'partials/users.html',
controller: UsersList,
data: {
activityStream: true,
activityStreamTarget: 'user'
},
ncyBreadcrumb: {
parent: 'setup',
label: 'USERS'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('users.add', {
url: '/add',
templateUrl: urlPrefix + 'partials/users.html',
controller: UsersAdd,
ncyBreadcrumb: {
parent: "users",
label: "CREATE USER"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('users.edit', {
url: '/:user_id',
templateUrl: urlPrefix + 'partials/users.html',
controller: UsersEdit,
data: {
activityStreamId: 'user_id'
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('userCredentials', {
url: '/users/:user_id/credentials',
templateUrl: urlPrefix + 'partials/users.html',
controller: CredentialsList,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('userCredentialAdd', {
url: '/users/:user_id/credentials/add',
templateUrl: urlPrefix + 'partials/teams.html',
controller: CredentialsAdd,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('teamUserCredentialEdit', {
url: '/teams/:user_id/credentials/:credential_id',
templateUrl: urlPrefix + 'partials/teams.html',
controller: CredentialsEdit,
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('sockets', {
url: '/sockets',
templateUrl: urlPrefix + 'partials/sockets.html',
controller: SocketsController,
ncyBreadcrumb: {
label: 'SOCKETS'
}
});
}
])
.config(['$provide', function($provide) {
$provide.decorator('$log', ['$delegate', function($delegate) {
var _debug = $delegate.debug;
$delegate.debug = function(msg) {
// only show debug messages when debug_mode set to true in config
if ($AnsibleConfig && $AnsibleConfig.debug_mode) {
_debug(msg);
}
};
return $delegate;
}]);
}])
.run(['$q', '$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'Socket',
'LoadConfig', 'Store', 'ShowSocketHelp', 'pendoService', 'Prompt', 'Rest', 'Wait', 'ProcessErrors', '$state', 'GetBasePath',
function ($q, $compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, Socket,
LoadConfig, Store, ShowSocketHelp, pendoService, Prompt, Rest, Wait, ProcessErrors, $state, GetBasePath) {
var sock;
$rootScope.addPermission = function (scope) {
$compile("