mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Ran all controller files through jsbeautifier.org and applied jsHint.
This commit is contained in:
@@ -10,26 +10,42 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function AdminsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
function AdminsList($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||||
Alert, AdminList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
Alert, AdminList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
||||||
ReturnToCaller,GetBasePath, SelectionInit)
|
ReturnToCaller, GetBasePath, SelectionInit) {
|
||||||
{
|
|
||||||
var list = AdminList;
|
|
||||||
var defaultUrl = GetBasePath('organizations') + $routeParams.organization_id + '/users/' ;
|
|
||||||
var view = GenerateList;
|
|
||||||
var mode = 'select';
|
|
||||||
var scope = view.inject(AdminList, { mode: mode }); // Inject our view
|
|
||||||
|
|
||||||
var url = GetBasePath('organizations') + $routeParams.organization_id + '/admins/';
|
var list = AdminList,
|
||||||
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
defaultUrl = GetBasePath('organizations') + $routeParams.organization_id + '/users/',
|
||||||
|
view = GenerateList,
|
||||||
|
mode = 'select',
|
||||||
|
scope = view.inject(AdminList, { mode: mode }),
|
||||||
|
url = GetBasePath('organizations') + $routeParams.organization_id + '/admins/';
|
||||||
|
|
||||||
|
SelectionInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: url,
|
||||||
|
returnToCaller: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
SearchInit({
|
||||||
|
scope: scope,
|
||||||
|
set: 'admins',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'admins', list: list, url: defaultUrl });
|
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'AdminList', 'GenerateList',
|
AdminsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'AdminList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'GetBasePath', 'SelectionInit'];
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'GetBasePath', 'SelectionInit'
|
||||||
|
];
|
||||||
@@ -8,139 +8,145 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* globals console:false */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
|
function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
|
||||||
Timer, Empty)
|
Timer, Empty) {
|
||||||
{
|
|
||||||
var setLoginFocus = function() {
|
|
||||||
$('#login-username').focus();
|
|
||||||
};
|
|
||||||
|
|
||||||
var sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
|
var setLoginFocus, lastPath, sessionExpired, scope;
|
||||||
|
|
||||||
var lastPath = function() {
|
setLoginFocus = function () {
|
||||||
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
$('#login-username').focus();
|
||||||
}
|
};
|
||||||
|
|
||||||
if ($AnsibleConfig.debug_mode && console) {
|
sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
|
||||||
console.log('User session expired: ' + sessionExpired);
|
|
||||||
console.log('Last URL: ' + lastPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide any lingering modal dialogs
|
lastPath = function () {
|
||||||
$('.modal[aria-hidden=false]').each( function() {
|
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
||||||
if ($(this).attr('id') !== 'login-modal') {
|
};
|
||||||
$(this).modal('hide');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Just in case, make sure the wait widget is not active
|
if ($AnsibleConfig.debug_mode && console) {
|
||||||
Wait('stop');
|
console.log('User session expired: ' + sessionExpired);
|
||||||
|
console.log('Last URL: ' + lastPath());
|
||||||
|
}
|
||||||
|
|
||||||
// Display the login dialog
|
// Hide any lingering modal dialogs
|
||||||
$('#login-modal').modal({ show: true, keyboard: false, backdrop: 'static' });
|
$('.modal[aria-hidden=false]').each(function () {
|
||||||
|
if ($(this).attr('id') !== 'login-modal') {
|
||||||
|
$(this).modal('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Set focus to username field
|
// Just in case, make sure the wait widget is not active
|
||||||
$('#login-modal').on('shown.bs.modal', function() {
|
Wait('stop');
|
||||||
setLoginFocus();
|
|
||||||
});
|
|
||||||
|
|
||||||
var scope = angular.element(document.getElementById('login-modal')).scope();
|
// Display the login dialog
|
||||||
|
$('#login-modal').modal({
|
||||||
|
show: true,
|
||||||
|
keyboard: false,
|
||||||
|
backdrop: 'static'
|
||||||
|
});
|
||||||
|
|
||||||
// Reset the login form
|
// Set focus to username field
|
||||||
scope['login_username'] = null;
|
$('#login-modal').on('shown.bs.modal', function () {
|
||||||
scope['login_password'] = null;
|
setLoginFocus();
|
||||||
scope['loginForm']['login_username'].$setPristine();
|
});
|
||||||
scope['loginForm']['login_password'].$setPristine();
|
|
||||||
|
|
||||||
if ($location.path() == '/logout') {
|
scope = angular.element(document.getElementById('login-modal')).scope();
|
||||||
//if logout request, clear AuthToken and user session data
|
|
||||||
Authorization.logout();
|
|
||||||
}
|
|
||||||
|
|
||||||
$rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out.
|
// Reset the login form
|
||||||
$cookieStore.put('userLoggedIn', false); //gets set back to true by Authorization.setToken().
|
scope.login_username = null;
|
||||||
|
scope.login_password = null;
|
||||||
|
scope.loginForm.login_username.$setPristine();
|
||||||
|
scope.loginForm.login_password.$setPristine();
|
||||||
|
|
||||||
$('#login-password').bind('keypress', function(e) {
|
if ($location.path() === '/logout') {
|
||||||
var code = (e.keyCode ? e.keyCode : e.which);
|
//if logout request, clear AuthToken and user session data
|
||||||
if (code == 13) {
|
Authorization.logout();
|
||||||
$('#login-button').click();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
scope.reset = function() {
|
$rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out.
|
||||||
$('#login-form input').each( function(index) { $(this).val(''); });
|
$cookieStore.put('userLoggedIn', false); //gets set back to true by Authorization.setToken().
|
||||||
};
|
|
||||||
|
|
||||||
// Call the API to get an auth token
|
$('#login-password').bind('keypress', function (e) {
|
||||||
scope.systemLogin = function(username, password) {
|
var code = (e.keyCode ? e.keyCode : e.which);
|
||||||
$('.api-error').empty();
|
if (code === 13) {
|
||||||
var token;
|
$('#login-button').click();
|
||||||
if (username == null || username == undefined || username == '' ||
|
}
|
||||||
password == null || password == undefined || password == '' ) {
|
});
|
||||||
Alert('Error!', 'Please provide a username and password before attempting to login.', 'alert-danger', setLoginFocus);
|
|
||||||
}
|
scope.reset = function () {
|
||||||
else {
|
$('#login-form input').each(function () {
|
||||||
Wait('start');
|
$(this).val('');
|
||||||
Authorization.retrieveToken(username, password)
|
});
|
||||||
.success( function(data, status, headers, config) {
|
};
|
||||||
$('#login-modal').modal('hide');
|
|
||||||
token = data.token;
|
// Call the API to get an auth token
|
||||||
Authorization.setToken(data.token, data.expires);
|
scope.systemLogin = function (username, password) {
|
||||||
$rootScope.sessionTimer = Timer.init();
|
$('.api-error').empty();
|
||||||
// Get all the profile/access info regarding the logged in user
|
var token;
|
||||||
Authorization.getUser()
|
if (Empty(username) || Empty(password)) {
|
||||||
.success(function(data, status, headers, config) {
|
Alert('Error!', 'Please provide a username and password before attempting to login.', 'alert-danger', setLoginFocus);
|
||||||
Authorization.setUserInfo(data);
|
} else {
|
||||||
$rootScope['user_is_superuser'] = data.results[0].is_superuser;
|
Wait('start');
|
||||||
Authorization.getLicense()
|
Authorization.retrieveToken(username, password)
|
||||||
.success(function(data, status, headers, config) {
|
.success(function (data, status) {
|
||||||
Authorization.setLicense(data['license_info']);
|
$('#login-modal').modal('hide');
|
||||||
if (lastPath()) {
|
token = data.token;
|
||||||
// Go back to most recent navigation path
|
Authorization.setToken(data.token, data.expires);
|
||||||
$location.path(lastPath());
|
$rootScope.sessionTimer = Timer.init();
|
||||||
}
|
// Get all the profile/access info regarding the logged in user
|
||||||
else {
|
Authorization.getUser()
|
||||||
$location.url('/home?login=true');
|
.success(function (data) {
|
||||||
}
|
Authorization.setUserInfo(data);
|
||||||
})
|
$rootScope.user_is_superuser = data.results[0].is_superuser;
|
||||||
.error(function(data, status, headers, config) {
|
Authorization.getLicense()
|
||||||
Wait('stop');
|
.success(function (data) {
|
||||||
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
Authorization.setLicense(data.license_info);
|
||||||
});
|
if (lastPath()) {
|
||||||
})
|
// Go back to most recent navigation path
|
||||||
.error( function(data, status, headers, config) {
|
$location.path(lastPath());
|
||||||
Wait('stop');
|
} else {
|
||||||
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
$location.url('/home?login=true');
|
||||||
});
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
if ( data.non_field_errors && data.non_field_errors.length == 0 ) {
|
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
||||||
// show field specific errors returned by the API
|
});
|
||||||
for (var key in data) {
|
})
|
||||||
scope[key + 'Error'] = data[key][0];
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
var hdr, msg, key;
|
||||||
|
Wait('stop');
|
||||||
|
if (data.non_field_errors && data.non_field_errors.length === 0) {
|
||||||
|
// show field specific errors returned by the API
|
||||||
|
for (key in data) {
|
||||||
|
scope[key + 'Error'] = data[key][0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (data.non_field_errors && data.non_field_errors.length > 0) {
|
||||||
|
hdr = 'Error';
|
||||||
|
msg = data.non_field_errors[0];
|
||||||
|
} else {
|
||||||
|
hdr = 'Error';
|
||||||
|
msg = 'The login attempt failed with a status of: ' + status;
|
||||||
|
}
|
||||||
|
scope.reset();
|
||||||
|
Alert(hdr, msg, 'alert-danger', setLoginFocus);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
var hdr, msg;
|
};
|
||||||
if ( data.non_field_errors && data.non_field_errors.length > 0 ) {
|
|
||||||
hdr = 'Error';
|
|
||||||
msg = data.non_field_errors[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
hdr = 'Error';
|
|
||||||
msg = 'The login attempt failed with a status of: ' + status;
|
|
||||||
}
|
|
||||||
scope.reset();
|
|
||||||
Alert(hdr, msg, 'alert-danger', setLoginFocus);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Authenticate.$inject = ['$cookieStore', '$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait',
|
Authenticate.$inject = ['$cookieStore', '$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait',
|
||||||
'Timer', 'Empty'];
|
'Timer', 'Empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,36 +10,48 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function Home ($scope, $compile, $routeParams, $rootScope, $location, Wait, ObjectCount, JobStatus, InventorySyncStatus, SCMSyncStatus,
|
function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, ObjectCount, JobStatus, InventorySyncStatus, SCMSyncStatus,
|
||||||
ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button) {
|
ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button) {
|
||||||
|
|
||||||
ClearScope('home'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('home');
|
||||||
//scope.
|
|
||||||
|
var buttons, html, e, waitCount, loadedCount;
|
||||||
|
|
||||||
// Add buttons to the top of the Home page. We're using lib/ansible/generator_helpers.js-> Buttons()
|
// Add buttons to the top of the Home page. We're using lib/ansible/generator_helpers.js-> Buttons()
|
||||||
// to build buttons dynamically and insure all styling and icons match the rest of the application.
|
// to build buttons dynamically and insure all styling and icons match the rest of the application.
|
||||||
var buttons = {
|
buttons = {
|
||||||
refresh: {
|
refresh: {
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
awToolTip: "Refresh the page",
|
awToolTip: "Refresh the page",
|
||||||
ngClick: "refresh()"
|
ngClick: "refresh()"
|
||||||
},
|
},
|
||||||
stream: {
|
stream: {
|
||||||
ngClick: "showActivity()",
|
ngClick: "showActivity()",
|
||||||
awToolTip: "View Activity Stream",
|
awToolTip: "View Activity Stream",
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var html = Button({ btn: buttons.refresh, action: 'refresh', toolbar: true });
|
|
||||||
html += Button({ btn: buttons.stream, action: 'stream', toolbar: true });
|
html = Button({
|
||||||
var e = angular.element(document.getElementById('home-list-actions'));
|
btn: buttons.refresh,
|
||||||
|
action: 'refresh',
|
||||||
|
toolbar: true
|
||||||
|
});
|
||||||
|
|
||||||
|
html += Button({
|
||||||
|
btn: buttons.stream,
|
||||||
|
action: 'stream',
|
||||||
|
toolbar: true
|
||||||
|
});
|
||||||
|
|
||||||
|
e = angular.element(document.getElementById('home-list-actions'));
|
||||||
e.html(html);
|
e.html(html);
|
||||||
$compile(e)($scope);
|
$compile(e)($scope);
|
||||||
|
|
||||||
var waitCount = 4;
|
waitCount = 4;
|
||||||
var loadedCount = 0;
|
loadedCount = 0;
|
||||||
|
|
||||||
if (!$routeParams['login']) {
|
if (!$routeParams.login) {
|
||||||
// If we're not logging in, start the Wait widget. Otherwise, it's already running.
|
// If we're not logging in, start the Wait widget. Otherwise, it's already running.
|
||||||
Wait('start');
|
Wait('start');
|
||||||
}
|
}
|
||||||
@@ -47,196 +59,231 @@ function Home ($scope, $compile, $routeParams, $rootScope, $location, Wait, Obje
|
|||||||
if ($scope.removeWidgetLoaded) {
|
if ($scope.removeWidgetLoaded) {
|
||||||
$scope.removeWidgetLoaded();
|
$scope.removeWidgetLoaded();
|
||||||
}
|
}
|
||||||
$scope.removeWidgetLoaded = $scope.$on('WidgetLoaded', function() {
|
$scope.removeWidgetLoaded = $scope.$on('WidgetLoaded', function () {
|
||||||
// Once all the widgets report back 'loaded', turn off Wait widget
|
// Once all the widgets report back 'loaded', turn off Wait widget
|
||||||
loadedCount++;
|
loadedCount++;
|
||||||
if ( loadedCount == waitCount ) {
|
if (loadedCount === waitCount) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($scope.removeDashboardReady) {
|
if ($scope.removeDashboardReady) {
|
||||||
$scope.removeDashboardReady();
|
$scope.removeDashboardReady();
|
||||||
}
|
}
|
||||||
$scope.removeDashboardReady = $scope.$on('dashboardReady', function(e, data) {
|
$scope.removeDashboardReady = $scope.$on('dashboardReady', function (e, data) {
|
||||||
JobStatus({ scope: $scope, target: 'container1', dashboard: data});
|
JobStatus({
|
||||||
InventorySyncStatus({ scope: $scope, target: 'container2', dashboard: data});
|
scope: $scope,
|
||||||
SCMSyncStatus({ scope: $scope, target: 'container4', dashboard: data});
|
target: 'container1',
|
||||||
ObjectCount({ scope: $scope, target: 'container3', dashboard: data});
|
dashboard: data
|
||||||
});
|
});
|
||||||
|
InventorySyncStatus({
|
||||||
|
scope: $scope,
|
||||||
|
target: 'container2',
|
||||||
|
dashboard: data
|
||||||
|
});
|
||||||
|
SCMSyncStatus({
|
||||||
|
scope: $scope,
|
||||||
|
target: 'container4',
|
||||||
|
dashboard: data
|
||||||
|
});
|
||||||
|
ObjectCount({
|
||||||
|
scope: $scope,
|
||||||
|
target: 'container3',
|
||||||
|
dashboard: data
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$scope.showActivity = function() { Stream({ scope: $scope }); }
|
$scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: $scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.refresh = function() {
|
$scope.refresh = function () {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
loadedCount = 0;
|
loadedCount = 0;
|
||||||
Rest.setUrl(GetBasePath('dashboard'));
|
Rest.setUrl(GetBasePath('dashboard'));
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
$scope.$emit('dashboardReady', data);
|
$scope.$emit('dashboardReady', data);
|
||||||
})
|
})
|
||||||
.error ( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors($scope, data, status, null,
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Failed to get dashboard: ' + status });
|
});
|
||||||
})
|
};
|
||||||
}
|
|
||||||
|
|
||||||
$scope.refresh();
|
$scope.refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Home.$inject=['$scope', '$compile', '$routeParams', '$rootScope', '$location', 'Wait', 'ObjectCount', 'JobStatus', 'InventorySyncStatus',
|
Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', 'Wait', 'ObjectCount', 'JobStatus', 'InventorySyncStatus',
|
||||||
'SCMSyncStatus', 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button'];
|
'SCMSyncStatus', 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
function HomeGroups($location, $routeParams, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait,
|
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait,
|
||||||
Alert, Rest, Empty, InventoryUpdate, Find) {
|
Alert, Rest, Empty, InventoryUpdate, Find) {
|
||||||
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
|
|
||||||
var generator = GenerateList;
|
var generator = GenerateList,
|
||||||
var list = HomeGroupList;
|
list = HomeGroupList,
|
||||||
var defaultUrl=GetBasePath('groups');
|
defaultUrl = GetBasePath('groups'),
|
||||||
|
scope = generator.inject(list, { mode: 'edit' }),
|
||||||
var scope = generator.inject(list, { mode: 'edit' });
|
opt;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
var hosts_status, update_status, last_update, stat;
|
var i, hosts_status, stat;
|
||||||
for (var i=0; i < scope.home_groups.length; i++) {
|
for (i = 0; i < scope.home_groups.length; i++) {
|
||||||
|
|
||||||
scope['home_groups'][i]['inventory_name'] = scope['home_groups'][i]['summary_fields']['inventory']['name'];
|
scope.home_groups[i].inventory_name = scope.home_groups[i].summary_fields.inventory.name;
|
||||||
|
|
||||||
stat = GetSyncStatusMsg({
|
stat = GetSyncStatusMsg({
|
||||||
status: scope.home_groups[i].summary_fields.inventory_source.status
|
status: scope.home_groups[i].summary_fields.inventory_source.status
|
||||||
}); // from helpers/Groups.js
|
}); // from helpers/Groups.js
|
||||||
|
|
||||||
hosts_status = GetHostsStatusMsg({
|
hosts_status = GetHostsStatusMsg({
|
||||||
active_failures: scope.home_groups[i].hosts_with_active_failures,
|
active_failures: scope.home_groups[i].hosts_with_active_failures,
|
||||||
total_hosts: scope.home_groups[i].total_hosts,
|
total_hosts: scope.home_groups[i].total_hosts,
|
||||||
inventory_id: scope.home_groups[i].inventory,
|
inventory_id: scope.home_groups[i].inventory,
|
||||||
group_id: scope.home_groups[i].id
|
group_id: scope.home_groups[i].id
|
||||||
});
|
});
|
||||||
|
|
||||||
scope['home_groups'][i].status_class = stat['class'],
|
|
||||||
scope['home_groups'][i].status_tooltip = stat['tooltip'],
|
|
||||||
scope['home_groups'][i].launch_tooltip = stat['launch_tip'],
|
|
||||||
scope['home_groups'][i].launch_class = stat['launch_class'],
|
|
||||||
scope['home_groups'][i].hosts_status_tip = hosts_status['tooltip'],
|
|
||||||
scope['home_groups'][i].show_failures = hosts_status['failures'],
|
|
||||||
scope['home_groups'][i].hosts_status_class = hosts_status['class'],
|
|
||||||
|
|
||||||
|
|
||||||
|
scope.home_groups[i].status_class = stat['class'];
|
||||||
|
scope.home_groups[i].status_tooltip = stat.tooltip;
|
||||||
|
scope.home_groups[i].launch_tooltip = stat.launch_tip;
|
||||||
|
scope.home_groups[i].launch_class = stat.launch_class;
|
||||||
|
scope.home_groups[i].hosts_status_tip = hosts_status.tooltip;
|
||||||
|
scope.home_groups[i].show_failures = hosts_status.failures;
|
||||||
|
scope.home_groups[i].hosts_status_class = hosts_status['class'];
|
||||||
scope.home_groups[i].status = scope.home_groups[i].summary_fields.inventory_source.status;
|
scope.home_groups[i].status = scope.home_groups[i].summary_fields.inventory_source.status;
|
||||||
scope.home_groups[i].source = (scope.home_groups[i].summary_fields.inventory_source) ?
|
scope.home_groups[i].source = (scope.home_groups[i].summary_fields.inventory_source) ?
|
||||||
scope.home_groups[i].summary_fields.inventory_source.source : null;
|
scope.home_groups[i].summary_fields.inventory_source.source : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'home_groups', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'home_groups',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
// Process search params
|
// Process search params
|
||||||
if ($routeParams['name']) {
|
if ($routeParams.name) {
|
||||||
scope[list.iterator + 'InputDisable'] = false;
|
scope[list.iterator + 'InputDisable'] = false;
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['name'];
|
scope[list.iterator + 'SearchValue'] = $routeParams.name;
|
||||||
scope[list.iterator + 'SearchField'] = 'name';
|
scope[list.iterator + 'SearchField'] = 'name';
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.name.label;
|
||||||
scope[list.iterator + 'SearchSelectValue'] = null;
|
scope[list.iterator + 'SearchSelectValue'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['id']) {
|
if ($routeParams.id) {
|
||||||
scope[list.iterator + 'InputDisable'] = false;
|
scope[list.iterator + 'InputDisable'] = false;
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['id'];
|
scope[list.iterator + 'SearchValue'] = $routeParams.id;
|
||||||
scope[list.iterator + 'SearchField'] = 'id';
|
scope[list.iterator + 'SearchField'] = 'id';
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['id'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.id.label;
|
||||||
scope[list.iterator + 'SearchSelectValue'] = null;
|
scope[list.iterator + 'SearchSelectValue'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['has_active_failures']) {
|
if ($routeParams.has_active_failures) {
|
||||||
scope[list.iterator + 'InputDisable'] = true;
|
scope[list.iterator + 'InputDisable'] = true;
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
scope[list.iterator + 'SearchValue'] = $routeParams.has_active_failures;
|
||||||
scope[list.iterator + 'SearchField'] = 'has_active_failures';
|
scope[list.iterator + 'SearchField'] = 'has_active_failures';
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['has_active_failures'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.has_active_failures.label;
|
||||||
scope[list.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
scope[list.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? { value: 1 } : { value: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['status'] && !$routeParams['source']) {
|
if ($routeParams.status && !$routeParams.source) {
|
||||||
scope[list.iterator + 'SearchField'] = 'status';
|
scope[list.iterator + 'SearchField'] = 'status';
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[list.iterator + 'SelectShow'] = true;
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields['status'].searchOptions;
|
scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['status'].label.replace(/\<br\>/g,' ');
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label.replace(/<br\>/g, ' ');
|
||||||
for (var opt in list.fields['status'].searchOptions) {
|
for (opt in list.fields.status.searchOptions) {
|
||||||
if (list.fields['status'].searchOptions[opt].value == $routeParams['status']) {
|
if (list.fields.status.searchOptions[opt].value === $routeParams.status) {
|
||||||
scope[list.iterator + 'SearchSelectValue'] = list.fields['status'].searchOptions[opt];
|
scope[list.iterator + 'SearchSelectValue'] = list.fields.status.searchOptions[opt];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['source']) {
|
if ($routeParams.source) {
|
||||||
scope[list.iterator + 'SearchField'] = 'source';
|
scope[list.iterator + 'SearchField'] = 'source';
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[list.iterator + 'SelectShow'] = true;
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields['source'].searchOptions;
|
scope[list.iterator + 'SearchSelectOpts'] = list.fields.source.searchOptions;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['source'].label.replace(/\<br\>/g,' ');
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.source.label.replace(/<br\>/g, ' ');
|
||||||
for (var opt in list.fields['source'].searchOptions) {
|
for (opt in list.fields.source.searchOptions) {
|
||||||
if (list.fields['source'].searchOptions[opt].value == $routeParams['source']) {
|
if (list.fields.source.searchOptions[opt].value === $routeParams.source) {
|
||||||
scope[list.iterator + 'SearchSelectValue'] = list.fields['source'].searchOptions[opt];
|
scope[list.iterator + 'SearchSelectValue'] = list.fields.source.searchOptions[opt];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['status']) {
|
if ($routeParams.status) {
|
||||||
scope[list.iterator + 'ExtraParms'] = '&inventory_source__status__icontains=' + $routeParams['status'];
|
scope[list.iterator + 'ExtraParms'] = '&inventory_source__status__icontains=' + $routeParams.status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['has_external_source']) {
|
if ($routeParams.has_external_source) {
|
||||||
scope[list.iterator + 'SearchField'] = 'has_external_source';
|
scope[list.iterator + 'SearchField'] = 'has_external_source';
|
||||||
scope[list.iterator + 'SearchValue'] = list.fields['has_external_source'].searchValue;
|
scope[list.iterator + 'SearchValue'] = list.fields.has_external_source.searchValue;
|
||||||
scope[list.iterator + 'InputDisable'] = true;
|
scope[list.iterator + 'InputDisable'] = true;
|
||||||
scope[list.iterator + 'SearchType'] = 'in';
|
scope[list.iterator + 'SearchType'] = 'in';
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['has_external_source'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.has_external_source.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.editGroup = function(group_id, inventory_id) {
|
scope.editGroup = function (group_id, inventory_id) {
|
||||||
GroupsEdit({ scope: scope, group_id: group_id, inventory_id: inventory_id, groups_reload: false });
|
GroupsEdit({
|
||||||
}
|
scope: scope,
|
||||||
|
group_id: group_id,
|
||||||
|
inventory_id: inventory_id,
|
||||||
|
groups_reload: false
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.viewUpdateStatus = function(id) {
|
scope.viewUpdateStatus = function (id) {
|
||||||
scope.groups = scope.home_groups;
|
scope.groups = scope.home_groups;
|
||||||
ViewUpdateStatus({ scope: scope, tree_id: id })
|
ViewUpdateStatus({
|
||||||
};
|
scope: scope,
|
||||||
|
tree_id: id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Launch inventory sync
|
// Launch inventory sync
|
||||||
scope.updateGroup = function(id) {
|
scope.updateGroup = function (id) {
|
||||||
var group = Find({ list: scope.home_groups, key: 'id', val: id});
|
var group = Find({ list: scope.home_groups, key: 'id', val: id });
|
||||||
if (group) {
|
if (group) {
|
||||||
if (Empty(group.source)) {
|
if (Empty(group.source)) {
|
||||||
// if no source, do nothing.
|
// if no source, do nothing.
|
||||||
}
|
} else if (group.status === 'updating') {
|
||||||
else if (group.status == 'updating') {
|
|
||||||
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
|
Alert('Update in Progress', 'The inventory update process is currently running for group <em>' +
|
||||||
scope.home_groups[i].name + '</em>. Use the Refresh button to monitor the status.', 'alert-info');
|
group.name + '</em>. Use the Refresh button to monitor the status.', 'alert-info');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(group.related.inventory_source);
|
Rest.setUrl(group.related.inventory_source);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
InventoryUpdate({
|
InventoryUpdate({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
url: data.related.update,
|
url: data.related.update,
|
||||||
@@ -244,100 +291,134 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
|
|||||||
group_source: data.source,
|
group_source: data.source,
|
||||||
tree_id: group.id,
|
tree_id: group.id,
|
||||||
group_id: group.id
|
group_id: group.id
|
||||||
});
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source +
|
|
||||||
' POST returned status: ' + status });
|
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source + ' POST returned status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.refresh = function() { scope.search(list.iterator, null, false, true); }
|
scope.refresh = function () {
|
||||||
|
scope.search(list.iterator, null, false, true);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
HomeGroups.$inject = ['$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
|
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
|
||||||
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find'
|
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
function HomeHosts($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, SearchInit, PaginateInit, FormatDate, SetStatus, ToggleHostEnabled, HostsEdit, Stream, Find, ShowJobSummary) {
|
GetBasePath, SearchInit, PaginateInit, FormatDate, SetStatus, ToggleHostEnabled, HostsEdit, Stream, Find, ShowJobSummary) {
|
||||||
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
|
|
||||||
var generator = GenerateList;
|
var generator = GenerateList,
|
||||||
var list = HomeHostList;
|
list = HomeHostList,
|
||||||
var defaultUrl=GetBasePath('hosts');
|
defaultUrl = GetBasePath('hosts'),
|
||||||
|
scope = generator.inject(list, { mode: 'edit' });
|
||||||
var scope = generator.inject(list, { mode: 'edit' });
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
for (var i=0; i < scope.hosts.length; i++) {
|
for (var i = 0; i < scope.hosts.length; i++) {
|
||||||
scope['hosts'][i]['inventory_name'] = scope['hosts'][i]['summary_fields']['inventory']['name'];
|
scope.hosts[i].inventory_name = scope.hosts[i].summary_fields.inventory.name;
|
||||||
//SetHostStatus(scope['hosts'][i]);
|
//SetHostStatus(scope['hosts'][i]);
|
||||||
SetStatus({ scope: scope, host: scope['hosts'][i] });
|
SetStatus({
|
||||||
|
scope: scope,
|
||||||
|
host: scope.hosts[i]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'hosts', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'hosts',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
// Process search params
|
// Process search params
|
||||||
if ($routeParams['name']) {
|
if ($routeParams.name) {
|
||||||
scope[HomeHostList.iterator + 'InputDisable'] = false;
|
scope[HomeHostList.iterator + 'InputDisable'] = false;
|
||||||
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['name'];
|
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.name;
|
||||||
scope[HomeHostList.iterator + 'SearchField'] = 'name';
|
scope[HomeHostList.iterator + 'SearchField'] = 'name';
|
||||||
scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.name.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['id']) {
|
if ($routeParams.id) {
|
||||||
scope[HomeHostList.iterator + 'InputDisable'] = false;
|
scope[HomeHostList.iterator + 'InputDisable'] = false;
|
||||||
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['id'];
|
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.id;
|
||||||
scope[HomeHostList.iterator + 'SearchField'] = 'id';
|
scope[HomeHostList.iterator + 'SearchField'] = 'id';
|
||||||
scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields['id'].label;
|
scope[HomeHostList.iterator + 'SearchFieldLabel'] = list.fields.id.label;
|
||||||
scope[HomeHostList.iterator + 'SearchSelectValue'] = null;
|
scope[HomeHostList.iterator + 'SearchSelectValue'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['has_active_failures']) {
|
if ($routeParams.has_active_failures) {
|
||||||
scope[HomeHostList.iterator + 'InputDisable'] = true;
|
scope[HomeHostList.iterator + 'InputDisable'] = true;
|
||||||
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams.has_active_failures;
|
||||||
scope[HomeHostList.iterator + 'SearchField'] = 'has_active_failures';
|
scope[HomeHostList.iterator + 'SearchField'] = 'has_active_failures';
|
||||||
scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields['has_active_failures'].label;
|
scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields.has_active_failures.label;
|
||||||
scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? { value: 1 } : { value: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.toggle_host_enabled = function(id, sources) { ToggleHostEnabled({ host_id: id, external_source: sources, scope: scope }); }
|
scope.toggle_host_enabled = function (id, sources) {
|
||||||
|
ToggleHostEnabled({
|
||||||
|
host_id: id,
|
||||||
|
external_source: sources,
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.editHost = function(host_id, host_name) {
|
scope.editHost = function (host_id) {
|
||||||
var host = Find({ list: scope.hosts, key: 'id', val: host_id });
|
var host = Find({
|
||||||
|
list: scope.hosts,
|
||||||
|
key: 'id',
|
||||||
|
val: host_id
|
||||||
|
});
|
||||||
if (host) {
|
if (host) {
|
||||||
HostsEdit({ scope: scope, host_id: host_id, inventory_id: host.inventory, group_id: null, hostsReload: false });
|
HostsEdit({
|
||||||
}
|
scope: scope,
|
||||||
|
host_id: host_id,
|
||||||
|
inventory_id: host.inventory,
|
||||||
|
group_id: null,
|
||||||
|
hostsReload: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
scope.showJobSummary = function(job_id) {
|
scope.showJobSummary = function (job_id) {
|
||||||
ShowJobSummary({ job_id: job_id });
|
ShowJobSummary({
|
||||||
}
|
job_id: job_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeHosts.$inject = [ '$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
HomeHosts.$inject = ['$location', '$routeParams', 'HomeHostList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'SetStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream',
|
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'SetStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream',
|
||||||
'Find', 'ShowJobSummary'
|
'Find', 'ShowJobSummary'
|
||||||
];
|
];
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -10,173 +10,161 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobEventList,
|
function JobEventsList($filter, $scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobEventList, GenerateList,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, LookUpInit, ToggleChildren,
|
||||||
ClearScope, ProcessErrors, GetBasePath, LookUpInit, ToggleChildren,
|
FormatDate, EventView, Refresh, Wait) {
|
||||||
FormatDate, EventView, Refresh, Wait)
|
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate');
|
ClearScope('htmlTemplate');
|
||||||
var list = JobEventList;
|
|
||||||
|
var list = JobEventList,
|
||||||
|
defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/', //?parent__isnull=1';
|
||||||
|
view = GenerateList,
|
||||||
|
scope = view.inject(list, { mode: 'edit' }),
|
||||||
|
page;
|
||||||
|
|
||||||
list.base = $location.path();
|
list.base = $location.path();
|
||||||
|
|
||||||
var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/'; //?parent__isnull=1';
|
|
||||||
|
|
||||||
var view = GenerateList;
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
var scope = view.inject(list, { mode: 'edit' });
|
|
||||||
|
|
||||||
scope.job_id = $routeParams.id;
|
scope.job_id = $routeParams.id;
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
scope.expand = true; //on load, automatically expand all nodes
|
scope.expand = true; //on load, automatically expand all nodes
|
||||||
|
|
||||||
scope.parentNode = 'parent-event'; // used in ngClass to dynamically set row level class and control
|
scope.parentNode = 'parent-event'; // used in ngClass to dynamically set row level class and control
|
||||||
scope.childNode = 'child-event'; // link color and cursor
|
scope.childNode = 'child-event'; // link color and cursor
|
||||||
|
|
||||||
if (scope.removeSetHostLinks) {
|
if (scope.removeSetHostLinks) {
|
||||||
scope.removeSetHostLinks();
|
scope.removeSetHostLinks();
|
||||||
}
|
}
|
||||||
scope.removeSetHostLinks = scope.$on('SetHostLinks', function(e, inventory_id) {
|
scope.removeSetHostLinks = scope.$on('SetHostLinks', function (e, inventory_id) {
|
||||||
for (var i=0; i < scope.jobevents.length; i++) {
|
for (var i = 0; i < scope.jobevents.length; i++) {
|
||||||
if (scope.jobevents[i].summary_fields.host) {
|
if (scope.jobevents[i].summary_fields.host) {
|
||||||
scope.jobevents[i].hostLink = "/#/inventories/" + inventory_id + "/hosts/?name=" +
|
scope.jobevents[i].hostLink = "/#/inventories/" + inventory_id + "/hosts/?name=" +
|
||||||
escape(scope.jobevents[i].summary_fields.host.name);
|
encodeURI(scope.jobevents[i].summary_fields.host.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function formatJSON(eventData) {
|
function formatJSON(eventData) {
|
||||||
//turn JSON event data into an html form
|
//turn JSON event data into an html form
|
||||||
var html = '';
|
|
||||||
if (eventData['res']) {
|
var i, n, rows, fld, txt,
|
||||||
var n, rows;
|
html = '',
|
||||||
var found = false;
|
found = false;
|
||||||
if (typeof eventData.res == 'string') {
|
|
||||||
n = eventData['res'].match(/\n/g);
|
if (eventData.res) {
|
||||||
rows = (n) ? n.length : 1;
|
if (typeof eventData.res === 'string') {
|
||||||
rows = (rows > 10) ? 10 : rows;
|
n = eventData.res.match(/\n/g);
|
||||||
found = true;
|
rows = (n) ? n.length : 1;
|
||||||
html += "<div class=\"form-group\">\n";
|
rows = (rows > 10) ? 10 : rows;
|
||||||
html += "<label>Traceback:</label>\n";
|
found = true;
|
||||||
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res + "</textarea>\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "</div>\n";
|
html += "<label>Traceback:</label>\n";
|
||||||
}
|
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res + "</textarea>\n";
|
||||||
else {
|
html += "</div>\n";
|
||||||
for (var fld in eventData.res) {
|
} else {
|
||||||
if ( (fld == 'msg' || fld == 'stdout' || fld == 'stderr') &&
|
for (fld in eventData.res) {
|
||||||
(eventData.res[fld] !== null && eventData.res[fld] !== '') ) {
|
if ((fld === 'msg' || fld === 'stdout' || fld === 'stderr') &&
|
||||||
html += "<div class=\"form-group\">\n";
|
(eventData.res[fld] !== null && eventData.res[fld] !== '')) {
|
||||||
html += "<label>";
|
|
||||||
switch(fld) {
|
|
||||||
case 'msg':
|
|
||||||
case 'stdout':
|
|
||||||
html += 'Output:';
|
|
||||||
break;
|
|
||||||
case 'stderr':
|
|
||||||
html += 'Error:';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
html += "</label>\n";
|
|
||||||
n = eventData['res'][fld].match(/\n/g);
|
|
||||||
rows = (n) ? n.length : 1;
|
|
||||||
rows = (rows > 10) ? 10 : rows;
|
|
||||||
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res[fld] + "</textarea>\n";
|
|
||||||
html += "</div>\n";
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
if ( fld == "results" && Array.isArray(eventData.res[fld]) && eventData.res[fld].length > 0 ) {
|
|
||||||
//html += "<textarea readonly class="
|
|
||||||
var txt = '';
|
|
||||||
for (var i=0; i < eventData.res[fld].length; i++) {
|
|
||||||
txt += eventData.res[fld][i];
|
|
||||||
}
|
|
||||||
n = txt.match(/\n/g);
|
|
||||||
rows = (n) ? n.length : 1;
|
|
||||||
rows = (rows > 10) ? 10 : rows;
|
|
||||||
if (txt !== '') {
|
|
||||||
html += "<div class=\"form-group\">\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "<label>Results:</label>\n";
|
html += "<label>";
|
||||||
html += "<textarea readonly class=\"form-control nowrap mono-space\" rows=\"" + rows + "\">" + txt + "</textarea>\n";
|
switch (fld) {
|
||||||
|
case 'msg':
|
||||||
|
case 'stdout':
|
||||||
|
html += 'Output:';
|
||||||
|
break;
|
||||||
|
case 'stderr':
|
||||||
|
html += 'Error:';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
html += "</label>\n";
|
||||||
|
n = eventData.res[fld].match(/\n/g);
|
||||||
|
rows = (n) ? n.length : 1;
|
||||||
|
rows = (rows > 10) ? 10 : rows;
|
||||||
|
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res[fld] + "</textarea>\n";
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
if (fld === "results" && Array.isArray(eventData.res[fld]) && eventData.res[fld].length > 0) {
|
||||||
if (fld == "rc" && eventData.res[fld] != '') {
|
//html += "<textarea readonly class="
|
||||||
html += "<div class=\"form-group\">\n";
|
txt = '';
|
||||||
html += "<label>Return Code:</label>\n";
|
for (i = 0; i < eventData.res[fld].length; i++) {
|
||||||
html += "<input type=\"text\" class=\"form-control nowrap mono-space\" value=\"" + eventData.res[fld] + "\" readonly >\n";
|
txt += eventData.res[fld][i];
|
||||||
html += "</div>\n";
|
}
|
||||||
found = true;
|
n = txt.match(/\n/g);
|
||||||
}
|
rows = (n) ? n.length : 1;
|
||||||
}
|
rows = (rows > 10) ? 10 : rows;
|
||||||
}
|
if (txt !== '') {
|
||||||
html = (found) ? "<form class=\"event-form\">\n" + html + "</form>\n" : '';
|
html += "<div class=\"form-group\">\n";
|
||||||
|
html += "<label>Results:</label>\n";
|
||||||
|
html += "<textarea readonly class=\"form-control nowrap mono-space\" rows=\"" + rows + "\">" + txt + "</textarea>\n";
|
||||||
|
html += "</div>\n";
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fld === "rc" && eventData.res[fld] !== '') {
|
||||||
|
html += "<div class=\"form-group\">\n";
|
||||||
|
html += "<label>Return Code:</label>\n";
|
||||||
|
html += "<input type=\"text\" class=\"form-control nowrap mono-space\" value=\"" + eventData.res[fld] + "\" readonly >\n";
|
||||||
|
html += "</div>\n";
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html = (found) ? "<form class=\"event-form\">\n" + html + "</form>\n" : '';
|
||||||
}
|
}
|
||||||
if (eventData['host']) {
|
if (eventData.hosts) {
|
||||||
html = "<span class=\"event-detail-host visible-sm\">" + eventData['host'] + "</span>\n" + html;
|
html = "<span class=\"event-detail-host visible-sm\">" + eventData.host + "</span>\n" + html;
|
||||||
}
|
} else {
|
||||||
else {
|
html = (html === '') ? null : html;
|
||||||
html = (html == '' ) ? null : html;
|
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
// Initialize the parent levels
|
// Initialize the parent levels
|
||||||
var set = scope[list.name];
|
var set = scope[list.name], i;
|
||||||
var cDate;
|
for (i = 0; i < set.length; i++) {
|
||||||
for (var i=0; i < set.length; i++) {
|
set[i].event_display = set[i].event_display.replace(/^\u00a0*/g, '');
|
||||||
set[i].event_display = set[i].event_display.replace(/^\u00a0*/g,'');
|
if (set[i].event_level < 3) {
|
||||||
if (set[i].event_level < 3 ) {
|
set[i].ngclick = "toggleChildren(" + set[i].id + ", \"" + set[i].related.children + "\")";
|
||||||
set[i]['ngclick'] = "toggleChildren(" + set[i].id + ", \"" + set[i].related.children + "\")";
|
set[i].ngicon = 'fa fa-minus-square-o node-toggle';
|
||||||
set[i]['ngicon'] = 'fa fa-minus-square-o node-toggle';
|
set[i]['class'] = 'parentNode';
|
||||||
set[i]['class'] = 'parentNode';
|
} else {
|
||||||
|
set[i].ngicon = 'fa fa-square-o node-no-toggle';
|
||||||
|
set[i]['class'] = 'childNode';
|
||||||
|
set[i].event_detail = formatJSON(set[i].event_data);
|
||||||
}
|
}
|
||||||
else {
|
set[i].show = true;
|
||||||
set[i]['ngicon'] = 'fa fa-square-o node-no-toggle';
|
set[i].spaces = set[i].event_level * 24;
|
||||||
set[i]['class'] = 'childNode';
|
|
||||||
set[i]['event_detail'] = formatJSON(set[i].event_data);
|
|
||||||
}
|
|
||||||
set[i]['show'] = true;
|
|
||||||
set[i]['spaces'] = set[i].event_level * 24;
|
|
||||||
if (scope.jobevents[i].failed) {
|
if (scope.jobevents[i].failed) {
|
||||||
scope.jobevents[i].status = 'error';
|
scope.jobevents[i].status = 'error';
|
||||||
if (i == set.length - 1) {
|
if (i === set.length - 1) {
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred durring one or more playbook tasks.";
|
scope.jobevents[i].statusBadgeToolTip = "A failure occurred durring one or more playbook tasks.";
|
||||||
}
|
} else if (set[i].event_level < 3) {
|
||||||
else if (set[i].event_level < 3) {
|
scope.jobevents[i].statusBadgeToolTip = "A failure occurred within the children of this event.";
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred within the children of this event.";
|
} else {
|
||||||
}
|
scope.jobevents[i].statusBadgeToolTip = "A failure occurred. Click to view details";
|
||||||
else {
|
}
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred. Click to view details";
|
} else if (scope.jobevents[i].changed) {
|
||||||
}
|
scope.jobevents[i].status = 'changed';
|
||||||
}
|
if (i === set.length - 1) {
|
||||||
else if (scope.jobevents[i].changed) {
|
scope.jobevents[i].statusBadgeToolTip = "A change was completed durring one or more playbook tasks.";
|
||||||
scope.jobevents[i].status = 'changed';
|
} else if (set[i].event_level < 3) {
|
||||||
if (i == set.length - 1) {
|
scope.jobevents[i].statusBadgeToolTip = "A change was completed by one or more children of this event.";
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed durring one or more playbook tasks.";
|
} else {
|
||||||
}
|
scope.jobevents[i].statusBadgeToolTip = "A change was completed. Click to view details";
|
||||||
else if (set[i].event_level < 3) {
|
}
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed by one or more children of this event.";
|
} else {
|
||||||
}
|
scope.jobevents[i].status = 'success';
|
||||||
else {
|
if (i === set.length - 1) {
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed. Click to view details";
|
scope.jobevents[i].statusBadgeToolTip = "All playbook tasks completed successfully.";
|
||||||
}
|
} else if (set[i].event_level < 3) {
|
||||||
}
|
scope.jobevents[i].statusBadgeToolTip = "All the children of this event completed successfully.";
|
||||||
else {
|
} else {
|
||||||
scope.jobevents[i].status = 'success';
|
scope.jobevents[i].statusBadgeToolTip = "No errors occurred. Click to view details";
|
||||||
if (i == set.length - 1) {
|
}
|
||||||
scope.jobevents[i].statusBadgeToolTip = "All playbook tasks completed successfully.";
|
|
||||||
}
|
|
||||||
else if (set[i].event_level < 3) {
|
|
||||||
scope.jobevents[i].statusBadgeToolTip = "All the children of this event completed successfully.";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope.jobevents[i].statusBadgeToolTip = "No errors occurred. Click to view details";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//cDate = new Date(set[i].created);
|
//cDate = new Date(set[i].created);
|
||||||
//set[i].created = FormatDate(cDate);
|
//set[i].created = FormatDate(cDate);
|
||||||
@@ -187,160 +175,180 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
// from job in the event that there are no job event records
|
// from job in the event that there are no job event records
|
||||||
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
scope.job_status = data.status;
|
scope.job_status = data.status;
|
||||||
scope.job_name = data.summary_fields.job_template.name;
|
scope.job_name = data.summary_fields.job_template.name;
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + scope.job_id, title: scope.job_id + ' - ' + data.summary_fields.job_template.name });
|
LoadBreadCrumbs({
|
||||||
scope.$emit('SetHostLinks', data.inventory);
|
path: '/jobs/' + scope.job_id,
|
||||||
})
|
title: scope.job_id + ' - ' + data.summary_fields.job_template.name
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, null,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
});
|
scope.$emit('SetHostLinks', data.inventory);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'jobevents', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
|
scope: scope,
|
||||||
|
set: 'jobevents',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
var page = ($routeParams.page) ? parseInt($routeParams.page) - 1 : null;
|
page = ($routeParams.page) ? parseInt($routeParams.page,10) - 1 : null;
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl, page: page });
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl,
|
||||||
|
page: page
|
||||||
|
});
|
||||||
|
|
||||||
// Called from Inventories tab, host failed events link:
|
// Called from Inventories tab, host failed events link:
|
||||||
if ($routeParams.host) {
|
if ($routeParams.host) {
|
||||||
scope[list.iterator + 'SearchField'] = 'host';
|
scope[list.iterator + 'SearchField'] = 'host';
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams.host;
|
scope[list.iterator + 'SearchValue'] = $routeParams.host;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['host'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.host.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search(list.iterator, $routeParams.page);
|
scope.search(list.iterator, $routeParams.page);
|
||||||
|
|
||||||
scope.toggleChildren = function(id, children) {
|
scope.toggleChildren = function (id, children) {
|
||||||
ToggleChildren({
|
ToggleChildren({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
list: list,
|
list: list,
|
||||||
id: id,
|
id: id,
|
||||||
children: children
|
children: children
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.viewJobEvent = function(id) {
|
scope.viewJobEvent = function (id) {
|
||||||
EventView({ event_id: id });
|
EventView({
|
||||||
}
|
event_id: id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.refresh = function() {
|
scope.refresh = function () {
|
||||||
scope['jobSearchSpin'] = true;
|
scope.jobSearchSpin = true;
|
||||||
scope['jobLoading'] = true;
|
scope.jobLoading = true;
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Refresh({ scope: scope, set: 'jobevents', iterator: 'jobevent', url: scope['current_url'] });
|
Refresh({
|
||||||
}
|
scope: scope,
|
||||||
|
set: 'jobevents',
|
||||||
|
iterator: 'jobevent',
|
||||||
|
url: scope.current_url
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobEventsList.$inject = [ '$filter', '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobEventList',
|
JobEventsList.$inject = ['$filter', '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobEventList',
|
||||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
'ProcessErrors','GetBasePath', 'LookUpInit', 'ToggleChildren', 'FormatDate', 'EventView', 'Refresh', 'Wait'
|
'ProcessErrors', 'GetBasePath', 'LookUpInit', 'ToggleChildren', 'FormatDate', 'EventView', 'Refresh', 'Wait'
|
||||||
];
|
];
|
||||||
|
|
||||||
function JobEventsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, JobEventForm, GenerateForm,
|
function JobEventsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobEventForm, GenerateForm,
|
||||||
Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, FormatDate, EventView,
|
Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, FormatDate, EventView,
|
||||||
Wait)
|
Wait) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
// Inject dynamic view
|
||||||
// Inject dynamic view
|
var form = JobEventForm,
|
||||||
var form = JobEventForm;
|
generator = GenerateForm,
|
||||||
var generator = GenerateForm;
|
scope = GenerateForm.inject(form, { mode: 'edit', related: true }),
|
||||||
var scope = GenerateForm.inject(form, {mode: 'edit', related: true});
|
defaultUrl = GetBasePath('base') + 'job_events/' + $routeParams.event_id + '/';
|
||||||
generator.reset();
|
|
||||||
|
|
||||||
var defaultUrl = GetBasePath('base') + 'job_events/' + $routeParams.event_id + '/';
|
generator.reset();
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
scope['event_display'] = data['event_display'].replace(/^\u00a0*/g,'');
|
var cDate, fld, n, rows;
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + $routeParams.job_id + '/job_events/' + $routeParams.event_id,
|
scope.event_display = data.event_display.replace(/^\u00a0*/g, '');
|
||||||
title: scope['event_display'] });
|
LoadBreadCrumbs({ path: '/jobs/' + $routeParams.job_id + '/job_events/' + $routeParams.event_id, title: scope.event_display });
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
switch(fld) {
|
switch (fld) {
|
||||||
case 'status':
|
case 'status':
|
||||||
if (data['failed']) {
|
if (data.failed) {
|
||||||
scope['status'] = 'error';
|
scope.status = 'error';
|
||||||
}
|
} else if (data.changed) {
|
||||||
else if (data['changed']) {
|
scope.status = 'changed';
|
||||||
scope['status'] = 'changed';
|
} else {
|
||||||
}
|
scope.status = 'success';
|
||||||
else {
|
|
||||||
scope['status'] = 'success';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'created':
|
|
||||||
var cDate = new Date(data['created']);
|
|
||||||
scope['created'] = FormatDate(cDate);
|
|
||||||
break;
|
|
||||||
case 'host':
|
|
||||||
if (data['summary_fields'] && data['summary_fields']['host']) {
|
|
||||||
scope['host'] = data['summary_fields']['host']['name'];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'id':
|
|
||||||
case 'task':
|
|
||||||
case 'play':
|
|
||||||
scope[fld] = data[fld];
|
|
||||||
break;
|
|
||||||
case 'start':
|
|
||||||
case 'end':
|
|
||||||
if (data['event_data'] && data['event_data']['res'] && data['event_data']['res'][fld] !== undefined) {
|
|
||||||
var cDate = new Date(data['event_data']['res'][fld]);
|
|
||||||
scope[fld] = FormatDate(cDate);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'msg':
|
case 'created':
|
||||||
case 'stdout':
|
cDate = new Date(data.created);
|
||||||
case 'stderr':
|
scope.created = FormatDate(cDate);
|
||||||
case 'delta':
|
break;
|
||||||
case 'rc':
|
case 'host':
|
||||||
if (data['event_data'] && data['event_data']['res'] && data['event_data']['res'][fld] !== undefined) {
|
if (data.summary_fields && data.summary_fields.host) {
|
||||||
scope[fld] = data['event_data']['res'][fld];
|
scope.host = data.summary_fields.host.name;
|
||||||
if (form.fields[fld].type == 'textarea') {
|
}
|
||||||
var n = data['event_data']['res'][fld].match(/\n/g);
|
break;
|
||||||
var rows = (n) ? n.length : 1;
|
case 'id':
|
||||||
rows = (rows > 15) ? 5 : rows;
|
case 'task':
|
||||||
$('textarea[name="' + fld + '"]').attr('rows',rows);
|
case 'play':
|
||||||
|
scope[fld] = data[fld];
|
||||||
|
break;
|
||||||
|
case 'start':
|
||||||
|
case 'end':
|
||||||
|
if (data.event_data && data.event_data.res && data.event_data.res[fld] !== undefined) {
|
||||||
|
cDate = new Date(data.event_data.res[fld]);
|
||||||
|
scope[fld] = FormatDate(cDate);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'msg':
|
||||||
|
case 'stdout':
|
||||||
|
case 'stderr':
|
||||||
|
case 'delta':
|
||||||
|
case 'rc':
|
||||||
|
if (data.event_data && data.event_data.res && data.event_data.res[fld] !== undefined) {
|
||||||
|
scope[fld] = data.event_data.res[fld];
|
||||||
|
if (form.fields[fld].type === 'textarea') {
|
||||||
|
n = data.event_data.res[fld].match(/\n/g);
|
||||||
|
rows = (n) ? n.length : 1;
|
||||||
|
rows = (rows > 15) ? 5 : rows;
|
||||||
|
$('textarea[name="' + fld + '"]').attr('rows', rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'module_name':
|
case 'module_name':
|
||||||
case 'module_args':
|
case 'module_args':
|
||||||
if (data['event_data']['res'] && data['event_data']['res']['invocation']) {
|
if (data.event_data.res && data.event_data.res.invocation) {
|
||||||
scope[fld] = data['event_data']['res']['invocation'][fld];
|
scope[fld] = data.event_data.res.invocation.fld;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve host: ' + $routeParams.event_id +
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve host: ' + $routeParams.event_id + '. GET status: ' + status });
|
'. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.navigateBack = function() {
|
scope.navigateBack = function () {
|
||||||
var url = '/jobs/' + $routeParams.job_id + '/job_events';
|
var url = '/jobs/' + $routeParams.job_id + '/job_events';
|
||||||
if ($routeParams.page) {
|
if ($routeParams.page) {
|
||||||
url += '?page=' + $routeParams.page;
|
url += '?page=' + $routeParams.page;
|
||||||
}
|
}
|
||||||
$location.url(url);
|
$location.url(url);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.rawView = function() {
|
scope.rawView = function () {
|
||||||
EventView({"event_id": scope.id });
|
EventView({
|
||||||
}
|
"event_id": scope.id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JobEventsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobEventForm',
|
JobEventsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobEventForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'FormatDate',
|
||||||
'FormatDate', 'EventView', 'Wait'
|
'EventView', 'Wait'
|
||||||
];
|
];
|
||||||
@@ -10,138 +10,158 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList,
|
function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList, GenerateList,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, Refresh,
|
||||||
ClearScope, ProcessErrors, GetBasePath, Refresh, JobStatusToolTip, Wait)
|
JobStatusToolTip, Wait) {
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate');
|
ClearScope('htmlTemplate');
|
||||||
var list = JobHostList;
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var list = JobHostList,
|
||||||
var defaultUrl = GetBasePath(base) + $routeParams.id + '/job_host_summaries/';
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var inventory_id;
|
defaultUrl = GetBasePath(base) + $routeParams.id + '/job_host_summaries/',
|
||||||
|
view = GenerateList,
|
||||||
|
scope = view.inject(list, { mode: 'edit' });
|
||||||
|
|
||||||
// When viewing all summaries for a particular host, show job ID, otherwise row ID.
|
// When viewing all summaries for a particular host, show job ID, otherwise row ID.
|
||||||
if (base == 'hosts') {
|
if (base === 'hosts') {
|
||||||
list.index = false;
|
list.index = false;
|
||||||
|
} else {
|
||||||
|
list.index = true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
list.index = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var view = GenerateList;
|
|
||||||
var scope = view.inject(list, { mode: 'edit' });
|
|
||||||
|
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
|
|
||||||
// control enable/disable/show of job specific view elements
|
// control enable/disable/show of job specific view elements
|
||||||
if (base == 'hosts') {
|
if (base === 'hosts') {
|
||||||
scope.job_id = null;
|
scope.job_id = null;
|
||||||
scope.host_id = $routeParams.id;
|
scope.host_id = $routeParams.id;
|
||||||
}
|
} else {
|
||||||
else {
|
scope.job_id = $routeParams.id;
|
||||||
scope.job_id = $routeParams.id;
|
scope.host_id = null;
|
||||||
scope.host_id = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.RemoveSetHostLink) {
|
if (scope.RemoveSetHostLink) {
|
||||||
scope.RemoveSetHostLink();
|
scope.RemoveSetHostLink();
|
||||||
}
|
}
|
||||||
scope.RemoveSetHostLink = scope.$on('setHostLink', function(e, inventory_id) {
|
scope.RemoveSetHostLink = scope.$on('setHostLink', function (e, inventory_id) {
|
||||||
for (var i=0; i < scope.jobhosts.length; i++) {
|
for (var i = 0; i < scope.jobhosts.length; i++) {
|
||||||
scope.jobhosts[i].hostLinkTo = '/#/inventories/' + inventory_id + '/?host_name=' +
|
scope.jobhosts[i].hostLinkTo = '/#/inventories/' + inventory_id + '/?host_name=' +
|
||||||
escape(scope.jobhosts[i].summary_fields.host.name);
|
encodeURI(scope.jobhosts[i].summary_fields.host.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// After a refresh, populate any needed summary field values on each row
|
// After a refresh, populate any needed summary field values on each row
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
|
|
||||||
// Set status, tooltips, badget icons, etc.
|
// Set status, tooltips, badget icons, etc.
|
||||||
for( var i=0; i < scope.jobhosts.length; i++) {
|
for (var i = 0; i < scope.jobhosts.length; i++) {
|
||||||
scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name;
|
scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name;
|
||||||
scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'failed' : 'success';
|
scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'failed' : 'success';
|
||||||
scope.jobhosts[i].statusBadgeToolTip = JobStatusToolTip(scope.jobhosts[i].status) +
|
scope.jobhosts[i].statusBadgeToolTip = JobStatusToolTip(scope.jobhosts[i].status) +
|
||||||
" Click to view details.";
|
" Click to view details.";
|
||||||
scope.jobhosts[i].statusLinkTo = '/#/jobs/' + scope.jobhosts[i].job + '/job_events/?host=' +
|
scope.jobhosts[i].statusLinkTo = '/#/jobs/' + scope.jobhosts[i].job + '/job_events/?host=' +
|
||||||
escape(scope.jobhosts[i].summary_fields.host.name);
|
encodeURI(scope.jobhosts[i].summary_fields.host.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.job_id !== null && scope.job_id !== undefined && scope.job_id !== '') {
|
if (scope.job_id !== null && scope.job_id !== undefined && scope.job_id !== '') {
|
||||||
// need job_status so we can show/hide refresh button
|
// need job_status so we can show/hide refresh button
|
||||||
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + data.id, title: data.id + ' - ' +
|
LoadBreadCrumbs({
|
||||||
data.summary_fields.job_template.name });
|
path: '/jobs/' + data.id,
|
||||||
scope.job_status = data.status;
|
title: data.id + ' - ' +
|
||||||
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
data.summary_fields.job_template.name
|
||||||
if ($rootScope.timer) {
|
});
|
||||||
clearInterval($rootScope.timer);
|
scope.job_status = data.status;
|
||||||
}
|
if (!(data.status === 'pending' || data.status === 'waiting' || data.status === 'running')) {
|
||||||
}
|
if ($rootScope.timer) {
|
||||||
scope.$emit('setHostLink', data.inventory);
|
clearInterval($rootScope.timer);
|
||||||
})
|
}
|
||||||
.error( function(data, status, headers, config) {
|
}
|
||||||
ProcessErrors(scope, data, status, null,
|
scope.$emit('setHostLink', data.inventory);
|
||||||
{ hdr: 'Error!', msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
})
|
||||||
});
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Make the host name appear in breadcrumbs
|
||||||
|
LoadBreadCrumbs({
|
||||||
|
path: '/hosts/' + scope.host_id,
|
||||||
|
title: ((scope.jobhosts.length > 0) ? scope.jobhosts[0].summary_fields.host.name : 'Host')
|
||||||
|
});
|
||||||
|
if ($routeParams.inventory) {
|
||||||
|
scope.$emit('setHostLink', $routeParams.inventory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
});
|
||||||
// Make the host name appear in breadcrumbs
|
|
||||||
LoadBreadCrumbs({ path: '/hosts/' + scope['host_id'],
|
|
||||||
title: ( (scope.jobhosts.length > 0) ? scope.jobhosts[0].summary_fields.host.name : 'Host' ) });
|
|
||||||
if ($routeParams['inventory']) {
|
|
||||||
scope.$emit('setHostLink', $routeParams['inventory']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'jobhosts', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'jobhosts',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
// Called from Inventories tab, host failed events link:
|
// Called from Inventories tab, host failed events link:
|
||||||
if ($routeParams['host_name']) {
|
if ($routeParams.host_name) {
|
||||||
scope[list.iterator + 'SearchField'] = 'host';
|
scope[list.iterator + 'SearchField'] = 'host';
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['host_name'];
|
scope[list.iterator + 'SearchValue'] = $routeParams.host_name;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['host'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.host.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
|
||||||
scope.showEvents = function(host_name, last_job) {
|
scope.showEvents = function (host_name, last_job) {
|
||||||
// When click on !Failed Events link, redirect to latest job/job_events for the host
|
// When click on !Failed Events link, redirect to latest job/job_events for the host
|
||||||
Rest.setUrl(last_job);
|
Rest.setUrl(last_job);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + data.id, title: data.name });
|
LoadBreadCrumbs({
|
||||||
$location.url('/jobs/' + data.id + '/job_events/?host=' + escape(host_name));
|
path: '/jobs/' + data.id,
|
||||||
})
|
title: data.name
|
||||||
.error( function(data, status, headers, config) {
|
});
|
||||||
ProcessErrors(scope, data, status, form,
|
$location.url('/jobs/' + data.id + '/job_events/?host=' + encodeURI(host_name));
|
||||||
{ hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + '. GET status: ' + status });
|
})
|
||||||
});
|
.error(function (data, status) {
|
||||||
}
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job +
|
||||||
|
'. GET status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.showJob = function(id) {
|
scope.showJob = function (id) {
|
||||||
$location.path('/jobs/' + id);
|
$location.path('/jobs/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.refresh = function() {
|
scope.refresh = function () {
|
||||||
if (scope.host_id == null) {
|
if (scope.host_id === null) {
|
||||||
scope['jobSearchSpin'] = true;
|
scope.jobSearchSpin = true;
|
||||||
scope['jobLoading'] = true;
|
scope.jobLoading = true;
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Refresh({ scope: scope, set: 'jobhosts', iterator: 'jobhost', url: scope['current_url'] });
|
Refresh({
|
||||||
}
|
scope: scope,
|
||||||
|
set: 'jobhosts',
|
||||||
|
iterator: 'jobhost',
|
||||||
|
url: scope.current_url
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JobHostSummaryList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobHostList',
|
JobHostSummaryList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobHostList',
|
||||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
'ProcessErrors', 'GetBasePath', 'Refresh', 'JobStatusToolTip', 'Wait'
|
'ProcessErrors', 'GetBasePath', 'Refresh', 'JobStatusToolTip', 'Wait'
|
||||||
];
|
];
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,10 @@
|
|||||||
* Controller functions for the Job model.
|
* Controller functions for the Job model.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global jsyaml:false */
|
/* global jsyaml:false */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobList, GenerateList, LoadBreadCrumbs, Prompt,
|
function JobsListCtrl($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobList, GenerateList, LoadBreadCrumbs, Prompt,
|
||||||
SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, LookUpInit, SubmitJob, FormatDate, Refresh,
|
SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, LookUpInit, SubmitJob, FormatDate, Refresh,
|
||||||
JobStatusToolTip, Empty, Wait) {
|
JobStatusToolTip, Empty, Wait) {
|
||||||
|
|
||||||
@@ -30,15 +28,15 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
var i,cDate;
|
var i, cDate;
|
||||||
$("tr.success").each(function() {
|
$("tr.success").each(function () {
|
||||||
// Make sure no rows have a green background
|
// Make sure no rows have a green background
|
||||||
var ngc = $(this).attr('ng-class');
|
var ngc = $(this).attr('ng-class');
|
||||||
scope[ngc] = "";
|
scope[ngc] = "";
|
||||||
});
|
});
|
||||||
if (scope.jobs && scope.jobs.length) {
|
if (scope.jobs && scope.jobs.length) {
|
||||||
for (i=0; i < scope.jobs.length; i++) {
|
for (i = 0; i < scope.jobs.length; i++) {
|
||||||
// Convert created date to local time zone
|
// Convert created date to local time zone
|
||||||
cDate = new Date(scope.jobs[i].created);
|
cDate = new Date(scope.jobs[i].created);
|
||||||
scope.jobs[i].created = FormatDate(cDate);
|
scope.jobs[i].created = FormatDate(cDate);
|
||||||
@@ -53,13 +51,21 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
|
|
||||||
if ($routeParams.job_host_summaries__host) {
|
if ($routeParams.job_host_summaries__host) {
|
||||||
defaultUrl += '?job_host_summaries__host=' + $routeParams.job_host_summaries__host;
|
defaultUrl += '?job_host_summaries__host=' + $routeParams.job_host_summaries__host;
|
||||||
}
|
} else if ($routeParams.inventory__int && $routeParams.status) {
|
||||||
else if ($routeParams.inventory__int && $routeParams.status) {
|
|
||||||
defaultUrl += '?inventory__int=' + $routeParams.inventory__int + '&status=' +
|
defaultUrl += '?inventory__int=' + $routeParams.inventory__int + '&status=' +
|
||||||
$routeParams.status;
|
$routeParams.status;
|
||||||
}
|
}
|
||||||
SearchInit({ scope: scope, set: 'jobs', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'jobs',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
// Called from Inventories page, failed jobs link. Find jobs for selected inventory.
|
// Called from Inventories page, failed jobs link. Find jobs for selected inventory.
|
||||||
if ($routeParams.inventory__int) {
|
if ($routeParams.inventory__int) {
|
||||||
@@ -76,7 +82,7 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
scope[list.iterator + 'SearchField'] = 'status';
|
scope[list.iterator + 'SearchField'] = 'status';
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[list.iterator + 'SelectShow'] = true;
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
|
scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label.replace(/<br>/g,' ');
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label.replace(/<br>/g, ' ');
|
||||||
for (opt in list.fields.status.searchOptions) {
|
for (opt in list.fields.status.searchOptions) {
|
||||||
if (list.fields.status.searchOptions[opt].value === $routeParams.status) {
|
if (list.fields.status.searchOptions[opt].value === $routeParams.status) {
|
||||||
scope[list.iterator + 'SearchSelectValue'] = list.fields.status.searchOptions[opt];
|
scope[list.iterator + 'SearchSelectValue'] = list.fields.status.searchOptions[opt];
|
||||||
@@ -89,33 +95,47 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.refresh = function() {
|
scope.refresh = function () {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
scope.jobLoading = false;
|
scope.jobLoading = false;
|
||||||
Refresh({ scope: scope, set: 'jobs', iterator: 'job', url: scope.current_url });
|
Refresh({
|
||||||
|
scope: scope,
|
||||||
|
set: 'jobs',
|
||||||
|
iterator: 'job',
|
||||||
|
url: scope.current_url
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.refreshJob = scope.refresh;
|
scope.refreshJob = scope.refresh;
|
||||||
|
|
||||||
scope.editJob = function(id, name) {
|
scope.editJob = function (id, name) {
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + id, title: id + ' - ' + name });
|
LoadBreadCrumbs({
|
||||||
|
path: '/jobs/' + id,
|
||||||
|
title: id + ' - ' + name
|
||||||
|
});
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.viewEvents = function(id, name) {
|
scope.viewEvents = function (id, name) {
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + id, title: id + ' - ' + name });
|
LoadBreadCrumbs({
|
||||||
|
path: '/jobs/' + id,
|
||||||
|
title: id + ' - ' + name
|
||||||
|
});
|
||||||
$location.path($location.path() + '/' + id + '/job_events');
|
$location.path($location.path() + '/' + id + '/job_events');
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.viewSummary = function(id, name) {
|
scope.viewSummary = function (id, name) {
|
||||||
LoadBreadCrumbs({ path: '/jobs/' + id, title: id + ' - ' + name });
|
LoadBreadCrumbs({
|
||||||
|
path: '/jobs/' + id,
|
||||||
|
title: id + ' - ' + name
|
||||||
|
});
|
||||||
$location.path($location.path() + '/' + id + '/job_host_summaries');
|
$location.path($location.path() + '/' + id + '/job_host_summaries');
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.deleteJob = function(id) {
|
scope.deleteJob = function (id) {
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data) {
|
.success(function (data) {
|
||||||
|
|
||||||
var action, url, action_label, hdr;
|
var action, url, action_label, hdr;
|
||||||
|
|
||||||
@@ -123,37 +143,35 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
url = data.related.cancel;
|
url = data.related.cancel;
|
||||||
action_label = 'cancel';
|
action_label = 'cancel';
|
||||||
hdr = 'Cancel Job';
|
hdr = 'Cancel Job';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
url = defaultUrl + id + '/';
|
url = defaultUrl + id + '/';
|
||||||
action_label = 'delete';
|
action_label = 'delete';
|
||||||
hdr = 'Delete Job';
|
hdr = 'Delete Job';
|
||||||
}
|
}
|
||||||
|
|
||||||
action = function() {
|
action = function () {
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
if (action_label === 'cancel') {
|
if (action_label === 'cancel') {
|
||||||
Rest.post()
|
Rest.post()
|
||||||
.success( function() {
|
.success(function () {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status) {
|
.error(function (data, status) {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
' failed. POST returned status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success( function() {
|
.success(function () {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status) {
|
.error(function (data, status) {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
' failed. DELETE returned status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -164,35 +182,41 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get job details. GET returned status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Failed to get job details. GET returned status: ' + status });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.submitJob = function(id, template) {
|
scope.submitJob = function (id, template) {
|
||||||
SubmitJob({ scope: scope, id: id, template: template });
|
SubmitJob({
|
||||||
|
scope: scope,
|
||||||
|
id: id,
|
||||||
|
template: template
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobsListCtrl.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobList',
|
JobsListCtrl.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobList',
|
||||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
'ProcessErrors','GetBasePath', 'LookUpInit', 'SubmitJob', 'FormatDate', 'Refresh', 'JobStatusToolTip',
|
'ProcessErrors', 'GetBasePath', 'LookUpInit', 'SubmitJob', 'FormatDate', 'Refresh', 'JobStatusToolTip',
|
||||||
'Empty', 'Wait'
|
'Empty', 'Wait'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, GenerateForm, Rest, Alert, ProcessErrors,
|
function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
LoadBreadCrumbs, RelatedSearchInit,RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList,
|
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList,
|
||||||
ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, FormatDate, JobStatusToolTip, Wait) {
|
ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, FormatDate, JobStatusToolTip, Wait) {
|
||||||
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
|
|
||||||
var defaultUrl= GetBasePath('jobs'),
|
var defaultUrl = GetBasePath('jobs'),
|
||||||
generator = GenerateForm,
|
generator = GenerateForm,
|
||||||
form = JobForm,
|
form = JobForm,
|
||||||
scope = generator.inject(form, {mode: 'edit', related: true}),
|
scope = generator.inject(form, {
|
||||||
|
mode: 'edit',
|
||||||
|
related: true
|
||||||
|
}),
|
||||||
master = {},
|
master = {},
|
||||||
id = $routeParams.id,
|
id = $routeParams.id,
|
||||||
relatedSets = {},
|
relatedSets = {},
|
||||||
@@ -209,18 +233,17 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
var url = GetBasePath('projects') + project + '/playbooks/';
|
var url = GetBasePath('projects') + project + '/playbooks/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data) {
|
.success(function (data) {
|
||||||
scope.playbook_options = [];
|
scope.playbook_options = [];
|
||||||
for (var i=0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
scope.playbook_options.push(data[i]);
|
scope.playbook_options.push(data[i]);
|
||||||
}
|
}
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
})
|
})
|
||||||
.error( function() {
|
.error(function () {
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +253,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
if (scope.jobLoadedRemove) {
|
if (scope.jobLoadedRemove) {
|
||||||
scope.jobLoadedRemove();
|
scope.jobLoadedRemove();
|
||||||
}
|
}
|
||||||
scope.jobLoadedRemove = scope.$on('jobLoaded', function(e, related_cloud_credential) {
|
scope.jobLoadedRemove = scope.$on('jobLoaded', function (e, related_cloud_credential) {
|
||||||
|
|
||||||
getPlaybooks(scope.project);
|
getPlaybooks(scope.project);
|
||||||
|
|
||||||
@@ -238,15 +261,15 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
$('#forks-slider').slider("option", "value", scope.forks);
|
$('#forks-slider').slider("option", "value", scope.forks);
|
||||||
$('#forks-slider').slider("disable");
|
$('#forks-slider').slider("disable");
|
||||||
$('input[type="checkbox"]').attr('disabled','disabled');
|
$('input[type="checkbox"]').attr('disabled', 'disabled');
|
||||||
$('input[type="radio"]').attr('disabled','disabled');
|
$('input[type="radio"]').attr('disabled', 'disabled');
|
||||||
$('#host_config_key-gen-btn').attr('disabled','disabled');
|
$('#host_config_key-gen-btn').attr('disabled', 'disabled');
|
||||||
$('textarea').attr('readonly','readonly');
|
$('textarea').attr('readonly', 'readonly');
|
||||||
|
|
||||||
// Get job template and display/hide host callback fields
|
// Get job template and display/hide host callback fields
|
||||||
Rest.setUrl(scope.template_url);
|
Rest.setUrl(scope.template_url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data) {
|
.success(function (data) {
|
||||||
var dft = (data.host_config_key) ? 'true' : 'false';
|
var dft = (data.host_config_key) ? 'true' : 'false';
|
||||||
scope.host_config_key = data.host_config_key;
|
scope.host_config_key = data.host_config_key;
|
||||||
md5Setup({
|
md5Setup({
|
||||||
@@ -258,7 +281,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.callback_url = (data.related) ? data.related.callback : '<< Job template not found >>';
|
scope.callback_url = (data.related) ? data.related.callback : '<< Job template not found >>';
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
})
|
})
|
||||||
.error( function() {
|
.error(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
scope.callback_url = '<< Job template not found >>';
|
scope.callback_url = '<< Job template not found >>';
|
||||||
});
|
});
|
||||||
@@ -267,16 +290,17 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
//Get the name of the cloud credential
|
//Get the name of the cloud credential
|
||||||
Rest.setUrl(related_cloud_credential);
|
Rest.setUrl(related_cloud_credential);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data) {
|
.success(function (data) {
|
||||||
scope.cloud_credential_name = data.name;
|
scope.cloud_credential_name = data.name;
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
})
|
})
|
||||||
.error( function(data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to related cloud credential. GET returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to related cloud credential. GET returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -285,7 +309,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
if (scope.removeJobTemplateLoadFinished) {
|
if (scope.removeJobTemplateLoadFinished) {
|
||||||
scope.removeJobTemplateLoadFinished();
|
scope.removeJobTemplateLoadFinished();
|
||||||
}
|
}
|
||||||
scope.removeJobTemplateLoadFinished = scope.$on('jobTemplateLoadFinished', function() {
|
scope.removeJobTemplateLoadFinished = scope.$on('jobTemplateLoadFinished', function () {
|
||||||
loadingFinishedCount++;
|
loadingFinishedCount++;
|
||||||
if (loadingFinishedCount >= 3) {
|
if (loadingFinishedCount >= 3) {
|
||||||
// The initial template load finished. Now load related jobs, which
|
// The initial template load finished. Now load related jobs, which
|
||||||
@@ -295,16 +319,27 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Our job type options
|
// Our job type options
|
||||||
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
|
scope.job_type_options = [{
|
||||||
scope.verbosity_options = [
|
value: 'run',
|
||||||
{ value: '0', label: 'Default' },
|
label: 'Run'
|
||||||
{ value: '1', label: 'Verbose' },
|
}, {
|
||||||
{ value: '3', label: 'Debug' }
|
value: 'check',
|
||||||
];
|
label: 'Check'
|
||||||
|
}];
|
||||||
|
scope.verbosity_options = [{
|
||||||
|
value: '0',
|
||||||
|
label: 'Default'
|
||||||
|
}, {
|
||||||
|
value: '1',
|
||||||
|
label: 'Verbose'
|
||||||
|
}, {
|
||||||
|
value: '3',
|
||||||
|
label: 'Debug'
|
||||||
|
}];
|
||||||
scope.playbook_options = null;
|
scope.playbook_options = null;
|
||||||
scope.playbook = null;
|
scope.playbook = null;
|
||||||
|
|
||||||
function calcRows (content) {
|
function calcRows(content) {
|
||||||
var n = content.match(/\n/g),
|
var n = content.match(/\n/g),
|
||||||
rows = (n) ? n.length : 1;
|
rows = (n) ? n.length : 1;
|
||||||
return (rows > 15) ? 15 : rows;
|
return (rows > 15) ? 15 : rows;
|
||||||
@@ -313,8 +348,8 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl + ':id/');
|
Rest.setUrl(defaultUrl + ':id/');
|
||||||
Rest.get({ params: {id: id} })
|
Rest.get({ params: { id: id } })
|
||||||
.success( function(data) {
|
.success(function (data) {
|
||||||
//LoadBreadCrumbs({ path: '/jobs/' + id, title: data.id + ' - ' + data.summary_fields.job_template.name });
|
//LoadBreadCrumbs({ path: '/jobs/' + id, title: data.id + ' - ' + data.summary_fields.job_template.name });
|
||||||
var i, cDate, fld, json_obj, related, set;
|
var i, cDate, fld, json_obj, related, set;
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
@@ -322,18 +357,16 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
if (fld !== 'variables' && data[fld] !== null && data[fld] !== undefined) {
|
if (fld !== 'variables' && data[fld] !== null && data[fld] !== undefined) {
|
||||||
if (form.fields[fld].type === 'select') {
|
if (form.fields[fld].type === 'select') {
|
||||||
if (scope[fld + '_options'] && scope[fld + '_options'].length > 0) {
|
if (scope[fld + '_options'] && scope[fld + '_options'].length > 0) {
|
||||||
for (i=0; i < scope[fld + '_options'].length; i++) {
|
for (i = 0; i < scope[fld + '_options'].length; i++) {
|
||||||
if (data[fld] === scope[fld + '_options'][i].value) {
|
if (data[fld] === scope[fld + '_options'][i].value) {
|
||||||
scope[fld] = scope[fld + '_options'][i];
|
scope[fld] = scope[fld + '_options'][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
}
|
}
|
||||||
master[fld] = scope[fld];
|
master[fld] = scope[fld];
|
||||||
@@ -347,8 +380,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
if ($.isEmptyObject(data.extra_vars) || data.extra_vars === "{}" || data.extra_vars === "null" ||
|
if ($.isEmptyObject(data.extra_vars) || data.extra_vars === "{}" || data.extra_vars === "null" ||
|
||||||
data.extra_vars === "" || data.extra_vars === null) {
|
data.extra_vars === "" || data.extra_vars === null) {
|
||||||
scope.variables = "---";
|
scope.variables = "---";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
json_obj = JSON.parse(data.extra_vars);
|
json_obj = JSON.parse(data.extra_vars);
|
||||||
scope.variables = jsyaml.safeDump(json_obj);
|
scope.variables = jsyaml.safeDump(json_obj);
|
||||||
}
|
}
|
||||||
@@ -367,8 +399,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Convert created date to local time zone
|
// Convert created date to local time zone
|
||||||
cDate = new Date(data.created);
|
cDate = new Date(data.created);
|
||||||
scope.created = FormatDate(cDate);
|
scope.created = FormatDate(cDate);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +407,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
scope.statusToolTip = JobStatusToolTip(data.status);
|
scope.statusToolTip = JobStatusToolTip(data.status);
|
||||||
|
|
||||||
$('form[name="jobs_form"] input[type="text"], form[name="jobs_form"] jobs_form textarea').attr('readonly','readonly');
|
$('form[name="jobs_form"] input[type="text"], form[name="jobs_form"] jobs_form textarea').attr('readonly', 'readonly');
|
||||||
$('form[name="jobs_form"] select').prop('disabled', 'disabled');
|
$('form[name="jobs_form"] select').prop('disabled', 'disabled');
|
||||||
$('form[name="jobs_form"] .lookup-btn').prop('disabled', 'disabled');
|
$('form[name="jobs_form"] .lookup-btn').prop('disabled', 'disabled');
|
||||||
$('form[name="jobs_form"] .buttons, form[name="jobs_form"] hr').hide();
|
$('form[name="jobs_form"] .buttons, form[name="jobs_form"] hr').hide();
|
||||||
@@ -385,7 +416,10 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
related = data.related;
|
related = data.related;
|
||||||
for (set in form.related) {
|
for (set in form.related) {
|
||||||
if (related[set]) {
|
if (related[set]) {
|
||||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
relatedSets[set] = {
|
||||||
|
url: related[set],
|
||||||
|
iterator: form.related[set].iterator
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,21 +452,30 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
RelatedPaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
scope.template_url = data.related.job_template;
|
scope.template_url = data.related.job_template;
|
||||||
scope.$emit('jobLoaded', data.related.cloud_credential);
|
scope.$emit('jobLoaded', data.related.cloud_credential);
|
||||||
})
|
})
|
||||||
.error( function(data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve job: ' + $routeParams.id + '. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve job: ' + $routeParams.id + '. GET status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.refresh = function() {
|
scope.refresh = function () {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data) {
|
.success(function (data) {
|
||||||
scope.status = data.status;
|
scope.status = data.status;
|
||||||
scope.result_stdout = data.result_stdout;
|
scope.result_stdout = data.result_stdout;
|
||||||
scope.result_traceback = data.result_traceback;
|
scope.result_traceback = data.result_traceback;
|
||||||
@@ -440,25 +483,26 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.traceback_rows = calcRows(scope.result_traceback);
|
scope.traceback_rows = calcRows(scope.result_traceback);
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.error( function(data, status) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, {
|
||||||
{ hdr: 'Error!', msg: 'Attempt to load job failed. GET returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Attempt to load job failed. GET returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.jobSummary = function() {
|
scope.jobSummary = function () {
|
||||||
$location.path('/jobs/' + id + '/job_host_summaries');
|
$location.path('/jobs/' + id + '/job_host_summaries');
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.jobEvents = function() {
|
scope.jobEvents = function () {
|
||||||
$location.path('/jobs/' + id + '/job_events');
|
$location.path('/jobs/' + id + '/job_events');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobForm',
|
JobsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList',
|
'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit', 'PromptPasswords',
|
||||||
'ProjectList', 'LookUpInit', 'PromptPasswords', 'GetBasePath', 'md5Setup', 'FormatDate',
|
'GetBasePath', 'md5Setup', 'FormatDate', 'JobStatusToolTip', 'Wait'
|
||||||
'JobStatusToolTip', 'Wait'
|
];
|
||||||
];
|
|
||||||
|
|||||||
@@ -10,269 +10,320 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function OrganizationsList ($routeParams, $scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt,
|
function OrganizationsList($routeParams, $scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt,
|
||||||
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope, ProcessErrors,
|
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope, ProcessErrors, GetBasePath, SelectionInit, Wait, Stream) {
|
||||||
GetBasePath, SelectionInit, Wait, Stream)
|
|
||||||
{
|
ClearScope('htmlTemplate');
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
|
||||||
//scope.
|
var list = OrganizationList,
|
||||||
|
generate = GenerateList,
|
||||||
|
paths = $location.path().replace(/^\//, '').split('/'),
|
||||||
|
mode = (paths[0] === 'organizations') ? 'edit' : 'select', // if base path 'users', we're here to add/edit users
|
||||||
|
scope = generate.inject(OrganizationList, { mode: mode }),
|
||||||
|
defaultUrl = GetBasePath('organizations'),
|
||||||
|
url;
|
||||||
|
|
||||||
var list = OrganizationList;
|
|
||||||
var generate = GenerateList;
|
|
||||||
var paths = $location.path().replace(/^\//,'').split('/');
|
|
||||||
var mode = (paths[0] == 'organizations') ? 'edit' : 'select'; // if base path 'users', we're here to add/edit users
|
|
||||||
var scope = generate.inject(OrganizationList, { mode: mode }); // Inject our view
|
|
||||||
var defaultUrl = GetBasePath('organizations');
|
|
||||||
var iterator = list.iterator;
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
var url = GetBasePath('projects') + $routeParams.project_id + '/organizations/';
|
url = GetBasePath('projects') + $routeParams.project_id + '/organizations/';
|
||||||
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
SelectionInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: url,
|
||||||
|
returnToCaller: 1
|
||||||
|
});
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
// Cleanup after a delete
|
// Cleanup after a delete
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').off();
|
$('#prompt-modal').off();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize search and paginate pieces and load data
|
// Initialize search and paginate pieces and load data
|
||||||
SearchInit({ scope: scope, set: list.name, list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: list.name,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.addOrganization = function() {
|
scope.addOrganization = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editOrganization = function(id) {
|
scope.editOrganization = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteOrganization = function(id, name) {
|
scope.deleteOrganization = function (id, name) {
|
||||||
|
|
||||||
var action = function() {
|
var action = function () {
|
||||||
$('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); });
|
$('#prompt-modal').on('hidden.bs.modal', function () {
|
||||||
$('#prompt-modal').modal('hide');
|
Wait('start');
|
||||||
var url = defaultUrl + id + '/';
|
});
|
||||||
Rest.setUrl(url);
|
$('#prompt-modal').modal('hide');
|
||||||
Rest.destroy()
|
var url = defaultUrl + id + '/';
|
||||||
.success( function(data, status, headers, config) {
|
Rest.setUrl(url);
|
||||||
scope.search(list.iterator);
|
Rest.destroy()
|
||||||
})
|
.success(function () {
|
||||||
.error( function(data, status, headers, config) {
|
scope.search(list.iterator);
|
||||||
Wait('stop');
|
})
|
||||||
ProcessErrors(scope, data, status, null,
|
.error(function (data, status) {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
Wait('stop');
|
||||||
});
|
ProcessErrors(scope, data, status, null, {
|
||||||
};
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
Prompt({ hdr: 'Delete',
|
});
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
|
||||||
action: action
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
OrganizationsList.$inject=[ '$routeParams', '$scope', '$rootScope', '$location', '$log', 'Rest', 'Alert', 'LoadBreadCrumbs', 'Prompt',
|
OrganizationsList.$inject = ['$routeParams', '$scope', '$rootScope', '$location', '$log', 'Rest', 'Alert', 'LoadBreadCrumbs', 'Prompt',
|
||||||
'GenerateList', 'OrganizationList', 'SearchInit', 'PaginateInit', 'ClearScope', 'ProcessErrors',
|
'GenerateList', 'OrganizationList', 'SearchInit', 'PaginateInit', 'ClearScope', 'ProcessErrors',
|
||||||
'GetBasePath', 'SelectionInit', 'Wait', 'Stream'];
|
'GetBasePath', 'SelectionInit', 'Wait', 'Stream'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
function OrganizationsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath,
|
||||||
ReturnToCaller, Wait)
|
ReturnToCaller, Wait) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var generator = GenerateForm;
|
var generator = GenerateForm,
|
||||||
var form = OrganizationForm;
|
form = OrganizationForm,
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
scope = generator.inject(form, { mode: 'add', related: false }),
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
var defaultUrl = GetBasePath('organizations');
|
|
||||||
generator.reset();
|
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
generator.reset();
|
||||||
|
|
||||||
// Save
|
LoadBreadCrumbs();
|
||||||
scope.formSave = function() {
|
|
||||||
generator.clearApiErrors();
|
|
||||||
Wait('start');
|
|
||||||
var url = GetBasePath(base);
|
|
||||||
url += (base != 'organizations') ? $routeParams['project_id'] + '/organizations/' : '';
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.post({ name: $scope.name,
|
|
||||||
description: $scope.description })
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
if (base == 'organizations') {
|
|
||||||
$rootScope.flashMessage = "New organization successfully created!";
|
|
||||||
$location.path('/organizations/' + data.id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ReturnToCaller(1);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new organization. Post returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cancel
|
// Save
|
||||||
scope.formReset = function() {
|
scope.formSave = function () {
|
||||||
$rootScope.flashMessage = null;
|
generator.clearApiErrors();
|
||||||
generator.reset();
|
Wait('start');
|
||||||
};
|
var url = GetBasePath(base);
|
||||||
}
|
url += (base !== 'organizations') ? $routeParams.project_id + '/organizations/' : '';
|
||||||
|
Rest.setUrl(url);
|
||||||
OrganizationsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
Rest.post({
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
name: $scope.name,
|
||||||
'ReturnToCaller', 'Wait'];
|
description: $scope.description
|
||||||
|
})
|
||||||
|
.success(function (data) {
|
||||||
function OrganizationsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
Wait('stop');
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
if (base === 'organizations') {
|
||||||
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream)
|
$rootScope.flashMessage = "New organization successfully created!";
|
||||||
{
|
$location.path('/organizations/' + data.id);
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
} else {
|
||||||
//scope.
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
// Inject dynamic view
|
})
|
||||||
var form = OrganizationForm;
|
.error(function (data, status) {
|
||||||
var generator = GenerateForm;
|
ProcessErrors(scope, data, status, form, {
|
||||||
var scope = GenerateForm.inject(form, {mode: 'edit', related: true});
|
hdr: 'Error!',
|
||||||
generator.reset();
|
msg: 'Failed to add new organization. Post returned status: ' + status
|
||||||
|
|
||||||
var defaultUrl = GetBasePath('organizations');
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
var master = {};
|
|
||||||
var id = $routeParams.organization_id;
|
|
||||||
var relatedSets = {};
|
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
|
||||||
if (scope.organizationLoadedRemove) {
|
|
||||||
scope.organizationLoadedRemove();
|
|
||||||
}
|
|
||||||
scope.organizationLoadedRemove = scope.$on('organizationLoaded', function() {
|
|
||||||
for (var set in relatedSets) {
|
|
||||||
scope.search(relatedSets[set].iterator);
|
|
||||||
}
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
|
||||||
Wait('start');
|
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name });
|
|
||||||
for (var fld in form.fields) {
|
|
||||||
if (data[fld]) {
|
|
||||||
scope[fld] = data[fld];
|
|
||||||
master[fld] = data[fld];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var related = data.related;
|
|
||||||
for (var set in form.related) {
|
|
||||||
if (related[set]) {
|
|
||||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
|
||||||
scope.$emit('organizationLoaded');
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status });
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Save changes to the parent
|
|
||||||
scope.formSave = function() {
|
|
||||||
generator.clearApiErrors();
|
|
||||||
Wait('start');
|
|
||||||
var params = {};
|
|
||||||
for (var fld in form.fields) {
|
|
||||||
params[fld] = scope[fld];
|
|
||||||
}
|
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
|
||||||
Rest.put(params)
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
master = params;
|
|
||||||
$rootScope.flashMessage = "Your changes were successfully saved!";
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors(scope, data, status, OrganizationForm,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to update organization: ' + id + '. PUT status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
|
||||||
|
|
||||||
// Reset the form
|
|
||||||
scope.formReset = function() {
|
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
generator.reset();
|
|
||||||
for (var fld in master) {
|
|
||||||
scope[fld] = master[fld];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Add button
|
|
||||||
scope.add = function(set) {
|
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
$location.path('/' + base + '/' + $routeParams.organization_id + '/' + set);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Edit button
|
|
||||||
scope.edit = function(set, id, name) {
|
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
$location.path('/' + set + '/' + id);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Delete button
|
|
||||||
scope['delete'] = function(set, itm_id, name, title) {
|
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
|
|
||||||
var action = function() {
|
|
||||||
Wait('start');
|
|
||||||
var url = defaultUrl + $routeParams.organization_id + '/' + set + '/';
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
scope.search(form.related[set].iterator);
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
ProcessErrors(scope, data, status, null,
|
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
|
||||||
action: action
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
}
|
// Cancel
|
||||||
|
scope.formReset = function () {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
generator.reset();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
OrganizationsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
OrganizationsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
||||||
'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'Wait', 'Stream'];
|
'ReturnToCaller', 'Wait'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
function OrganizationsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
||||||
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||||
|
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream) {
|
||||||
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
|
//scope.
|
||||||
|
|
||||||
|
// Inject dynamic view
|
||||||
|
var form = OrganizationForm,
|
||||||
|
generator = GenerateForm,
|
||||||
|
scope = GenerateForm.inject(form, { mode: 'edit', related: true }),
|
||||||
|
defaultUrl = GetBasePath('organizations'),
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {},
|
||||||
|
id = $routeParams.organization_id,
|
||||||
|
relatedSets = {};
|
||||||
|
|
||||||
|
generator.reset();
|
||||||
|
|
||||||
|
// After the Organization is loaded, retrieve each related set
|
||||||
|
if (scope.organizationLoadedRemove) {
|
||||||
|
scope.organizationLoadedRemove();
|
||||||
|
}
|
||||||
|
scope.organizationLoadedRemove = scope.$on('organizationLoaded', function () {
|
||||||
|
for (var set in relatedSets) {
|
||||||
|
scope.search(relatedSets[set].iterator);
|
||||||
|
}
|
||||||
|
Wait('stop');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Retrieve detail record and prepopulate the form
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
var fld, related, set;
|
||||||
|
LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name });
|
||||||
|
for (fld in form.fields) {
|
||||||
|
if (data[fld]) {
|
||||||
|
scope[fld] = data[fld];
|
||||||
|
master[fld] = data[fld];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
related = data.related;
|
||||||
|
for (set in form.related) {
|
||||||
|
if (related[set]) {
|
||||||
|
relatedSets[set] = {
|
||||||
|
url: related[set],
|
||||||
|
iterator: form.related[set].iterator
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
|
RelatedSearchInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
RelatedPaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
scope.$emit('organizationLoaded');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, form, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Save changes to the parent
|
||||||
|
scope.formSave = function () {
|
||||||
|
var fld, params = {};
|
||||||
|
generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
for (fld in form.fields) {
|
||||||
|
params[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
|
Rest.put(params)
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
master = params;
|
||||||
|
$rootScope.flashMessage = "Your changes were successfully saved!";
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(scope, data, status, OrganizationForm, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to update organization: ' + id + '. PUT status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reset the form
|
||||||
|
scope.formReset = function () {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
generator.reset();
|
||||||
|
for (var fld in master) {
|
||||||
|
scope[fld] = master[fld];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Related set: Add button
|
||||||
|
scope.add = function (set) {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
$location.path('/' + base + '/' + $routeParams.organization_id + '/' + set);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Related set: Edit button
|
||||||
|
scope.edit = function (set, id) {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
$location.path('/' + set + '/' + id);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Related set: Delete button
|
||||||
|
scope['delete'] = function (set, itm_id, name, title) {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
|
var action = function () {
|
||||||
|
Wait('start');
|
||||||
|
var url = defaultUrl + $routeParams.organization_id + '/' + set + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({
|
||||||
|
id: itm_id,
|
||||||
|
disassociate: 1
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.search(form.related[set].iterator);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. POST returned status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
OrganizationsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
||||||
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
||||||
|
'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'Wait', 'Stream'
|
||||||
|
];
|
||||||
@@ -10,303 +10,324 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, PermissionList,
|
function PermissionsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, PermissionList,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors,
|
||||||
ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait)
|
GetBasePath, CheckAccess, Wait) {
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
|
||||||
var list = PermissionList;
|
//scope.
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var list = PermissionList,
|
||||||
var defaultUrl = GetBasePath(base);
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
defaultUrl += ($routeParams['user_id'] !== undefined) ? $routeParams['user_id'] : $routeParams['team_id'];
|
defaultUrl = GetBasePath(base),
|
||||||
|
view = GenerateList,
|
||||||
|
scope = view.inject(list, { mode: 'edit' }); // Inject our view
|
||||||
|
|
||||||
|
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
||||||
defaultUrl += '/permissions/';
|
defaultUrl += '/permissions/';
|
||||||
|
|
||||||
var view = GenerateList;
|
|
||||||
var scope = view.inject(list, { mode: 'edit' }); // Inject our view
|
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
|
|
||||||
CheckAccess({ scope: scope });
|
CheckAccess({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
// Cleanup after a delete
|
// Cleanup after a delete
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').off();
|
$('#prompt-modal').off();
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'permissions', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'permissions',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.addPermission = function() {
|
scope.addPermission = function () {
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editPermission = function(id) {
|
scope.editPermission = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deletePermission = function(id, name) {
|
scope.deletePermission = function (id, name) {
|
||||||
var action = function() {
|
var action = function () {
|
||||||
$('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); });
|
$('#prompt-modal').on('hidden.bs.modal', function () {
|
||||||
$('#prompt-modal').modal('hide');
|
Wait('start');
|
||||||
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
});
|
||||||
Rest.setUrl(url);
|
$('#prompt-modal').modal('hide');
|
||||||
Rest.destroy()
|
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
||||||
.success( function(data, status, headers, config) {
|
Rest.setUrl(url);
|
||||||
scope.search(list.iterator);
|
Rest.destroy()
|
||||||
})
|
.success(function () {
|
||||||
.error( function(data, status, headers, config) {
|
scope.search(list.iterator);
|
||||||
Wait('stop');
|
})
|
||||||
ProcessErrors(scope, data, status, null,
|
.error(function (data, status) {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
Wait('stop');
|
||||||
});
|
ProcessErrors(scope, data, status, null, {
|
||||||
};
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
if (scope.PermissionAddAllowed) {
|
|
||||||
Prompt({ hdr: 'Delete',
|
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
|
||||||
action: action
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
if (scope.PermissionAddAllowed) {
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'PermissionList',
|
PermissionsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'PermissionList',
|
||||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller',
|
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller',
|
||||||
'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait'
|
'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
function PermissionsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
||||||
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess,
|
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess,
|
||||||
Wait, PermissionCategoryChange)
|
Wait, PermissionCategoryChange) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var form = PermissionsForm;
|
var form = PermissionsForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var defaultUrl = GetBasePath(base) + id + '/permissions';
|
scope = generator.inject(form, { mode: 'add', related: false }),
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
master = {};
|
||||||
var master = {};
|
|
||||||
|
|
||||||
CheckAccess({ scope: scope })
|
CheckAccess({ scope: scope });
|
||||||
generator.reset();
|
generator.reset();
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope['inventoryrequired'] = true;
|
scope.inventoryrequired = true;
|
||||||
scope['projectrequired'] = false;
|
scope.projectrequired = false;
|
||||||
scope.category = 'Inventory';
|
scope.category = 'Inventory';
|
||||||
master.category = 'Inventory';
|
master.category = 'Inventory';
|
||||||
master.inventoryrequired = true;
|
master.inventoryrequired = true;
|
||||||
master.projectrequired = false;
|
master.projectrequired = false;
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: null,
|
current_item: null,
|
||||||
list: InventoryList,
|
list: InventoryList,
|
||||||
field: 'inventory'
|
field: 'inventory'
|
||||||
});
|
});
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: null,
|
current_item: null,
|
||||||
list: ProjectList,
|
list: ProjectList,
|
||||||
field: 'project'
|
field: 'project'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function() {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
var fld, url, data = {};
|
||||||
Wait('start');
|
generator.clearApiErrors();
|
||||||
if (scope.PermissionAddAllowed) {
|
Wait('start');
|
||||||
var data = {};
|
if (scope.PermissionAddAllowed) {
|
||||||
for (var fld in form.fields) {
|
data = {};
|
||||||
data[fld] = scope[fld];
|
for (fld in form.fields) {
|
||||||
}
|
data[fld] = scope[fld];
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
}
|
||||||
Rest.setUrl(url);
|
url = (base === 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
||||||
Rest.post(data)
|
Rest.setUrl(url);
|
||||||
.success( function(data, status, headers, config) {
|
Rest.post(data)
|
||||||
Wait('stop');
|
.success(function () {
|
||||||
ReturnToCaller(1);
|
Wait('stop');
|
||||||
})
|
ReturnToCaller(1);
|
||||||
.error( function(data, status, headers, config) {
|
})
|
||||||
Wait('stop');
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, PermissionsForm,
|
Wait('stop');
|
||||||
{ hdr: 'Error!', msg: 'Failed to create new permission. Post returned status: ' + status });
|
ProcessErrors(scope, data, status, PermissionsForm, {
|
||||||
});
|
hdr: 'Error!',
|
||||||
}
|
msg: 'Failed to create new permission. Post returned status: ' + status
|
||||||
else {
|
});
|
||||||
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.', 'alert-danger');
|
});
|
||||||
}
|
} else {
|
||||||
};
|
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.',
|
||||||
|
'alert-danger');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function() {
|
scope.formReset = function () {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
generator.reset();
|
generator.reset();
|
||||||
for (var fld in master) {
|
for (var fld in master) {
|
||||||
scope[fld] = master[fld];
|
scope[fld] = master[fld];
|
||||||
}
|
}
|
||||||
scope.selectCategory();
|
scope.selectCategory();
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.selectCategory = function() { PermissionCategoryChange({ scope: scope, reset: true }); };
|
scope.selectCategory = function () {
|
||||||
|
PermissionCategoryChange({
|
||||||
|
scope: scope,
|
||||||
|
reset: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
scope.selectCategory();
|
scope.selectCategory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
PermissionsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
|
||||||
'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait',
|
'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'PermissionCategoryChange'
|
||||||
'PermissionCategoryChange'
|
];
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
function PermissionsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller,
|
||||||
ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess,
|
ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess,
|
||||||
Wait, PermissionCategoryChange)
|
Wait, PermissionCategoryChange) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
|
||||||
|
|
||||||
var generator = GenerateForm;
|
var generator = GenerateForm,
|
||||||
var form = PermissionsForm;
|
form = PermissionsForm,
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
scope = generator.inject(form, { mode: 'edit', related: true }),
|
||||||
var base_id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
base_id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
id = $routeParams.permission_id,
|
||||||
var id = $routeParams.permission_id;
|
defaultUrl = GetBasePath('base') + 'permissions/' + id + '/',
|
||||||
var defaultUrl = GetBasePath('base') + 'permissions/' + id + '/';
|
master = {};
|
||||||
generator.reset();
|
|
||||||
|
|
||||||
var master = {};
|
generator.reset();
|
||||||
var relatedSets = {};
|
|
||||||
|
|
||||||
CheckAccess({ scope: scope });
|
|
||||||
|
|
||||||
scope.selectCategory = function(resetIn) {
|
|
||||||
var reset = (resetIn == false) ? false : true;
|
|
||||||
PermissionCategoryChange({ scope: scope, reset: reset }); }
|
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
|
||||||
Wait('start');
|
|
||||||
Rest.setUrl(defaultUrl);
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
|
|
||||||
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
|
||||||
|
|
||||||
for (var fld in form.fields) {
|
|
||||||
if (data[fld]) {
|
|
||||||
if (form.fields[fld].sourceModel) {
|
|
||||||
var sourceModel = form.fields[fld].sourceModel;
|
|
||||||
var sourceField = form.fields[fld].sourceField;
|
|
||||||
scope[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
|
||||||
master[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
|
||||||
}
|
|
||||||
scope[fld] = data[fld];
|
|
||||||
master[fld] = scope[fld];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scope.category = 'Deploy';
|
|
||||||
if (data['permission_type'] != 'run' && data['permission_type'] != 'check' ) {
|
|
||||||
scope.category = 'Inventory';
|
|
||||||
}
|
|
||||||
master['category'] = scope.category;
|
|
||||||
scope.selectCategory(false); //call without resetting scope.category value
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
scope: scope,
|
|
||||||
form: form,
|
|
||||||
current_item: data.inventory,
|
|
||||||
list: InventoryList,
|
|
||||||
field: 'inventory'
|
|
||||||
});
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
scope: scope,
|
|
||||||
form: form,
|
|
||||||
current_item: data.project,
|
|
||||||
list: ProjectList,
|
|
||||||
field: 'project'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!scope.PermissionAddAllowed) {
|
|
||||||
// If not a privileged user, disable access
|
|
||||||
$('form[name="permission_form"]').find('select, input, button').each(function(index){
|
|
||||||
if ($(this).is('input') || $(this).is('select')) {
|
|
||||||
$(this).attr('readonly','readonly');
|
|
||||||
}
|
|
||||||
if ( $(this).is('input[type="checkbox"]') ||
|
|
||||||
$(this).is('input[type="radio"]') ||
|
|
||||||
$(this).is('button') ) {
|
|
||||||
$(this).attr('disabled','disabled');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Wait('stop');
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Save changes to the parent
|
CheckAccess({
|
||||||
scope.formSave = function() {
|
scope: scope
|
||||||
generator.clearApiErrors();
|
});
|
||||||
Wait('start');
|
|
||||||
var data = {}
|
scope.selectCategory = function (resetIn) {
|
||||||
for (var fld in form.fields) {
|
var reset = (resetIn === false) ? false : true;
|
||||||
data[fld] = scope[fld];
|
PermissionCategoryChange({ scope: scope, reset: reset });
|
||||||
}
|
};
|
||||||
Rest.setUrl(defaultUrl);
|
|
||||||
Rest.put(data)
|
// Retrieve detail record and prepopulate the form
|
||||||
.success( function(data, status, headers, config) {
|
Wait('start');
|
||||||
Wait('stop');
|
Rest.setUrl(defaultUrl);
|
||||||
ReturnToCaller(1);
|
Rest.get()
|
||||||
})
|
.success(function (data) {
|
||||||
.error( function(data, status, headers, config) {
|
var fld, sourceModel, sourceField;
|
||||||
Wait('stop');
|
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
||||||
ProcessErrors(scope, data, status, form,
|
for (fld in form.fields) {
|
||||||
{ hdr: 'Error!', msg: 'Failed to update Permission: ' + $routeParams.id + '. PUT status: ' + status });
|
if (data[fld]) {
|
||||||
});
|
if (form.fields[fld].sourceModel) {
|
||||||
};
|
sourceModel = form.fields[fld].sourceModel;
|
||||||
|
sourceField = form.fields[fld].sourceField;
|
||||||
|
scope[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
||||||
|
master[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
||||||
|
}
|
||||||
|
scope[fld] = data[fld];
|
||||||
|
master[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.category = 'Deploy';
|
||||||
|
if (data.permission_type !== 'run' && data.permission_type !== 'check') {
|
||||||
|
scope.category = 'Inventory';
|
||||||
|
}
|
||||||
|
master.category = scope.category;
|
||||||
|
scope.selectCategory(false); //call without resetting scope.category value
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
current_item: data.inventory,
|
||||||
|
list: InventoryList,
|
||||||
|
field: 'inventory'
|
||||||
|
});
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
current_item: data.project,
|
||||||
|
list: ProjectList,
|
||||||
|
field: 'project'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!scope.PermissionAddAllowed) {
|
||||||
|
// If not a privileged user, disable access
|
||||||
|
$('form[name="permission_form"]').find('select, input, button').each(function () {
|
||||||
|
if ($(this).is('input') || $(this).is('select')) {
|
||||||
|
$(this).attr('readonly', 'readonly');
|
||||||
|
}
|
||||||
|
if ($(this).is('input[type="checkbox"]') ||
|
||||||
|
$(this).is('input[type="radio"]') ||
|
||||||
|
$(this).is('button')) {
|
||||||
|
$(this).attr('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Wait('stop');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Cancel
|
// Save changes to the parent
|
||||||
scope.formReset = function() {
|
scope.formSave = function () {
|
||||||
generator.reset();
|
var fld, data = {};
|
||||||
for (var fld in master) {
|
generator.clearApiErrors();
|
||||||
scope[fld] = master[fld];
|
Wait('start');
|
||||||
}
|
for (fld in form.fields) {
|
||||||
scope.selectCategory(false);
|
data[fld] = scope[fld];
|
||||||
};
|
}
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
Rest.put(data)
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update Permission: ' +
|
||||||
|
$routeParams.id + '. PUT status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Cancel
|
||||||
|
scope.formReset = function () {
|
||||||
|
generator.reset();
|
||||||
|
for (var fld in master) {
|
||||||
|
scope[fld] = master[fld];
|
||||||
|
}
|
||||||
|
scope.selectCategory(false);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
PermissionsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath',
|
||||||
'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess',
|
'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'PermissionCategoryChange'
|
||||||
'Wait', 'PermissionCategoryChange'
|
];
|
||||||
];
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -10,346 +10,376 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function TeamsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, TeamList,
|
function TeamsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, TeamList, GenerateList, LoadBreadCrumbs,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, SetTeamListeners, GetBasePath, SelectionInit, Wait,
|
||||||
ClearScope, ProcessErrors, SetTeamListeners, GetBasePath, SelectionInit, Wait, Stream)
|
Stream) {
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate');
|
||||||
//scope.
|
|
||||||
var list = TeamList;
|
var list = TeamList,
|
||||||
var defaultUrl = GetBasePath('teams');
|
defaultUrl = GetBasePath('teams'),
|
||||||
var view = GenerateList;
|
view = GenerateList,
|
||||||
var paths = $location.path().replace(/^\//,'').split('/');
|
paths = $location.path().replace(/^\//, '').split('/'),
|
||||||
var mode = (paths[0] == 'teams') ? 'edit' : 'select'; // if base path 'teams', we're here to add/edit teams
|
mode = (paths[0] === 'teams') ? 'edit' : 'select', // if base path 'teams', we're here to add/edit teams
|
||||||
var scope = view.inject(list, { mode: mode }); // Inject our view
|
scope = view.inject(list, { mode: mode }),
|
||||||
|
url;
|
||||||
|
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
|
|
||||||
var url = GetBasePath('base') + $location.path() + '/';
|
url = GetBasePath('base') + $location.path() + '/';
|
||||||
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
SelectionInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: url,
|
||||||
|
returnToCaller: 1
|
||||||
|
});
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
// After a refresh, populate the organization name on each row
|
// After a refresh, populate the organization name on each row
|
||||||
|
var i;
|
||||||
if (scope.teams) {
|
if (scope.teams) {
|
||||||
for ( var i=0; i < scope.teams.length; i++) {
|
for (i = 0; i < scope.teams.length; i++) {
|
||||||
scope.teams[i].organization_name = scope.teams[i].summary_fields.organization.name;
|
scope.teams[i].organization_name = scope.teams[i].summary_fields.organization.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'teams',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.addTeam = function() {
|
scope.addTeam = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editTeam = function(id) {
|
scope.editTeam = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteTeam = function(id, name) {
|
scope.deleteTeam = function (id, name) {
|
||||||
|
|
||||||
var action = function() {
|
var action = function () {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var url = defaultUrl + id + '/';
|
var url = defaultUrl + id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
hdr: 'Error!',
|
||||||
});
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
};
|
});
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
|
||||||
action: action
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
scope.lookupOrganization = function(organization_id) {
|
|
||||||
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
return data.name;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'TeamList', 'GenerateList',
|
TeamsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'TeamList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
||||||
'SetTeamListeners', 'GetBasePath', 'SelectionInit', 'Wait', 'Stream' ];
|
'SetTeamListeners', 'GetBasePath', 'SelectionInit', 'Wait', 'Stream'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function TeamsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm,
|
function TeamsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm,
|
||||||
Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList,
|
Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList,
|
||||||
OrganizationList, SearchInit, PaginateInit, GetBasePath, LookUpInit, Wait)
|
OrganizationList, SearchInit, PaginateInit, GetBasePath, LookUpInit, Wait) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var defaultUrl = GetBasePath('teams');
|
var defaultUrl = GetBasePath('teams'),
|
||||||
var form = TeamForm;
|
form = TeamForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
scope = generator.inject(form, { mode: 'add', related: false });
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
generator.reset();
|
|
||||||
LoadBreadCrumbs();
|
|
||||||
|
|
||||||
LookUpInit({
|
$rootScope.flashMessage = null;
|
||||||
scope: scope,
|
generator.reset();
|
||||||
form: form,
|
LoadBreadCrumbs();
|
||||||
current_item: null,
|
|
||||||
list: OrganizationList,
|
|
||||||
field: 'organization'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save
|
LookUpInit({
|
||||||
scope.formSave = function() {
|
scope: scope,
|
||||||
generator.clearApiErrors();
|
form: form,
|
||||||
Wait('start');
|
current_item: null,
|
||||||
Rest.setUrl(defaultUrl);
|
list: OrganizationList,
|
||||||
var data = {}
|
field: 'organization'
|
||||||
for (var fld in form.fields) {
|
});
|
||||||
data[fld] = scope[fld];
|
|
||||||
}
|
|
||||||
Rest.post(data)
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
$rootScope.flashMessage = "New team successfully created!";
|
|
||||||
$location.path('/teams/' + data.id);
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new team. Post returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Reset
|
// Save
|
||||||
scope.formReset = function() {
|
scope.formSave = function () {
|
||||||
// Defaults
|
var fld, data;
|
||||||
generator.reset();
|
generator.clearApiErrors();
|
||||||
};
|
Wait('start');
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
data = {};
|
||||||
|
for (fld in form.fields) {
|
||||||
|
data[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
Rest.post(data)
|
||||||
|
.success(function (data) {
|
||||||
|
Wait('stop');
|
||||||
|
$rootScope.flashMessage = "New team successfully created!";
|
||||||
|
$location.path('/teams/' + data.id);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to add new team. Post returned status: ' +
|
||||||
|
status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
scope.formReset = function () {
|
||||||
|
// Defaults
|
||||||
|
generator.reset();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm', 'GenerateForm',
|
TeamsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
||||||
'OrganizationList', 'SearchInit', 'PaginateInit', 'GetBasePath', 'LookUpInit', 'Wait'];
|
'OrganizationList', 'SearchInit', 'PaginateInit', 'GetBasePath', 'LookUpInit', 'Wait'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm,
|
function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||||
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt,
|
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt,
|
||||||
GetBasePath, CheckAccess, OrganizationList, Wait, Stream)
|
GetBasePath, CheckAccess, OrganizationList, Wait, Stream) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
|
||||||
|
|
||||||
var defaultUrl=GetBasePath('teams');
|
var defaultUrl = GetBasePath('teams'),
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var form = TeamForm;
|
form = TeamForm,
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
scope = generator.inject(form, { mode: 'edit', related: true }),
|
||||||
generator.reset();
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {},
|
||||||
|
id = $routeParams.team_id,
|
||||||
|
relatedSets = {};
|
||||||
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
generator.reset();
|
||||||
var master = {};
|
|
||||||
var id = $routeParams.team_id;
|
|
||||||
var relatedSets = {};
|
|
||||||
|
|
||||||
scope.PermissionAddAllowed = false;
|
scope.PermissionAddAllowed = false;
|
||||||
|
|
||||||
// Retrieve each related set and any lookups
|
// Retrieve each related set and any lookups
|
||||||
if (scope.teamLoadedRemove) {
|
if (scope.teamLoadedRemove) {
|
||||||
scope.teamLoadedRemove();
|
scope.teamLoadedRemove();
|
||||||
}
|
}
|
||||||
scope.teamLoadedRemove = scope.$on('teamLoaded', function() {
|
scope.teamLoadedRemove = scope.$on('teamLoaded', function () {
|
||||||
CheckAccess({ scope: scope });
|
CheckAccess({ scope: scope });
|
||||||
Rest.setUrl(scope['organization_url']);
|
Rest.setUrl(scope.organization_url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
scope['organization_name'] = data.name;
|
scope.organization_name = data.name;
|
||||||
master['organization_name'] = data.name;
|
master.organization_name = data.name;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve organization: ' +
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve organization: ' + scope.orgnization_url + '. GET status: ' + status });
|
scope.orgnization_url + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl + ':id/');
|
Rest.setUrl(defaultUrl + ':id/');
|
||||||
Rest.get({ params: {id: id} })
|
Rest.get({
|
||||||
.success( function(data, status, headers, config) {
|
params: {
|
||||||
LoadBreadCrumbs({ path: '/teams/' + id, title: data.name });
|
id: id
|
||||||
for (var fld in form.fields) {
|
}
|
||||||
if (data[fld]) {
|
})
|
||||||
scope[fld] = data[fld];
|
.success(function (data) {
|
||||||
master[fld] = scope[fld];
|
var fld, related, set;
|
||||||
}
|
LoadBreadCrumbs({ path: '/teams/' + id, title: data.name });
|
||||||
}
|
for (fld in form.fields) {
|
||||||
var related = data.related;
|
if (data[fld]) {
|
||||||
for (var set in form.related) {
|
scope[fld] = data[fld];
|
||||||
if (related[set]) {
|
master[fld] = scope[fld];
|
||||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
}
|
||||||
}
|
}
|
||||||
}
|
related = data.related;
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
for (set in form.related) {
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
if (related[set]) {
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
relatedSets[set] = {
|
||||||
|
url: related[set],
|
||||||
|
iterator: form.related[set].iterator
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
|
RelatedSearchInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
RelatedPaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: data['organization'],
|
current_item: data.organization,
|
||||||
list: OrganizationList,
|
list: OrganizationList,
|
||||||
field: 'organization'
|
field: 'organization'
|
||||||
});
|
});
|
||||||
|
|
||||||
scope['organization_url'] = data.related.organization;
|
scope.organization_url = data.related.organization;
|
||||||
scope.$emit('teamLoaded');
|
scope.$emit('teamLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to retrieve team: ' + $routeParams.team_id +
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve team: ' + $routeParams.team_id + '. GET status: ' + status });
|
'. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function() {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
var data = {}, fld;
|
||||||
Wait('start');
|
generator.clearApiErrors();
|
||||||
$rootScope.flashMessage = null;
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl + $routeParams.team_id +'/');
|
$rootScope.flashMessage = null;
|
||||||
var data = {}
|
Rest.setUrl(defaultUrl + $routeParams.team_id + '/');
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
(base == 'teams') ? ReturnToCaller() : ReturnToCaller(1);
|
if (base === 'teams') {
|
||||||
})
|
ReturnToCaller();
|
||||||
.error( function(data, status, headers, config) {
|
}
|
||||||
Wait('stop');
|
ReturnToCaller(1);
|
||||||
ProcessErrors(scope, data, status, form,
|
})
|
||||||
{ hdr: 'Error!', msg: 'Failed to update team: ' + $routeParams.team_id + '. PUT status: ' + status });
|
.error(function (data, status) {
|
||||||
});
|
Wait('stop');
|
||||||
};
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to update team: ' + $routeParams.team_id + '. PUT status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function() {
|
scope.formReset = function () {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
generator.reset();
|
generator.reset();
|
||||||
for (var fld in master) {
|
for (var fld in master) {
|
||||||
scope[fld] = master[fld];
|
scope[fld] = master[fld];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Related set: Add button
|
// Related set: Add button
|
||||||
scope.add = function(set) {
|
scope.add = function (set) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if (set == 'permissions') {
|
if (set === 'permissions') {
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set + '/add');
|
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set + '/add');
|
||||||
}
|
} else {
|
||||||
else {
|
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
||||||
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
}
|
||||||
}
|
} else {
|
||||||
}
|
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set);
|
||||||
else {
|
}
|
||||||
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set);
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Edit button
|
// Related set: Edit button
|
||||||
scope.edit = function(set, id, name) {
|
scope.edit = function (set, id) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if (set == 'permissions') {
|
if (set === 'permissions') {
|
||||||
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set + '/' + id);
|
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set + '/' + id);
|
||||||
}
|
} else {
|
||||||
else {
|
$location.path('/' + set + '/' + id);
|
||||||
$location.path('/' + set + '/' + id);
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Delete button
|
// Related set: Delete button
|
||||||
scope['delete'] = function(set, itm_id, name, title) {
|
scope['delete'] = function (set, itm_id, name, title) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
var action = function() {
|
var action = function () {
|
||||||
var url;
|
var url;
|
||||||
if (set == 'permissions') {
|
if (set === 'permissions') {
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
url = GetBasePath('base') + 'permissions/' + itm_id + '/';
|
url = GetBasePath('base') + 'permissions/' + itm_id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
scope.search(form.related[set].iterator);
|
scope.search(form.related[set].iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
' failed. DELETE returned status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
||||||
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
}
|
||||||
}
|
} else {
|
||||||
}
|
url = defaultUrl + $routeParams.team_id + '/' + set + '/';
|
||||||
else {
|
Rest.setUrl(url);
|
||||||
var url = defaultUrl + $routeParams.team_id + '/' + set + '/';
|
Rest.post({ id: itm_id, disassociate: 1 })
|
||||||
Rest.setUrl(url);
|
.success(function () {
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
$('#prompt-modal').modal('hide');
|
||||||
.success( function(data, status, headers, config) {
|
scope.search(form.related[set].iterator);
|
||||||
$('#prompt-modal').modal('hide');
|
})
|
||||||
scope.search(form.related[set].iterator);
|
.error(function (data, status) {
|
||||||
})
|
$('#prompt-modal').modal('hide');
|
||||||
.error( function(data, status, headers, config) {
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||||
$('#prompt-modal').modal('hide');
|
' failed. POST returned status: ' + status });
|
||||||
ProcessErrors(scope, data, status, null,
|
});
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
}
|
||||||
});
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
|
||||||
action: action
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt',
|
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream'
|
||||||
'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream'
|
];
|
||||||
];
|
|
||||||
|
|
||||||
@@ -7,449 +7,476 @@
|
|||||||
* Controller functions for User model.
|
* Controller functions for User model.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, UserList,
|
function UsersList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, UserList, GenerateList, LoadBreadCrumbs,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, Wait, Stream) {
|
||||||
ClearScope, ProcessErrors, GetBasePath, SelectionInit, Wait, Stream)
|
|
||||||
{
|
ClearScope('htmlTemplate');
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
|
||||||
//scope.
|
var list = UserList,
|
||||||
|
defaultUrl = GetBasePath('users'),
|
||||||
|
view = GenerateList,
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
mode = (base === 'users') ? 'edit' : 'select', // if base path 'users', we're here to add/edit users
|
||||||
|
scope = view.inject(UserList, { mode: mode }),
|
||||||
|
url = (base === 'organizations') ? GetBasePath('organizations') + $routeParams.organization_id + '/users/' :
|
||||||
|
GetBasePath('teams') + $routeParams.team_id + '/users/';
|
||||||
|
|
||||||
var list = UserList;
|
|
||||||
var defaultUrl = GetBasePath('users');
|
|
||||||
var view = GenerateList;
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
var mode = (base == 'users') ? 'edit' : 'select'; // if base path 'users', we're here to add/edit users
|
|
||||||
var scope = view.inject(UserList, { mode: mode }); // Inject our view
|
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
|
|
||||||
var url = (base == 'organizations') ? GetBasePath('organizations') + $routeParams.organization_id + '/users/' :
|
SelectionInit({
|
||||||
GetBasePath('teams') + $routeParams.team_id + '/users/';
|
scope: scope,
|
||||||
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
list: list,
|
||||||
|
url: url,
|
||||||
|
returnToCaller: 1
|
||||||
|
});
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
// Cleanup after a delete
|
// Cleanup after a delete
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').off();
|
$('#prompt-modal').off();
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
SearchInit({ scope: scope, set: 'users', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'users',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.addUser = function() {
|
scope.addUser = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editUser = function(id) {
|
scope.editUser = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteUser = function(id, name) {
|
scope.deleteUser = function (id, name) {
|
||||||
|
|
||||||
var action = function() {
|
var action = function () {
|
||||||
$('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); });
|
$('#prompt-modal').on('hidden.bs.modal', function () {
|
||||||
$('#prompt-modal').modal('hide');
|
Wait('start');
|
||||||
var url = defaultUrl + id + '/';
|
});
|
||||||
Rest.setUrl(url);
|
$('#prompt-modal').modal('hide');
|
||||||
Rest.destroy()
|
var url = defaultUrl + id + '/';
|
||||||
.success( function(data, status, headers, config) {
|
Rest.setUrl(url);
|
||||||
scope.search(list.iterator);
|
Rest.destroy()
|
||||||
})
|
.success(function () {
|
||||||
.error( function(data, status, headers, config) {
|
scope.search(list.iterator);
|
||||||
Wait('stop');
|
})
|
||||||
ProcessErrors(scope, data, status, null,
|
.error(function (data, status) {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
Wait('stop');
|
||||||
});
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' +
|
||||||
};
|
status });
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
|
||||||
action: action
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
UsersList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'UserList', 'GenerateList',
|
UsersList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'UserList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath',
|
||||||
'GetBasePath', 'SelectionInit', 'Wait', 'Stream'];
|
'SelectionInit', 'Wait', 'Stream'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
function UsersAdd($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
LoadBreadCrumbs, ReturnToCaller, ClearScope, GetBasePath, LookUpInit, OrganizationList, ResetForm, Wait) {
|
||||||
GetBasePath, LookUpInit, OrganizationList, ResetForm, Wait)
|
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
|
||||||
//scope.
|
|
||||||
|
|
||||||
// Inject dynamic view
|
ClearScope('htmlTemplate');
|
||||||
var defaultUrl = GetBasePath('organizations');
|
|
||||||
var form = UserForm;
|
|
||||||
ResetForm();
|
|
||||||
var generator = GenerateForm;
|
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
|
||||||
|
|
||||||
scope.ldap_user = false;
|
// Inject dynamic view
|
||||||
scope.not_ldap_user = !scope.ldap_user;
|
var defaultUrl = GetBasePath('organizations'),
|
||||||
scope.ldap_dn = null;
|
form = UserForm,
|
||||||
|
generator = GenerateForm,
|
||||||
|
scope = generator.inject(form, { mode: 'add', related: false });
|
||||||
|
|
||||||
generator.reset();
|
ResetForm();
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
scope.ldap_user = false;
|
||||||
|
scope.not_ldap_user = !scope.ldap_user;
|
||||||
|
scope.ldap_dn = null;
|
||||||
|
|
||||||
// Configure the lookup dialog. If we're adding a user through the Organizations tab,
|
generator.reset();
|
||||||
// default the Organization value.
|
|
||||||
LookUpInit({
|
|
||||||
scope: scope,
|
|
||||||
form: form,
|
|
||||||
current_item: ($routeParams.organization_id !== undefined) ? $routeParams.organization_id : null,
|
|
||||||
list: OrganizationList,
|
|
||||||
field: 'organization'
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($routeParams.organization_id) {
|
LoadBreadCrumbs();
|
||||||
scope.organization = $routeParams.organization_id;
|
|
||||||
Rest.setUrl(GetBasePath('organizations') + $routeParams.organization_id + '/');
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
scope['organization_name'] = data.name;
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to lookup Organization: ' + data.id + '. GET returned status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save
|
// Configure the lookup dialog. If we're adding a user through the Organizations tab,
|
||||||
scope.formSave = function() {
|
// default the Organization value.
|
||||||
generator.clearApiErrors();
|
LookUpInit({
|
||||||
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
scope: scope,
|
||||||
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
form: form,
|
||||||
var data = {}
|
current_item: ($routeParams.organization_id !== undefined) ? $routeParams.organization_id : null,
|
||||||
for (var fld in form.fields) {
|
list: OrganizationList,
|
||||||
if (form.fields[fld].realName) {
|
field: 'organization'
|
||||||
data[form.fields[fld].realName] = scope[fld];
|
});
|
||||||
}
|
|
||||||
else {
|
|
||||||
data[fld] = scope[fld];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data.is_superuser = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
if ($routeParams.organization_id) {
|
||||||
data.is_superuser;
|
scope.organization = $routeParams.organization_id;
|
||||||
Wait('start');
|
Rest.setUrl(GetBasePath('organizations') + $routeParams.organization_id + '/');
|
||||||
Rest.post(data)
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
scope.organization_name = data.name;
|
||||||
if (base == 'users') {
|
})
|
||||||
$rootScope.flashMessage = 'New user successfully created!';
|
.error(function (data, status) {
|
||||||
$location.path('/users/' + data.id);
|
ProcessErrors(scope, data, status, form, {
|
||||||
}
|
hdr: 'Error!',
|
||||||
else {
|
msg: 'Failed to lookup Organization: ' + data.id + '. GET returned status: ' + status
|
||||||
ReturnToCaller(1);
|
});
|
||||||
}
|
});
|
||||||
})
|
}
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new user. POST returned status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope.organization_name_api_error = 'A value is required';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cancel
|
// Save
|
||||||
scope.formReset = function() {
|
scope.formSave = function () {
|
||||||
// Defaults
|
generator.clearApiErrors();
|
||||||
generator.reset();
|
var fld, data = {};
|
||||||
scope.ldap_user = false;
|
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
||||||
};
|
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
||||||
|
for (fld in form.fields) {
|
||||||
|
if (form.fields[fld].realName) {
|
||||||
|
data[form.fields[fld].realName] = scope[fld];
|
||||||
|
} else {
|
||||||
|
data[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.is_superuser = data.is_superuser || false;
|
||||||
|
Wait('start');
|
||||||
|
Rest.post(data)
|
||||||
|
.success(function (data) {
|
||||||
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
if (base === 'users') {
|
||||||
|
$rootScope.flashMessage = 'New user successfully created!';
|
||||||
|
$location.path('/users/' + data.id);
|
||||||
|
}
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to add new user. POST returned status: ' + status });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
scope.organization_name_api_error = 'A value is required';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Password change
|
// Cancel
|
||||||
scope.clearPWConfirm = function(fld) {
|
scope.formReset = function () {
|
||||||
// If password value changes, make sure password_confirm must be re-entered
|
// Defaults
|
||||||
scope[fld] = '';
|
generator.reset();
|
||||||
scope[form.name + '_form'][fld].$setValidity('awpassmatch', false);
|
scope.ldap_user = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Password change
|
||||||
|
scope.clearPWConfirm = function (fld) {
|
||||||
|
// If password value changes, make sure password_confirm must be re-entered
|
||||||
|
scope[fld] = '';
|
||||||
|
scope[form.name + '_form'][fld].$setValidity('awpassmatch', false);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
UsersAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath',
|
||||||
'LookUpInit', 'OrganizationList', 'ResetForm', 'Wait' ];
|
'LookUpInit', 'OrganizationList', 'ResetForm', 'Wait'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||||
RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath, Prompt, CheckAccess,
|
RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath, Prompt, CheckAccess,
|
||||||
ResetForm, Wait, Stream)
|
ResetForm, Wait, Stream) {
|
||||||
{
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
//scope.
|
||||||
//scope.
|
|
||||||
|
|
||||||
var defaultUrl=GetBasePath('users');
|
var defaultUrl = GetBasePath('users'),
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var form = UserForm;
|
form = UserForm,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var master = {};
|
master = {},
|
||||||
var id = $routeParams.user_id;
|
id = $routeParams.user_id,
|
||||||
var relatedSets = {};
|
relatedSets = {};
|
||||||
|
|
||||||
if ($scope.removeFormReady) {
|
if ($scope.removeFormReady) {
|
||||||
$scope.removeFormReady();
|
$scope.removeFormReady();
|
||||||
}
|
}
|
||||||
$scope.removeFormReady = $scope.$on('formReady', function() {
|
$scope.removeFormReady = $scope.$on('formReady', function () {
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
var scope = generator.inject(form, { mode: 'edit', related: true });
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
scope.removePostRefresh();
|
scope.removePostRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.PermissionAddAllowed = false;
|
scope.PermissionAddAllowed = false;
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
// After the Organization is loaded, retrieve each related set
|
||||||
if (scope.removeUserLoaded) {
|
if (scope.removeUserLoaded) {
|
||||||
scope.removeUserLoaded();
|
scope.removeUserLoaded();
|
||||||
}
|
}
|
||||||
scope.removeUserLoaded = scope.$on('userLoaded', function() {
|
scope.removeUserLoaded = scope.$on('userLoaded', function () {
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
CheckAccess({ scope: scope }); //Does the user have access to add/edit Permissions?
|
CheckAccess({
|
||||||
Wait('stop');
|
scope: scope
|
||||||
});
|
}); //Does the user have access to add/edit Permissions?
|
||||||
|
Wait('stop');
|
||||||
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Rest.setUrl(defaultUrl + ':id/');
|
Rest.setUrl(defaultUrl + ':id/');
|
||||||
Rest.get({ params: {id: id} })
|
Rest.get({ params: { id: id } })
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
LoadBreadCrumbs({ path: '/users/' + id, title: data.username });
|
LoadBreadCrumbs({ path: '/users/' + id, title: data.username });
|
||||||
for (var fld in form.fields) {
|
var fld, related, set;
|
||||||
if (data[fld]) {
|
for (fld in form.fields) {
|
||||||
if (fld == 'is_superuser') {
|
if (data[fld]) {
|
||||||
scope[fld] = (data[fld] == 'true' || data[fld] == true) ? 'true' : 'false';
|
if (fld === 'is_superuser') {
|
||||||
}
|
scope[fld] = (data[fld] === 'true' || data[fld] === true) ? 'true' : 'false';
|
||||||
else {
|
} else {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
}
|
}
|
||||||
master[fld] = scope[fld];
|
master[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var related = data.related;
|
related = data.related;
|
||||||
for (var set in form.related) {
|
for (set in form.related) {
|
||||||
if (related[set]) {
|
if (related[set]) {
|
||||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
relatedSets[set] = {
|
||||||
}
|
url: related[set],
|
||||||
}
|
iterator: form.related[set].iterator
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scope.ldap_user = (data.ldap_dn !== null && data.ldap_dn !== undefined && data.ldap_dn !== '') ? true : false;
|
scope.ldap_user = (data.ldap_dn !== null && data.ldap_dn !== undefined && data.ldap_dn !== '') ? true : false;
|
||||||
scope.not_ldap_user = !scope.ldap_user;
|
scope.not_ldap_user = !scope.ldap_user;
|
||||||
master.ldap_user = scope.ldap_user;
|
master.ldap_user = scope.ldap_user;
|
||||||
|
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
scope: scope,
|
||||||
scope.$emit('userLoaded');
|
form: form,
|
||||||
})
|
relatedSets: relatedSets
|
||||||
.error( function(data, status, headers, config) {
|
});
|
||||||
ProcessErrors(scope, data, status, form,
|
RelatedPaginateInit({
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve user: ' + $routeParams.id + '. GET status: ' + status });
|
scope: scope,
|
||||||
});
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
scope.$emit('userLoaded');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve user: ' +
|
||||||
|
$routeParams.id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function() {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
var data = {}, fld;
|
||||||
$rootScope.flashMessage = null;
|
generator.clearApiErrors();
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
$rootScope.flashMessage = null;
|
||||||
var data = {}
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (form.fields[fld].realName) {
|
if (form.fields[fld].realName) {
|
||||||
data[form.fields[fld].realName] = scope[fld];
|
data[form.fields[fld].realName] = scope[fld];
|
||||||
}
|
} else {
|
||||||
else {
|
data[fld] = scope[fld];
|
||||||
data[fld] = scope[fld];
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
data.is_superuser = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
data.is_superuser = data.is_superuser || false;
|
||||||
data.is_superuser;
|
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
(base == 'users') ? ReturnToCaller() : ReturnToCaller(1);
|
if (base === 'users') {
|
||||||
})
|
ReturnToCaller();
|
||||||
.error( function(data, status, headers, config) {
|
}
|
||||||
Wait('stop');
|
ReturnToCaller(1);
|
||||||
ProcessErrors(scope, data, status, form,
|
})
|
||||||
{ hdr: 'Error!', msg: 'Failed to update users: ' + $routeParams.id + '. PUT status: ' + status });
|
.error(function (data, status) {
|
||||||
});
|
Wait('stop');
|
||||||
};
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update users: ' + $routeParams.id +
|
||||||
|
'. PUT status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function() {
|
scope.formReset = function () {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
generator.reset();
|
generator.reset();
|
||||||
for (var fld in master) {
|
for (var fld in master) {
|
||||||
scope[fld] = master[fld];
|
scope[fld] = master[fld];
|
||||||
}
|
}
|
||||||
scope['password_confirm'] = scope['password'];
|
scope.password_confirm = scope.password;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Password change
|
// Password change
|
||||||
scope.clearPWConfirm = function(fld) {
|
scope.clearPWConfirm = function (fld) {
|
||||||
// If password value changes, make sure password_confirm must be re-entered
|
// If password value changes, make sure password_confirm must be re-entered
|
||||||
scope[fld] = '';
|
scope[fld] = '';
|
||||||
scope[form.name + '_form'][fld].$setValidity('awpassmatch', false);
|
scope[form.name + '_form'][fld].$setValidity('awpassmatch', false);
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// Related set: Add button
|
// Related set: Add button
|
||||||
scope.add = function(set) {
|
scope.add = function (set) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if (set == 'permissions') {
|
if (set === 'permissions') {
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
$location.path('/' + base + '/' + $routeParams.user_id + '/' + set + '/add');
|
$location.path('/' + base + '/' + $routeParams.user_id + '/' + set + '/add');
|
||||||
}
|
} else {
|
||||||
else {
|
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
||||||
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
}
|
||||||
}
|
} else {
|
||||||
}
|
$location.path('/' + base + '/' + $routeParams.user_id + '/' + set);
|
||||||
else {
|
}
|
||||||
$location.path('/' + base + '/' + $routeParams.user_id + '/' + set);
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Edit button
|
// Related set: Edit button
|
||||||
scope.edit = function(set, id, name) {
|
scope.edit = function (set, id) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if (set == 'permissions') {
|
if (set === 'permissions') {
|
||||||
$location.path('/users/' + $routeParams.user_id + '/permissions/' + id);
|
$location.path('/users/' + $routeParams.user_id + '/permissions/' + id);
|
||||||
}
|
} else {
|
||||||
else {
|
$location.path('/' + set + '/' + id);
|
||||||
$location.path('/' + set + '/' + id);
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Related set: Delete button
|
// Related set: Delete button
|
||||||
scope['delete'] = function(set, itm_id, name, title) {
|
scope['delete'] = function (set, itm_id, name, title) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
var action = function() {
|
var action = function () {
|
||||||
var url;
|
var url;
|
||||||
if (set == 'permissions') {
|
if (set === 'permissions') {
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
url = GetBasePath('base') + 'permissions/' + itm_id + '/';
|
url = GetBasePath('base') + 'permissions/' + itm_id + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.destroy()
|
||||||
|
.success(function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.search(form.related[set].iterator);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
url = defaultUrl + $routeParams.user_id + '/' + set + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.post({
|
||||||
.success( function(data, status, headers, config) {
|
id: itm_id,
|
||||||
|
disassociate: 1
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
scope.search(form.related[set].iterator);
|
scope.search(form.related[set].iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. POST returned status: ' + status
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
url = defaultUrl + $routeParams.user_id + '/' + set + '/';
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
scope.search(form.related[set].iterator);
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
ProcessErrors(scope, data, status, null,
|
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.username + ' ' + title + '?',
|
hdr: 'Delete',
|
||||||
action: action
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.username + ' ' + title + '?',
|
||||||
});
|
action: action
|
||||||
}
|
|
||||||
|
|
||||||
}); // $scope.$on
|
|
||||||
|
|
||||||
// Put form back to its original state
|
|
||||||
ResetForm();
|
|
||||||
|
|
||||||
|
|
||||||
if ($scope.removeModifyForm) {
|
|
||||||
$scope.removeModifyForm();
|
|
||||||
}
|
|
||||||
$scope.removeModifyForm = $scope.$on('modifyForm', function() {
|
|
||||||
// Modify form based on LDAP settings
|
|
||||||
Rest.setUrl(GetBasePath('config'));
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
if (data['user_ldap_fields']) {
|
|
||||||
var fld;
|
|
||||||
for (var i=0; i < data['user_ldap_fields'].length; i++) {
|
|
||||||
fld = data['user_ldap_fields'][i];
|
|
||||||
if (form.fields[fld]) {
|
|
||||||
form.fields[fld]['readonly'] = true;
|
|
||||||
form.fields[fld]['editRequired'] = false;
|
|
||||||
if (form.fields[fld].awRequiredWhen) {
|
|
||||||
delete form.fields[fld].awRequiredWhen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$scope.$emit('formReady');
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors($scope, data, status, null,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve application config. GET status: ' + status });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Wait('start');
|
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
if (data.ldap_dn !== null && data.ldap_dn !== undefined && data.ldap_dn !== '') {
|
|
||||||
//this is an LDAP user
|
|
||||||
$scope.$emit('modifyForm');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.$emit('formReady');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors($scope, data, status, null,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve user: ' + id + '. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
}); // $scope.$on
|
||||||
|
|
||||||
|
// Put form back to its original state
|
||||||
|
ResetForm();
|
||||||
|
|
||||||
|
|
||||||
|
if ($scope.removeModifyForm) {
|
||||||
|
$scope.removeModifyForm();
|
||||||
|
}
|
||||||
|
$scope.removeModifyForm = $scope.$on('modifyForm', function () {
|
||||||
|
// Modify form based on LDAP settings
|
||||||
|
Rest.setUrl(GetBasePath('config'));
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
var i, fld;
|
||||||
|
if (data.user_ldap_fields) {
|
||||||
|
for (i = 0; i < data.user_ldap_fields.length; i++) {
|
||||||
|
fld = data.user_ldap_fields[i];
|
||||||
|
if (form.fields[fld]) {
|
||||||
|
form.fields[fld].readonly = true;
|
||||||
|
form.fields[fld].editRequired = false;
|
||||||
|
if (form.fields[fld].awRequiredWhen) {
|
||||||
|
delete form.fields[fld].awRequiredWhen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$scope.$emit('formReady');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve application config. GET status: ' + status });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
if (data.ldap_dn !== null && data.ldap_dn !== undefined && data.ldap_dn !== '') {
|
||||||
|
//this is an LDAP user
|
||||||
|
$scope.$emit('modifyForm');
|
||||||
|
} else {
|
||||||
|
$scope.$emit('formReady');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve user: ' + id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
UsersEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm',
|
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Prompt', 'CheckAccess',
|
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream'
|
||||||
'ResetForm', 'Wait', 'Stream'];
|
];
|
||||||
|
|
||||||
Reference in New Issue
Block a user