update edit controller to PUT app instead of POST

remove old applications tokens code
This commit is contained in:
John Mitchell 2018-03-12 17:40:08 -04:00
parent 80db90b34c
commit 9d6fab9417
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
4 changed files with 5 additions and 201 deletions

View File

@ -97,7 +97,11 @@ function EditApplicationsController (models, $state, strings, $scope) {
const payload = _.merge(data, hiddenData);
return application.request('post', { data: payload });
return application.request('put', { data: payload });
};
vm.form.onSaveSuccess = () => {
$state.go('applications.edit', { application_id: application.get('id') }, { reload: true });
};
}

View File

@ -1,22 +0,0 @@
export default ['i18n', function(i18n) {
return {
name: 'applications',
search: {
order_by: 'id'
},
iterator: 'application',
// TODO: change
basePath: 'projects',
listTitle: i18n._('APPLICATIONS'),
index: false,
hover: true,
fields: {
name: {
key: true,
label: i18n._('Name'),
columnClass: 'col-md-3 col-sm-3 col-xs-9'
},
}
};}];

View File

@ -1,108 +0,0 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default ['Rest', 'Wait', 'UserTokensFormObject',
'ProcessErrors', 'GetBasePath', 'Alert',
'GenerateForm', '$scope', '$state', 'CreateSelect2', 'GetChoices' 'i18n',
function(
Rest, Wait, UserTokensFormObject,
ProcessErrors, GetBasePath, Alert,
GenerateForm, $scope, $state, CreateSelect2, GetChoices i18n
) {
var generator = GenerateForm,
form = UserTokensFormObject;
init();
function init() {
Rest.setUrl(GetBasePath('users') + '/authorized_tokens');
Rest.options()
.then(({data}) => {
if (!data.actions.POST) {
$state.go("^");
Alert('Permission Error', 'You do not have permission to add a token.', 'alert-info');
}
});
// apply form definition's default field values
GenerateForm.applyDefaults(form, $scope);
}
CreateSelect2({
element: '#user_token_scope',
multiple: false
});
// Save
$scope.formSave = function() {
// var params,
// v = $scope.notification_type.value;
//
// generator.clearApiErrors($scope);
// params = {
// "name": $scope.name,
// "description": $scope.description,
// "organization": $scope.organization,
// "notification_type": v,
// "notification_configuration": {}
// };
//
// function processValue(value, i, field) {
// if (field.type === 'textarea') {
// if (field.name === 'headers') {
// $scope[i] = JSON.parse($scope[i]);
// } else {
// $scope[i] = $scope[i].toString().split('\n');
// }
// }
// if (field.type === 'checkbox') {
// $scope[i] = Boolean($scope[i]);
// }
// if (field.type === 'number') {
// $scope[i] = Number($scope[i]);
// }
// if (i === "username" && $scope.notification_type.value === "email" && value === null) {
// $scope[i] = "";
// }
// if (field.type === 'sensitive' && value === null) {
// $scope[i] = "";
// }
// return $scope[i];
// }
//
// params.notification_configuration = _.object(Object.keys(form.fields)
// .filter(i => (form.fields[i].ngShow && form.fields[i].ngShow.indexOf(v) > -1))
// .map(i => [i, processValue($scope[i], i, form.fields[i])]));
//
// delete params.notification_configuration.email_options;
//
// for(var j = 0; j < form.fields.email_options.options.length; j++) {
// if(form.fields.email_options.options[j].ngShow && form.fields.email_options.options[j].ngShow.indexOf(v) > -1) {
// params.notification_configuration[form.fields.email_options.options[j].value] = Boolean($scope[form.fields.email_options.options[j].value]);
// }
// }
//
// Wait('start');
// Rest.setUrl(url);
// Rest.post(params)
// .then(() => {
// $state.go('notifications', {}, { reload: true });
// Wait('stop');
// })
// .catch(({data, status}) => {
// ProcessErrors($scope, data, status, form, {
// hdr: 'Error!',
// msg: 'Failed to add new notifier. POST returned status: ' + status
// });
// });
};
$scope.formCancel = function() {
$state.go('notifications');
};
}
];

View File

@ -1,70 +0,0 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
/**
* @ngdoc function
* @name forms.function:Tokens
* @description This form is for adding a token on the user's page
*/
export default ['i18n',
function(i18n) {
return {
addTitle: i18n._('CREATE TOKEN'),
name: 'token',
basePath: 'tokens',
well: false,
formLabelSize: 'col-lg-3',
formFieldSize: 'col-lg-9',
iterator: 'token',
stateTree: 'users',
fields: {
application: {
label: i18n._('Application'),
type: 'lookup',
list: 'ApplicationList',
sourceModel: 'application',
// TODO: update to actual path
basePath: 'projects',
sourceField: 'name',
dataTitle: i18n._('Application'),
required: true,
dataContainer: 'body',
dataPlacement: 'right',
ngDisabled: '!(token.summary_fields.user_capabilities.edit || canAdd)',
awLookupWhen: '(token.summary_fields.user_capabilities.edit || canAdd)'
// TODO: help popover
},
scope: {
label: i18n._('Description'),
type: 'select',
class: 'Form-dropDown--scmType',
defaultText: 'Choose a scope',
ngOptions: 'scope.label for scope in scope_options track by scope.value',
required: true,
ngDisabled: '!(token.summary_fields.user_capabilities.edit || canAdd)'
// TODO: help popover
}
},
buttons: {
cancel: {
ngClick: 'formCancel()',
ngShow: '(token.summary_fields.user_capabilities.edit || canAdd)'
},
close: {
ngClick: 'formCancel()',
ngShow: '!(token.summary_fields.user_capabilities.edit || canAdd)'
},
save: {
ngClick: 'formSave()',
ngDisabled: true,
ngShow: '(token.summary_fields.user_capabilities.edit || canAdd)'
}
},
related: {
}
};
}];