diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 926d0703ea..2804ca7f09 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -29,9 +29,12 @@ import {CredentialsAdd, CredentialsEdit, CredentialsList} from './controllers/Cr import {JobsListController} from './controllers/Jobs'; import {PortalController} from './controllers/Portal'; import systemTracking from './system-tracking/main'; +import inventoryScripts from './inventory-scripts/main'; +import managementJobs from './management-jobs/main'; import routeExtensions from './shared/route-extensions/main'; import breadcrumbs from './shared/breadcrumbs/main'; + // modules import setupMenu from './setup-menu/main'; import mainMenu from './main-menu/main'; @@ -67,6 +70,7 @@ import './shared/Socket'; import './job-templates/main'; import './shared/features/main'; + /*#if DEBUG#*/ import {__deferLoadIfEnabled} from './debug'; __deferLoadIfEnabled(); @@ -81,6 +85,8 @@ var tower = angular.module('Tower', [ browserData.name, breadcrumbs.name, systemTracking.name, + inventoryScripts.name, + managementJobs.name, setupMenu.name, mainMenu.name, dashboard.name, @@ -104,7 +110,6 @@ var tower = angular.module('Tower', [ 'PaginationHelpers', 'RefreshHelper', 'AdminListDefinition', - 'CustomInventoryListDefinition', 'AWDirectives', 'AdhocFormDefinition', 'InventoriesListDefinition', @@ -181,10 +186,8 @@ var tower = angular.module('Tower', [ 'AboutAnsibleHelpModal', 'SurveyQuestionFormDefinition', 'PortalJobsListDefinition', - 'ConfigureTowerHelper', - 'ConfigureTowerJobsListDefinition', - 'CreateCustomInventoryHelper', - 'CustomInventoryListDefinition', + + 'AdhocHelper', 'features', 'longDateFilter' @@ -895,7 +898,7 @@ var tower = angular.module('Tower', [ }] } }). - + when('/license', { name: 'license', templateUrl: urlPrefix + 'partials/license.html', @@ -933,9 +936,9 @@ var tower = angular.module('Tower', [ }]) .run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'HideStream', 'Socket', - 'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', 'ConfigureTower', 'CreateCustomInventory', + 'LoadConfig', 'Store', 'ShowSocketHelp', 'AboutAnsibleHelp', function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, Timer, ClearScope, HideStream, Socket, - LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp, ConfigureTower, CreateCustomInventory) { + LoadConfig, Store, ShowSocketHelp, AboutAnsibleHelp) { var sock; @@ -1143,19 +1146,6 @@ var tower = angular.module('Tower', [ $location.path('/home/'); }; - $rootScope.configureTower = function(){ - ConfigureTower({ - scope: $rootScope, - parent_scope: $rootScope - }); - }; - - $rootScope.createCustomInv = function(){ - CreateCustomInventory({ - parent_scope: $rootScope - }); - }; - }); // end of 'ConfigReady' diff --git a/awx/ui/client/src/controllers/Authentication.js b/awx/ui/client/src/controllers/Authentication.js index ccabce45aa..5b85c7c7e3 100644 --- a/awx/ui/client/src/controllers/Authentication.js +++ b/awx/ui/client/src/controllers/Authentication.js @@ -58,7 +58,7 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, $location, Authorization, ToggleClass, Alert, Wait, Timer, Empty, ClearScope) { - var setLoginFocus, lastPath, sessionExpired, loginAgain, + var setLoginFocus, lastPath, lastUser, sessionExpired, loginAgain, e, html, scope = $rootScope.$new(); setLoginFocus = function () { @@ -83,6 +83,15 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath; }; + lastUser = function(){ + if(!Empty($rootScope.lastUser) && $rootScope.lastUser === $rootScope.current_user.id){ + return true; + } + else { + return false; + } + }; + $log.debug('User session expired: ' + sessionExpired); $log.debug('Last URL: ' + lastPath()); @@ -176,7 +185,7 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, .success(function (data) { Authorization.setLicense(data); Wait("stop"); - if (lastPath()) { + if (lastPath() && lastUser()) { // Go back to most recent navigation path $location.path(lastPath()); } else { diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index 34233b9a98..73ae12258f 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name controllers.function:Credentials @@ -176,6 +176,7 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $r current_item: (!Empty($routeParams.team_id)) ? $routeParams.team_id : null, list: TeamList, field: 'team', + input_type: 'radio', autopopulateLookup: false }); @@ -347,6 +348,7 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $ form: form, current_item: (!Empty($scope.team_id)) ? $scope.team_id : null, list: TeamList, + input_type: 'radio', field: 'team' }); diff --git a/awx/ui/client/src/controllers/Inventories.js b/awx/ui/client/src/controllers/Inventories.js index 0baa2b5a1b..187a99d10e 100644 --- a/awx/ui/client/src/controllers/Inventories.js +++ b/awx/ui/client/src/controllers/Inventories.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name controllers.function:Inventories @@ -433,7 +433,7 @@ export function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $r .success(function (data) { var inventory_id = data.id; Wait('stop'); - $location.path('/inventories/' + inventory_id + '/'); + $location.path('/inventories/' + inventory_id + '/manage'); }) .error(function (data, status) { ProcessErrors( $scope, data, status, form, { hdr: 'Error!', diff --git a/awx/ui/client/src/forms.js b/awx/ui/client/src/forms.js index 403fc0bfc2..1620543189 100644 --- a/awx/ui/client/src/forms.js +++ b/awx/ui/client/src/forms.js @@ -7,7 +7,6 @@ import ActivityDetail from "./forms/ActivityDetail"; import Credentials from "./forms/Credentials"; import Adhoc from "./forms/Adhoc"; -import CustomInventory from "./forms/CustomInventory"; import EventsViewer from "./forms/EventsViewer"; import Groups from "./forms/Groups"; import HostGroups from "./forms/HostGroups"; @@ -37,7 +36,6 @@ export { ActivityDetail, Credentials, Adhoc, - CustomInventory, EventsViewer, Groups, HostGroups, diff --git a/awx/ui/client/src/forms/CustomInventory.js b/awx/ui/client/src/forms/CustomInventory.js deleted file mode 100644 index 4a69431954..0000000000 --- a/awx/ui/client/src/forms/CustomInventory.js +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - - /** - * @ngdoc function - * @name forms.function:CustomInventory - * @description This form is for adding/editing an organization -*/ - -export default - angular.module('CustomInventoryFormDefinition', []) - .value('CustomInventoryForm', { - - addTitle: 'Create Custom Inventory', //Title in add mode - editTitle: '{{ name }}', //Title in edit mode - name: 'custom_inventory', //entity or model name in singular form - well: false, - showActions: false, - - fields: { - name: { - label: 'Name', - type: 'text', - addRequired: true, - editRequired: true, - capitalize: false - }, - description: { - label: 'Description', - type: 'text', - addRequired: false, - editRequired: false - }, - organization: { - label: 'Organization', - type: 'lookup', - awRequiredWhen: { - variable: "orgrequired", - init: true - }, - sourceModel: 'organization', - sourceField: 'name', - ngClick: 'lookUpOrganization()' - }, - script: { - label: 'Custom Script', - type: 'textarea', - hintText: "Drag and drop an inventory script on the field below", - addRequired: true, - editRequired: true, - awDropFile: true, - 'class': 'ssh-key-field', - rows: 10, - awPopOver: "

