mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 12:57:40 -02:30
Ran all controller files through jsbeautifier.org and applied jsHint.
This commit is contained in:
@@ -12,24 +12,40 @@
|
|||||||
|
|
||||||
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,20 +8,24 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* 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() {
|
var setLoginFocus, lastPath, sessionExpired, scope;
|
||||||
|
|
||||||
|
setLoginFocus = function () {
|
||||||
$('#login-username').focus();
|
$('#login-username').focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
var sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
|
sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
|
||||||
|
|
||||||
var lastPath = function() {
|
lastPath = function () {
|
||||||
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
||||||
}
|
};
|
||||||
|
|
||||||
if ($AnsibleConfig.debug_mode && console) {
|
if ($AnsibleConfig.debug_mode && console) {
|
||||||
console.log('User session expired: ' + sessionExpired);
|
console.log('User session expired: ' + sessionExpired);
|
||||||
@@ -39,22 +43,26 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
|||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|
||||||
// Display the login dialog
|
// Display the login dialog
|
||||||
$('#login-modal').modal({ show: true, keyboard: false, backdrop: 'static' });
|
$('#login-modal').modal({
|
||||||
|
show: true,
|
||||||
|
keyboard: false,
|
||||||
|
backdrop: 'static'
|
||||||
|
});
|
||||||
|
|
||||||
// Set focus to username field
|
// Set focus to username field
|
||||||
$('#login-modal').on('shown.bs.modal', function () {
|
$('#login-modal').on('shown.bs.modal', function () {
|
||||||
setLoginFocus();
|
setLoginFocus();
|
||||||
});
|
});
|
||||||
|
|
||||||
var scope = angular.element(document.getElementById('login-modal')).scope();
|
scope = angular.element(document.getElementById('login-modal')).scope();
|
||||||
|
|
||||||
// Reset the login form
|
// Reset the login form
|
||||||
scope['login_username'] = null;
|
scope.login_username = null;
|
||||||
scope['login_password'] = null;
|
scope.login_password = null;
|
||||||
scope['loginForm']['login_username'].$setPristine();
|
scope.loginForm.login_username.$setPristine();
|
||||||
scope['loginForm']['login_password'].$setPristine();
|
scope.loginForm.login_password.$setPristine();
|
||||||
|
|
||||||
if ($location.path() == '/logout') {
|
if ($location.path() === '/logout') {
|
||||||
//if logout request, clear AuthToken and user session data
|
//if logout request, clear AuthToken and user session data
|
||||||
Authorization.logout();
|
Authorization.logout();
|
||||||
}
|
}
|
||||||
@@ -64,72 +72,69 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
|||||||
|
|
||||||
$('#login-password').bind('keypress', function (e) {
|
$('#login-password').bind('keypress', function (e) {
|
||||||
var code = (e.keyCode ? e.keyCode : e.which);
|
var code = (e.keyCode ? e.keyCode : e.which);
|
||||||
if (code == 13) {
|
if (code === 13) {
|
||||||
$('#login-button').click();
|
$('#login-button').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.reset = function () {
|
scope.reset = function () {
|
||||||
$('#login-form input').each( function(index) { $(this).val(''); });
|
$('#login-form input').each(function () {
|
||||||
|
$(this).val('');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call the API to get an auth token
|
// Call the API to get an auth token
|
||||||
scope.systemLogin = function (username, password) {
|
scope.systemLogin = function (username, password) {
|
||||||
$('.api-error').empty();
|
$('.api-error').empty();
|
||||||
var token;
|
var token;
|
||||||
if (username == null || username == undefined || username == '' ||
|
if (Empty(username) || Empty(password)) {
|
||||||
password == null || password == undefined || password == '' ) {
|
|
||||||
Alert('Error!', 'Please provide a username and password before attempting to login.', 'alert-danger', setLoginFocus);
|
Alert('Error!', 'Please provide a username and password before attempting to login.', 'alert-danger', setLoginFocus);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Authorization.retrieveToken(username, password)
|
Authorization.retrieveToken(username, password)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data, status) {
|
||||||
$('#login-modal').modal('hide');
|
$('#login-modal').modal('hide');
|
||||||
token = data.token;
|
token = data.token;
|
||||||
Authorization.setToken(data.token, data.expires);
|
Authorization.setToken(data.token, data.expires);
|
||||||
$rootScope.sessionTimer = Timer.init();
|
$rootScope.sessionTimer = Timer.init();
|
||||||
// Get all the profile/access info regarding the logged in user
|
// Get all the profile/access info regarding the logged in user
|
||||||
Authorization.getUser()
|
Authorization.getUser()
|
||||||
.success(function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
Authorization.setUserInfo(data);
|
Authorization.setUserInfo(data);
|
||||||
$rootScope['user_is_superuser'] = data.results[0].is_superuser;
|
$rootScope.user_is_superuser = data.results[0].is_superuser;
|
||||||
Authorization.getLicense()
|
Authorization.getLicense()
|
||||||
.success(function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
Authorization.setLicense(data['license_info']);
|
Authorization.setLicense(data.license_info);
|
||||||
if (lastPath()) {
|
if (lastPath()) {
|
||||||
// Go back to most recent navigation path
|
// Go back to most recent navigation path
|
||||||
$location.path(lastPath());
|
$location.path(lastPath());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$location.url('/home?login=true');
|
$location.url('/home?login=true');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function(data, status, headers, config) {
|
.error(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
|
var hdr, msg, key;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
if ( data.non_field_errors && data.non_field_errors.length == 0 ) {
|
if (data.non_field_errors && data.non_field_errors.length === 0) {
|
||||||
// show field specific errors returned by the API
|
// show field specific errors returned by the API
|
||||||
for (var key in data) {
|
for (key in data) {
|
||||||
scope[key + 'Error'] = data[key][0];
|
scope[key + 'Error'] = data[key][0];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var hdr, msg;
|
|
||||||
if (data.non_field_errors && data.non_field_errors.length > 0) {
|
if (data.non_field_errors && data.non_field_errors.length > 0) {
|
||||||
hdr = 'Error';
|
hdr = 'Error';
|
||||||
msg = data.non_field_errors[0];
|
msg = data.non_field_errors[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
hdr = 'Error';
|
hdr = 'Error';
|
||||||
msg = 'The login attempt failed with a status of: ' + status;
|
msg = 'The login attempt failed with a status of: ' + status;
|
||||||
}
|
}
|
||||||
@@ -138,9 +143,10 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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'
|
||||||
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -7,54 +7,53 @@
|
|||||||
* Controller functions for the Credential model.
|
* Controller functions for the Credential model.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, CredentialList,
|
function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, CredentialList,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||||
ClearScope, ProcessErrors, GetBasePath, SelectionInit, GetChoices, Wait, Stream)
|
ClearScope, ProcessErrors, GetBasePath, SelectionInit, GetChoices, Wait, Stream) {
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate');
|
||||||
//scope.
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
var list = CredentialList;
|
var list = CredentialList,
|
||||||
var defaultUrl = GetBasePath('credentials');
|
defaultUrl = GetBasePath('credentials'),
|
||||||
var view = GenerateList;
|
view = GenerateList,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var mode = (base == 'credentials') ? 'edit' : 'select'; // if base path 'credentials', we're here to add/edit
|
mode = (base === 'credentials') ? 'edit' : 'select', // if base path 'credentials', we're here to add/edit
|
||||||
var scope = view.inject(list, { mode: mode }); // Inject our view
|
scope = view.inject(list, { mode: mode }),
|
||||||
|
url;
|
||||||
|
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
scope.credentialLoading = true;
|
scope.credentialLoading = true;
|
||||||
|
|
||||||
var url = GetBasePath(base);
|
url = GetBasePath(base) + ( (base === 'users') ? $routeParams.user_id + '/credentials/' : $routeParams.team_id + '/credentials/' );
|
||||||
url += (base == 'users') ? $routeParams.user_id + '/credentials/' : $routeParams.team_id + '/credentials/';
|
|
||||||
|
|
||||||
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
|
||||||
|
var i, j;
|
||||||
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').off();
|
$('#prompt-modal').off();
|
||||||
|
|
||||||
list.fields.kind.searchOptions = scope.credential_kind_options;
|
list.fields.kind.searchOptions = scope.credential_kind_options;
|
||||||
|
|
||||||
// Translate the kind value
|
// Translate the kind value
|
||||||
for(var i=0; i < scope.credentials.length; i++) {
|
for (i = 0; i < scope.credentials.length; i++) {
|
||||||
/*
|
for (j = 0; j < scope.credential_kind_options.length; j++) {
|
||||||
if (scope.credentials[i].summary_fields.user) {
|
if (scope.credential_kind_options[j].value === scope.credentials[i].kind) {
|
||||||
scope.credentials[i].user_username = scope.credentials[i].summary_fields.user.username;
|
scope.credentials[i].kind = scope.credential_kind_options[j].label;
|
||||||
}
|
|
||||||
if (scope.credentials[i].summary_fields.team) {
|
|
||||||
scope.credentials[i].team_name = scope.credentials[i].summary_fields.team.name;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for (var j=0; j < scope.credential_kind_options.length; j++) {
|
|
||||||
if (scope.credential_kind_options[j].value == scope.credentials[i].kind) {
|
|
||||||
scope.credentials[i].kind = scope.credential_kind_options[j].label
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,8 +64,17 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
scope.removeChoicesReady();
|
scope.removeChoicesReady();
|
||||||
}
|
}
|
||||||
scope.removeChoicesReady = scope.$on('choicesReadyCredential', function () {
|
scope.removeChoicesReady = scope.$on('choicesReadyCredential', function () {
|
||||||
SearchInit({ scope: scope, set: 'credentials', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'credentials',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,20 +90,26 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.addCredential = function () {
|
scope.addCredential = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editCredential = function (id) {
|
scope.editCredential = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteCredential = function (id, name) {
|
scope.deleteCredential = 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 () {
|
||||||
|
Wait('start');
|
||||||
|
});
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
var url = defaultUrl + id + '/';
|
var url = defaultUrl + id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
@@ -105,39 +119,43 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
})
|
})
|
||||||
.error(function (data, status, headers, config) {
|
.error(function (data, status, headers, config) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
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',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
CredentialsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'CredentialList', 'GenerateList',
|
CredentialsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'CredentialList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
||||||
'GetBasePath', 'SelectionInit', 'GetChoices', 'Wait', 'Stream' ];
|
'GetBasePath', 'SelectionInit', 'GetChoices', 'Wait', 'Stream'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm,
|
function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GenerateList, SearchInit, PaginateInit, LookUpInit, UserList, TeamList, GetBasePath,
|
GenerateList, SearchInit, PaginateInit, LookUpInit, UserList, TeamList, GetBasePath,
|
||||||
GetChoices, Empty, KindChange, OwnerChange, FormSave, DebugForm)
|
GetChoices, Empty, KindChange, OwnerChange, FormSave, DebugForm) {
|
||||||
{
|
|
||||||
ClearScope('tree-form');
|
ClearScope('tree-form');
|
||||||
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('credentials');
|
var form = CredentialForm,
|
||||||
var form = CredentialForm;
|
generator = GenerateForm,
|
||||||
var generator = GenerateForm;
|
scope = generator.inject(form, { mode: 'add', related: false }),
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
defaultUrl = GetBasePath('credentials'),
|
||||||
var defaultUrl = GetBasePath('credentials');
|
url;
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
@@ -167,54 +185,70 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
|
|
||||||
if (!Empty($routeParams.user_id)) {
|
if (!Empty($routeParams.user_id)) {
|
||||||
// Get the username based on incoming route
|
// Get the username based on incoming route
|
||||||
scope['owner'] = 'user';
|
scope.owner = 'user';
|
||||||
scope['user'] = $routeParams.user_id;
|
scope.user = $routeParams.user_id;
|
||||||
OwnerChange({ scope: scope });
|
OwnerChange({
|
||||||
var url = GetBasePath('users') + $routeParams.user_id + '/';
|
scope: scope
|
||||||
|
});
|
||||||
|
url = GetBasePath('users') + $routeParams.user_id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data, status, headers, config) {
|
.success(function (data, status, headers, config) {
|
||||||
scope['user_username'] = data.username;
|
scope.user_username = data.username;
|
||||||
})
|
})
|
||||||
.error(function (data, status, headers, config) {
|
.error(function (data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve user. GET status: ' + status
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve user. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else if (!Empty($routeParams.team_id)) {
|
} else if (!Empty($routeParams.team_id)) {
|
||||||
// Get the username based on incoming route
|
// Get the username based on incoming route
|
||||||
scope['owner'] = 'team';
|
scope.owner = 'team';
|
||||||
scope['team'] = $routeParams.team_id;
|
scope.team = $routeParams.team_id;
|
||||||
OwnerChange({ scope: scope });
|
OwnerChange({
|
||||||
var url = GetBasePath('teams') + $routeParams.team_id + '/';
|
scope: scope
|
||||||
|
});
|
||||||
|
url = GetBasePath('teams') + $routeParams.team_id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data, status, headers, config) {
|
.success(function (data, status, headers, config) {
|
||||||
scope['team_name'] = data.name;
|
scope.team_name = data.name;
|
||||||
})
|
})
|
||||||
.error(function (data, status, headers, config) {
|
.error(function (data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve team. GET status: ' + status
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve team. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else {
|
} else {
|
||||||
// default type of owner to a user
|
// default type of owner to a user
|
||||||
scope['owner'] = 'user';
|
scope.owner = 'user';
|
||||||
OwnerChange({ scope: scope });
|
OwnerChange({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Kind change
|
// Handle Kind change
|
||||||
scope.kindChange = function () {
|
scope.kindChange = function () {
|
||||||
KindChange({ scope: scope, form: form, reset: true });
|
KindChange({
|
||||||
}
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
reset: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function() { generator.clearApiErrors(); FormSave({ scope: scope, mode: 'add' }) };
|
scope.formSave = function () {
|
||||||
|
generator.clearApiErrors();
|
||||||
|
FormSave({
|
||||||
|
scope: scope,
|
||||||
|
mode: 'add'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Handle Owner change
|
// Handle Owner change
|
||||||
scope.ownerChange = function () {
|
scope.ownerChange = function () {
|
||||||
OwnerChange({ scope: scope });
|
OwnerChange({
|
||||||
}
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Reset defaults
|
// Reset defaults
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
@@ -227,7 +261,7 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
// 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);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Respond to 'Ask at runtime?' checkbox
|
// Respond to 'Ask at runtime?' checkbox
|
||||||
scope.ask = function (fld, associated) {
|
scope.ask = function (fld, associated) {
|
||||||
@@ -235,13 +269,12 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
scope[fld] = 'ASK';
|
scope[fld] = 'ASK';
|
||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope[fld] = '';
|
scope[fld] = '';
|
||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Click clear button
|
// Click clear button
|
||||||
scope.clear = function (fld, associated) {
|
scope.clear = function (fld, associated) {
|
||||||
@@ -249,14 +282,15 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
scope[form.name + '_form'].$setDirty();
|
scope[form.name + '_form'].$setDirty();
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm', 'GenerateForm',
|
CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
||||||
'SearchInit', 'PaginateInit', 'LookUpInit', 'UserList', 'TeamList', 'GetBasePath', 'GetChoices', 'Empty',
|
'SearchInit', 'PaginateInit', 'LookUpInit', 'UserList', 'TeamList', 'GetBasePath', 'GetChoices', 'Empty',
|
||||||
'KindChange', 'OwnerChange', 'FormSave', 'DebugForm'];
|
'KindChange', 'OwnerChange', 'FormSave', 'DebugForm'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm,
|
function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm,
|
||||||
@@ -264,34 +298,29 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
RelatedPaginateInit, ReturnToCaller, ClearScope, Prompt, GetBasePath, GetChoices,
|
RelatedPaginateInit, ReturnToCaller, ClearScope, Prompt, GetBasePath, GetChoices,
|
||||||
KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, FormSave, Stream,
|
KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, FormSave, Stream,
|
||||||
Wait
|
Wait
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
ClearScope('tree-form');
|
ClearScope('htmlTemplate');
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
|
||||||
//scope.
|
var defaultUrl = GetBasePath('credentials'),
|
||||||
|
generator = GenerateForm,
|
||||||
|
form = CredentialForm,
|
||||||
|
scope = generator.inject(form, { mode: 'edit', related: true }),
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {},
|
||||||
|
id = $routeParams.credential_id;
|
||||||
|
|
||||||
var defaultUrl=GetBasePath('credentials');
|
|
||||||
var generator = GenerateForm;
|
|
||||||
var form = CredentialForm;
|
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
scope.id = id;
|
||||||
var defaultUrl = GetBasePath('credentials');
|
|
||||||
|
|
||||||
var master = {};
|
|
||||||
var id = $routeParams.credential_id;
|
|
||||||
scope['id'] = id;
|
|
||||||
|
|
||||||
var relatedSets = {};
|
|
||||||
|
|
||||||
function setAskCheckboxes() {
|
function setAskCheckboxes() {
|
||||||
for (var fld in form.fields) {
|
var fld, i;
|
||||||
if (form.fields[fld].type == 'password' && scope[fld] == 'ASK') {
|
for (fld in form.fields) {
|
||||||
|
if (form.fields[fld].type === 'password' && scope[fld] === 'ASK') {
|
||||||
// turn on 'ask' checkbox for password fields with value of 'ASK'
|
// turn on 'ask' checkbox for password fields with value of 'ASK'
|
||||||
$("#" + fld + "-clear-btn").attr("disabled", "disabled");
|
$("#" + fld + "-clear-btn").attr("disabled", "disabled");
|
||||||
scope[fld + '_ask'] = true;
|
scope[fld + '_ask'] = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope[fld + '_ask'] = false;
|
scope[fld + '_ask'] = false;
|
||||||
$("#" + fld + "-clear-btn").removeAttr("disabled");
|
$("#" + fld + "-clear-btn").removeAttr("disabled");
|
||||||
}
|
}
|
||||||
@@ -299,9 +328,9 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set kind field to the correct option
|
// Set kind field to the correct option
|
||||||
for (var i=0; i < scope['credential_kind_options'].length; i++) {
|
for (i = 0; i < scope.credential_kind_options.length; i++) {
|
||||||
if (scope['kind'] == scope['credential_kind_options'][i].value) {
|
if (scope.kind === scope.credential_kind_options[i].value) {
|
||||||
scope['kind'] = scope['credential_kind_options'][i];
|
scope.kind = scope.credential_kind_options[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,7 +343,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: (!Empty($scope['user_id'])) ? scope['user_id'] : null,
|
current_item: (!Empty($scope.user_id)) ? scope.user_id : null,
|
||||||
list: UserList,
|
list: UserList,
|
||||||
field: 'user'
|
field: 'user'
|
||||||
});
|
});
|
||||||
@@ -322,14 +351,20 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: (!Empty($scope['team_id'])) ? scope['team_id'] : null,
|
current_item: (!Empty($scope.team_id)) ? scope.team_id : null,
|
||||||
list: TeamList,
|
list: TeamList,
|
||||||
field: 'team'
|
field: 'team'
|
||||||
});
|
});
|
||||||
|
|
||||||
setAskCheckboxes();
|
setAskCheckboxes();
|
||||||
KindChange({ scope: scope, form: form, reset: false });
|
KindChange({
|
||||||
OwnerChange({ scope: scope });
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
reset: false
|
||||||
|
});
|
||||||
|
OwnerChange({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -339,15 +374,26 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
scope.removeChoicesReady = scope.$on('choicesReadyCredential', function () {
|
scope.removeChoicesReady = scope.$on('choicesReadyCredential', function () {
|
||||||
// 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({
|
||||||
.success( function(data, status, headers, config) {
|
params: {
|
||||||
LoadBreadCrumbs({ path: '/credentials/' + id, title: data.name });
|
id: id
|
||||||
for (var fld in form.fields) {
|
}
|
||||||
|
})
|
||||||
|
.success(function (data) {
|
||||||
|
|
||||||
|
var i, fld;
|
||||||
|
|
||||||
|
LoadBreadCrumbs({
|
||||||
|
path: '/credentials/' + id,
|
||||||
|
title: data.name
|
||||||
|
});
|
||||||
|
|
||||||
|
for (fld in form.fields) {
|
||||||
if (data[fld] !== null && data[fld] !== undefined) {
|
if (data[fld] !== null && data[fld] !== undefined) {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
master[fld] = scope[fld];
|
master[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
if (form.fields[fld].type == 'lookup' && data.summary_fields[form.fields[fld].sourceModel]) {
|
if (form.fields[fld].type === 'lookup' && data.summary_fields[form.fields[fld].sourceModel]) {
|
||||||
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||||
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
@@ -355,44 +401,45 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Empty(scope['user'])) {
|
if (!Empty(scope.user)) {
|
||||||
scope['owner'] = 'user';
|
scope.owner = 'user';
|
||||||
|
} else {
|
||||||
|
scope.owner = 'team';
|
||||||
}
|
}
|
||||||
else {
|
master.owner = scope.owner;
|
||||||
scope['owner'] = 'team';
|
|
||||||
}
|
|
||||||
master['owner'] = scope['owner'];
|
|
||||||
|
|
||||||
for (var i=0; i < scope.credential_kind_options.length; i++) {
|
for (i = 0; i < scope.credential_kind_options.length; i++) {
|
||||||
if (scope.credential_kind_options[i].value == data.kind) {
|
if (scope.credential_kind_options[i].value === data.kind) {
|
||||||
scope.kind = scope.credential_kind_options[i];
|
scope.kind = scope.credential_kind_options[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
master['kind'] = scope['kind'];
|
master.kind = scope.kind;
|
||||||
|
|
||||||
switch (data.kind) {
|
switch (data.kind) {
|
||||||
case 'aws':
|
case 'aws':
|
||||||
scope['access_key'] = data.username;
|
scope.access_key = data.username;
|
||||||
scope['secret_key'] = data.password;
|
scope.secret_key = data.password;
|
||||||
master['access_key'] = scope['access_key'];
|
master.access_key = scope.access_key;
|
||||||
master['secret_key'] = scope['secret_key'];
|
master.secret_key = scope.secret_key;
|
||||||
break;
|
break;
|
||||||
case 'ssh':
|
case 'ssh':
|
||||||
scope['ssh_password'] = data.password;
|
scope.ssh_password = data.password;
|
||||||
master['ssh_password'] = scope['ssh_password'];
|
master.ssh_password = scope.ssh_password;
|
||||||
break;
|
break;
|
||||||
case 'rax':
|
case 'rax':
|
||||||
scope['api_key'] = data['password'];
|
scope.api_key = data.password;
|
||||||
master['api_key'] = scope['api_key'];
|
master.api_key = scope.api_key;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.$emit('credentialLoaded');
|
scope.$emit('credentialLoaded');
|
||||||
})
|
})
|
||||||
.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 Credential: ' + $routeParams.id + '. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve Credential: ' + $routeParams.id + '. GET status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -406,20 +453,36 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
callback: 'choicesReadyCredential'
|
callback: 'choicesReadyCredential'
|
||||||
});
|
});
|
||||||
|
|
||||||
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() { generator.clearApiErrors(); FormSave({ scope: scope, mode: 'edit' }) };
|
scope.formSave = function () {
|
||||||
|
generator.clearApiErrors();
|
||||||
|
FormSave({
|
||||||
|
scope: scope,
|
||||||
|
mode: 'edit'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Handle Owner change
|
// Handle Owner change
|
||||||
scope.ownerChange = function () {
|
scope.ownerChange = function () {
|
||||||
OwnerChange({ scope: scope });
|
OwnerChange({
|
||||||
}
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Handle Kind change
|
// Handle Kind change
|
||||||
scope.kindChange = function () {
|
scope.kindChange = function () {
|
||||||
KindChange({ scope: scope, form: form, reset: true });
|
KindChange({
|
||||||
}
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
reset: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
@@ -428,8 +491,14 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
scope[fld] = master[fld];
|
scope[fld] = master[fld];
|
||||||
}
|
}
|
||||||
setAskCheckboxes();
|
setAskCheckboxes();
|
||||||
KindChange({ scope: scope, form: form, reset: false });
|
KindChange({
|
||||||
OwnerChange({ scope: scope });
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
reset: false
|
||||||
|
});
|
||||||
|
OwnerChange({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Related set: Add button
|
// Related set: Add button
|
||||||
@@ -439,7 +508,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 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;
|
||||||
$location.path('/' + base + '/' + $routeParams.id + '/' + set + '/' + id);
|
$location.path('/' + base + '/' + $routeParams.id + '/' + set + '/' + id);
|
||||||
};
|
};
|
||||||
@@ -451,31 +520,37 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
var action = function () {
|
var action = function () {
|
||||||
var url = defaultUrl + id + '/' + set + '/';
|
var url = defaultUrl + id + '/' + set + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
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. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
// 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);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Respond to 'Ask at runtime?' checkbox
|
// Respond to 'Ask at runtime?' checkbox
|
||||||
scope.ask = function (fld, associated) {
|
scope.ask = function (fld, associated) {
|
||||||
@@ -484,27 +559,25 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
scope[fld] = 'ASK';
|
scope[fld] = 'ASK';
|
||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$("#" + fld + "-clear-btn").removeAttr("disabled");
|
$("#" + fld + "-clear-btn").removeAttr("disabled");
|
||||||
scope[fld] = '';
|
scope[fld] = '';
|
||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.clear = function (fld, associated) {
|
scope.clear = function (fld, associated) {
|
||||||
scope[fld] = '';
|
scope[fld] = '';
|
||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
scope[form.name + '_form'].$setDirty();
|
scope[form.name + '_form'].$setDirty();
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CredentialsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm',
|
CredentialsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices',
|
'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices', 'KindChange', 'UserList', 'TeamList', 'LookUpInit',
|
||||||
'KindChange', 'UserList', 'TeamList', 'LookUpInit', 'Empty', 'OwnerChange', 'FormSave', 'Stream',
|
'Empty', 'OwnerChange', 'FormSave', 'Stream', 'Wait'
|
||||||
'Wait'];
|
];
|
||||||
|
|
||||||
@@ -13,12 +13,13 @@
|
|||||||
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",
|
||||||
@@ -30,16 +31,27 @@ function Home ($scope, $compile, $routeParams, $rootScope, $location, Wait, Obje
|
|||||||
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');
|
||||||
}
|
}
|
||||||
@@ -50,7 +62,7 @@ function Home ($scope, $compile, $routeParams, $rootScope, $location, Wait, Obje
|
|||||||
$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');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -59,35 +71,55 @@ function Home ($scope, $compile, $routeParams, $rootScope, $location, Wait, Obje
|
|||||||
$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,
|
||||||
@@ -97,21 +129,20 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
|
|||||||
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
|
||||||
@@ -124,101 +155,119 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
|
|||||||
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_class = stat['class'];
|
||||||
scope['home_groups'][i].status_tooltip = stat['tooltip'],
|
scope.home_groups[i].status_tooltip = stat.tooltip;
|
||||||
scope['home_groups'][i].launch_tooltip = stat['launch_tip'],
|
scope.home_groups[i].launch_tooltip = stat.launch_tip;
|
||||||
scope['home_groups'][i].launch_class = stat['launch_class'],
|
scope.home_groups[i].launch_class = stat.launch_class;
|
||||||
scope['home_groups'][i].hosts_status_tip = hosts_status['tooltip'],
|
scope.home_groups[i].hosts_status_tip = hosts_status.tooltip;
|
||||||
scope['home_groups'][i].show_failures = hosts_status['failures'],
|
scope.home_groups[i].show_failures = hosts_status.failures;
|
||||||
scope['home_groups'][i].hosts_status_class = hosts_status['class'],
|
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
|
||||||
@@ -227,16 +276,14 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
|
|||||||
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,
|
||||||
@@ -246,16 +293,18 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
|
|||||||
group_id: group.id
|
group_id: group.id
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source +
|
msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source + ' POST returned status: ' + status
|
||||||
' POST returned status: ' + status });
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.refresh = function() { scope.search(list.iterator, null, false, true); }
|
scope.refresh = function () {
|
||||||
|
scope.search(list.iterator, null, false, true);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,69 +320,101 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process
|
|||||||
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
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,53 +11,70 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function InventoriesList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, InventoryList,
|
function InventoriesList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, InventoryList,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors,
|
||||||
ClearScope, ProcessErrors, GetBasePath, Wait, Stream, EditInventoryProperties)
|
GetBasePath, Wait, Stream, EditInventoryProperties) {
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate');
|
||||||
//scope.
|
|
||||||
var list = InventoryList;
|
var list = InventoryList,
|
||||||
var defaultUrl = GetBasePath('inventory');
|
defaultUrl = GetBasePath('inventory'),
|
||||||
var view = GenerateList;
|
view = GenerateList,
|
||||||
var paths = $location.path().replace(/^\//,'').split('/');
|
paths = $location.path().replace(/^\//, '').split('/'),
|
||||||
var mode = (paths[0] == 'inventories') ? 'edit' : 'select'; // if base path 'users', we're here to add/edit users
|
mode = (paths[0] === 'inventories') ? 'edit' : 'select', // if base path 'users', we're here to add/edit users
|
||||||
var scope = view.inject(InventoryList, { mode: mode }); // Inject our view
|
scope = view.inject(InventoryList, { mode: mode });
|
||||||
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'inventories', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'inventories',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
if ($routeParams['name']) {
|
if ($routeParams.name) {
|
||||||
scope[InventoryList.iterator + 'InputDisable'] = false;
|
scope[InventoryList.iterator + 'InputDisable'] = false;
|
||||||
scope[InventoryList.iterator + 'SearchValue'] = $routeParams['name'];
|
scope[InventoryList.iterator + 'SearchValue'] = $routeParams.name;
|
||||||
scope[InventoryList.iterator + 'SearchField'] = 'name';
|
scope[InventoryList.iterator + 'SearchField'] = 'name';
|
||||||
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['name'].label;
|
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.name.label;
|
||||||
scope[InventoryList.iterator + 'SearchSelectValue'] = null;
|
scope[InventoryList.iterator + 'SearchSelectValue'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['has_active_failures']) {
|
if ($routeParams.has_active_failures) {
|
||||||
scope[InventoryList.iterator + 'InputDisable'] = true;
|
scope[InventoryList.iterator + 'InputDisable'] = true;
|
||||||
scope[InventoryList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
scope[InventoryList.iterator + 'SearchValue'] = $routeParams.has_active_failures;
|
||||||
scope[InventoryList.iterator + 'SearchField'] = 'has_active_failures';
|
scope[InventoryList.iterator + 'SearchField'] = 'has_active_failures';
|
||||||
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['has_active_failures'].label;
|
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.has_active_failures.label;
|
||||||
scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams.has_active_failures === 'true') ? {
|
||||||
|
value: 1
|
||||||
|
} : {
|
||||||
|
value: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['has_inventory_sources']) {
|
if ($routeParams.has_inventory_sources) {
|
||||||
scope[InventoryList.iterator + 'InputDisable'] = true;
|
scope[InventoryList.iterator + 'InputDisable'] = true;
|
||||||
scope[InventoryList.iterator + 'SearchValue'] = $routeParams['has_inventory_sources'];
|
scope[InventoryList.iterator + 'SearchValue'] = $routeParams.has_inventory_sources;
|
||||||
scope[InventoryList.iterator + 'SearchField'] = 'has_inventory_sources';
|
scope[InventoryList.iterator + 'SearchField'] = 'has_inventory_sources';
|
||||||
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['has_inventory_sources'].label;
|
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.has_inventory_sources.label;
|
||||||
scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams['has_inventory_sources'] == 'true') ? { value: 1 } : { value: 0 };
|
scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams.has_inventory_sources === 'true') ? {
|
||||||
|
value: 1
|
||||||
|
} : {
|
||||||
|
value: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['inventory_sources_with_failures']) {
|
if ($routeParams.inventory_sources_with_failures) {
|
||||||
// pass a value of true, however this field actually contains an integer value
|
// pass a value of true, however this field actually contains an integer value
|
||||||
scope[InventoryList.iterator + 'InputDisable'] = true;
|
scope[InventoryList.iterator + 'InputDisable'] = true;
|
||||||
scope[InventoryList.iterator + 'SearchValue'] = $routeParams['inventory_sources_with_failures'];
|
scope[InventoryList.iterator + 'SearchValue'] = $routeParams.inventory_sources_with_failures;
|
||||||
scope[InventoryList.iterator + 'SearchField'] = 'inventory_sources_with_failures';
|
scope[InventoryList.iterator + 'SearchField'] = 'inventory_sources_with_failures';
|
||||||
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['inventory_sources_with_failures'].label;
|
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields.inventory_sources_with_failures.label;
|
||||||
scope[InventoryList.iterator + 'SearchType'] = 'gtzero';
|
scope[InventoryList.iterator + 'SearchType'] = 'gtzero';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,18 +97,16 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
|
|
||||||
if (scope.inventories[i].hosts_with_active_failures > 0) {
|
if (scope.inventories[i].hosts_with_active_failures > 0) {
|
||||||
scope.inventories[i].failed_hosts_tip = scope.inventories[i].hosts_with_active_failures +
|
scope.inventories[i].failed_hosts_tip = scope.inventories[i].hosts_with_active_failures +
|
||||||
( (scope.inventories[i].hosts_with_active_failures == 1) ? ' host' : ' hosts' ) + ' with job failures. Click to view details.';
|
((scope.inventories[i].hosts_with_active_failures === 1) ? ' host' : ' hosts') + ' with job failures. Click to view details.';
|
||||||
scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
||||||
scope.inventories[i].failed_hosts_class = 'true';
|
scope.inventories[i].failed_hosts_class = 'true';
|
||||||
}
|
} else {
|
||||||
else {
|
if (scope.inventories[i].total_hosts === 0) {
|
||||||
if (scope.inventories[i].total_hosts == 0) {
|
|
||||||
// no hosts
|
// no hosts
|
||||||
scope.inventories[i].failed_hosts_tip = "No hosts defined. Click to add.";
|
scope.inventories[i].failed_hosts_tip = "No hosts defined. Click to add.";
|
||||||
scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
scope.inventories[i].failed_hosts_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
||||||
scope.inventories[i].failed_hosts_class = 'na';
|
scope.inventories[i].failed_hosts_class = 'na';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// many hosts with 0 failures
|
// many hosts with 0 failures
|
||||||
scope.inventories[i].failed_hosts_tip = scope.inventories[i].total_hosts +
|
scope.inventories[i].failed_hosts_tip = scope.inventories[i].total_hosts +
|
||||||
((scope.inventories[i].total_hosts > 1) ? ' hosts' : ' host') + " with no job failures. Click to view details.";
|
((scope.inventories[i].total_hosts > 1) ? ' hosts' : ' host') + " with no job failures. Click to view details.";
|
||||||
@@ -104,19 +119,17 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
scope.inventories[i].status = scope.inventories[i].inventory_sources_with_failures + ' / ' + scope.inventories[i].total_inventory_sources;
|
scope.inventories[i].status = scope.inventories[i].inventory_sources_with_failures + ' / ' + scope.inventories[i].total_inventory_sources;
|
||||||
if (scope.inventories[i].inventory_sources_with_failures > 0) {
|
if (scope.inventories[i].inventory_sources_with_failures > 0) {
|
||||||
scope.inventories[i].status_tip = scope.inventories[i].inventory_sources_with_failures + ' cloud ' +
|
scope.inventories[i].status_tip = scope.inventories[i].inventory_sources_with_failures + ' cloud ' +
|
||||||
( (scope.inventories[i].inventory_sources_with_failures == 1) ? 'source' : 'sources' ) +
|
((scope.inventories[i].inventory_sources_with_failures === 1) ? 'source' : 'sources') +
|
||||||
' with failures. Click to view details.';
|
' with failures. Click to view details.';
|
||||||
scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
||||||
scope.inventories[i].status_class = 'failed';
|
scope.inventories[i].status_class = 'failed';
|
||||||
}
|
} else {
|
||||||
else {
|
if (scope.inventories[i].total_inventory_sources === 0) {
|
||||||
if (scope.inventories[i].total_inventory_sources == 0) {
|
|
||||||
// no groups are reporting a source
|
// no groups are reporting a source
|
||||||
scope.inventories[i].status_tip = "Not synced with a cloud source. Click to edit.";
|
scope.inventories[i].status_tip = "Not synced with a cloud source. Click to edit.";
|
||||||
scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
scope.inventories[i].status_link = '/#/inventories/' + scope.inventories[i].id + '/';
|
||||||
scope.inventories[i].status_class = 'na';
|
scope.inventories[i].status_class = 'na';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// many hosts with 0 failures
|
// many hosts with 0 failures
|
||||||
scope.inventories[i].status_tip = scope.inventories[i].total_inventory_sources +
|
scope.inventories[i].status_tip = scope.inventories[i].total_inventory_sources +
|
||||||
' cloud ' + ((scope.inventories[i].total_inventory_sources > 1) ? 'sources' : 'source') +
|
' cloud ' + ((scope.inventories[i].total_inventory_sources > 1) ? 'sources' : 'source') +
|
||||||
@@ -137,19 +150,26 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.editInventoryProperties = function (inventory_id) {
|
scope.editInventoryProperties = function (inventory_id) {
|
||||||
EditInventoryProperties({ scope: scope, inventory_id: inventory_id });
|
EditInventoryProperties({
|
||||||
}
|
scope: scope,
|
||||||
|
inventory_id: inventory_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.addInventory = function () {
|
scope.addInventory = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editInventory = function (id) {
|
scope.editInventory = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteInventory = function (id, name) {
|
scope.deleteInventory = function (id, name) {
|
||||||
|
|
||||||
@@ -161,64 +181,71 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.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: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.lookupOrganization = function (organization_id) {
|
scope.lookupOrganization = function (organization_id) {
|
||||||
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
|
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
return data.name;
|
return data.name;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status
|
// Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status
|
||||||
scope.viewJobs = function (id) {
|
scope.viewJobs = function (id) {
|
||||||
$location.url('/jobs/?inventory__int=' + id);
|
$location.url('/jobs/?inventory__int=' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.viewFailedJobs = function (id) {
|
scope.viewFailedJobs = function (id) {
|
||||||
$location.url('/jobs/?inventory__int=' + id + '&status=failed');
|
$location.url('/jobs/?inventory__int=' + id + '&status=failed');
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoriesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
|
InventoriesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
||||||
'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties'];
|
'GetBasePath', 'Wait', 'Stream', 'EditInventoryProperties'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm,
|
function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GenerateList, OrganizationList, SearchInit, PaginateInit, LookUpInit, GetBasePath,
|
GenerateList, OrganizationList, SearchInit, PaginateInit, LookUpInit, GetBasePath,
|
||||||
ParseTypeChange, Wait)
|
ParseTypeChange, 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('inventory');
|
var defaultUrl = GetBasePath('inventory'),
|
||||||
var form = InventoryForm;
|
form = InventoryForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
|
scope;
|
||||||
|
|
||||||
form.well = true,
|
form.well = true;
|
||||||
form.formLabelSize = null;
|
form.formLabelSize = null;
|
||||||
form.formFieldSize = null;
|
form.formFieldSize = null;
|
||||||
|
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
scope = generator.inject(form, {
|
||||||
|
mode: 'add',
|
||||||
|
related: false
|
||||||
|
});
|
||||||
scope.inventoryParseType = 'yaml';
|
scope.inventoryParseType = 'yaml';
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
@@ -238,12 +265,13 @@ function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
try {
|
try {
|
||||||
|
var fld, json_data, data;
|
||||||
|
|
||||||
// Make sure we have valid variable data
|
// Make sure we have valid variable data
|
||||||
if (scope.inventoryParseType == 'json') {
|
if (scope.inventoryParseType === 'json') {
|
||||||
var json_data = JSON.parse(scope.inventory_variables); //make sure JSON parses
|
json_data = JSON.parse(scope.inventory_variables); //make sure JSON parses
|
||||||
}
|
} else {
|
||||||
else {
|
json_data = jsyaml.load(scope.inventory_variables); //parse yaml
|
||||||
var json_data = jsyaml.load(scope.inventory_variables); //parse yaml
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our JSON is actually an object
|
// Make sure our JSON is actually an object
|
||||||
@@ -251,13 +279,12 @@ function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
throw "failed to return an object!";
|
throw "failed to return an object!";
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = {}
|
data = {};
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (fld != 'inventory_variables') {
|
if (fld !== 'inventory_variables') {
|
||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,33 +292,34 @@ function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var inventory_id = data.id;
|
var inventory_id = data.id;
|
||||||
if (scope.inventory_variables) {
|
if (scope.inventory_variables) {
|
||||||
Rest.setUrl(data.related.variable_data);
|
Rest.setUrl(data.related.variable_data);
|
||||||
Rest.put(json_data)
|
Rest.put(json_data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$location.path('/inventories/' + inventory_id + '/');
|
$location.path('/inventories/' + inventory_id + '/');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
{ hdr: 'Error!', msg: 'Failed to add inventory varaibles. PUT returned status: ' + status });
|
msg: 'Failed to add inventory varaibles. PUT returned status: ' + status
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else {
|
} else {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$location.path('/inventories/' + inventory_id + '/');
|
$location.path('/inventories/' + inventory_id + '/');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new inventory. Post returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new inventory. Post returned status: ' + status
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
catch(err) {
|
} catch (err) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert("Error", "Error parsing inventory variables. Parser returned: " + err);
|
Alert("Error", "Error parsing inventory variables. Parser returned: " + err);
|
||||||
}
|
}
|
||||||
@@ -317,31 +345,38 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find,
|
Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find,
|
||||||
HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost,
|
HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost,
|
||||||
Stream, GetBasePath, ShowJobSummary, ApplyEllipsis, WatchInventoryWindowResize, HelpDialog, InventoryGroupsHelp,
|
Stream, GetBasePath, ShowJobSummary, ApplyEllipsis, WatchInventoryWindowResize, HelpDialog, InventoryGroupsHelp,
|
||||||
Store)
|
Store) {
|
||||||
{
|
|
||||||
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 = InventoryGroups;
|
list = InventoryGroups;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
|
|
||||||
$scope.inventory_id = $routeParams.inventory_id;
|
$scope.inventory_id = $routeParams.inventory_id;
|
||||||
|
|
||||||
LoadBreadCrumbs({ path: $location.path(), title: '{{ inventory_name }}' });
|
LoadBreadCrumbs({
|
||||||
|
path: $location.path(),
|
||||||
|
title: '{{ inventory_name }}'
|
||||||
|
});
|
||||||
|
|
||||||
// After the tree data loads for the first time, generate the groups and hosts lists
|
// After the tree data loads for the first time, generate the groups and hosts lists
|
||||||
if ($scope.removeGroupTreeLoaded) {
|
if ($scope.removeGroupTreeLoaded) {
|
||||||
$scope.removeGroupTreeLoaded();
|
$scope.removeGroupTreeLoaded();
|
||||||
}
|
}
|
||||||
$scope.removeGroupTreeLoaded = $scope.$on('GroupTreeLoaded', function(e, inventory_name, groups) {
|
$scope.removeGroupTreeLoaded = $scope.$on('GroupTreeLoaded', function (event, inventory_name, groups) {
|
||||||
// Add breadcrumbs
|
// Add breadcrumbs
|
||||||
var e = angular.element(document.getElementById('breadcrumbs'));
|
var e, inventoryAutoHelp;
|
||||||
|
e = angular.element(document.getElementById('breadcrumbs'));
|
||||||
e.html(Breadcrumbs({ list: list, mode: 'edit' }));
|
e.html(Breadcrumbs({ list: list, mode: 'edit' }));
|
||||||
$compile(e)($scope);
|
$compile(e)($scope);
|
||||||
|
|
||||||
// Add groups view
|
// Add groups view
|
||||||
generator.inject(list, { mode: 'edit', id: 'groups-container', breadCrumbs: false, searchSize: 'col-lg-5 col-md-5 col-sm-5' });
|
generator.inject(list, {
|
||||||
|
mode: 'edit',
|
||||||
|
id: 'groups-container',
|
||||||
|
breadCrumbs: false,
|
||||||
|
searchSize: 'col-lg-5 col-md-5 col-sm-5'
|
||||||
|
});
|
||||||
$scope.groups = groups;
|
$scope.groups = groups;
|
||||||
$scope.inventory_name = inventory_name;
|
$scope.inventory_name = inventory_name;
|
||||||
|
|
||||||
@@ -352,35 +387,44 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
$scope.groups[0].selected_class = 'selected';
|
$scope.groups[0].selected_class = 'selected';
|
||||||
$scope.groups[0].active_class = 'active-row';
|
$scope.groups[0].active_class = 'active-row';
|
||||||
$scope.selected_group_name = $scope.groups[0].name;
|
$scope.selected_group_name = $scope.groups[0].name;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.selected_tree_id = null;
|
$scope.selected_tree_id = null;
|
||||||
$scope.selected_group_id = null;
|
$scope.selected_group_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add hosts view
|
// Add hosts view
|
||||||
$scope.show_failures = false;
|
$scope.show_failures = false;
|
||||||
InjectHosts({ scope: $scope, inventory_id: $scope.inventory_id, tree_id: $scope.selected_tree_id, group_id: $scope.selected_group_id });
|
InjectHosts({
|
||||||
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id,
|
||||||
|
tree_id: $scope.selected_tree_id,
|
||||||
|
group_id: $scope.selected_group_id
|
||||||
|
});
|
||||||
|
|
||||||
// As the window shrinks and expands, apply ellipsis
|
// As the window shrinks and expands, apply ellipsis
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
// Hack to keep group name from slipping to a new line
|
// Hack to keep group name from slipping to a new line
|
||||||
$('#groups_table .name-column').each(function () {
|
$('#groups_table .name-column').each(function () {
|
||||||
var td_width = $(this).width();
|
var td_width, level_width, level_padding, level, pct;
|
||||||
var level_width = $(this).find('.level').width();
|
td_width = $(this).width();
|
||||||
var level_padding = parseInt($(this).find('.level').css('padding-left').replace(/px/,''));
|
level_width = $(this).find('.level').width();
|
||||||
var level = level_width + level_padding;
|
level_padding = parseInt($(this).find('.level').css('padding-left').replace(/px/, ''));
|
||||||
var pct = ( 100 - Math.ceil((level / td_width)*100) ) + '%';
|
level = level_width + level_padding;
|
||||||
$(this).find('.group-name').css({ width: pct });
|
pct = (100 - Math.ceil((level / td_width) * 100)) + '%';
|
||||||
|
$(this).find('.group-name').css({
|
||||||
|
width: pct
|
||||||
|
});
|
||||||
});
|
});
|
||||||
ApplyEllipsis('#groups_table .group-name a');
|
ApplyEllipsis('#groups_table .group-name a');
|
||||||
ApplyEllipsis('#hosts_table .host-name a');
|
ApplyEllipsis('#hosts_table .host-name a');
|
||||||
}, 2500); //give the window time to display
|
}, 2500); //give the window time to display
|
||||||
WatchInventoryWindowResize();
|
WatchInventoryWindowResize();
|
||||||
|
|
||||||
var inventoryAutoHelp = Store('inventoryAutoHelp');
|
inventoryAutoHelp = Store('inventoryAutoHelp');
|
||||||
if (inventoryAutoHelp !== 'off' && $scope.autoShowGroupHelp) {
|
if (inventoryAutoHelp !== 'off' && $scope.autoShowGroupHelp) {
|
||||||
$scope.showGroupHelp({ autoShow: true });
|
$scope.showGroupHelp({
|
||||||
|
autoShow: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -390,9 +434,11 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
if ($scope.removeGroupTreeRefreshed) {
|
if ($scope.removeGroupTreeRefreshed) {
|
||||||
$scope.removeGroupTreeRefreshed();
|
$scope.removeGroupTreeRefreshed();
|
||||||
}
|
}
|
||||||
$scope.removeGroupTreeRefreshed = $scope.$on('GroupTreeRefreshed', function(e, inventory_name, groups) {
|
$scope.removeGroupTreeRefreshed = $scope.$on('GroupTreeRefreshed', function () {
|
||||||
// Reapply ellipsis to groups
|
// Reapply ellipsis to groups
|
||||||
setTimeout(function() { ApplyEllipsis('#groups_table .group-name a'); }, 2500);
|
setTimeout(function () {
|
||||||
|
ApplyEllipsis('#groups_table .group-name a');
|
||||||
|
}, 2500);
|
||||||
// Reselect the preveiously selected group node, causing host view to refresh.
|
// Reselect the preveiously selected group node, causing host view to refresh.
|
||||||
$scope.showHosts($scope.selected_tree_id, $scope.selected_group_id, false);
|
$scope.showHosts($scope.selected_tree_id, $scope.selected_group_id, false);
|
||||||
});
|
});
|
||||||
@@ -401,10 +447,14 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
if ($scope.removeGroupDeleteCompleted) {
|
if ($scope.removeGroupDeleteCompleted) {
|
||||||
$scope.removeGroupDeleteCompleted();
|
$scope.removeGroupDeleteCompleted();
|
||||||
}
|
}
|
||||||
$scope.removeGroupDeleteCompleted = $scope.$on('GroupDeleteCompleted', function(e) {
|
$scope.removeGroupDeleteCompleted = $scope.$on('GroupDeleteCompleted', function () {
|
||||||
$scope.selected_tree_id = 1;
|
$scope.selected_tree_id = 1;
|
||||||
$scope.selected_group_id = null;
|
$scope.selected_group_id = null;
|
||||||
BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: true });
|
BuildTree({
|
||||||
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id,
|
||||||
|
refresh: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Respond to a group drag-n-drop
|
// Respond to a group drag-n-drop
|
||||||
@@ -412,7 +462,11 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
$scope.removeCopyMoveGroup();
|
$scope.removeCopyMoveGroup();
|
||||||
}
|
}
|
||||||
$scope.removeCopyMoveGroup = $scope.$on('CopyMoveGroup', function (e, inbound_tree_id, target_tree_id) {
|
$scope.removeCopyMoveGroup = $scope.$on('CopyMoveGroup', function (e, inbound_tree_id, target_tree_id) {
|
||||||
CopyMoveGroup({ scope: $scope, target_tree_id: target_tree_id, inbound_tree_id: inbound_tree_id });
|
CopyMoveGroup({
|
||||||
|
scope: $scope,
|
||||||
|
target_tree_id: target_tree_id,
|
||||||
|
inbound_tree_id: inbound_tree_id
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Respond to a host drag-n-drop
|
// Respond to a host drag-n-drop
|
||||||
@@ -420,7 +474,11 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
$scope.removeCopyMoveHost();
|
$scope.removeCopyMoveHost();
|
||||||
}
|
}
|
||||||
$scope.removeCopyMoveHost = $scope.$on('CopyMoveHost', function (e, target_tree_id, host_id) {
|
$scope.removeCopyMoveHost = $scope.$on('CopyMoveHost', function (e, target_tree_id, host_id) {
|
||||||
CopyMoveHost({ scope: $scope, target_tree_id: target_tree_id, host_id: host_id });
|
CopyMoveHost({
|
||||||
|
scope: $scope,
|
||||||
|
target_tree_id: target_tree_id,
|
||||||
|
host_id: host_id
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.showHosts = function (tree_id, group_id, show_failures) {
|
$scope.showHosts = function (tree_id, group_id, show_failures) {
|
||||||
@@ -432,30 +490,43 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
$scope.hosts = [];
|
$scope.hosts = [];
|
||||||
$scope.show_failures = show_failures; // turn on failed hosts filter in hosts view
|
$scope.show_failures = show_failures; // turn on failed hosts filter in hosts view
|
||||||
for (var i = 0; i < $scope.groups.length; i++) {
|
for (var i = 0; i < $scope.groups.length; i++) {
|
||||||
if ($scope.groups[i].id == tree_id) {
|
if ($scope.groups[i].id === tree_id) {
|
||||||
$scope.groups[i].selected_class = 'selected';
|
$scope.groups[i].selected_class = 'selected';
|
||||||
$scope.groups[i].active_class = 'active-row';
|
$scope.groups[i].active_class = 'active-row';
|
||||||
$scope.selected_group_name = $scope.groups[i].name;
|
$scope.selected_group_name = $scope.groups[i].name;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.groups[i].selected_class = '';
|
$scope.groups[i].selected_class = '';
|
||||||
$scope.groups[i].active_class = '';
|
$scope.groups[i].active_class = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HostsReload({ scope: $scope, group_id: group_id, tree_id: tree_id, inventory_id: $scope.inventory_id });
|
HostsReload({
|
||||||
}
|
scope: $scope,
|
||||||
else {
|
group_id: group_id,
|
||||||
|
tree_id: tree_id,
|
||||||
|
inventory_id: $scope.inventory_id
|
||||||
|
});
|
||||||
|
} else {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.createGroup = function () {
|
$scope.createGroup = function () {
|
||||||
GroupsAdd({ scope: $scope, inventory_id: $scope.inventory_id, group_id: $scope.selected_group_id });
|
GroupsAdd({
|
||||||
}
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id,
|
||||||
|
group_id: $scope.selected_group_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.editGroup = function (group_id, tree_id) {
|
$scope.editGroup = function (group_id, tree_id) {
|
||||||
GroupsEdit({ scope: $scope, inventory_id: $scope.inventory_id, group_id: group_id, tree_id: tree_id, groups_reload: true });
|
GroupsEdit({
|
||||||
}
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id,
|
||||||
|
group_id: group_id,
|
||||||
|
tree_id: tree_id,
|
||||||
|
groups_reload: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Launch inventory sync
|
// Launch inventory sync
|
||||||
$scope.updateGroup = function (id) {
|
$scope.updateGroup = function (id) {
|
||||||
@@ -463,16 +534,14 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
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.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,
|
||||||
@@ -482,24 +551,30 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
group_id: group.group_id
|
group_id: group.group_id
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' +
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + group.related.inventory_source +
|
group.related.inventory_source + ' POST returned status: ' + status });
|
||||||
' POST returned status: ' + status });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.cancelUpdate = function (tree_id) {
|
$scope.cancelUpdate = function (tree_id) {
|
||||||
GroupsCancelUpdate({ scope: $scope, tree_id: tree_id });
|
GroupsCancelUpdate({
|
||||||
}
|
scope: $scope,
|
||||||
|
tree_id: tree_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.toggle = function (tree_id) {
|
$scope.toggle = function (tree_id) {
|
||||||
// Expand/collapse nodes
|
// Expand/collapse nodes
|
||||||
ToggleChildren({ scope: $scope, list: list, id: tree_id });
|
ToggleChildren({
|
||||||
}
|
scope: $scope,
|
||||||
|
list: list,
|
||||||
|
id: tree_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.refreshGroups = function (tree_id, group_id) {
|
$scope.refreshGroups = function (tree_id, group_id) {
|
||||||
// Refresh the tree data when refresh button cicked
|
// Refresh the tree data when refresh button cicked
|
||||||
@@ -507,80 +582,129 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
$scope.selected_tree_id = tree_id;
|
$scope.selected_tree_id = tree_id;
|
||||||
$scope.selected_group_id = group_id;
|
$scope.selected_group_id = group_id;
|
||||||
}
|
}
|
||||||
BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: true });
|
BuildTree({
|
||||||
}
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id,
|
||||||
|
refresh: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.viewUpdateStatus = function (tree_id, group_id) {
|
$scope.viewUpdateStatus = function (tree_id, group_id) {
|
||||||
ViewUpdateStatus({ scope: $scope, tree_id: tree_id, group_id: group_id });
|
ViewUpdateStatus({
|
||||||
}
|
scope: $scope,
|
||||||
|
tree_id: tree_id,
|
||||||
|
group_id: group_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.deleteGroup = function (tree_id, group_id) {
|
$scope.deleteGroup = function (tree_id, group_id) {
|
||||||
GroupsDelete({ scope: $scope, tree_id: tree_id, group_id: group_id, inventory_id: $scope.inventory_id });
|
GroupsDelete({
|
||||||
}
|
scope: $scope,
|
||||||
|
tree_id: tree_id,
|
||||||
|
group_id: group_id,
|
||||||
|
inventory_id: $scope.inventory_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.createHost = function () {
|
$scope.createHost = function () {
|
||||||
HostsCreate({ scope: $scope });
|
HostsCreate({
|
||||||
}
|
scope: $scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.editInventoryProperties = function () {
|
$scope.editInventoryProperties = function () {
|
||||||
EditInventoryProperties({ scope: $scope, inventory_id: $scope.inventory_id });
|
EditInventoryProperties({
|
||||||
}
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.editHost = function (host_id) {
|
$scope.editHost = function (host_id) {
|
||||||
HostsEdit({ scope: $scope, host_id: host_id, inventory_id: $scope.inventory_id });
|
HostsEdit({
|
||||||
}
|
scope: $scope,
|
||||||
|
host_id: host_id,
|
||||||
|
inventory_id: $scope.inventory_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.deleteHost = function (host_id, host_name) {
|
$scope.deleteHost = function (host_id, host_name) {
|
||||||
HostsDelete({ scope: $scope, host_id: host_id, host_name: host_name });
|
HostsDelete({
|
||||||
}
|
scope: $scope,
|
||||||
|
host_id: host_id,
|
||||||
|
host_name: host_name
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.toggleHostEnabled = function (host_id, external_source) {
|
$scope.toggleHostEnabled = function (host_id, external_source) {
|
||||||
ToggleHostEnabled({ scope: $scope, host_id: host_id, external_source: external_source });
|
ToggleHostEnabled({
|
||||||
}
|
scope: $scope,
|
||||||
|
host_id: host_id,
|
||||||
|
external_source: external_source
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.showGroupActivity = function () {
|
$scope.showGroupActivity = function () {
|
||||||
var url, title, group;
|
var url, title, group;
|
||||||
if ($scope.selected_group_id) {
|
if ($scope.selected_group_id) {
|
||||||
group = Find({ list: $scope.groups, key: 'id', val: $scope.selected_tree_id });
|
group = Find({
|
||||||
|
list: $scope.groups,
|
||||||
|
key: 'id',
|
||||||
|
val: $scope.selected_tree_id
|
||||||
|
});
|
||||||
url = GetBasePath('activity_stream') + '?group__id=' + $scope.selected_group_id;
|
url = GetBasePath('activity_stream') + '?group__id=' + $scope.selected_group_id;
|
||||||
title = 'Showing all activities for group ' + group.name;
|
title = 'Showing all activities for group ' + group.name;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
title = 'Showing all activities for all ' + $scope.inventory_name + ' groups';
|
title = 'Showing all activities for all ' + $scope.inventory_name + ' groups';
|
||||||
url = GetBasePath('activity_stream') + '?group__inventory__id=' + $scope.inventory_id;
|
url = GetBasePath('activity_stream') + '?group__inventory__id=' + $scope.inventory_id;
|
||||||
}
|
}
|
||||||
Stream({ scope: $scope, inventory_name: $scope.inventory_name, url: url, title: title });
|
Stream({
|
||||||
}
|
scope: $scope,
|
||||||
|
inventory_name: $scope.inventory_name,
|
||||||
|
url: url,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.showHostActivity = function () {
|
$scope.showHostActivity = function () {
|
||||||
var url, title;
|
var url, title;
|
||||||
title = 'Showing all activities for all ' + $scope.inventory_name + ' hosts';
|
title = 'Showing all activities for all ' + $scope.inventory_name + ' hosts';
|
||||||
url = GetBasePath('activity_stream') + '?host__inventory__id=' + $scope.inventory_id;
|
url = GetBasePath('activity_stream') + '?host__inventory__id=' + $scope.inventory_id;
|
||||||
Stream({ scope: $scope, inventory_name: $scope.inventory_name, url: url, title: title });
|
Stream({
|
||||||
}
|
scope: $scope,
|
||||||
|
inventory_name: $scope.inventory_name,
|
||||||
|
url: url,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.showJobSummary = function (job_id) {
|
$scope.showJobSummary = function (job_id) {
|
||||||
ShowJobSummary({ job_id: job_id });
|
ShowJobSummary({
|
||||||
}
|
job_id: job_id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.showGroupHelp = function (params) {
|
$scope.showGroupHelp = function (params) {
|
||||||
var opts = { defn: InventoryGroupsHelp };
|
var opts = {
|
||||||
|
defn: InventoryGroupsHelp
|
||||||
|
};
|
||||||
if (params) {
|
if (params) {
|
||||||
opts.autoShow = params.autoShow || false;
|
opts.autoShow = params.autoShow || false;
|
||||||
}
|
}
|
||||||
HelpDialog(opts);
|
HelpDialog(opts);
|
||||||
}
|
};
|
||||||
|
|
||||||
//Load tree data for the first time
|
//Load tree data for the first time
|
||||||
BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: false });
|
BuildTree({
|
||||||
|
scope: $scope,
|
||||||
|
inventory_id: $scope.inventory_id,
|
||||||
|
refresh: false
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoriesEdit.$inject = ['$scope', '$location', '$routeParams', '$compile', 'GenerateList', 'ClearScope', 'InventoryGroups', 'InventoryHosts',
|
InventoriesEdit.$inject = ['$scope', '$location', '$routeParams', '$compile', 'GenerateList', 'ClearScope', 'InventoryGroups', 'InventoryHosts',
|
||||||
'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete',
|
'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete', 'Breadcrumbs',
|
||||||
'Breadcrumbs', 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren',
|
'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren', 'ViewUpdateStatus', 'GroupsCancelUpdate',
|
||||||
'ViewUpdateStatus', 'GroupsCancelUpdate', 'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit',
|
'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit', 'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost',
|
||||||
'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost', 'Stream', 'GetBasePath', 'ShowJobSummary',
|
'Stream', 'GetBasePath', 'ShowJobSummary', 'ApplyEllipsis', 'WatchInventoryWindowResize', 'HelpDialog', 'InventoryGroupsHelp', 'Store'
|
||||||
'ApplyEllipsis', 'WatchInventoryWindowResize', 'HelpDialog', 'InventoryGroupsHelp', 'Store'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -10,21 +10,19 @@
|
|||||||
|
|
||||||
'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 = [];
|
||||||
@@ -40,19 +38,21 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
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) {
|
||||||
|
if (typeof eventData.res === 'string') {
|
||||||
|
n = eventData.res.match(/\n/g);
|
||||||
rows = (n) ? n.length : 1;
|
rows = (n) ? n.length : 1;
|
||||||
rows = (rows > 10) ? 10 : rows;
|
rows = (rows > 10) ? 10 : rows;
|
||||||
found = true;
|
found = true;
|
||||||
@@ -60,10 +60,9 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
html += "<label>Traceback:</label>\n";
|
html += "<label>Traceback:</label>\n";
|
||||||
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res + "</textarea>\n";
|
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res + "</textarea>\n";
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
} else {
|
||||||
else {
|
for (fld in eventData.res) {
|
||||||
for (var fld in eventData.res) {
|
if ((fld === 'msg' || fld === 'stdout' || fld === 'stderr') &&
|
||||||
if ( (fld == 'msg' || fld == 'stdout' || fld == 'stderr') &&
|
|
||||||
(eventData.res[fld] !== null && eventData.res[fld] !== '')) {
|
(eventData.res[fld] !== null && eventData.res[fld] !== '')) {
|
||||||
html += "<div class=\"form-group\">\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "<label>";
|
html += "<label>";
|
||||||
@@ -77,17 +76,17 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
html += "</label>\n";
|
html += "</label>\n";
|
||||||
n = eventData['res'][fld].match(/\n/g);
|
n = eventData.res[fld].match(/\n/g);
|
||||||
rows = (n) ? n.length : 1;
|
rows = (n) ? n.length : 1;
|
||||||
rows = (rows > 10) ? 10 : rows;
|
rows = (rows > 10) ? 10 : rows;
|
||||||
html += "<textarea readonly class=\"form-control nowrap\" rows=\"" + rows + "\">" + eventData.res[fld] + "</textarea>\n";
|
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 === "results" && Array.isArray(eventData.res[fld]) && eventData.res[fld].length > 0) {
|
||||||
//html += "<textarea readonly class="
|
//html += "<textarea readonly class="
|
||||||
var txt = '';
|
txt = '';
|
||||||
for (var i=0; i < eventData.res[fld].length; i++) {
|
for (i = 0; i < eventData.res[fld].length; i++) {
|
||||||
txt += eventData.res[fld][i];
|
txt += eventData.res[fld][i];
|
||||||
}
|
}
|
||||||
n = txt.match(/\n/g);
|
n = txt.match(/\n/g);
|
||||||
@@ -101,7 +100,7 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fld == "rc" && eventData.res[fld] != '') {
|
if (fld === "rc" && eventData.res[fld] !== '') {
|
||||||
html += "<div class=\"form-group\">\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "<label>Return Code:</label>\n";
|
html += "<label>Return Code:</label>\n";
|
||||||
html += "<input type=\"text\" class=\"form-control nowrap mono-space\" value=\"" + eventData.res[fld] + "\" readonly >\n";
|
html += "<input type=\"text\" class=\"form-control nowrap mono-space\" value=\"" + eventData.res[fld] + "\" readonly >\n";
|
||||||
@@ -112,11 +111,10 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
}
|
}
|
||||||
html = (found) ? "<form class=\"event-form\">\n" + html + "</form>\n" : '';
|
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;
|
||||||
}
|
}
|
||||||
@@ -126,55 +124,45 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
}
|
}
|
||||||
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 {
|
||||||
else {
|
set[i].ngicon = 'fa fa-square-o node-no-toggle';
|
||||||
set[i]['ngicon'] = 'fa fa-square-o node-no-toggle';
|
|
||||||
set[i]['class'] = 'childNode';
|
set[i]['class'] = 'childNode';
|
||||||
set[i]['event_detail'] = formatJSON(set[i].event_data);
|
set[i].event_detail = formatJSON(set[i].event_data);
|
||||||
}
|
}
|
||||||
set[i]['show'] = true;
|
set[i].show = true;
|
||||||
set[i]['spaces'] = set[i].event_level * 24;
|
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 {
|
||||||
else {
|
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred. Click to view details";
|
scope.jobevents[i].statusBadgeToolTip = "A failure occurred. Click to view details";
|
||||||
}
|
}
|
||||||
}
|
} else if (scope.jobevents[i].changed) {
|
||||||
else if (scope.jobevents[i].changed) {
|
|
||||||
scope.jobevents[i].status = 'changed';
|
scope.jobevents[i].status = 'changed';
|
||||||
if (i == set.length - 1) {
|
if (i === set.length - 1) {
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed durring one or more playbook tasks.";
|
scope.jobevents[i].statusBadgeToolTip = "A change was completed 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 change was completed by one or more children of this event.";
|
scope.jobevents[i].statusBadgeToolTip = "A change was completed by one or more children of this event.";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed. Click to view details";
|
scope.jobevents[i].statusBadgeToolTip = "A change was completed. Click to view details";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.jobevents[i].status = 'success';
|
scope.jobevents[i].status = 'success';
|
||||||
if (i == set.length - 1) {
|
if (i === set.length - 1) {
|
||||||
scope.jobevents[i].statusBadgeToolTip = "All playbook tasks completed successfully.";
|
scope.jobevents[i].statusBadgeToolTip = "All playbook tasks completed successfully.";
|
||||||
}
|
} else if (set[i].event_level < 3) {
|
||||||
else if (set[i].event_level < 3) {
|
|
||||||
scope.jobevents[i].statusBadgeToolTip = "All the children of this event completed successfully.";
|
scope.jobevents[i].statusBadgeToolTip = "All the children of this event completed successfully.";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.jobevents[i].statusBadgeToolTip = "No errors occurred. Click to view details";
|
scope.jobevents[i].statusBadgeToolTip = "No errors occurred. Click to view details";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,28 +175,43 @@ 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({
|
||||||
|
path: '/jobs/' + scope.job_id,
|
||||||
|
title: scope.job_id + ' - ' + data.summary_fields.job_template.name
|
||||||
|
});
|
||||||
scope.$emit('SetHostLinks', data.inventory);
|
scope.$emit('SetHostLinks', data.inventory);
|
||||||
})
|
})
|
||||||
.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 get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
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);
|
||||||
@@ -220,18 +223,25 @@ function JobEventsList ($filter, $scope, $rootScope, $location, $log, $routePara
|
|||||||
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',
|
||||||
@@ -241,47 +251,43 @@ JobEventsList.$inject = [ '$filter', '$scope', '$rootScope', '$location', '$log'
|
|||||||
|
|
||||||
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,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var scope = GenerateForm.inject(form, {mode: 'edit', related: true});
|
scope = GenerateForm.inject(form, { mode: 'edit', related: true }),
|
||||||
generator.reset();
|
defaultUrl = GetBasePath('base') + 'job_events/' + $routeParams.event_id + '/';
|
||||||
|
|
||||||
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;
|
break;
|
||||||
case 'created':
|
case 'created':
|
||||||
var cDate = new Date(data['created']);
|
cDate = new Date(data.created);
|
||||||
scope['created'] = FormatDate(cDate);
|
scope.created = FormatDate(cDate);
|
||||||
break;
|
break;
|
||||||
case 'host':
|
case 'host':
|
||||||
if (data['summary_fields'] && data['summary_fields']['host']) {
|
if (data.summary_fields && data.summary_fields.host) {
|
||||||
scope['host'] = data['summary_fields']['host']['name'];
|
scope.host = data.summary_fields.host.name;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'id':
|
case 'id':
|
||||||
@@ -291,8 +297,8 @@ function JobEventsEdit ($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
break;
|
break;
|
||||||
case 'start':
|
case 'start':
|
||||||
case 'end':
|
case 'end':
|
||||||
if (data['event_data'] && data['event_data']['res'] && data['event_data']['res'][fld] !== undefined) {
|
if (data.event_data && data.event_data.res && data.event_data.res[fld] !== undefined) {
|
||||||
var cDate = new Date(data['event_data']['res'][fld]);
|
cDate = new Date(data.event_data.res[fld]);
|
||||||
scope[fld] = FormatDate(cDate);
|
scope[fld] = FormatDate(cDate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -301,11 +307,11 @@ function JobEventsEdit ($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
case 'stderr':
|
case 'stderr':
|
||||||
case 'delta':
|
case 'delta':
|
||||||
case 'rc':
|
case 'rc':
|
||||||
if (data['event_data'] && data['event_data']['res'] && data['event_data']['res'][fld] !== undefined) {
|
if (data.event_data && data.event_data.res && data.event_data.res[fld] !== undefined) {
|
||||||
scope[fld] = data['event_data']['res'][fld];
|
scope[fld] = data.event_data.res[fld];
|
||||||
if (form.fields[fld].type == 'textarea') {
|
if (form.fields[fld].type === 'textarea') {
|
||||||
var n = data['event_data']['res'][fld].match(/\n/g);
|
n = data.event_data.res[fld].match(/\n/g);
|
||||||
var rows = (n) ? n.length : 1;
|
rows = (n) ? n.length : 1;
|
||||||
rows = (rows > 15) ? 5 : rows;
|
rows = (rows > 15) ? 5 : rows;
|
||||||
$('textarea[name="' + fld + '"]').attr('rows', rows);
|
$('textarea[name="' + fld + '"]').attr('rows', rows);
|
||||||
}
|
}
|
||||||
@@ -313,17 +319,17 @@ function JobEventsEdit ($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
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 () {
|
||||||
@@ -332,15 +338,17 @@ function JobEventsEdit ($scope, $rootScope, $compile, $location, $log, $routePar
|
|||||||
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,35 +10,32 @@
|
|||||||
|
|
||||||
'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 {
|
||||||
else {
|
|
||||||
list.index = true;
|
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;
|
||||||
}
|
}
|
||||||
@@ -49,7 +46,7 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
|
|||||||
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,47 +63,62 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
|
|||||||
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,
|
||||||
|
title: data.id + ' - ' +
|
||||||
|
data.summary_fields.job_template.name
|
||||||
|
});
|
||||||
scope.job_status = data.status;
|
scope.job_status = data.status;
|
||||||
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
if (!(data.status === 'pending' || data.status === 'waiting' || data.status === 'running')) {
|
||||||
if ($rootScope.timer) {
|
if ($rootScope.timer) {
|
||||||
clearInterval($rootScope.timer);
|
clearInterval($rootScope.timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.$emit('setHostLink', data.inventory);
|
scope.$emit('setHostLink', data.inventory);
|
||||||
})
|
})
|
||||||
.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 get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else {
|
} else {
|
||||||
// Make the host name appear in breadcrumbs
|
// Make the host name appear in breadcrumbs
|
||||||
LoadBreadCrumbs({ path: '/hosts/' + scope['host_id'],
|
LoadBreadCrumbs({
|
||||||
title: ( (scope.jobhosts.length > 0) ? scope.jobhosts[0].summary_fields.host.name : 'Host' ) });
|
path: '/hosts/' + scope.host_id,
|
||||||
if ($routeParams['inventory']) {
|
title: ((scope.jobhosts.length > 0) ? scope.jobhosts[0].summary_fields.host.name : 'Host')
|
||||||
scope.$emit('setHostLink', $routeParams['inventory']);
|
});
|
||||||
|
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);
|
||||||
@@ -116,28 +128,36 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
|
|||||||
// 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,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + '. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
}
|
$location.url('/jobs/' + data.id + '/job_events/?host=' + encodeURI(host_name));
|
||||||
|
})
|
||||||
|
.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
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,22 +7,21 @@
|
|||||||
* Controller functions for the Job Template model.
|
* Controller functions for the Job Template model.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function JobTemplatesList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobTemplateList,
|
function JobTemplatesList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobTemplateList,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||||
ClearScope, ProcessErrors, GetBasePath, PromptPasswords, JobTemplateForm, CredentialList,
|
ClearScope, ProcessErrors, GetBasePath, PromptPasswords, JobTemplateForm, CredentialList,
|
||||||
LookUpInit, SubmitJob, Wait, Stream)
|
LookUpInit, SubmitJob, 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 list = JobTemplateList;
|
var list = JobTemplateList,
|
||||||
var defaultUrl = GetBasePath('job_templates');
|
defaultUrl = GetBasePath('job_templates'),
|
||||||
var view = GenerateList;
|
view = GenerateList,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var mode = (base == 'job_templates') ? 'edit' : 'select';
|
mode = (base === 'job_templates') ? 'edit' : 'select',
|
||||||
var scope = view.inject(list, { mode: mode });
|
scope = view.inject(list, { mode: mode });
|
||||||
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
@@ -34,56 +33,74 @@ function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Re
|
|||||||
$('#prompt-modal').off();
|
$('#prompt-modal').off();
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'job_templates', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'job_templates',
|
||||||
|
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['name']) {
|
if ($routeParams.name) {
|
||||||
scope[list.iterator + 'SearchField'] = 'name';
|
scope[list.iterator + 'SearchField'] = 'name';
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['name'];
|
scope[list.iterator + 'SearchValue'] = $routeParams.name;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.name.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.addJobTemplate = function () {
|
scope.addJobTemplate = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editJobTemplate = function (id) {
|
scope.editJobTemplate = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteJobTemplate = function (id, name) {
|
scope.deleteJobTemplate = 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 () {
|
||||||
|
Wait('start');
|
||||||
|
});
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
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 () {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
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',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.submitJob = function (id) {
|
scope.submitJob = function (id) {
|
||||||
SubmitJob({ scope: scope, id: id });
|
SubmitJob({ scope: scope, id: id });
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobTemplatesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobTemplateList',
|
JobTemplatesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobTemplateList',
|
||||||
@@ -95,26 +112,33 @@ JobTemplatesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$rout
|
|||||||
function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm,
|
function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, InventoryList, CredentialList, ProjectList, LookUpInit,
|
GetBasePath, InventoryList, CredentialList, ProjectList, LookUpInit,
|
||||||
md5Setup, ParseTypeChange, Wait, Empty)
|
md5Setup, ParseTypeChange, Wait, Empty) {
|
||||||
{
|
|
||||||
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('job_templates');
|
var defaultUrl = GetBasePath('job_templates'),
|
||||||
var form = JobTemplateForm;
|
form = JobTemplateForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
scope = generator.inject(form, { mode: 'add', related: false }),
|
||||||
var master = {};
|
master = {},
|
||||||
|
CloudCredentialList = {},
|
||||||
|
selectPlaybook, checkSCMStatus;
|
||||||
|
|
||||||
scope.parseType = 'yaml';
|
scope.parseType = 'yaml';
|
||||||
ParseTypeChange(scope);
|
ParseTypeChange(scope);
|
||||||
|
|
||||||
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
|
scope.job_type_options = [
|
||||||
|
{ value: 'run', label: 'Run' },
|
||||||
|
{ value: 'check', label: 'Check' }
|
||||||
|
];
|
||||||
|
|
||||||
scope.verbosity_options = [
|
scope.verbosity_options = [
|
||||||
{ value: '0', label: 'Default' },
|
{ value: '0', label: 'Default' },
|
||||||
{ value: '1', label: 'Verbose' },
|
{ value: '1', label: 'Verbose' },
|
||||||
{ value: '3', label: 'Debug' }];
|
{ value: '3', label: 'Debug' }
|
||||||
|
];
|
||||||
|
|
||||||
scope.playbook_options = [];
|
scope.playbook_options = [];
|
||||||
scope.allow_callbacks = 'false';
|
scope.allow_callbacks = 'false';
|
||||||
|
|
||||||
@@ -138,10 +162,9 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
// Clone the CredentialList object for use with cloud_credential. Cloning
|
// Clone the CredentialList object for use with cloud_credential. Cloning
|
||||||
// and changing properties to avoid collision.
|
// and changing properties to avoid collision.
|
||||||
var CloudCredentialList = {};
|
|
||||||
jQuery.extend(true, CloudCredentialList, CredentialList);
|
jQuery.extend(true, CloudCredentialList, CredentialList);
|
||||||
CloudCredentialList.name = 'cloudcredentials',
|
CloudCredentialList.name = 'cloudcredentials';
|
||||||
CloudCredentialList.iterator = 'cloudcredential',
|
CloudCredentialList.iterator = 'cloudcredential';
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
url: GetBasePath('credentials') + '?cloud=true',
|
url: GetBasePath('credentials') + '?cloud=true',
|
||||||
@@ -164,35 +187,38 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Update playbook select whenever project value changes
|
// Update playbook select whenever project value changes
|
||||||
var selectPlaybook = function(oldValue, newValue) {
|
selectPlaybook = function (oldValue, newValue) {
|
||||||
if (oldValue != newValue) {
|
var url;
|
||||||
|
if (oldValue !== newValue) {
|
||||||
if (scope.project) {
|
if (scope.project) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var url = GetBasePath('projects') + scope.project + '/playbooks/';
|
url = GetBasePath('projects') + scope.project + '/playbooks/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var opts = [];
|
var i, opts = [];
|
||||||
for (var i=0; i < data.length; i++) {
|
for (i = 0; i < data.length; i++) {
|
||||||
opts.push(data[i]);
|
opts.push(data[i]);
|
||||||
}
|
}
|
||||||
scope.playbook_options = opts;
|
scope.playbook_options = opts;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.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 get playbook list for ' + url +'. GET returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get playbook list for ' + url + '. GET returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Detect and alert user to potential SCM status issues
|
// Detect and alert user to potential SCM status issues
|
||||||
var checkSCMStatus = function(oldValue, newValue) {
|
checkSCMStatus = function (oldValue, newValue) {
|
||||||
if (oldValue !== newValue && !Empty(scope.project)) {
|
if (oldValue !== newValue && !Empty(scope.project)) {
|
||||||
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var msg;
|
var msg;
|
||||||
switch (data.status) {
|
switch (data.status) {
|
||||||
case 'failed':
|
case 'failed':
|
||||||
@@ -213,12 +239,14 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
Alert('Waning', msg, 'alert-info');
|
Alert('Waning', msg, 'alert-info');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.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 get project ' + scope.project +'. GET returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get project ' + scope.project + '. GET returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Register a watcher on project_name
|
// Register a watcher on project_name
|
||||||
if (scope.selectPlaybookUnregister) {
|
if (scope.selectPlaybookUnregister) {
|
||||||
@@ -241,14 +269,13 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var data = {}
|
var data = {}, json_data, fld;
|
||||||
try {
|
try {
|
||||||
// Make sure we have valid variable data
|
// Make sure we have valid variable data
|
||||||
if (scope.parseType == 'json') {
|
if (scope.parseType === 'json') {
|
||||||
var json_data = JSON.parse(scope.variables); //make sure JSON parses
|
json_data = JSON.parse(scope.variables); //make sure JSON parses
|
||||||
}
|
} else {
|
||||||
else {
|
json_data = jsyaml.load(scope.variables); //parse yaml
|
||||||
var json_data = jsyaml.load(scope.variables); //parse yaml
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our JSON is actually an object
|
// Make sure our JSON is actually an object
|
||||||
@@ -256,37 +283,40 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
throw "failed to return an object!";
|
throw "failed to return an object!";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
if (form.fields[fld].type === 'select' && fld !== 'playbook') {
|
||||||
data[fld] = scope[fld].value;
|
data[fld] = scope[fld].value;
|
||||||
}
|
} else {
|
||||||
else {
|
if (fld !== 'variables') {
|
||||||
if (fld != 'variables') {
|
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.extra_vars = JSON.stringify(json_data, undefined, '\t');
|
data.extra_vars = JSON.stringify(json_data, undefined, '\t');
|
||||||
if (data.extra_vars == "null" || data.extra_vars == null) {
|
if (Empty(data.extra_vars)) {
|
||||||
data.extra_vars = "";
|
data.extra_vars = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.post(data)
|
Rest.post(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 == 'job_templates') ? ReturnToCaller() : ReturnToCaller(1);
|
if (base === 'job_templates') {
|
||||||
|
ReturnToCaller();
|
||||||
|
}
|
||||||
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new job template. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new job template. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
} catch (err) {
|
||||||
catch(err) {
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
||||||
}
|
}
|
||||||
@@ -306,79 +336,84 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
JobTemplatesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',
|
JobTemplatesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope',
|
||||||
'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit',
|
'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit',
|
||||||
'md5Setup', 'ParseTypeChange', 'Wait', 'Empty' ];
|
'md5Setup', 'ParseTypeChange', 'Wait', 'Empty'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm,
|
function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm, GenerateForm, Rest,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList,
|
||||||
RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList,
|
CredentialList, ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, ParseTypeChange, JobStatusToolTip, FormatDate,
|
||||||
ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, ParseTypeChange,
|
Wait, Stream, Empty, Prompt) {
|
||||||
JobStatusToolTip, FormatDate, Wait, Stream, Empty)
|
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
|
||||||
//scope.
|
|
||||||
|
|
||||||
var defaultUrl= GetBasePath('job_templates');
|
ClearScope('htmlTemplate');
|
||||||
var generator = GenerateForm;
|
|
||||||
var form = JobTemplateForm;
|
var defaultUrl = GetBasePath('job_templates'),
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
generator = GenerateForm,
|
||||||
var loadingFinishedCount = 0;
|
form = JobTemplateForm,
|
||||||
|
scope = generator.inject(form, { mode: 'edit', related: true }),
|
||||||
|
loadingFinishedCount = 0,
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {},
|
||||||
|
id = $routeParams.id,
|
||||||
|
relatedSets = {},
|
||||||
|
checkSCMStatus, getPlaybooks;
|
||||||
|
|
||||||
scope.parseType = 'yaml';
|
scope.parseType = 'yaml';
|
||||||
ParseTypeChange(scope);
|
ParseTypeChange(scope);
|
||||||
|
|
||||||
// Our job type options
|
// Our job type options
|
||||||
scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }];
|
scope.job_type_options = [
|
||||||
|
{ value: 'run', label: 'Run' },
|
||||||
|
{ value: 'check', label: 'Check' }
|
||||||
|
];
|
||||||
|
|
||||||
scope.verbosity_options = [
|
scope.verbosity_options = [
|
||||||
{ value: '0', label: 'Default' },
|
{ value: '0', label: 'Default' },
|
||||||
{ value: '1', label: 'Verbose' },
|
{ value: '1', label: 'Verbose' },
|
||||||
{ value: '3', label: 'Debug' }];
|
{ value: '3', label: 'Debug' }
|
||||||
|
];
|
||||||
|
|
||||||
scope.playbook_options = null;
|
scope.playbook_options = null;
|
||||||
scope.playbook = null;
|
scope.playbook = null;
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
getPlaybooks = function (project) {
|
||||||
var master = {};
|
var url;
|
||||||
var id = $routeParams.id;
|
if (!Empty(project)) {
|
||||||
var relatedSets = {};
|
url = GetBasePath('projects') + project + '/playbooks/';
|
||||||
|
|
||||||
function getPlaybooks(project) {
|
|
||||||
if (project !== null && project !== '' && project !== undefined) {
|
|
||||||
var url = GetBasePath('projects') + project + '/playbooks/';
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
|
var i;
|
||||||
scope.playbook_options = [];
|
scope.playbook_options = [];
|
||||||
for (var i=0; i < data.length; i++) {
|
for (i = 0; i < data.length; i++) {
|
||||||
scope.playbook_options.push(data[i]);
|
scope.playbook_options.push(data[i]);
|
||||||
if (data[i] == scope.playbook) {
|
if (data[i] === scope.playbook) {
|
||||||
scope['job_templates_form']['playbook'].$setValidity('required',true);
|
scope.job_templates_form.playbook.$setValidity('required', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scope.playbook) {
|
if (scope.playbook) {
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert('Missing Playbooks', 'Unable to retrieve the list of playbooks for this project. Choose a different ' +
|
Alert('Missing Playbooks', 'Unable to retrieve the list of playbooks for this project. Choose a different ' +
|
||||||
' project or make the playbooks available on the file system.', 'alert-info');
|
' project or make the playbooks available on the file system.', 'alert-info');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Detect and alert user to potential SCM status issues
|
// Detect and alert user to potential SCM status issues
|
||||||
var checkSCMStatus = function() {
|
checkSCMStatus = function () {
|
||||||
if (!Empty(scope.project)) {
|
if (!Empty(scope.project)) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var msg;
|
var msg;
|
||||||
switch (data.status) {
|
switch (data.status) {
|
||||||
case 'failed':
|
case 'failed':
|
||||||
@@ -400,12 +435,12 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
Alert('Waning', msg, 'alert-info');
|
Alert('Waning', msg, 'alert-info');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.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 get project ' + scope.project +
|
||||||
{ hdr: 'Error!', msg: 'Failed to get project ' + scope.project +'. GET returned status: ' + status });
|
'. GET returned status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// Register a watcher on project_name. Refresh the playbook list on change.
|
// Register a watcher on project_name. Refresh the playbook list on change.
|
||||||
@@ -441,16 +476,16 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
scope.removeRelatedJobs();
|
scope.removeRelatedJobs();
|
||||||
}
|
}
|
||||||
scope.removeRelatedJobs = scope.$on('relatedjobs', function () {
|
scope.removeRelatedJobs = scope.$on('relatedjobs', function () {
|
||||||
if (scope['jobs'] && scope['jobs'].length) {
|
var i, cDate;
|
||||||
var cDate;
|
if (scope.jobs && scope.jobs.length) {
|
||||||
for (var 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);
|
||||||
// Set tooltip and link
|
// Set tooltip and link
|
||||||
scope['jobs'][i].statusBadgeToolTip = JobStatusToolTip(scope['jobs'][i].status) +
|
scope.jobs[i].statusBadgeToolTip = JobStatusToolTip(scope.jobs[i].status) +
|
||||||
" Click to view status details.";
|
" Click to view status details.";
|
||||||
scope['jobs'][i].statusLinkTo = '/#/jobs/' + scope['jobs'][i].id;
|
scope.jobs[i].statusLinkTo = '/#/jobs/' + scope.jobs[i].id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -459,19 +494,19 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
scope.cloudCredentialReadyRemove();
|
scope.cloudCredentialReadyRemove();
|
||||||
}
|
}
|
||||||
scope.cloudCredentialReadyRemove = scope.$on('cloudCredentialReady', function (e, name) {
|
scope.cloudCredentialReadyRemove = scope.$on('cloudCredentialReady', function (e, name) {
|
||||||
scope['cloud_credential_name'] = name;
|
var CloudCredentialList = {};
|
||||||
master['cloud_credential_name'] = name;
|
scope.cloud_credential_name = name;
|
||||||
|
master.cloud_credential_name = name;
|
||||||
// Clone the CredentialList object for use with cloud_credential. Cloning
|
// Clone the CredentialList object for use with cloud_credential. Cloning
|
||||||
// and changing properties to avoid collision.
|
// and changing properties to avoid collision.
|
||||||
var CloudCredentialList = {};
|
|
||||||
jQuery.extend(true, CloudCredentialList, CredentialList);
|
jQuery.extend(true, CloudCredentialList, CredentialList);
|
||||||
CloudCredentialList.name = 'cloudcredentials',
|
CloudCredentialList.name = 'cloudcredentials';
|
||||||
CloudCredentialList.iterator = 'cloudcredential',
|
CloudCredentialList.iterator = 'cloudcredential';
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
url: GetBasePath('credentials') + '?cloud=true',
|
url: GetBasePath('credentials') + '?cloud=true',
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: scope['cloud_credential'],
|
current_item: scope.cloud_credential,
|
||||||
list: CloudCredentialList,
|
list: CloudCredentialList,
|
||||||
field: 'cloud_credential',
|
field: 'cloud_credential',
|
||||||
hdr: 'Select Cloud Credential'
|
hdr: 'Select Cloud Credential'
|
||||||
@@ -485,10 +520,10 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
scope.jobTemplateLoadedRemove();
|
scope.jobTemplateLoadedRemove();
|
||||||
}
|
}
|
||||||
scope.jobTemplateLoadedRemove = scope.$on('jobTemplateLoaded', function (e, related_cloud_credential) {
|
scope.jobTemplateLoadedRemove = scope.$on('jobTemplateLoaded', function (e, related_cloud_credential) {
|
||||||
|
var dft;
|
||||||
getPlaybooks(scope.project);
|
getPlaybooks(scope.project);
|
||||||
|
|
||||||
var dft = (scope['host_config_key'] === "" || scope['host_config_key'] === null) ? 'false' : 'true';
|
dft = (scope.host_config_key === "" || scope.host_config_key === null) ? 'false' : 'true';
|
||||||
md5Setup({
|
md5Setup({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
master: master,
|
master: master,
|
||||||
@@ -499,15 +534,14 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
if (related_cloud_credential) {
|
if (related_cloud_credential) {
|
||||||
Rest.setUrl(related_cloud_credential);
|
Rest.setUrl(related_cloud_credential);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
scope.$emit('cloudCredentialReady', data.name);
|
scope.$emit('cloudCredentialReady', data.name);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, {hdr: 'Error!',
|
||||||
{ hdr: 'Error!', msg: 'Failed to related cloud credential. GET returned status: ' + status });
|
msg: 'Failed to related cloud credential. GET returned status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// No existing cloud credential
|
// No existing cloud credential
|
||||||
scope.$emit('cloudCredentialReady', null);
|
scope.$emit('cloudCredentialReady', null);
|
||||||
}
|
}
|
||||||
@@ -517,40 +551,38 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
// 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) {
|
||||||
|
var fld, i, json_obj, related, set;
|
||||||
LoadBreadCrumbs({ path: '/job_templates/' + id, title: data.name });
|
LoadBreadCrumbs({ path: '/job_templates/' + id, title: data.name });
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
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 (var 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];
|
||||||
}
|
}
|
||||||
if (fld == 'variables') {
|
if (fld === 'variables') {
|
||||||
// Parse extra_vars, converting to YAML.
|
// Parse extra_vars, converting to YAML.
|
||||||
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);
|
||||||
var json_obj = JSON.parse(data.extra_vars);
|
|
||||||
scope.variables = jsyaml.safeDump(json_obj);
|
scope.variables = jsyaml.safeDump(json_obj);
|
||||||
}
|
}
|
||||||
master.variables = scope.variables;
|
master.variables = scope.variables;
|
||||||
}
|
}
|
||||||
if (form.fields[fld].type == 'lookup' && data.summary_fields[form.fields[fld].sourceModel]) {
|
if (form.fields[fld].type === 'lookup' && data.summary_fields[form.fields[fld].sourceModel]) {
|
||||||
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||||
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||||
@@ -559,15 +591,18 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.url = data.url;
|
scope.url = data.url;
|
||||||
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['callback_url'] = data.related['callback'];
|
scope.callback_url = data.related.callback;
|
||||||
master['callback_url'] = scope['callback_url'];
|
master.callback_url = scope.callback_url;
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
@@ -596,27 +631,35 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 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.$emit('jobTemplateLoaded', data.related.cloud_credential);
|
scope.$emit('jobTemplateLoaded', data.related.cloud_credential);
|
||||||
})
|
})
|
||||||
.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 job template: ' + $routeParams.id + '. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve job template: ' + $routeParams.id + '. GET status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var data = {}
|
var data = {}, json_data, fld;
|
||||||
try {
|
try {
|
||||||
// Make sure we have valid variable data
|
// Make sure we have valid variable data
|
||||||
if (scope.parseType == 'json') {
|
if (scope.parseType === 'json') {
|
||||||
var json_data = JSON.parse(scope.variables); //make sure JSON parses
|
json_data = JSON.parse(scope.variables); //make sure JSON parses
|
||||||
}
|
} else {
|
||||||
else {
|
json_data = jsyaml.load(scope.variables); //parse yaml
|
||||||
var json_data = jsyaml.load(scope.variables); //parse yaml
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our JSON is actually an object
|
// Make sure our JSON is actually an object
|
||||||
@@ -624,42 +667,49 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
throw "failed to return an object!";
|
throw "failed to return an object!";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
if (form.fields[fld].type === 'select' && fld !== 'playbook') {
|
||||||
data[fld] = scope[fld].value;
|
data[fld] = scope[fld].value;
|
||||||
}
|
} else {
|
||||||
else {
|
if (fld !== 'variables' && fld !== 'callback_url') {
|
||||||
if (fld != 'variables' && fld != 'callback_url') {
|
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.extra_vars = JSON.stringify(json_data, undefined, '\t');
|
data.extra_vars = JSON.stringify(json_data, undefined, '\t');
|
||||||
if (data.extra_vars == "null" || data.extra_vars == null) {
|
if (data.extra_vars === "null" || data.extra_vars === null) {
|
||||||
data.extra_vars = "";
|
data.extra_vars = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
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 == 'job_templates') ? ReturnToCaller() : ReturnToCaller(1);
|
if (base === 'job_templates') {
|
||||||
|
ReturnToCaller();
|
||||||
|
}
|
||||||
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.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 update job template. PUT returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to update job template. PUT returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
} catch (err) {
|
||||||
catch(err) {
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
Alert("Error", "Error parsing extra variables. Parser returned: " + err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
@@ -678,7 +728,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 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;
|
||||||
$location.path('/' + set + '/' + id);
|
$location.path('/' + set + '/' + id);
|
||||||
};
|
};
|
||||||
@@ -690,29 +740,34 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
var action = function () {
|
var action = function () {
|
||||||
var url = defaultUrl + id + '/' + set + '/';
|
var url = defaultUrl + id + '/' + set + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
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. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JobTemplatesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',
|
JobTemplatesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',
|
||||||
'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', 'ParseTypeChange',
|
'GetBasePath', 'md5Setup', 'ParseTypeChange', 'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream', 'Empty', 'Prompt'
|
||||||
'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream', 'Empty'
|
|
||||||
];
|
];
|
||||||
@@ -7,9 +7,7 @@
|
|||||||
* 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,
|
||||||
@@ -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) {
|
||||||
@@ -92,23 +98,37 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
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');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,8 +143,7 @@ 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';
|
||||||
@@ -140,11 +159,10 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
})
|
})
|
||||||
.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');
|
||||||
@@ -152,8 +170,8 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
})
|
})
|
||||||
.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 });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -165,13 +183,16 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.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
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +213,10 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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 = {},
|
||||||
@@ -219,8 +243,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
.error(function () {
|
.error(function () {
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.$emit('jobTemplateLoadFinished');
|
scope.$emit('jobTemplateLoadFinished');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,11 +295,12 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -295,12 +319,23 @@ 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;
|
||||||
|
|
||||||
@@ -327,13 +362,11 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,14 +452,23 @@ 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 () {
|
||||||
@@ -442,8 +485,10 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
})
|
})
|
||||||
.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
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -457,8 +502,7 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
}
|
}
|
||||||
|
|
||||||
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'
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -11,25 +11,29 @@
|
|||||||
'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();
|
||||||
@@ -41,63 +45,81 @@ function OrganizationsList ($routeParams, $scope, $rootScope, $location, $log, R
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 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 () {
|
||||||
|
Wait('start');
|
||||||
|
});
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
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 () {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.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: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
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();
|
generator.reset();
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
@@ -107,23 +129,26 @@ function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var url = GetBasePath(base);
|
var url = GetBasePath(base);
|
||||||
url += (base != 'organizations') ? $routeParams['project_id'] + '/organizations/' : '';
|
url += (base !== 'organizations') ? $routeParams.project_id + '/organizations/' : '';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ name: $scope.name,
|
Rest.post({
|
||||||
description: $scope.description })
|
name: $scope.name,
|
||||||
.success( function(data, status, headers, config) {
|
description: $scope.description
|
||||||
|
})
|
||||||
|
.success(function (data) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
if (base == 'organizations') {
|
if (base === 'organizations') {
|
||||||
$rootScope.flashMessage = "New organization successfully created!";
|
$rootScope.flashMessage = "New organization successfully created!";
|
||||||
$location.path('/organizations/' + data.id);
|
$location.path('/organizations/' + data.id);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ReturnToCaller(1);
|
ReturnToCaller(1);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.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 add new organization. Post returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to add new organization. Post returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,27 +161,27 @@ function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
|
|
||||||
OrganizationsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
OrganizationsAdd.$inject = ['$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'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function OrganizationsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
function OrganizationsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||||
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream)
|
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, 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.
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var form = OrganizationForm;
|
var form = OrganizationForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var scope = GenerateForm.inject(form, {mode: 'edit', related: true});
|
scope = GenerateForm.inject(form, { mode: 'edit', related: true }),
|
||||||
generator.reset();
|
defaultUrl = GetBasePath('organizations'),
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {},
|
||||||
|
id = $routeParams.organization_id,
|
||||||
|
relatedSets = {};
|
||||||
|
|
||||||
var defaultUrl = GetBasePath('organizations');
|
generator.reset();
|
||||||
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
|
// After the Organization is loaded, retrieve each related set
|
||||||
if (scope.organizationLoadedRemove) {
|
if (scope.organizationLoadedRemove) {
|
||||||
@@ -173,54 +198,73 @@ function OrganizationsEdit ($scope, $rootScope, $compile, $location, $log, $rout
|
|||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
|
var fld, related, set;
|
||||||
LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name });
|
LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name });
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
master[fld] = data[fld];
|
master[fld] = data[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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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.$emit('organizationLoaded');
|
scope.$emit('organizationLoaded');
|
||||||
})
|
})
|
||||||
.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 organization: ' + $routeParams.id + '. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var fld, params = {};
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var params = {};
|
for (fld in form.fields) {
|
||||||
for (var fld in form.fields) {
|
|
||||||
params[fld] = scope[fld];
|
params[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
Rest.put(params)
|
Rest.put(params)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
master = params;
|
master = params;
|
||||||
$rootScope.flashMessage = "Your changes were successfully saved!";
|
$rootScope.flashMessage = "Your changes were successfully saved!";
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, OrganizationForm,
|
ProcessErrors(scope, data, status, OrganizationForm, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to update organization: ' + id + '. PUT status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to update organization: ' + id + '. PUT status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
@@ -238,7 +282,7 @@ function OrganizationsEdit ($scope, $rootScope, $compile, $location, $log, $rout
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 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;
|
||||||
$location.path('/' + set + '/' + id);
|
$location.path('/' + set + '/' + id);
|
||||||
};
|
};
|
||||||
@@ -251,28 +295,35 @@ function OrganizationsEdit ($scope, $rootScope, $compile, $location, $log, $rout
|
|||||||
Wait('start');
|
Wait('start');
|
||||||
var url = defaultUrl + $routeParams.organization_id + '/' + set + '/';
|
var url = defaultUrl + $routeParams.organization_id + '/' + set + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
Rest.post({
|
||||||
.success( function(data, status, headers, config) {
|
id: itm_id,
|
||||||
|
disassociate: 1
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#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) {
|
||||||
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. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
OrganizationsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
OrganizationsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'OrganizationForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
||||||
'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'Wait', 'Stream'];
|
'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'Wait', 'Stream'
|
||||||
|
];
|
||||||
@@ -11,22 +11,26 @@
|
|||||||
'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.
|
//scope.
|
||||||
var list = PermissionList;
|
var list = PermissionList,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var defaultUrl = GetBasePath(base);
|
defaultUrl = GetBasePath(base),
|
||||||
defaultUrl += ($routeParams['user_id'] !== undefined) ? $routeParams['user_id'] : $routeParams['team_id'];
|
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();
|
||||||
@@ -37,8 +41,17 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
$('#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();
|
||||||
@@ -47,36 +60,41 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
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 () {
|
||||||
|
Wait('start');
|
||||||
|
});
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.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: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'PermissionList',
|
PermissionsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'PermissionList',
|
||||||
@@ -88,26 +106,24 @@ PermissionsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$route
|
|||||||
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;
|
||||||
@@ -131,28 +147,31 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var fld, url, data = {};
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
if (scope.PermissionAddAllowed) {
|
if (scope.PermissionAddAllowed) {
|
||||||
var data = {};
|
data = {};
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
url = (base === 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ReturnToCaller(1);
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, PermissionsForm,
|
ProcessErrors(scope, data, status, PermissionsForm, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to create new permission. Post returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to create new permission. Post returned status: ' + status
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else {
|
} else {
|
||||||
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.', 'alert-danger');
|
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.',
|
||||||
|
'alert-danger');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -166,7 +185,12 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
scope.selectCategory();
|
scope.selectCategory();
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.selectCategory = function() { PermissionCategoryChange({ scope: scope, reset: true }); };
|
scope.selectCategory = function () {
|
||||||
|
PermissionCategoryChange({
|
||||||
|
scope: scope,
|
||||||
|
reset: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
scope.selectCategory();
|
scope.selectCategory();
|
||||||
@@ -174,51 +198,50 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
}
|
}
|
||||||
|
|
||||||
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();
|
generator.reset();
|
||||||
|
|
||||||
var master = {};
|
|
||||||
var relatedSets = {};
|
|
||||||
|
|
||||||
CheckAccess({ scope: scope });
|
CheckAccess({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
|
||||||
scope.selectCategory = function (resetIn) {
|
scope.selectCategory = function (resetIn) {
|
||||||
var reset = (resetIn == false) ? false : true;
|
var reset = (resetIn === false) ? false : true;
|
||||||
PermissionCategoryChange({ scope: scope, reset: reset }); }
|
PermissionCategoryChange({ scope: scope, reset: reset });
|
||||||
|
};
|
||||||
|
|
||||||
// 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) {
|
||||||
|
var fld, sourceModel, sourceField;
|
||||||
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
||||||
|
for (fld in form.fields) {
|
||||||
for (var fld in form.fields) {
|
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
if (form.fields[fld].sourceModel) {
|
if (form.fields[fld].sourceModel) {
|
||||||
var sourceModel = form.fields[fld].sourceModel;
|
sourceModel = form.fields[fld].sourceModel;
|
||||||
var sourceField = form.fields[fld].sourceField;
|
sourceField = form.fields[fld].sourceField;
|
||||||
scope[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
scope[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
||||||
master[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
master[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
||||||
}
|
}
|
||||||
@@ -228,10 +251,10 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.category = 'Deploy';
|
scope.category = 'Deploy';
|
||||||
if (data['permission_type'] != 'run' && data['permission_type'] != 'check' ) {
|
if (data.permission_type !== 'run' && data.permission_type !== 'check') {
|
||||||
scope.category = 'Inventory';
|
scope.category = 'Inventory';
|
||||||
}
|
}
|
||||||
master['category'] = scope.category;
|
master.category = scope.category;
|
||||||
scope.selectCategory(false); //call without resetting scope.category value
|
scope.selectCategory(false); //call without resetting scope.category value
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
@@ -252,7 +275,7 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
if (!scope.PermissionAddAllowed) {
|
if (!scope.PermissionAddAllowed) {
|
||||||
// If not a privileged user, disable access
|
// If not a privileged user, disable access
|
||||||
$('form[name="permission_form"]').find('select, input, button').each(function(index){
|
$('form[name="permission_form"]').find('select, input, button').each(function () {
|
||||||
if ($(this).is('input') || $(this).is('select')) {
|
if ($(this).is('input') || $(this).is('select')) {
|
||||||
$(this).attr('readonly', 'readonly');
|
$(this).attr('readonly', 'readonly');
|
||||||
}
|
}
|
||||||
@@ -265,30 +288,30 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var fld, data = {};
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var data = {}
|
for (fld in form.fields) {
|
||||||
for (var fld in form.fields) {
|
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ReturnToCaller(1);
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update Permission: ' +
|
||||||
{ hdr: 'Error!', msg: 'Failed to update Permission: ' + $routeParams.id + '. PUT status: ' + status });
|
$routeParams.id + '. PUT status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -305,8 +328,6 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
}
|
}
|
||||||
|
|
||||||
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'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -10,29 +10,33 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, ProjectList,
|
function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, ProjectList, GenerateList, LoadBreadCrumbs,
|
||||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate,
|
||||||
ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate, ProjectStatus,
|
ProjectStatus, FormatDate, Refresh, Wait, Stream, GetChoices, Empty) {
|
||||||
FormatDate, Refresh, Wait, Stream, GetChoices)
|
|
||||||
{
|
|
||||||
ClearScope('htmlTemplate');
|
ClearScope('htmlTemplate');
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
var list = ProjectList;
|
var list = ProjectList,
|
||||||
var defaultUrl = GetBasePath('projects');
|
defaultUrl = GetBasePath('projects'),
|
||||||
var view = GenerateList;
|
view = GenerateList,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var mode = (base == 'projects') ? 'edit' : 'select';
|
mode = (base === 'projects') ? 'edit' : 'select',
|
||||||
var scope = view.inject(list, { mode: mode });
|
scope = view.inject(list, { mode: mode }),
|
||||||
|
url = (base === 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl,
|
||||||
|
choiceCount = 0;
|
||||||
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
scope.projectLoading = true;
|
scope.projectLoading = true;
|
||||||
|
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
if (mode === 'select') {
|
||||||
|
SelectionInit({
|
||||||
if (mode == 'select') {
|
scope: scope,
|
||||||
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
list: list,
|
||||||
|
url: url,
|
||||||
|
returnToCaller: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.removePostRefresh) {
|
if (scope.removePostRefresh) {
|
||||||
@@ -40,12 +44,13 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
}
|
}
|
||||||
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
scope.removePostRefresh = scope.$on('PostRefresh', function () {
|
||||||
// Cleanup after a delete
|
// Cleanup after a delete
|
||||||
|
var j, i;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').off();
|
$('#prompt-modal').off();
|
||||||
|
|
||||||
if (scope.projects) {
|
if (scope.projects) {
|
||||||
for (var i=0; i < scope.projects.length; i++) {
|
for (i = 0; i < scope.projects.length; i++) {
|
||||||
if (scope.projects[i].status == 'ok') {
|
if (scope.projects[i].status === 'ok') {
|
||||||
scope.projects[i].status = 'n/a';
|
scope.projects[i].status = 'n/a';
|
||||||
}
|
}
|
||||||
switch (scope.projects[i].status) {
|
switch (scope.projects[i].status) {
|
||||||
@@ -66,14 +71,13 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ?
|
scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ?
|
||||||
FormatDate(new Date(scope.projects[i].last_updated)) : null;
|
FormatDate(new Date(scope.projects[i].last_updated)) : null;
|
||||||
|
|
||||||
for (var j=0; j < scope.project_scm_type_options.length; j++) {
|
for (j = 0; j < scope.project_scm_type_options.length; j++) {
|
||||||
if (scope.project_scm_type_options[j].value == scope.projects[i].scm_type) {
|
if (scope.project_scm_type_options[j].value === scope.projects[i].scm_type) {
|
||||||
scope.projects[i].scm_type = scope.project_scm_type_options[j].label
|
scope.projects[i].scm_type = scope.project_scm_type_options[j].label;
|
||||||
if (scope.projects[i].scm_type == 'Manual') {
|
if (scope.projects[i].scm_type === 'Manual') {
|
||||||
scope.projects[i].scm_update_tooltip = 'Manaul projects do not require an SCM update';
|
scope.projects[i].scm_update_tooltip = 'Manaul projects do not require an SCM update';
|
||||||
scope.projects[i].scm_type_class = 'btn-disabled';
|
scope.projects[i].scm_type_class = 'btn-disabled';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.projects[i].scm_update_tooltip = "Start an SCM update";
|
scope.projects[i].scm_update_tooltip = "Start an SCM update";
|
||||||
scope.projects[i].scm_type_class = "";
|
scope.projects[i].scm_type_class = "";
|
||||||
}
|
}
|
||||||
@@ -88,39 +92,48 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
scope.removeChoicesHere();
|
scope.removeChoicesHere();
|
||||||
}
|
}
|
||||||
scope.removeChoicesHere = scope.$on('choicesCompleteProject', function () {
|
scope.removeChoicesHere = scope.$on('choicesCompleteProject', function () {
|
||||||
|
var opt;
|
||||||
|
|
||||||
list.fields.scm_type.searchOptions = scope.project_scm_type_options;
|
list.fields.scm_type.searchOptions = scope.project_scm_type_options;
|
||||||
list.fields.status.searchOptions = scope.project_status_options;
|
list.fields.status.searchOptions = scope.project_status_options;
|
||||||
|
|
||||||
if ($routeParams['scm_type'] && $routeParams['status']) {
|
if ($routeParams.scm_type && $routeParams.status) {
|
||||||
// Request coming from home page. User wants all errors for an scm_type
|
// Request coming from home page. User wants all errors for an scm_type
|
||||||
defaultUrl += '?status=' + $routeParams['status'];
|
defaultUrl += '?status=' + $routeParams.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'projects', list: list, url: defaultUrl });
|
SearchInit({
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
scope: scope,
|
||||||
|
set: 'projects',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
|
||||||
if ($routeParams['scm_type']) {
|
if ($routeParams.scm_type) {
|
||||||
scope[list.iterator + 'SearchField'] = 'scm_type';
|
scope[list.iterator + 'SearchField'] = 'scm_type';
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[list.iterator + 'SelectShow'] = true;
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields['scm_type'].searchOptions;
|
scope[list.iterator + 'SearchSelectOpts'] = list.fields.scm_type.searchOptions;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['scm_type'].label.replace(/\<br\>/g,' ');
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.scm_type.label.replace(/<br\>/g, ' ');
|
||||||
for (var opt in list.fields['scm_type'].searchOptions) {
|
for (opt in list.fields.scm_type.searchOptions) {
|
||||||
if (list.fields['scm_type'].searchOptions[opt].value == $routeParams['scm_type']) {
|
if (list.fields.scm_type.searchOptions[opt].value === $routeParams.scm_type) {
|
||||||
scope[list.iterator + 'SearchSelectValue'] = list.fields['scm_type'].searchOptions[opt];
|
scope[list.iterator + 'SearchSelectValue'] = list.fields.scm_type.searchOptions[opt];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if ($routeParams.status) {
|
||||||
else if ($routeParams['status']) {
|
scope[list.iterator + 'SearchValue'] = $routeParams.status;
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['status'];
|
|
||||||
scope[list.iterator + 'SearchField'] = 'status';
|
scope[list.iterator + 'SearchField'] = 'status';
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[list.iterator + 'SelectShow'] = true;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['status'].label;
|
scope[list.iterator + 'SearchFieldLabel'] = list.fields.status.label;
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields['status'].searchOptions;
|
scope[list.iterator + 'SearchSelectOpts'] = list.fields.status.searchOptions;
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,14 +141,12 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
});
|
});
|
||||||
|
|
||||||
var choiceCount = 0;
|
|
||||||
|
|
||||||
if (scope.removeChoicesReady) {
|
if (scope.removeChoicesReady) {
|
||||||
scope.removeChoicesReady();
|
scope.removeChoicesReady();
|
||||||
}
|
}
|
||||||
scope.removeChoicesReady = scope.$on('choicesReadyProject', function () {
|
scope.removeChoicesReady = scope.$on('choicesReadyProject', function () {
|
||||||
choiceCount++;
|
choiceCount++;
|
||||||
if (choiceCount == 2) {
|
if (choiceCount === 2) {
|
||||||
scope.$emit('choicesCompleteProject');
|
scope.$emit('choicesCompleteProject');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -160,22 +171,24 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({ scope: scope });
|
||||||
|
};
|
||||||
|
|
||||||
scope.addProject = function () {
|
scope.addProject = function () {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.editProject = function (id) {
|
scope.editProject = function (id) {
|
||||||
$location.path($location.path() + '/' + id);
|
$location.path($location.path() + '/' + id);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.showSCMStatus = function (id) {
|
scope.showSCMStatus = function (id) {
|
||||||
// Refresh the project list
|
// Refresh the project list
|
||||||
var statusCheckRemove = scope.$on('PostRefresh', function() {
|
var i, statusCheckRemove = scope.$on('PostRefresh', function () {
|
||||||
var project;
|
var project;
|
||||||
for (var i=0; i < scope.projects.length; i++) {
|
for (i= 0; i < scope.projects.length; i++) {
|
||||||
if (scope.projects[i].id == id) {
|
if (scope.projects[i].id === id) {
|
||||||
project = scope.projects[i];
|
project = scope.projects[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -183,18 +196,21 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
if (project.scm_type !== null) {
|
if (project.scm_type !== null) {
|
||||||
if (project.related.current_update) {
|
if (project.related.current_update) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
ProjectStatus({ project_id: id, last_update: project.related.current_update });
|
ProjectStatus({
|
||||||
}
|
project_id: id,
|
||||||
else if (project.related.last_update) {
|
last_update: project.related.current_update
|
||||||
|
});
|
||||||
|
} else if (project.related.last_update) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
ProjectStatus({ project_id: id, last_update: project.related.last_update });
|
ProjectStatus({
|
||||||
}
|
project_id: id,
|
||||||
else {
|
last_update: project.related.last_update
|
||||||
|
});
|
||||||
|
} else {
|
||||||
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' +
|
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' +
|
||||||
' completed. If you have not already done so, start an update for this project.', 'alert-info');
|
' completed. If you have not already done so, start an update for this project.', 'alert-info');
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Alert('Missing SCM Configuration', 'The selected project is not configured for SCM. You must first edit the project, provide SCM settings, ' +
|
Alert('Missing SCM Configuration', 'The selected project is not configured for SCM. You must first edit the project, provide SCM settings, ' +
|
||||||
'and then run an update.', 'alert-info');
|
'and then run an update.', 'alert-info');
|
||||||
}
|
}
|
||||||
@@ -203,45 +219,49 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
|
|
||||||
// Refresh the project list so we're looking at the latest data
|
// Refresh the project list so we're looking at the latest data
|
||||||
scope.search(list.iterator, null, false, true);
|
scope.search(list.iterator, null, false, true);
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.deleteProject = function (id, name) {
|
scope.deleteProject = function (id, name) {
|
||||||
var action = function () {
|
var action = function () {
|
||||||
$('#prompt-modal').on('hiden.bs.modal', function(){ Wait('start'); });
|
$('#prompt-modal').on('hiden.bs.modal', function () {
|
||||||
|
Wait('start');
|
||||||
|
});
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
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 () {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.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: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
if (scope.removeCancelUpdate) {
|
if (scope.removeCancelUpdate) {
|
||||||
scope.removeCancelUpdate();
|
scope.removeCancelUpdate();
|
||||||
}
|
}
|
||||||
scope.removeCancelUpdate = scope.$on('Cancel_Update', function (e, url) {
|
scope.removeCancelUpdate = scope.$on('Cancel_Update', function (e, url) {
|
||||||
// Cancel the project update process
|
// Cancel the project update process
|
||||||
Rest.setUrl(url)
|
Rest.setUrl(url);
|
||||||
Rest.post()
|
Rest.post()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Alert('SCM Update Cancel', 'Your request to cancel the update was submitted to the task maanger.', 'alert-info');
|
Alert('SCM Update Cancel', 'Your request to cancel the update was submitted to the task maanger.', 'alert-info');
|
||||||
scope.refresh();
|
scope.refresh();
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -253,27 +273,24 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
var url = data.related.cancel;
|
var url = data.related.cancel;
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
if (data.can_cancel) {
|
if (data.can_cancel) {
|
||||||
scope.$emit('Cancel_Update', url);
|
scope.$emit('Cancel_Update', url);
|
||||||
}
|
} else {
|
||||||
else {
|
Alert('Cancel Not Allowed', 'Either you do not have access or the SCM update process completed. ' +
|
||||||
Alert('Cancel Not Allowed', 'Either you do not have access or the SCM update process completed. Click the <em>Refresh</em> button to' +
|
'Click the <em>Refresh</em> button to view the latest status.', 'alert-info');
|
||||||
' view the latest status.', 'alert-info');
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.cancelUpdate = function (id, name) {
|
scope.cancelUpdate = function (id, name) {
|
||||||
// Start the cancel process
|
// Start the cancel process
|
||||||
var project;
|
var i, project, found = false;
|
||||||
var found = false;
|
for (i = 0; i < scope.projects.length; i++) {
|
||||||
for (var i=0; i < scope.projects.length; i++) {
|
if (scope.projects[i].id === id) {
|
||||||
if (scope.projects[i].id == id) {
|
|
||||||
project = scope.projects[i];
|
project = scope.projects[i];
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@@ -282,86 +299,96 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
if (found && project.related.current_update) {
|
if (found && project.related.current_update) {
|
||||||
Rest.setUrl(project.related.current_update);
|
Rest.setUrl(project.related.current_update);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
scope.$emit('Check_Cancel', data);
|
scope.$emit('Check_Cancel', data);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null, {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
else {
|
} else {
|
||||||
Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + name + '. Click the <em>Refresh</em> ' +
|
Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + name + '. Click the <em>Refresh</em> ' +
|
||||||
'button to view the latet status.', 'alert-info');
|
'button to view the latet status.', 'alert-info');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.refresh = function () {
|
scope.refresh = function () {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
scope['projectLoading'] = false;
|
scope.projectLoading = false;
|
||||||
Refresh({ scope: scope, set: 'projects', iterator: 'project', url: scope['current_url'] });
|
Refresh({
|
||||||
}
|
scope: scope,
|
||||||
|
set: 'projects',
|
||||||
|
iterator: 'project',
|
||||||
|
url: scope.current_url
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
scope.SCMUpdate = function (project_id) {
|
scope.SCMUpdate = function (project_id) {
|
||||||
for (var i=0; i < scope.projects.length; i++) {
|
var i;
|
||||||
if (scope.projects[i].id == project_id) {
|
for (i = 0; i < scope.projects.length; i++) {
|
||||||
if (scope.projects[i].scm_type == "Manual" || scope.projects[i].scm_type == "" || scope.projects[i].scm_type == null ) {
|
if (scope.projects[i].id === project_id) {
|
||||||
|
if (scope.projects[i].scm_type === "Manual" || Empty(scope.projects[i].scm_type)) {
|
||||||
// Do not respond. Button appears greyed out as if it is disabled. Not disabled though, because we need mouse over event
|
// Do not respond. Button appears greyed out as if it is disabled. Not disabled though, because we need mouse over event
|
||||||
// to work. So user can click, but we just won't do anything.
|
// to work. So user can click, but we just won't do anything.
|
||||||
//Alert('Missing SCM Setup', 'Before running an SCM update, edit the project and provide the SCM access information.', 'alert-info');
|
//Alert('Missing SCM Setup', 'Before running an SCM update, edit the project and provide the SCM access information.', 'alert-info');
|
||||||
break;
|
break;
|
||||||
}
|
} else if (scope.projects[i].status === 'updating') {
|
||||||
else if (scope.projects[i].status == 'updating') {
|
|
||||||
Alert('Update in Progress', 'The SCM update process is running. Use the Refresh button to monitor the status.', 'alert-info');
|
Alert('Update in Progress', 'The SCM update process is running. Use the Refresh button to monitor the status.', 'alert-info');
|
||||||
}
|
} else {
|
||||||
else {
|
ProjectUpdate({
|
||||||
ProjectUpdate({ scope: scope, project_id: project_id });
|
scope: scope,
|
||||||
}
|
project_id: project_id
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'ProjectList', 'GenerateList',
|
ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'ProjectList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath',
|
||||||
'GetBasePath', 'SelectionInit', 'ProjectUpdate', 'ProjectStatus', 'FormatDate', 'Refresh', 'Wait', 'Stream',
|
'SelectionInit', 'ProjectUpdate', 'ProjectStatus', 'FormatDate', 'Refresh', 'Wait', 'Stream', 'GetChoices', 'Empty'
|
||||||
'GetChoices' ];
|
];
|
||||||
|
|
||||||
|
|
||||||
function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
||||||
GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
|
GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
|
||||||
CredentialList, GetChoices, DebugForm, Wait)
|
CredentialList, GetChoices, DebugForm, Wait) {
|
||||||
{
|
|
||||||
ClearScope('tree-form');
|
ClearScope('tree-form');
|
||||||
ClearScope('htmlTemplate');
|
ClearScope('htmlTemplate');
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var form = ProjectsForm;
|
var form = ProjectsForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
var defaultUrl = GetBasePath('projects');
|
defaultUrl = GetBasePath('projects'),
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
scope = generator.inject(form, { mode: 'add', related: false }),
|
||||||
var id = $routeParams.id;
|
master = {};
|
||||||
var master = {};
|
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
GetProjectPath({ scope: scope, master: master });
|
GetProjectPath({
|
||||||
|
scope: scope,
|
||||||
|
master: master
|
||||||
|
});
|
||||||
|
|
||||||
if (scope.removeChoicesReady) {
|
if (scope.removeChoicesReady) {
|
||||||
scope.removeChoicesReady();
|
scope.removeChoicesReady();
|
||||||
}
|
}
|
||||||
scope.removeChoicesReady = scope.$on('choicesReady', function () {
|
scope.removeChoicesReady = scope.$on('choicesReady', function () {
|
||||||
for (var i=0; i < scope.scm_type_options.length; i++) {
|
var i;
|
||||||
if (scope.scm_type_options[i].value == '') {
|
for (i = 0; i < scope.scm_type_options.length; i++) {
|
||||||
scope['scm_type'] = scope.scm_type_options[i];
|
if (scope.scm_type_options[i].value === '') {
|
||||||
|
scope.scm_type = scope.scm_type_options[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.scmRequired = false;
|
scope.scmRequired = false;
|
||||||
master['scm_type'] = scope['scm_type'];
|
master.scm_type = scope.scm_type;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load the list of options for Kind
|
// Load the list of options for Kind
|
||||||
@@ -390,15 +417,15 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var i, fld, url, data={};
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
var data = {};
|
data = {};
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (form.fields[fld].type == 'checkbox_group') {
|
if (form.fields[fld].type === 'checkbox_group') {
|
||||||
for (var i=0; i < form.fields[fld].fields.length; i++) {
|
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
||||||
data[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
|
data[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (form.fields[fld].type !== 'alertblock') {
|
if (form.fields[fld].type !== 'alertblock') {
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
@@ -407,54 +434,61 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
data.scm_type = scope.scm_type.value;
|
data.scm_type = scope.scm_type.value;
|
||||||
if (scope.scm_type.value !== '') {
|
if (scope.scm_type.value !== '') {
|
||||||
delete data.local_path;
|
delete data.local_path;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
data.local_path = scope.local_path.value;
|
data.local_path = scope.local_path.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
url = (base === 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var id = data.id;
|
var id = data.id,
|
||||||
var url = GetBasePath('projects') + id + '/organizations/';
|
url = GetBasePath('projects') + id + '/organizations/',
|
||||||
var org = { id: scope.organization };
|
org = { id: scope.organization };
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(org)
|
Rest.post(org)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$rootScope.flashMessage = "New project successfully created!";
|
$rootScope.flashMessage = "New project successfully created!";
|
||||||
(base == 'projects') ? ReturnToCaller() : ReturnToCaller(1);
|
if (base === 'projects') {
|
||||||
|
ReturnToCaller();
|
||||||
|
}
|
||||||
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, ProjectsForm,
|
ProcessErrors(scope, data, status, ProjectsForm, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to add organization to project. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to add organization to project. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, ProjectsForm,
|
ProcessErrors(scope, data, status, ProjectsForm, {
|
||||||
{ hdr: 'Error!', msg: 'Failed to create new project. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to create new project. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.scmChange = function () {
|
scope.scmChange = function () {
|
||||||
// When an scm_type is set, path is not required
|
// When an scm_type is set, path is not required
|
||||||
if (scope.scm_type) {
|
if (scope.scm_type) {
|
||||||
scope.pathRequired = (scope.scm_type.value == '') ? true : false;
|
scope.pathRequired = (scope.scm_type.value === '') ? true : false;
|
||||||
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
|
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
|
||||||
scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
|
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
|
var fld;
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
generator.reset();
|
generator.reset();
|
||||||
for (var fld in master) {
|
for (fld in master) {
|
||||||
scope[fld] = master[fld];
|
scope.fld = master.fld;
|
||||||
}
|
}
|
||||||
scope.scmChange();
|
scope.scmChange();
|
||||||
};
|
};
|
||||||
@@ -468,24 +502,23 @@ ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log',
|
|||||||
|
|
||||||
|
|
||||||
function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt,
|
||||||
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath,
|
ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, Authorization, CredentialList, LookUpInit, GetChoices,
|
||||||
Authorization, CredentialList, LookUpInit, GetChoices, Empty, DebugForm, Wait, Stream)
|
Empty, DebugForm, Wait, Stream) {
|
||||||
{
|
|
||||||
ClearScope('tree-form');
|
|
||||||
ClearScope('htmlTemplate');
|
ClearScope('htmlTemplate');
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var form = ProjectsForm;
|
var form = ProjectsForm,
|
||||||
var generator = GenerateForm;
|
generator = GenerateForm,
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
scope = generator.inject(form, { mode: 'edit', related: true }),
|
||||||
generator.reset();
|
defaultUrl = GetBasePath('projects') + $routeParams.id + '/',
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {},
|
||||||
|
id = $routeParams.id,
|
||||||
|
relatedSets = {};
|
||||||
|
|
||||||
var defaultUrl = GetBasePath('projects') + $routeParams.id + '/';
|
generator.reset();
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
|
||||||
var master = {};
|
|
||||||
var id = $routeParams.id;
|
|
||||||
var relatedSets = {};
|
|
||||||
|
|
||||||
scope.project_local_paths = [];
|
scope.project_local_paths = [];
|
||||||
scope.base_dir = '';
|
scope.base_dir = '';
|
||||||
@@ -495,18 +528,21 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
scope.projectLoadedRemove();
|
scope.projectLoadedRemove();
|
||||||
}
|
}
|
||||||
scope.projectLoadedRemove = scope.$on('projectLoaded', function () {
|
scope.projectLoadedRemove = scope.$on('projectLoaded', function () {
|
||||||
for (var set in relatedSets) {
|
var set, opts=[];
|
||||||
|
|
||||||
|
for (set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Authorization.getUserInfo('is_superuser') == true) {
|
if (Authorization.getUserInfo('is_superuser') === true) {
|
||||||
GetProjectPath({ scope: scope, master: master });
|
GetProjectPath({ scope: scope, master: master });
|
||||||
}
|
} else {
|
||||||
else {
|
opts.push({
|
||||||
var opts = [];
|
label: scope.local_path,
|
||||||
opts.push({ label: scope['local_path'], value: scope['local_path'] });
|
value: scope.local_path
|
||||||
|
});
|
||||||
scope.project_local_paths = opts;
|
scope.project_local_paths = opts;
|
||||||
scope.local_path = scope['project_local_paths'][0];
|
scope.local_path = scope.project_local_paths[0];
|
||||||
scope.base_dir = 'You do not have access to view this property';
|
scope.base_dir = 'You do not have access to view this property';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,9 +554,9 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
field: 'credential'
|
field: 'credential'
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.pathRequired = (scope.scm_type.value == '') ? true : false;
|
scope.pathRequired = (scope.scm_type.value === '') ? true : false;
|
||||||
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
|
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
|
||||||
scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
|
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -531,16 +567,16 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.get({ params: { id: id } })
|
Rest.get({ params: { id: id } })
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
|
var related, set, fld, i;
|
||||||
LoadBreadCrumbs({ path: '/projects/' + id, title: data.name });
|
LoadBreadCrumbs({ path: '/projects/' + id, title: data.name });
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (form.fields[fld].type == 'checkbox_group') {
|
if (form.fields[fld].type === 'checkbox_group') {
|
||||||
for (var i=0; i < form.fields[fld].fields.length; i++) {
|
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
||||||
scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
|
scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
|
||||||
master[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
|
master[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
master[fld] = data[fld];
|
master[fld] = data[fld];
|
||||||
@@ -554,17 +590,20 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.scm_type = (Empty(data.scm_type)) ? '' : data.scm_type;
|
data.scm_type = (Empty(data.scm_type)) ? '' : data.scm_type;
|
||||||
|
|
||||||
for (var i=0; i < scope.scm_type_options.length; i++) {
|
for (i = 0; i < scope.scm_type_options.length; i++) {
|
||||||
if (scope.scm_type_options[i].value == data.scm_type) {
|
if (scope.scm_type_options[i].value === data.scm_type) {
|
||||||
scope.scm_type = scope.scm_type_options[i];
|
scope.scm_type = scope.scm_type_options[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -573,23 +612,31 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
if (scope.scm_type.value !== '') {
|
if (scope.scm_type.value !== '') {
|
||||||
scope.pathRequired = false;
|
scope.pathRequired = false;
|
||||||
scope.scmRequired = true;
|
scope.scmRequired = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.pathRequired = true;
|
scope.pathRequired = true;
|
||||||
scope.scmRequired = false;
|
scope.scmRequired = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
master['scm_type'] = scope['scm_type'];
|
master.scm_type = scope.scm_type;
|
||||||
scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
|
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
|
||||||
|
|
||||||
// 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.$emit('projectLoaded');
|
scope.$emit('projectLoaded');
|
||||||
})
|
})
|
||||||
.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 project: ' + id + '. GET status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve project: ' + id + '. GET status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -606,17 +653,17 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var fld, i, params;
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
var params = {};
|
params = {};
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (form.fields[fld].type == 'checkbox_group') {
|
if (form.fields[fld].type === 'checkbox_group') {
|
||||||
for (var i=0; i < form.fields[fld].fields.length; i++) {
|
for (i = 0; i < form.fields[fld].fields.length; i++) {
|
||||||
params[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
|
params[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (form.fields[fld].type !== 'alertblock') {
|
if (form.fields[fld].type !== 'alertblock') {
|
||||||
params[fld] = scope[fld];
|
params[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
@@ -626,25 +673,27 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
params.scm_type = scope.scm_type.value;
|
params.scm_type = scope.scm_type.value;
|
||||||
if (scope.scm_type.value !== '') {
|
if (scope.scm_type.value !== '') {
|
||||||
delete params.local_path;
|
delete params.local_path;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
params.local_path = scope.local_path.value;
|
params.local_path = scope.local_path.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.put(params)
|
Rest.put(params)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ReturnToCaller();
|
ReturnToCaller();
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Related set: Add button
|
// Related set: Add button
|
||||||
scope.add = function (set) {
|
scope.add = function (set) {
|
||||||
@@ -653,7 +702,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 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;
|
||||||
$location.path('/' + set + '/' + id);
|
$location.path('/' + set + '/' + id);
|
||||||
};
|
};
|
||||||
@@ -665,30 +714,30 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
Rest.post({ id: itm_id, disassociate: 1 })
|
||||||
.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 + ' failed. POST returned status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
scope.scmChange = function () {
|
scope.scmChange = function () {
|
||||||
if (scope.scm_type) {
|
if (scope.scm_type) {
|
||||||
scope.pathRequired = (scope.scm_type.value == '') ? true : false;
|
scope.pathRequired = (scope.scm_type.value === '') ? true : false;
|
||||||
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
|
scope.scmRequired = (scope.scm_type.value !== '') ? true : false;
|
||||||
scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
|
scope.scmBranchLabel = (scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
@@ -698,13 +747,11 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
scope[fld] = master[fld];
|
scope[fld] = master[fld];
|
||||||
}
|
}
|
||||||
scope.scmChange();
|
scope.scmChange();
|
||||||
//DebugForm({ scope: scope, form: form });
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
|
ProjectsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm', 'GenerateForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'Prompt', 'ClearScope',
|
||||||
'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
|
'GetBasePath', 'ReturnToCaller', 'GetProjectPath', 'Authorization', 'CredentialList', 'LookUpInit', 'GetChoices', 'Empty',
|
||||||
'GetProjectPath', 'Authorization', 'CredentialList', 'LookUpInit', 'GetChoices', 'Empty',
|
|
||||||
'DebugForm', 'Wait', 'Stream'
|
'DebugForm', 'Wait', 'Stream'
|
||||||
];
|
];
|
||||||
@@ -10,50 +10,71 @@
|
|||||||
|
|
||||||
'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) {
|
||||||
|
|
||||||
@@ -62,54 +83,47 @@ function TeamsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale
|
|||||||
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',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
scope.lookupOrganization = function(organization_id) {
|
|
||||||
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
return data.name;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
$rootScope.flashMessage = null;
|
||||||
generator.reset();
|
generator.reset();
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
@@ -124,23 +138,24 @@ function TeamsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var fld, data;
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
var data = {}
|
data = {};
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$rootScope.flashMessage = "New team successfully created!";
|
$rootScope.flashMessage = "New team successfully created!";
|
||||||
$location.path('/teams/' + data.id);
|
$location.path('/teams/' + data.id);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to add new team. Post returned status: ' +
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new team. Post returned status: ' + status });
|
status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,27 +168,27 @@ function TeamsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -183,16 +198,16 @@ function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
}
|
}
|
||||||
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);
|
||||||
@@ -202,63 +217,85 @@ function TeamsEdit ($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({
|
||||||
.success( function(data, status, headers, config) {
|
params: {
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.success(function (data) {
|
||||||
|
var fld, related, set;
|
||||||
LoadBreadCrumbs({ path: '/teams/' + id, title: data.name });
|
LoadBreadCrumbs({ path: '/teams/' + id, title: data.name });
|
||||||
for (var fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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
|
||||||
|
});
|
||||||
|
|
||||||
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 () {
|
||||||
|
var data = {}, fld;
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
Wait('start');
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
Rest.setUrl(defaultUrl + $routeParams.team_id + '/');
|
Rest.setUrl(defaultUrl + $routeParams.team_id + '/');
|
||||||
var data = {}
|
for (fld in form.fields) {
|
||||||
for (var 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();
|
||||||
|
}
|
||||||
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||||
{ hdr: 'Error!', msg: 'Failed to update team: ' + $routeParams.team_id + '. PUT status: ' + status });
|
msg: 'Failed to update team: ' + $routeParams.team_id + '. PUT status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -274,26 +311,23 @@ function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// 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 {
|
||||||
else {
|
|
||||||
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set);
|
$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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -304,52 +338,48 @@ function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
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 {
|
||||||
else {
|
url = defaultUrl + $routeParams.team_id + '/' + set + '/';
|
||||||
var url = defaultUrl + $routeParams.team_id + '/' + set + '/';
|
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
Rest.post({ id: itm_id, disassociate: 1 })
|
||||||
.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. POST returned status: ' + status });
|
' failed. POST returned status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
||||||
action: action
|
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,27 +7,30 @@
|
|||||||
* 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();
|
||||||
@@ -39,65 +42,81 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale
|
|||||||
});
|
});
|
||||||
|
|
||||||
$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 () {
|
||||||
|
Wait('start');
|
||||||
|
});
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
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 () {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.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: 'Call to ' + url + ' failed. DELETE returned status: ' +
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
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');
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
|
||||||
//scope.
|
|
||||||
|
|
||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var defaultUrl = GetBasePath('organizations');
|
var defaultUrl = GetBasePath('organizations'),
|
||||||
var form = UserForm;
|
form = UserForm,
|
||||||
|
generator = GenerateForm,
|
||||||
|
scope = generator.inject(form, { mode: 'add', related: false });
|
||||||
|
|
||||||
ResetForm();
|
ResetForm();
|
||||||
var generator = GenerateForm;
|
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
|
||||||
|
|
||||||
scope.ldap_user = false;
|
scope.ldap_user = false;
|
||||||
scope.not_ldap_user = !scope.ldap_user;
|
scope.not_ldap_user = !scope.ldap_user;
|
||||||
@@ -121,51 +140,46 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.organization = $routeParams.organization_id;
|
scope.organization = $routeParams.organization_id;
|
||||||
Rest.setUrl(GetBasePath('organizations') + $routeParams.organization_id + '/');
|
Rest.setUrl(GetBasePath('organizations') + $routeParams.organization_id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
scope['organization_name'] = data.name;
|
scope.organization_name = data.name;
|
||||||
})
|
})
|
||||||
.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 lookup Organization: ' + data.id + '. GET returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to lookup Organization: ' + data.id + '. GET returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
|
var fld, data = {};
|
||||||
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
||||||
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
||||||
var data = {}
|
for (fld in form.fields) {
|
||||||
for (var 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 || false;
|
||||||
data.is_superuser = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
|
||||||
data.is_superuser;
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
var base = $location.path().replace(/^\//, '').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
if (base == 'users') {
|
if (base === 'users') {
|
||||||
$rootScope.flashMessage = 'New user successfully created!';
|
$rootScope.flashMessage = 'New user successfully created!';
|
||||||
$location.path('/users/' + data.id);
|
$location.path('/users/' + data.id);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ReturnToCaller(1);
|
ReturnToCaller(1);
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to add new user. POST returned status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new user. POST returned status: ' + status });
|
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scope.organization_name_api_error = 'A value is required';
|
scope.organization_name_api_error = 'A value is required';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -182,29 +196,29 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// 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);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
@@ -227,30 +241,35 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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({
|
||||||
|
scope: scope
|
||||||
|
}); //Does the user have access to add/edit Permissions?
|
||||||
Wait('stop');
|
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;
|
||||||
|
for (fld in form.fields) {
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
if (fld == 'is_superuser') {
|
if (fld === 'is_superuser') {
|
||||||
scope[fld] = (data[fld] == 'true' || data[fld] == true) ? 'true' : 'false';
|
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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,48 +278,60 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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,
|
||||||
|
form: form,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
|
RelatedPaginateInit({
|
||||||
|
scope: scope,
|
||||||
|
relatedSets: relatedSets
|
||||||
|
});
|
||||||
scope.$emit('userLoaded');
|
scope.$emit('userLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve user: ' +
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve user: ' + $routeParams.id + '. GET status: ' + status });
|
$routeParams.id + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function () {
|
scope.formSave = function () {
|
||||||
|
var data = {}, fld;
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
var data = {}
|
for (fld in form.fields) {
|
||||||
for (var 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();
|
||||||
|
}
|
||||||
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error(function (data, status) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form, { hdr: 'Error!', msg: 'Failed to update users: ' + $routeParams.id +
|
||||||
{ hdr: 'Error!', msg: 'Failed to update users: ' + $routeParams.id + '. PUT status: ' + status });
|
'. PUT status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.showActivity = function() { Stream({ scope: scope }); }
|
scope.showActivity = function () {
|
||||||
|
Stream({
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function () {
|
scope.formReset = function () {
|
||||||
@@ -309,7 +340,7 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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
|
||||||
@@ -318,32 +349,29 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
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 {
|
||||||
else {
|
|
||||||
$location.path('/' + base + '/' + $routeParams.user_id + '/' + set);
|
$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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -354,47 +382,50 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
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!',
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
msg: 'Call to ' + url + ' 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 {
|
||||||
else {
|
|
||||||
url = defaultUrl + $routeParams.user_id + '/' + set + '/';
|
url = defaultUrl + $routeParams.user_id + '/' + set + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
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. POST returned status: ' + status });
|
hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. POST returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.username + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.username + ' ' + title + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
}); // $scope.$on
|
}); // $scope.$on
|
||||||
|
|
||||||
// Put form back to its original state
|
// Put form back to its original state
|
||||||
@@ -408,14 +439,14 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Modify form based on LDAP settings
|
// Modify form based on LDAP settings
|
||||||
Rest.setUrl(GetBasePath('config'));
|
Rest.setUrl(GetBasePath('config'));
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
if (data['user_ldap_fields']) {
|
var i, fld;
|
||||||
var fld;
|
if (data.user_ldap_fields) {
|
||||||
for (var i=0; i < data['user_ldap_fields'].length; i++) {
|
for (i = 0; i < data.user_ldap_fields.length; i++) {
|
||||||
fld = data['user_ldap_fields'][i];
|
fld = data.user_ldap_fields[i];
|
||||||
if (form.fields[fld]) {
|
if (form.fields[fld]) {
|
||||||
form.fields[fld]['readonly'] = true;
|
form.fields[fld].readonly = true;
|
||||||
form.fields[fld]['editRequired'] = false;
|
form.fields[fld].editRequired = false;
|
||||||
if (form.fields[fld].awRequiredWhen) {
|
if (form.fields[fld].awRequiredWhen) {
|
||||||
delete form.fields[fld].awRequiredWhen;
|
delete form.fields[fld].awRequiredWhen;
|
||||||
}
|
}
|
||||||
@@ -424,32 +455,28 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
}
|
}
|
||||||
$scope.$emit('formReady');
|
$scope.$emit('formReady');
|
||||||
})
|
})
|
||||||
.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 application config. GET status: ' + status });
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve application config. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success(function (data) {
|
||||||
if (data.ldap_dn !== null && data.ldap_dn !== undefined && data.ldap_dn !== '') {
|
if (data.ldap_dn !== null && data.ldap_dn !== undefined && data.ldap_dn !== '') {
|
||||||
//this is an LDAP user
|
//this is an LDAP user
|
||||||
$scope.$emit('modifyForm');
|
$scope.$emit('modifyForm');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.$emit('formReady');
|
$scope.$emit('formReady');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.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 user: ' + id + '. GET status: ' + status });
|
||||||
{ 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