Drag and drop your custom inventory script file here or create one in the field to import your custom inventory. " + - "

Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python

", - dataTitle: 'Custom Script', - dataPlacement: 'right', - dataContainer: "body" - }, - }, - - buttons: { //for now always generates '); - elem = angular.element(document.getElementById('configure-schedules-form-container')); - $compile(elem)(scope); - - if (scope.removeScheduleReady) { - scope.removeScheduleReady(); - } - scope.removeScheduleReady = scope.$on('ScheduleReady', function() { - // Insert the scheduler widget into the hidden div - scheduler = SchedulerInit({ scope: scope, requireFutureStartTime: false }); - scheduler.inject('configure-schedules-form', false); - scheduler.injectDetail('configure-schedules-detail', false); - scheduler.clear(); - scope.formShowing = true; - scope.showRRuleDetail = false; - scope.schedulesTitle = (mode === 'edit') ? 'Edit Schedule' : 'Create Schedule'; - - - // display the scheduler widget - showForm = function() { - $('#configure-jobs').show('slide', { direction: 'left' }, 500); - $('#configure-jobs').hide(); - Wait('stop'); - $('#configure-schedules-overlay').width($('#configure-schedules-tab') - .width()).height($('#configure-schedules-tab').height()).show(); - container.width($('#configure-schedules-tab').width() - 18); - SetSchedulesInnerDialogSize(); - container.show('slide', { direction: 'right' }, 300); - // scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30; - target.show(); - if (scope.isFactCleanup) { - scope.$watch('scheduler_form.keep_amount.$modelValue', function(newVal) { - if (!newVal && newVal !== 0) { - $('#configure-save-button').prop("disabled", true); - } else if (isNaN(newVal)) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal < 0) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal > 9999) { - $('#configure-save-button').prop("disabled", true); - } else { - $('#configure-save-button').prop("disabled", false); - } - }); - scope.$watch('scheduler_form.granularity_keep_amount.$modelValue', function(newVal2) { - if (!newVal2 && newVal2 !== 0) { - $('#configure-save-button').prop("disabled", true); - } else if (isNaN(newVal2)) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal2 < 0) { - $('#configure-save-button').prop("disabled", true); - } else if (newVal2 > 9999) { - $('#configure-save-button').prop("disabled", true); - } else { - $('#configure-save-button').prop("disabled", false); - } - }); - } - if(mode==="add"){ - scope.$apply(function(){ - scope.schedulerPurgeDays = 30; - scope.schedulerName = name+' Schedule'; - }); - } - if (mode === 'edit') { - scope.$apply(function() { - scheduler.setRRule(schedule.rrule); - scheduler.setName(schedule.name); - scope.schedulerPurgeDays = (!Empty(scope.days)) ? Number(scope.days) : 30; - }); - } - }; - setTimeout(function() { showForm(); }, 1000); - }); - - restoreList = function() { - // $('#group-save-button').prop('disabled', false); - $('#configure-jobs').show('slide', { direction: 'right' }, 500); - // $('#configure-jobs').width($('#configure-jobs').width()).height($('#configure-jobs').height()).hide(); - // parent_scope.refreshSchedules(); - list.show('slide', { direction: 'right' }, 500); - $('#configure-schedules-overlay').width($('#configure-schedules-tab').width()).height($('#configure-schedules-tab').height()).hide(); - parent_scope.refreshSchedules(); - - }; - - scope.showScheduleDetail = function() { - if (scope.formShowing) { - if (scheduler.isValid()) { - detail.width($('#configure-schedules-form').width()).height($('#configure-schedules-form').height()); - target.hide(); - detail.show(); - scope.formShowing = false; - } - } - else { - detail.hide(); - target.show(); - scope.formShowing = true; - } - }; - - if (scope.removeScheduleSaved) { - scope.removeScheduleSaved(); - } - scope.removeScheduleSaved = scope.$on('ScheduleSaved', function() { - Wait('stop'); - $("#configure-save-button").remove(); - container.hide('slide', { direction: 'left' }, 500, restoreList); - scope.$destroy(); - }); - - scope.saveScheduleForm = function() { - var extra_vars; - if (scheduler.isValid()) { - scope.schedulerIsValid = true; - url = (mode==="edit") ? GetBasePath('schedules')+id+'/' : url; - if (scope.isFactCleanup) { - extra_vars = { - "older_than": scope.scheduler_form.keep_amount.$viewValue + scope.scheduler_form.keep_unit.$viewValue.value, - "granularity": scope.scheduler_form.granularity_keep_amount.$viewValue + scope.scheduler_form.granularity_keep_unit.$viewValue.value - }; - } else { - extra_vars = { - "days" : scope.scheduler_form.schedulerPurgeDays.$viewValue - }; - } - schedule.extra_data = JSON.stringify(extra_vars); - - SchedulePost({ - scope: scope, - url: url, - scheduler: scheduler, - callback: 'ScheduleSaved', - mode: mode, - schedule: schedule - }); - } - else { - scope.schedulerIsValid = false; - } - }; - - scope.deleteSystemSchedule = function(){ - var hdr = 'Delete Schedule', - action = function () { - Wait('start'); - Rest.setUrl(schedule.url); - Rest.destroy() - .success(function () { - $('#prompt-modal').modal('hide'); - Wait('stop'); - // scope.$emit(callback, id); - scope.cancelScheduleForm(); - }) - .error(function (data, status) { - try { - $('#prompt-modal').modal('hide'); - } - catch(e) { - // ignore - } - ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + - ' failed. DELETE returned: ' + status }); - }); - }; - - Prompt({ - hdr: hdr, - body: "
Are you sure you want to delete the " + scope.schedulerName + " schedule?
", - action: action, - backdrop: false - }); - }; - - scope.cancelScheduleForm = function() { - container.hide('slide', { direction: 'right' }, 500, restoreList); - $("#configure-save-button").remove(); - scope.$destroy(); - }; - - if (mode === 'edit') { - // Get the existing record - Rest.setUrl(url); //GetBasePath('schedules')+id+'/'); - Rest.get() - .success(function(data) { - schedule = data.results[0]; - id = schedule.id; - if (!/DTSTART/.test(schedule.rrule)) { - schedule.rrule += ";DTSTART=" + schedule.dtstart.replace(/\.\d+Z$/,'Z'); - } - schedule.rrule = schedule.rrule.replace(/ RRULE:/,';'); - schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART='); - scope.$emit('ScheduleReady'); - }) - .error(function(data,status){ - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Failed to get: ' + url + ' GET returned: ' + status }); - }); - } - else { - scope.$emit('ScheduleReady'); - } - }; - }]); diff --git a/awx/ui/client/src/helpers/CustomInventory.js b/awx/ui/client/src/helpers/CustomInventory.js deleted file mode 100644 index 2098109a03..0000000000 --- a/awx/ui/client/src/helpers/CustomInventory.js +++ /dev/null @@ -1,362 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - -/** - * @ngdoc function - * @name helpers.function:CustomInventory - * @description - * Schedules Helper - * - * Display the scheduler widget in a dialog - * - */ - -import listGenerator from '../shared/list-generator/main'; - -export default - angular.module('CreateCustomInventoryHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', listGenerator.name, 'ModalDialog', - 'GeneratorHelpers', 'CustomInventoryFormDefinition']) - - .factory('CreateCustomInventory', ['Wait', 'CreateDialog', 'CustomInventoryList', 'generateList', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'PlaybookRun', 'CustomInventoryAdd', - 'SchedulesList', 'CustomInventoryEdit', 'Rest' , 'ProcessErrors', 'CustomInventoryForm', 'GenerateForm', 'Prompt', - function(Wait, CreateDialog, CustomInventoryList, GenerateList, GetBasePath, SearchInit, PaginateInit, PlaybookRun, CustomInventoryAdd, - SchedulesList, CustomInventoryEdit, Rest, ProcessErrors, CustomInventoryForm, GenerateForm, Prompt) { - return function(params) { - // Set modal dimensions based on viewport width - - var scope = params.parent_scope.$new(), - callback = 'OpenConfig', - defaultUrl = GetBasePath('inventory_scripts'), - list = CustomInventoryList, - view = GenerateList, - buttons = [ - { - "label": "Close", - "onClick": function() { - // $(this).dialog('close'); - scope.cancelConfigure(); - }, - "icon": "fa-times", - "class": "btn btn-default", - "id": "script-close-button" - } - ]; - - scope.cleanupJob = true; - - if(scope.removeOpenConfig) { - scope.removeOpenConfig(); - } - scope.removeOpenConfig = scope.$on('OpenConfig', function() { - $('#custom-script-dialog').dialog('open'); - $('#script-close-button').focus(); - $('#script-close-button').blur(); - }); - - view.inject( list, { - id : 'custom-script-dialog', - mode: 'edit', - scope: scope, - breadCrumbs: false, - activityStream: false, - showSearch: true - }); - - SearchInit({ - scope: scope, - set: 'source_scripts' , // 'custom_inventories', - list: list, - url: defaultUrl - }); - PaginateInit({ - scope: scope, - list: list, - url: defaultUrl - }); - - scope.search(list.iterator); - - // SchedulesControllerInit({ - // scope: scope, - // parent_scope: parent_scope, - // // list: list - // }); - - - CreateDialog({ - id: 'custom-script-dialog', - title: 'Inventory Scripts', - target: 'custom-script-dialog', - scope: scope, - buttons: buttons, - width: 700, - height: 800, - minWidth: 400, - callback: callback, - onClose: function () { - // Destroy on close - $('.tooltip').each(function () { - // Remove any lingering tooltip
elements - $(this).remove(); - }); - $('.popover').each(function () { - // remove lingering popover
elements - $(this).remove(); - }); - // $("#configure-jobs").show(); - // $("#configure-schedules-form-container").hide(); - // $('#configure-schedules-list').empty(); - // $('#configure-schedules-form').empty(); - // $('#configure-schedules-detail').empty(); - // $('#configure-tower-dialog').hide(); - $(this).dialog('destroy'); - scope.cancelConfigure(); - }, - }); - - - - // Cancel - scope.cancelConfigure = function () { - try { - $('#custom-script-dialog').dialog('close'); - } - catch(e) { - //ignore - } - if (scope.searchCleanup) { - scope.searchCleanup(); - } - // if (!Empty(parent_scope) && parent_scope.restoreSearch) { - // parent_scope.restoreSearch(); - // } - else { - Wait('stop'); - } - }; - - scope.editCustomInv = function(id){ - CustomInventoryEdit({ - scope: scope, - id: id - }); - }; - scope.deleteCustomInv = function(id, name){ - - var action = function () { - $('#prompt-modal').modal('hide'); - Wait('start'); - var url = defaultUrl + id + '/'; - Rest.setUrl(url); - Rest.destroy() - .success(function () { - scope.search(list.iterator); - }) - .error(function (data, status) { - ProcessErrors(scope, data, status, null, { hdr: 'Error!', - msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); - }); - }; - - var bodyHtml = "
Are you sure you want to delete " + name + "?
"; - Prompt({ - hdr: 'Delete', - body: bodyHtml, - action: action - }); - }; - - scope.addCustomInv = function(){ - CustomInventoryAdd({ - scope: scope - }); - }; - - - - }; - }]) - - - .factory('CustomInventoryAdd', ['$compile','SchedulerInit', 'Rest', 'Wait', 'CustomInventoryList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm', - 'SearchInit' , 'PaginateInit', 'generateList', 'LookUpInit', 'OrganizationList', - function($compile, SchedulerInit, Rest, Wait, CustomInventoryList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm, - SearchInit, PaginateInit, GenerateList, LookUpInit, OrganizationList) { - return function(params) { - var scope = params.scope, - generator = GenerateForm, - form = CustomInventoryForm, - view = GenerateList, - list = CustomInventoryList, - url = GetBasePath('inventory_scripts'); - - generator.inject(form, { id:'custom-script-dialog', mode: 'add' , scope:scope, related: false, breadCrumbs: false}); - generator.reset(); - - LookUpInit({ - url: GetBasePath('organization'), - scope: scope, - form: form, - // hdr: "Select Custom Inventory", - list: OrganizationList, - field: 'organization', - input_type: 'radio' - }); - - // Save - scope.formSave = function () { - generator.clearApiErrors(); - Wait('start'); - Rest.setUrl(url); - Rest.post({ name: scope.name, description: scope.description, organization: scope.organization, script: scope.script }) - .success(function () { - view.inject( list, { - id : 'custom-script-dialog', - mode: 'edit', - scope: scope, - breadCrumbs: false, - activityStream: false, - showSearch: true - }); - - SearchInit({ - scope: scope, - set: 'source_scripts', //'custom_inventories', - list: list, - url: url - }); - PaginateInit({ - scope: scope, - list: list, - url: url - }); - - scope.search(list.iterator); - Wait('stop'); - Wait('stop'); - - }) - .error(function (data, status) { - ProcessErrors(scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to add new inventory script. POST returned status: ' + status }); - }); - }; - - // Cancel - scope.formReset = function () { - generator.reset(); - }; - }; - }]) - - .factory('CustomInventoryEdit', ['$compile','CustomInventoryList', 'Rest', 'Wait', 'generateList', 'CustomInventoryForm', 'ProcessErrors', 'GetBasePath', 'Empty', 'GenerateForm', - 'SearchInit', 'PaginateInit', '$routeParams', 'OrganizationList', 'LookUpInit', - function($compile, CustomInventoryList, Rest, Wait, GenerateList, CustomInventoryForm, ProcessErrors, GetBasePath, Empty, GenerateForm, - SearchInit, PaginateInit, $routeParams, OrganizationList, LookUpInit) { - return function(params) { - var scope = params.scope, - id = params.id, - generator = GenerateForm, - form = CustomInventoryForm, - view = GenerateList, - list = CustomInventoryList, - master = {}, - url = GetBasePath('inventory_scripts'); - - generator.inject(form, { - id:'custom-script-dialog', - mode: 'edit' , - scope:scope, - related: false, - breadCrumbs: false, - activityStream: false - }); - generator.reset(); - LookUpInit({ - url: GetBasePath('organization'), - scope: scope, - form: form, - // hdr: "Select Custom Inventory", - list: OrganizationList, - field: 'organization', - input_type: 'radio' - }); - - // Retrieve detail record and prepopulate the form - Wait('start'); - Rest.setUrl(url + id+'/'); - Rest.get() - .success(function (data) { - var fld; - for (fld in form.fields) { - if (data[fld]) { - scope[fld] = data[fld]; - master[fld] = data[fld]; - } - - if (form.fields[fld].sourceModel && data.summary_fields && - data.summary_fields[form.fields[fld].sourceModel]) { - scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = - data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField]; - master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = - data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField]; - } - } - Wait('stop'); - }) - .error(function (data, status) { - ProcessErrors(scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to retrieve inventory script: ' + $routeParams.id + '. GET status: ' + status }); - }); - - scope.formSave = function () { - generator.clearApiErrors(); - Wait('start'); - Rest.setUrl(url+ id+'/'); - Rest.put({ name: scope.name, description: scope.description, organization: scope.organization, script: scope.script }) - .success(function () { - view.inject( list, { - id : 'custom-script-dialog', - mode: 'edit', - scope: scope, - breadCrumbs: false, - activityStream: false, - showSearch: true - }); - - SearchInit({ - scope: scope, - set: 'source_scripts', //'custom_inventories', - list: list, - url: url - }); - PaginateInit({ - scope: scope, - list: list, - url: url - }); - - scope.search(list.iterator); - - Wait('stop'); - - }) - .error(function (data, status) { - ProcessErrors(scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to add new inventory script. PUT returned status: ' + status }); - }); - }; - - scope.formReset = function () { - generator.reset(); - for (var fld in master) { - scope[fld] = master[fld]; - } - scope.organization_name = master.organization_name; - - }; - }; - }]); diff --git a/awx/ui/client/src/helpers/Groups.js b/awx/ui/client/src/helpers/Groups.js index 553f236c66..3ec0ad2a86 100644 --- a/awx/ui/client/src/helpers/Groups.js +++ b/awx/ui/client/src/helpers/Groups.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + 'use strict'; /** @@ -235,8 +235,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name * TODO: Document * */ -.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList', 'CreateSelect2', - function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList, CreateSelect2) { +.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'inventoryScriptsListObject', 'CreateSelect2', + function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, inventoryScriptsListObject, CreateSelect2) { return function (params) { var scope = params.scope, @@ -289,7 +289,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name scope: scope, form: form, hdr: "Select Custom Inventory", - list: CustomInventoryList, + list: inventoryScriptsListObject, field: 'source_script', input_type: 'radio' }); diff --git a/awx/ui/client/src/helpers/PaginationHelpers.js b/awx/ui/client/src/helpers/PaginationHelpers.js index 1f35ad70ae..652e17c7f2 100644 --- a/awx/ui/client/src/helpers/PaginationHelpers.js +++ b/awx/ui/client/src/helpers/PaginationHelpers.js @@ -3,7 +3,7 @@ * * All Rights Reserved *************************************************/ - + /** * @ngdoc function * @name helpers.function:PaginationHelpers @@ -28,7 +28,7 @@ export default scope[iterator + '_num_pages'] = Math.ceil((count / scope[iterator + '_page_size'])); scope[iterator + '_num_pages'] = (scope[iterator + '_num_pages'] <= 0) ? 1 : scope[iterator + '_num_pages']; scope[iterator + '_total_rows'] = count; - $('#pagination-links li:eq(1)').removeAttr('class'); + $('#'+iterator+'-pagination #pagination-links li:eq(1)').removeAttr('class'); // Which page are we on? if (Empty(next) && previous) { // no next page, but there is a previous page @@ -36,7 +36,7 @@ export default } else if (next && Empty(previous)) { // next page available, but no previous page scope[iterator + '_page'] = 1; - $('#pagination-links li:eq(1)').attr('class', 'disabled'); + $('#'+iterator+'-pagination #pagination-links li:eq(1)').attr('class', 'disabled'); } else if (next && previous) { // we're in between next and previous scope[iterator + '_page'] = parseInt(previous.match(/page=\d+/)[0].replace(/page=/, '')) + 1; diff --git a/awx/ui/client/src/helpers/Schedules.js b/awx/ui/client/src/helpers/Schedules.js index 0aa0f2e6fe..6c07823926 100644 --- a/awx/ui/client/src/helpers/Schedules.js +++ b/awx/ui/client/src/helpers/Schedules.js @@ -75,8 +75,10 @@ export default }; }]) - .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', 'Rest', 'ProcessErrors', 'GetBasePath', 'SchedulePost', - function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ProcessErrors, GetBasePath, SchedulePost) { + .factory('EditSchedule', ['SchedulerInit', 'ShowSchedulerModal', 'Wait', + 'Rest', 'ProcessErrors', 'GetBasePath', 'SchedulePost', + function(SchedulerInit, ShowSchedulerModal, Wait, Rest, ProcessErrors, + GetBasePath, SchedulePost) { return function(params) { var scope = params.scope, id = params.id, @@ -84,6 +86,63 @@ export default schedule, scheduler, url = GetBasePath('schedules') + id + '/'; + delete scope.isFactCleanup; + delete scope.cleanupJob; + + function setGranularity(){ + var a,b, prompt_for_days, + keep_unit, + granularity, + granularity_keep_unit; + + if(scope.cleanupJob){ + scope.schedulerPurgeDays = Number(schedule.extra_data.days); + // scope.scheduler_form.schedulerPurgeDays.$setViewValue( Number(schedule.extra_data.days)); + } + else if(scope.isFactCleanup){ + scope.keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.granularity_keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + // the API returns something like 20w or 1y + a = schedule.extra_data.older_than; // "20y" + b = schedule.extra_data.granularity; // "1w" + prompt_for_days = Number(_.initial(a,1).join('')); // 20 + keep_unit = _.last(a); // "y" + granularity = Number(_.initial(b,1).join('')); // 1 + granularity_keep_unit = _.last(b); // "w" + + scope.keep_amount = prompt_for_days; + scope.granularity_keep_amount = granularity; + scope.keep_unit = _.find(scope.keep_unit_choices, function(i){ + return i.value === keep_unit; + }); + scope.granularity_keep_unit =_.find(scope.granularity_keep_unit_choices, function(i){ + return i.value === granularity_keep_unit; + }); + } + } + if (scope.removeDialogReady) { scope.removeDialogReady(); } @@ -94,6 +153,10 @@ export default scope.$apply(function() { scheduler.setRRule(schedule.rrule); scheduler.setName(schedule.name); + if(scope.isFactCleanup || scope.cleanupJob){ + setGranularity(); + } + }); }, 300); }); @@ -112,7 +175,6 @@ export default } schedule.rrule = schedule.rrule.replace(/ RRULE:/,';'); schedule.rrule = schedule.rrule.replace(/DTSTART:/,'DTSTART='); - ShowSchedulerModal({ scope: scope, callback: 'DialogReady', title: 'Edit Schedule' }); scope.showRRuleDetail = false; }); @@ -141,6 +203,8 @@ export default }); }; + + $('#scheduler-tabs li a').on('shown.bs.tab', function(e) { if ($(e.target).text() === 'Details') { if (!scheduler.isValid()) { @@ -156,6 +220,13 @@ export default Rest.get() .success(function(data) { schedule = data; + if(schedule.hasOwnProperty('extra_data')) { + if(schedule.extra_data.hasOwnProperty('granularity')){ + scope.isFactCleanup = true; + } else { + scope.cleanupJob = true; + } + } scope.$emit('ScheduleFound'); }) .error(function(data,status){ @@ -181,6 +252,43 @@ export default else if (!Empty($routeParams.id)) { url += $routeParams.id + '/schedules/'; } + else if (!Empty($routeParams.management_job)) { + url += $routeParams.management_job + '/schedules/'; + if(scope.management_job.id === 4){ + scope.isFactCleanup = true; + scope.keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.granularity_keep_unit_choices = [{ + "label" : "Days", + "value" : "d" + }, + { + "label": "Weeks", + "value" : "w" + }, + { + "label" : "Years", + "value" : "y" + }]; + scope.prompt_for_days_facts_form.keep_amount.$setViewValue(30); + scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1); + scope.keep_unit = scope.keep_unit_choices[0]; + scope.granularity_keep_unit = scope.granularity_keep_unit_choices[1]; + } + else { + scope.cleanupJob = true; + } + } if (scope.removeDialogReady) { scope.removeDialogReady(); @@ -239,7 +347,7 @@ export default mode = params.mode, schedule = (params.schedule) ? params.schedule : {}, callback = params.callback, - newSchedule, rrule; + newSchedule, rrule, extra_vars; if (scheduler.isValid()) { Wait('start'); @@ -248,6 +356,20 @@ export default schedule.name = newSchedule.name; schedule.rrule = RRuleToAPI(rrule.toString()); schedule.description = (/error/.test(rrule.toText())) ? '' : rrule.toText(); + + if (scope.isFactCleanup) { + extra_vars = { + "older_than": scope.scheduler_form.keep_amount.$viewValue + scope.scheduler_form.keep_unit.$viewValue.value, + "granularity": scope.scheduler_form.granularity_keep_amount.$viewValue + scope.scheduler_form.granularity_keep_unit.$viewValue.value + }; + } else if (scope.cleanupJob) { + extra_vars = { + "days" : scope.scheduler_form.schedulerPurgeDays.$viewValue + }; + } + schedule.extra_data = JSON.stringify(extra_vars); + + Rest.setUrl(url); if (mode === 'add') { Rest.post(schedule) @@ -442,8 +564,10 @@ export default }]) - .factory('SchedulesControllerInit', ['$location', 'ToggleSchedule', 'DeleteSchedule', 'EditSchedule', 'AddSchedule', - function($location, ToggleSchedule, DeleteSchedule, EditSchedule, AddSchedule) { + .factory('SchedulesControllerInit', ['$location', 'ToggleSchedule', + 'DeleteSchedule', 'EditSchedule', 'AddSchedule', + function($location, ToggleSchedule, DeleteSchedule, EditSchedule, + AddSchedule) { return function(params) { var scope = params.scope, parent_scope = params.parent_scope, diff --git a/awx/ui/client/src/inventory-scripts/add/add.controller.js b/awx/ui/client/src/inventory-scripts/add/add.controller.js new file mode 100644 index 0000000000..29f431726a --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/add/add.controller.js @@ -0,0 +1,67 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +export default + [ '$compile','SchedulerInit', 'Rest', 'Wait', + 'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty', + 'GenerateForm', 'SearchInit' , 'PaginateInit', + 'LookUpInit', 'OrganizationList', '$scope', 'transitionTo', + function( + $compile, SchedulerInit, Rest, Wait, + inventoryScriptsFormObject, ProcessErrors, GetBasePath, Empty, + GenerateForm, SearchInit, PaginateInit, + LookUpInit, OrganizationList, $scope, transitionTo + ) { + var scope = $scope, + generator = GenerateForm, + form = inventoryScriptsFormObject, + url = GetBasePath('inventory_scripts'); + + generator.inject(form, { + mode: 'add' , + scope:scope, + related: false + }); + generator.reset(); + + LookUpInit({ + url: GetBasePath('organization'), + scope: scope, + form: form, + list: OrganizationList, + field: 'organization', + input_type: 'radio' + }); + + // Save + scope.formSave = function () { + generator.clearApiErrors(); + Wait('start'); + Rest.setUrl(url); + Rest.post({ + name: scope.name, + description: scope.description, + organization: scope.organization, + script: scope.script + }) + .success(function () { + transitionTo('inventoryScriptsList'); + Wait('stop'); + + }) + .error(function (data, status) { + ProcessErrors(scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new inventory script. POST returned status: ' + status }); + }); + }; + + // Cancel + scope.formReset = function () { + generator.reset(); + }; + + } + ]; diff --git a/awx/ui/client/src/inventory-scripts/add/add.partial.html b/awx/ui/client/src/inventory-scripts/add/add.partial.html new file mode 100644 index 0000000000..a9e7a04b9b --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/add/add.partial.html @@ -0,0 +1,12 @@ + + + + + + + +
+
+
diff --git a/awx/ui/client/src/inventory-scripts/add/add.route.js b/awx/ui/client/src/inventory-scripts/add/add.route.js new file mode 100644 index 0000000000..d9259cf596 --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/add/add.route.js @@ -0,0 +1,19 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import {templateUrl} from '../../shared/template-url/template-url.factory'; + +export default { + name: 'inventoryScriptsAdd', + route: '/inventory_scripts/add', + templateUrl: templateUrl('inventory-scripts/add/add'), + controller: 'addController', + resolve: { + features: ['FeaturesService', function(FeaturesService) { + return FeaturesService.get(); + }] + } +}; diff --git a/awx/ui/client/src/inventory-scripts/add/main.js b/awx/ui/client/src/inventory-scripts/add/main.js new file mode 100644 index 0000000000..f996e43b13 --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/add/main.js @@ -0,0 +1,17 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import route from './add.route'; +import controller from './add.controller'; + +export default + angular.module('inventoryScriptsAdd', []) + .controller('addController', controller) + .config(['$routeProvider', function($routeProvider) { + var url = route.route; + delete route.route; + $routeProvider.when(url, route); + }]); diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.controller.js b/awx/ui/client/src/inventory-scripts/edit/edit.controller.js new file mode 100644 index 0000000000..0d2d2c52ed --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/edit/edit.controller.js @@ -0,0 +1,103 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +export default + [ 'Rest', 'Wait', + 'inventoryScriptsFormObject', 'ProcessErrors', 'GetBasePath', + 'GenerateForm', 'SearchInit' , 'PaginateInit', + 'LookUpInit', 'OrganizationList', 'inventory_script', + '$scope', 'transitionTo', + function( + Rest, Wait, + inventoryScriptsFormObject, ProcessErrors, GetBasePath, + GenerateForm, SearchInit, PaginateInit, + LookUpInit, OrganizationList, inventory_script, + $scope, transitionTo + ) { + var generator = GenerateForm, + id = inventory_script.id, + form = inventoryScriptsFormObject, + master = {}, + url = GetBasePath('inventory_scripts'); + + $scope.inventory_script = inventory_script; + generator.inject(form, { + mode: 'edit' , + scope:$scope, + breadCrumbs: true, + related: false, + activityStream: false + }); + generator.reset(); + LookUpInit({ + url: GetBasePath('organization'), + scope: $scope, + form: form, + // hdr: "Select Custom Inventory", + list: OrganizationList, + field: 'organization', + input_type: 'radio' + }); + + // Retrieve detail record and prepopulate the form + Wait('start'); + Rest.setUrl(url + id+'/'); + Rest.get() + .success(function (data) { + var fld; + for (fld in form.fields) { + if (data[fld]) { + $scope[fld] = data[fld]; + master[fld] = data[fld]; + } + + if (form.fields[fld].sourceModel && data.summary_fields && + data.summary_fields[form.fields[fld].sourceModel]) { + $scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = + data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField]; + master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = + data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField]; + } + } + Wait('stop'); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to retrieve inventory script: ' + id + '. GET status: ' + status }); + }); + + $scope.formSave = function () { + generator.clearApiErrors(); + Wait('start'); + Rest.setUrl(url+ id+'/'); + Rest.put({ + name: $scope.name, + description: $scope.description, + organization: $scope.organization, + script: $scope.script + }) + .success(function () { + transitionTo('inventoryScriptsList'); + Wait('stop'); + + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new inventory script. PUT returned status: ' + status }); + }); + }; + + $scope.formReset = function () { + generator.reset(); + for (var fld in master) { + $scope[fld] = master[fld]; + } + $scope.organization_name = master.organization_name; + + }; + + } + ]; diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.partial.html b/awx/ui/client/src/inventory-scripts/edit/edit.partial.html new file mode 100644 index 0000000000..854bcf4fad --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/edit/edit.partial.html @@ -0,0 +1,9 @@ + + + + + + +
+
+
diff --git a/awx/ui/client/src/inventory-scripts/edit/edit.route.js b/awx/ui/client/src/inventory-scripts/edit/edit.route.js new file mode 100644 index 0000000000..0215420bdd --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/edit/edit.route.js @@ -0,0 +1,46 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import {templateUrl} from '../../shared/template-url/template-url.factory'; + +export default { + name: 'inventoryScriptsEdit', + route: '/inventory_scripts/:inventory_script', + templateUrl: templateUrl('inventory-scripts/edit/edit'), + controller: 'editController', + resolve: { + features: ['FeaturesService', function(FeaturesService) { + return FeaturesService.get(); + }], + inventory_script: + [ '$route', + '$q', + 'Rest', + 'GetBasePath', + 'ProcessErrors', + function($route, $q, rest, getBasePath, ProcessErrors) { + if ($route.current.hasModelKey('inventory_script')) { + return $q.when($route.current.params.model.inventory_script); + } + + var inventoryScriptId = $route.current.params.inventory_script; + + var url = getBasePath('inventory_scripts') + inventoryScriptId + '/'; + rest.setUrl(url); + return rest.get() + .then(function(data) { + return data.data; + }).catch(function (response) { + ProcessErrors(null, response.data, response.status, null, { + hdr: 'Error!', + msg: 'Failed to get inventory script info. GET returned status: ' + + response.status + }); + }); + } + ] + } +}; diff --git a/awx/ui/client/src/inventory-scripts/edit/main.js b/awx/ui/client/src/inventory-scripts/edit/main.js new file mode 100644 index 0000000000..e0e3326800 --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/edit/main.js @@ -0,0 +1,17 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import route from './edit.route'; +import controller from './edit.controller'; + +export default + angular.module('inventoryScriptsEdit', []) + .controller('editController', controller) + .config(['$routeProvider', function($routeProvider) { + var url = route.route; + delete route.route; + $routeProvider.when(url, route); + }]); diff --git a/awx/ui/client/src/inventory-scripts/inventory-scripts.form.js b/awx/ui/client/src/inventory-scripts/inventory-scripts.form.js new file mode 100644 index 0000000000..f430dfe5d2 --- /dev/null +++ b/awx/ui/client/src/inventory-scripts/inventory-scripts.form.js @@ -0,0 +1,75 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + + /** + * @ngdoc function + * @name forms.function:CustomInventory + * @description This form is for adding/editing an organization +*/ + +export default function() { + return { + + // addTitle: 'Create Custom Inventory', + // editTitle: '{{ name }}', + // name: 'custom_inventory', + well: true, + showActions: true, + + fields: { + name: { + label: 'Name', + type: 'text', + addRequired: true, + editRequired: true, + capitalize: false + }, + description: { + label: 'Description', + type: 'text', + addRequired: false, + editRequired: false + }, + organization: { + label: 'Organization', + type: 'lookup', + awRequiredWhen: { + variable: "orgrequired", + init: true + }, + sourceModel: 'organization', + sourceField: 'name', + ngClick: 'lookUpOrganization()' + }, + script: { + label: 'Custom Script', + type: 'textarea', + hintText: "Drag and drop an inventory script on the field below", + addRequired: true, + editRequired: true, + awDropFile: true, + // 'class': 'ssh-key-field', + rows: 10, + awPopOver: "

Drag and drop your custom inventory script file here or create one in the field to import your custom inventory. " + + "

Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python

", + dataTitle: 'Custom Script', + dataPlacement: 'right', + dataContainer: "body" + }, + }, + + buttons: { //for now always generates -
-
-
-
-
-
- View Details - Back to options - - - -
-
- - - diff --git a/awx/ui/client/src/partials/schedule_dialog.html b/awx/ui/client/src/partials/schedule_dialog.html index d9feaf4e38..bdf72a5dd5 100644 --- a/awx/ui/client/src/partials/schedule_dialog.html +++ b/awx/ui/client/src/partials/schedule_dialog.html @@ -1,4 +1,4 @@ -
+
- - +

View Your License

diff --git a/awx/ui/client/src/setup-menu/setup.controller.js b/awx/ui/client/src/setup-menu/setup.controller.js index f55c4ddc91..31ca9f7fe8 100644 --- a/awx/ui/client/src/setup-menu/setup.controller.js +++ b/awx/ui/client/src/setup-menu/setup.controller.js @@ -2,26 +2,11 @@ export default [ '$scope', '$rootScope', 'AboutAnsibleHelp', - 'ConfigureTower', - 'CreateCustomInventory', function( $scope, $rootScope, - showAboutModal, - configureTower, - showInventoryScriptsModal + showAboutModal ) { $scope.showAboutModal = showAboutModal; - - $scope.showManagementJobsModal = - configureTower.bind(null, - { scope: $rootScope, - parent_scope: $rootScope - }); - - $scope.showInventoryScriptsModal = showInventoryScriptsModal.bind(null, - { parent_scope: $rootScope - }); - } ]; diff --git a/awx/ui/client/src/shared/AuthService.js b/awx/ui/client/src/shared/AuthService.js index b83c22ae19..5224f7580b 100644 --- a/awx/ui/client/src/shared/AuthService.js +++ b/awx/ui/client/src/shared/AuthService.js @@ -67,8 +67,7 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) var scope = angular.element(document.getElementById('main-view')).scope(); scope.$destroy(); //$rootScope.$destroy(); - $cookieStore.remove('token_expires'); - $cookieStore.remove('current_user'); + if($cookieStore.get('lastPath')==='/portal'){ $cookieStore.put( 'lastPath', '/portal'); @@ -76,7 +75,7 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) } else if ($cookieStore.get('lastPath') !== '/home' || $cookieStore.get('lastPath') !== '/' || $cookieStore.get('lastPath') !== '/login' || $cookieStore.get('lastPath') !== '/logout'){ // do nothing - $rootScope.lastPath = $cookieStore.get('lastPath'); + $rootScope.lastPath = $cookieStore.get('lastPath'); } else { // your last path was home @@ -84,6 +83,9 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) $rootScope.lastPath = '/home'; } + $rootScope.lastUser = $cookieStore.get('current_user').id; + $cookieStore.remove('token_expires'); + $cookieStore.remove('current_user'); $cookieStore.remove('token'); $cookieStore.put('userLoggedIn', false); $cookieStore.put('sessionExpired', false); diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index 97d55dc7b8..b85c11a3a4 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -152,33 +152,9 @@ - + - - +