mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
Merge pull request #601 from mabashian/275-delete-warnings
More verbose delete warnings
This commit is contained in:
commit
2ab33467d8
@ -45,6 +45,7 @@ module.exports = {
|
||||
ignoreTemplateLiterals: true,
|
||||
}],
|
||||
'no-continue': 'off',
|
||||
'no-debugger': 'off',
|
||||
'no-mixed-operators': 'off',
|
||||
'no-param-reassign': 'off',
|
||||
'no-plusplus': 'off',
|
||||
|
||||
@ -42,7 +42,7 @@ function AddCredentialsController (models, $state, strings) {
|
||||
vm.form.save = data => {
|
||||
data.user = me.get('id');
|
||||
|
||||
return credential.request('post', data);
|
||||
return credential.request('post', { data });
|
||||
};
|
||||
|
||||
vm.form.onSaveSuccess = res => {
|
||||
|
||||
@ -27,6 +27,11 @@ function CredentialsStrings (BaseString) {
|
||||
ns.permissions = {
|
||||
TITLE: t.s('CREDENTIALS PERMISSIONS')
|
||||
};
|
||||
|
||||
ns.deleteCredential = {
|
||||
CONFIRM: t.s('Are you sure you want to delete this credential?'),
|
||||
INVALIDATE: t.s('Doing so will invalidate the following:')
|
||||
};
|
||||
}
|
||||
|
||||
CredentialsStrings.$inject = ['BaseStringService'];
|
||||
|
||||
@ -88,7 +88,7 @@ function EditCredentialsController (models, $state, $scope, strings) {
|
||||
data.user = me.get('id');
|
||||
credential.unset('inputs');
|
||||
|
||||
return credential.request('put', data);
|
||||
return credential.request('put', { data });
|
||||
};
|
||||
|
||||
vm.form.onSaveSuccess = () => {
|
||||
|
||||
@ -33,7 +33,10 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="Modal-content modal-content">
|
||||
<div class="Modal-header">
|
||||
<div class="Modal-title" ng-bind="promptHeader" id="prompt-header"></div>
|
||||
<div class="Modal-title" id="prompt-header">
|
||||
<span ng-bind="promptHeader"></span>
|
||||
<span class="Modal-titleResourceName" ng-bind="promptResourceName"></span>
|
||||
</div>
|
||||
<div class="Modal-exitHolder">
|
||||
<button class="close Modal-exit" data-target="#prompt-modal" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times-circle"></i></button>
|
||||
</div>
|
||||
@ -42,7 +45,7 @@
|
||||
</div>
|
||||
<div class="Modal-footer">
|
||||
<a href="#" data-target="#prompt-modal" data-dismiss="modal" id="prompt_cancel_btn" class="btn Modal-defaultButton Modal-footerButton" translate>CANCEL</a>
|
||||
<a href="" ng-class="promptActionBtnClass" ng-click="promptAction()" id="prompt_action_btn" class="btn Modal-footerButton" ng-bind="promptActionText"></a>
|
||||
<a href="" ng-hide="hideActionButton" ng-class="promptActionBtnClass" ng-click="promptAction()" id="prompt_action_btn" class="btn Modal-footerButton" ng-bind="promptActionText"></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- modal-content -->
|
||||
|
||||
@ -1,34 +1,46 @@
|
||||
let $http;
|
||||
let $q;
|
||||
let cache;
|
||||
let strings;
|
||||
|
||||
function request (method, resource) {
|
||||
if (Array.isArray(method)) {
|
||||
const promises = method.map((_method_, i) =>
|
||||
this.request(_method_, Array.isArray(resource) ? resource[i] : resource));
|
||||
function request (method, resource, config) {
|
||||
let req = this.parseRequestConfig(method, resource, config);
|
||||
|
||||
if (Array.isArray(req.method)) {
|
||||
const promises = req.method.map((_method, i) => {
|
||||
const _resource = Array.isArray(req.resource) ? req.resource[i] : req.resource;
|
||||
|
||||
req = this.parseRequestConfig(_method, _resource, config);
|
||||
|
||||
if (this.isCacheable(req)) {
|
||||
return this.requestWithCache(req);
|
||||
}
|
||||
|
||||
return this.request(req);
|
||||
});
|
||||
|
||||
return $q.all(promises);
|
||||
}
|
||||
|
||||
if (this.isCacheable(method, resource)) {
|
||||
return this.requestWithCache(method, resource);
|
||||
if (this.isCacheable(req)) {
|
||||
return this.requestWithCache(req);
|
||||
}
|
||||
|
||||
return this.http[method](resource);
|
||||
return this.http[req.method](req);
|
||||
}
|
||||
|
||||
function requestWithCache (method, resource) {
|
||||
const key = cache.createKey(method, this.path, resource);
|
||||
function requestWithCache (config) {
|
||||
const key = cache.createKey(config.method, this.path, config.resource);
|
||||
|
||||
return cache.get(key)
|
||||
.then(data => {
|
||||
if (data) {
|
||||
this.model[method.toUpperCase()] = data;
|
||||
this.model[config.method.toUpperCase()] = data;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
return this.http[method](resource)
|
||||
return this.http[config.method](config)
|
||||
.then(res => {
|
||||
cache.put(key, res.data);
|
||||
|
||||
@ -77,18 +89,22 @@ function search (params, config) {
|
||||
});
|
||||
}
|
||||
|
||||
function httpGet (resource) {
|
||||
function httpGet (config = {}) {
|
||||
const req = {
|
||||
method: 'GET',
|
||||
url: this.path
|
||||
};
|
||||
|
||||
if (typeof resource === 'object') {
|
||||
this.model.GET = resource;
|
||||
if (config.params) {
|
||||
req.params = config.params;
|
||||
}
|
||||
|
||||
if (typeof config.resource === 'object') {
|
||||
this.model.GET = config.resource;
|
||||
|
||||
return $q.resolve();
|
||||
} else if (resource) {
|
||||
req.url = `${this.path}${resource}/`;
|
||||
} else if (config.resource) {
|
||||
req.url = `${this.path}${config.resource}/`;
|
||||
}
|
||||
|
||||
return $http(req)
|
||||
@ -99,40 +115,51 @@ function httpGet (resource) {
|
||||
});
|
||||
}
|
||||
|
||||
function httpPost (data) {
|
||||
function httpPost (config = {}) {
|
||||
const req = {
|
||||
method: 'POST',
|
||||
url: this.path,
|
||||
data
|
||||
data: config.data
|
||||
};
|
||||
|
||||
return $http(req).then(res => {
|
||||
this.model.GET = res.data;
|
||||
return $http(req)
|
||||
.then(res => {
|
||||
this.model.GET = res.data;
|
||||
|
||||
return res;
|
||||
});
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
function httpPut (changes) {
|
||||
const model = Object.assign(this.get(), changes);
|
||||
function httpPatch (config = {}) {
|
||||
const req = {
|
||||
method: 'PUT',
|
||||
url: `${this.path}${this.get('id')}/`,
|
||||
data: config.changes
|
||||
};
|
||||
|
||||
return $http(req);
|
||||
}
|
||||
|
||||
function httpPut (config = {}) {
|
||||
const model = _.merge(this.get(), config.data);
|
||||
|
||||
const req = {
|
||||
method: 'PUT',
|
||||
url: `${this.path}${model.id}/`,
|
||||
url: `${this.path}${this.get('id')}/`,
|
||||
data: model
|
||||
};
|
||||
|
||||
return $http(req).then(res => res);
|
||||
return $http(req);
|
||||
}
|
||||
|
||||
function httpOptions (resource) {
|
||||
function httpOptions (config = {}) {
|
||||
const req = {
|
||||
method: 'OPTIONS',
|
||||
url: this.path
|
||||
};
|
||||
|
||||
if (resource) {
|
||||
req.url = `${this.path}${resource}/`;
|
||||
if (config.resource) {
|
||||
req.url = `${this.path}${config.resource}/`;
|
||||
}
|
||||
|
||||
return $http(req)
|
||||
@ -143,6 +170,19 @@ function httpOptions (resource) {
|
||||
});
|
||||
}
|
||||
|
||||
function httpDelete (config = {}) {
|
||||
const req = {
|
||||
method: 'DELETE',
|
||||
url: this.path
|
||||
};
|
||||
|
||||
if (config.resource) {
|
||||
req.url = `${this.path}${config.resource}/`;
|
||||
}
|
||||
|
||||
return $http(req);
|
||||
}
|
||||
|
||||
function options (keys) {
|
||||
return this.find('options', keys);
|
||||
}
|
||||
@ -349,6 +389,22 @@ function graft (id) {
|
||||
return new this.Constructor('get', item, true);
|
||||
}
|
||||
|
||||
function getDependentResourceCounts (id) {
|
||||
this.setDependentResources(id);
|
||||
|
||||
const promises = [];
|
||||
|
||||
this.dependentResources.forEach(resource => {
|
||||
promises.push(resource.model.request('get', { params: resource.params })
|
||||
.then(res => ({
|
||||
label: resource.model.label,
|
||||
count: res.data.count
|
||||
})));
|
||||
});
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* `create` is called on instantiation of every model. Models can be
|
||||
* instantiated empty or with `GET` and/or `OPTIONS` requests that yield data.
|
||||
@ -358,20 +414,22 @@ function graft (id) {
|
||||
* @arg {string=} method - Populate the model with `GET` or `OPTIONS` data.
|
||||
* @arg {(string|Object)=} resource - An `id` reference to a particular
|
||||
* resource or an existing model's data.
|
||||
* @arg {boolean=} isGraft - Create a new instance from existing model data.
|
||||
* @arg {config=} config - Create a new instance from existing model data.
|
||||
*
|
||||
* @returns {(Object|Promise)} - Returns a reference to the model instance
|
||||
* if an empty instance or graft is created. Otherwise, a promise yielding
|
||||
* a model instance is returned.
|
||||
*/
|
||||
function create (method, resource, isGraft, config) {
|
||||
if (!method) {
|
||||
function create (method, resource, config) {
|
||||
const req = this.parseRequestConfig(method, resource, config);
|
||||
|
||||
if (!req || !req.method) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.promise = this.request(method, resource, config);
|
||||
this.promise = this.request(req);
|
||||
|
||||
if (isGraft) {
|
||||
if (req.graft) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -379,17 +437,55 @@ function create (method, resource, isGraft, config) {
|
||||
.then(() => this);
|
||||
}
|
||||
|
||||
function parseRequestConfig (method, resource, config) {
|
||||
if (!method) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let req = {};
|
||||
|
||||
if (Array.isArray(method)) {
|
||||
if (Array.isArray(resource)) {
|
||||
req.resource = resource;
|
||||
} else if (resource === null) {
|
||||
req.resource = undefined;
|
||||
} else if (typeof resource === 'object') {
|
||||
req = resource;
|
||||
}
|
||||
|
||||
req.method = method;
|
||||
} else if (typeof method === 'string') {
|
||||
if (resource === null) {
|
||||
req.resource = undefined;
|
||||
} else if (typeof resource === 'object') {
|
||||
req = resource;
|
||||
} else {
|
||||
req.resource = resource;
|
||||
}
|
||||
|
||||
req.method = method;
|
||||
} else if (typeof method === 'object') {
|
||||
req = method;
|
||||
} else {
|
||||
req = config;
|
||||
req.method = method;
|
||||
req.resource = resource === null ? undefined : resource;
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base functionality for API interaction.
|
||||
*
|
||||
* @arg {string} path - The API resource for the model extending BaseModel to
|
||||
* @arg {string} resource - The API resource for the model extending BaseModel to
|
||||
* use.
|
||||
* @arg {Object=} settings - Configuration applied to all instances of the
|
||||
* extending model.
|
||||
* @arg {boolean=} settings.cache - Cache the model data.
|
||||
*
|
||||
*/
|
||||
function BaseModel (path, settings) {
|
||||
function BaseModel (resource, settings) {
|
||||
this.create = create;
|
||||
this.find = find;
|
||||
this.get = get;
|
||||
@ -401,33 +497,39 @@ function BaseModel (path, settings) {
|
||||
this.match = match;
|
||||
this.normalizePath = normalizePath;
|
||||
this.options = options;
|
||||
this.parseRequestConfig = parseRequestConfig;
|
||||
this.request = request;
|
||||
this.requestWithCache = requestWithCache;
|
||||
this.search = search;
|
||||
this.set = set;
|
||||
this.unset = unset;
|
||||
this.extend = extend;
|
||||
this.getDependentResourceCounts = getDependentResourceCounts;
|
||||
|
||||
this.http = {
|
||||
get: httpGet.bind(this),
|
||||
options: httpOptions.bind(this),
|
||||
patch: httpPatch.bind(this),
|
||||
post: httpPost.bind(this),
|
||||
put: httpPut.bind(this),
|
||||
delete: httpDelete.bind(this)
|
||||
};
|
||||
|
||||
this.model = {};
|
||||
this.path = this.normalizePath(path);
|
||||
this.path = this.normalizePath(resource);
|
||||
this.label = strings.get(`${resource}.LABEL`);
|
||||
this.settings = settings || {};
|
||||
}
|
||||
|
||||
function BaseModelLoader (_$http_, _$q_, _cache_) {
|
||||
function BaseModelLoader (_$http_, _$q_, _cache_, ModelsStrings) {
|
||||
$http = _$http_;
|
||||
$q = _$q_;
|
||||
cache = _cache_;
|
||||
strings = ModelsStrings;
|
||||
|
||||
return BaseModel;
|
||||
}
|
||||
|
||||
BaseModelLoader.$inject = ['$http', '$q', 'CacheService'];
|
||||
BaseModelLoader.$inject = ['$http', '$q', 'CacheService', 'ModelsStrings'];
|
||||
|
||||
export default BaseModelLoader;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
let $log;
|
||||
let BaseModel;
|
||||
let Base;
|
||||
|
||||
function getTruncatedVersion () {
|
||||
let version;
|
||||
@ -17,18 +17,18 @@ function isOpen () {
|
||||
return this.get('license_info.license_type') === 'open';
|
||||
}
|
||||
|
||||
function ConfigModel (method, resource, graft) {
|
||||
BaseModel.call(this, 'config', { cache: true });
|
||||
function ConfigModel (method, resource, config) {
|
||||
Base.call(this, 'config', { cache: true });
|
||||
|
||||
this.Constructor = ConfigModel;
|
||||
this.getTruncatedVersion = getTruncatedVersion;
|
||||
this.isOpen = isOpen;
|
||||
|
||||
return this.create(method, resource, graft);
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function ConfigModelLoader (_BaseModel_, _$log_) {
|
||||
BaseModel = _BaseModel_;
|
||||
function ConfigModelLoader (BaseModel, _$log_) {
|
||||
Base = BaseModel;
|
||||
$log = _$log_;
|
||||
|
||||
return ConfigModel;
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
const ENCRYPTED_VALUE = '$encrypted$';
|
||||
|
||||
let BaseModel;
|
||||
let Base;
|
||||
let Project;
|
||||
let JobTemplate;
|
||||
let Inventory;
|
||||
let InventorySource;
|
||||
|
||||
function createFormSchema (method, config) {
|
||||
if (!config) {
|
||||
@ -40,22 +44,69 @@ function assignInputGroupValues (inputs) {
|
||||
});
|
||||
}
|
||||
|
||||
function CredentialModel (method, resource, graft) {
|
||||
BaseModel.call(this, 'credentials');
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new Project(),
|
||||
params: {
|
||||
credential: id
|
||||
}
|
||||
},
|
||||
{
|
||||
model: new JobTemplate(),
|
||||
params: {
|
||||
credential: id,
|
||||
ask_credential_on_launch: false
|
||||
}
|
||||
},
|
||||
{
|
||||
model: new Inventory(),
|
||||
params: {
|
||||
insights_credential: id
|
||||
}
|
||||
},
|
||||
{
|
||||
model: new InventorySource(),
|
||||
params: {
|
||||
credential: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function CredentialModel (method, resource, config) {
|
||||
Base.call(this, 'credentials');
|
||||
|
||||
this.Constructor = CredentialModel;
|
||||
this.createFormSchema = createFormSchema.bind(this);
|
||||
this.assignInputGroupValues = assignInputGroupValues.bind(this);
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, graft);
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function CredentialModelLoader (_BaseModel_) {
|
||||
BaseModel = _BaseModel_;
|
||||
function CredentialModelLoader (
|
||||
BaseModel,
|
||||
ProjectModel,
|
||||
JobTemplateModel,
|
||||
InventoryModel,
|
||||
InventorySourceModel
|
||||
) {
|
||||
Base = BaseModel;
|
||||
Project = ProjectModel;
|
||||
JobTemplate = JobTemplateModel;
|
||||
Inventory = InventoryModel;
|
||||
InventorySource = InventorySourceModel;
|
||||
|
||||
return CredentialModel;
|
||||
}
|
||||
|
||||
CredentialModelLoader.$inject = ['BaseModel'];
|
||||
CredentialModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'ProjectModel',
|
||||
'JobTemplateModel',
|
||||
'InventoryModel',
|
||||
'InventorySourceModel'
|
||||
];
|
||||
|
||||
export default CredentialModelLoader;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
let BaseModel;
|
||||
let Base;
|
||||
let Credential;
|
||||
|
||||
function categorizeByKind () {
|
||||
const group = {};
|
||||
@ -30,22 +31,38 @@ function mergeInputProperties () {
|
||||
});
|
||||
}
|
||||
|
||||
function CredentialTypeModel (method, resource, graft) {
|
||||
BaseModel.call(this, 'credential_types');
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new Credential(),
|
||||
params: {
|
||||
credential_type: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function CredentialTypeModel (method, resource, config) {
|
||||
Base.call(this, 'credential_types');
|
||||
|
||||
this.Constructor = CredentialTypeModel;
|
||||
this.categorizeByKind = categorizeByKind.bind(this);
|
||||
this.mergeInputProperties = mergeInputProperties.bind(this);
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, graft);
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function CredentialTypeModelLoader (_BaseModel_) {
|
||||
BaseModel = _BaseModel_;
|
||||
function CredentialTypeModelLoader (BaseModel, CredentialModel) {
|
||||
Base = BaseModel;
|
||||
Credential = CredentialModel;
|
||||
|
||||
return CredentialTypeModel;
|
||||
}
|
||||
|
||||
CredentialTypeModelLoader.$inject = ['BaseModel'];
|
||||
CredentialTypeModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'CredentialModel'
|
||||
];
|
||||
|
||||
export default CredentialTypeModelLoader;
|
||||
|
||||
36
awx/ui/client/lib/models/Inventory.js
Normal file
36
awx/ui/client/lib/models/Inventory.js
Normal file
@ -0,0 +1,36 @@
|
||||
let Base;
|
||||
let JobTemplate;
|
||||
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new JobTemplate(),
|
||||
params: {
|
||||
inventory: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function InventoryModel (method, resource, config) {
|
||||
Base.call(this, 'inventories');
|
||||
|
||||
this.Constructor = InventoryModel;
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function InventoryModelLoader (BaseModel, JobTemplateModel) {
|
||||
Base = BaseModel;
|
||||
JobTemplate = JobTemplateModel;
|
||||
|
||||
return InventoryModel;
|
||||
}
|
||||
|
||||
InventoryModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'JobTemplateModel'
|
||||
];
|
||||
|
||||
export default InventoryModelLoader;
|
||||
36
awx/ui/client/lib/models/InventoryScript.js
Normal file
36
awx/ui/client/lib/models/InventoryScript.js
Normal file
@ -0,0 +1,36 @@
|
||||
let Base;
|
||||
let InventorySource;
|
||||
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new InventorySource(),
|
||||
params: {
|
||||
source_script: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function InventoryScriptModel (method, resource, config) {
|
||||
Base.call(this, 'inventory_scripts');
|
||||
|
||||
this.Constructor = InventoryScriptModel;
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function InventoryScriptModelLoader (BaseModel, InventorySourceModel) {
|
||||
Base = BaseModel;
|
||||
InventorySource = InventorySourceModel;
|
||||
|
||||
return InventoryScriptModel;
|
||||
}
|
||||
|
||||
InventoryScriptModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'InventorySourceModel'
|
||||
];
|
||||
|
||||
export default InventoryScriptModelLoader;
|
||||
39
awx/ui/client/lib/models/InventorySource.js
Normal file
39
awx/ui/client/lib/models/InventorySource.js
Normal file
@ -0,0 +1,39 @@
|
||||
let Base;
|
||||
let WorkflowJobTemplateNode;
|
||||
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new WorkflowJobTemplateNode(),
|
||||
params: {
|
||||
unified_job_template: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function InventorySourceModel (method, resource, config) {
|
||||
Base.call(this, 'inventory_sources');
|
||||
|
||||
this.Constructor = InventorySourceModel;
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function InventorySourceModelLoader (
|
||||
BaseModel,
|
||||
WorkflowJobTemplateNodeModel
|
||||
) {
|
||||
Base = BaseModel;
|
||||
WorkflowJobTemplateNode = WorkflowJobTemplateNodeModel;
|
||||
|
||||
return InventorySourceModel;
|
||||
}
|
||||
|
||||
InventorySourceModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'WorkflowJobTemplateNodeModel'
|
||||
];
|
||||
|
||||
export default InventorySourceModelLoader;
|
||||
36
awx/ui/client/lib/models/JobTemplate.js
Normal file
36
awx/ui/client/lib/models/JobTemplate.js
Normal file
@ -0,0 +1,36 @@
|
||||
let Base;
|
||||
let WorkflowJobTemplateNode;
|
||||
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new WorkflowJobTemplateNode(),
|
||||
params: {
|
||||
unified_job_template: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function JobTemplateModel (method, resource, config) {
|
||||
Base.call(this, 'job_templates');
|
||||
|
||||
this.Constructor = JobTemplateModel;
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function JobTemplateModelLoader (BaseModel, WorkflowJobTemplateNodeModel) {
|
||||
Base = BaseModel;
|
||||
WorkflowJobTemplateNode = WorkflowJobTemplateNodeModel;
|
||||
|
||||
return JobTemplateModel;
|
||||
}
|
||||
|
||||
JobTemplateModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'WorkflowJobTemplateNodeModel'
|
||||
];
|
||||
|
||||
export default JobTemplateModelLoader;
|
||||
@ -1,11 +1,11 @@
|
||||
let BaseModel;
|
||||
let Base;
|
||||
|
||||
function MeModel (method, resource, graft) {
|
||||
BaseModel.call(this, 'me');
|
||||
function MeModel (method, resource, config) {
|
||||
Base.call(this, 'me');
|
||||
|
||||
this.Constructor = MeModel;
|
||||
|
||||
return this.create(method, resource, graft)
|
||||
return this.create(method, resource, config)
|
||||
.then(() => {
|
||||
if (this.has('results')) {
|
||||
_.merge(this.model.GET, this.get('results[0]'));
|
||||
@ -16,8 +16,8 @@ function MeModel (method, resource, graft) {
|
||||
});
|
||||
}
|
||||
|
||||
function MeModelLoader (_BaseModel_) {
|
||||
BaseModel = _BaseModel_;
|
||||
function MeModelLoader (BaseModel) {
|
||||
Base = BaseModel;
|
||||
|
||||
return MeModel;
|
||||
}
|
||||
|
||||
@ -1,19 +1,21 @@
|
||||
let BaseModel;
|
||||
let Base;
|
||||
|
||||
function OrganizationModel (method, resource, graft) {
|
||||
BaseModel.call(this, 'organizations');
|
||||
function OrganizationModel (method, resource, config) {
|
||||
Base.call(this, 'organizations');
|
||||
|
||||
this.Constructor = OrganizationModel;
|
||||
|
||||
return this.create(method, resource, graft);
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function OrganizationModelLoader (_BaseModel_) {
|
||||
BaseModel = _BaseModel_;
|
||||
function OrganizationModelLoader (BaseModel) {
|
||||
Base = BaseModel;
|
||||
|
||||
return OrganizationModel;
|
||||
}
|
||||
|
||||
OrganizationModelLoader.$inject = ['BaseModel'];
|
||||
OrganizationModelLoader.$inject = [
|
||||
'BaseModel'
|
||||
];
|
||||
|
||||
export default OrganizationModelLoader;
|
||||
|
||||
59
awx/ui/client/lib/models/Project.js
Normal file
59
awx/ui/client/lib/models/Project.js
Normal file
@ -0,0 +1,59 @@
|
||||
let Base;
|
||||
let JobTemplate;
|
||||
let WorkflowJobTemplateNode;
|
||||
let InventorySource;
|
||||
|
||||
function setDependentResources (id) {
|
||||
this.dependentResources = [
|
||||
{
|
||||
model: new JobTemplate(),
|
||||
params: {
|
||||
project: id
|
||||
}
|
||||
},
|
||||
{
|
||||
model: new WorkflowJobTemplateNode(),
|
||||
params: {
|
||||
unified_job_template: id
|
||||
}
|
||||
},
|
||||
{
|
||||
model: new InventorySource(),
|
||||
params: {
|
||||
source_project: id
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function ProjectModel (method, resource, config) {
|
||||
Base.call(this, 'projects');
|
||||
|
||||
this.Constructor = ProjectModel;
|
||||
this.setDependentResources = setDependentResources.bind(this);
|
||||
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function ProjectModelLoader (
|
||||
BaseModel,
|
||||
JobTemplateModel,
|
||||
WorkflowJobTemplateNodeModel,
|
||||
InventorySourceModel,
|
||||
) {
|
||||
Base = BaseModel;
|
||||
JobTemplate = JobTemplateModel;
|
||||
WorkflowJobTemplateNode = WorkflowJobTemplateNodeModel;
|
||||
InventorySource = InventorySourceModel;
|
||||
|
||||
return ProjectModel;
|
||||
}
|
||||
|
||||
ProjectModelLoader.$inject = [
|
||||
'BaseModel',
|
||||
'JobTemplateModel',
|
||||
'WorkflowJobTemplateNodeModel',
|
||||
'InventorySourceModel'
|
||||
];
|
||||
|
||||
export default ProjectModelLoader;
|
||||
21
awx/ui/client/lib/models/WorkflowJobTemplateNode.js
Normal file
21
awx/ui/client/lib/models/WorkflowJobTemplateNode.js
Normal file
@ -0,0 +1,21 @@
|
||||
let Base;
|
||||
|
||||
function WorkflowJobTemplateNodeModel (method, resource, config) {
|
||||
Base.call(this, 'workflow_job_template_nodes');
|
||||
|
||||
this.Constructor = WorkflowJobTemplateNodeModel;
|
||||
|
||||
return this.create(method, resource, config);
|
||||
}
|
||||
|
||||
function WorkflowJobTemplateNodeModelLoader (BaseModel) {
|
||||
Base = BaseModel;
|
||||
|
||||
return WorkflowJobTemplateNodeModel;
|
||||
}
|
||||
|
||||
WorkflowJobTemplateNodeModelLoader.$inject = [
|
||||
'BaseModel'
|
||||
];
|
||||
|
||||
export default WorkflowJobTemplateNodeModelLoader;
|
||||
@ -6,6 +6,14 @@ import Credential from '~models/Credential';
|
||||
import CredentialType from '~models/CredentialType';
|
||||
import Me from '~models/Me';
|
||||
import Organization from '~models/Organization';
|
||||
import Project from '~models/Project';
|
||||
import JobTemplate from '~models/JobTemplate';
|
||||
import WorkflowJobTemplateNode from '~models/WorkflowJobTemplateNode';
|
||||
import InventorySource from '~models/InventorySource';
|
||||
import Inventory from '~models/Inventory';
|
||||
import InventoryScript from '~models/InventoryScript';
|
||||
|
||||
import ModelsStrings from '~models/models.strings';
|
||||
|
||||
const MODULE_NAME = 'at.lib.models';
|
||||
|
||||
@ -18,6 +26,13 @@ angular
|
||||
.service('CredentialModel', Credential)
|
||||
.service('CredentialTypeModel', CredentialType)
|
||||
.service('MeModel', Me)
|
||||
.service('OrganizationModel', Organization);
|
||||
.service('OrganizationModel', Organization)
|
||||
.service('ProjectModel', Project)
|
||||
.service('JobTemplateModel', JobTemplate)
|
||||
.service('WorkflowJobTemplateNodeModel', WorkflowJobTemplateNode)
|
||||
.service('InventorySourceModel', InventorySource)
|
||||
.service('InventoryModel', Inventory)
|
||||
.service('InventoryScriptModel', InventoryScript)
|
||||
.service('ModelsStrings', ModelsStrings);
|
||||
|
||||
export default MODULE_NAME;
|
||||
|
||||
52
awx/ui/client/lib/models/models.strings.js
Normal file
52
awx/ui/client/lib/models/models.strings.js
Normal file
@ -0,0 +1,52 @@
|
||||
function ModelsStrings (BaseString) {
|
||||
BaseString.call(this, 'models');
|
||||
|
||||
const { t } = this;
|
||||
const ns = this.models;
|
||||
|
||||
ns.credentials = {
|
||||
LABEL: t.s('Credentials')
|
||||
};
|
||||
|
||||
ns.credential_types = {
|
||||
LABEL: t.s('Credential Types')
|
||||
};
|
||||
|
||||
ns.inventories = {
|
||||
LABEL: t.s('Inventories')
|
||||
};
|
||||
|
||||
ns.inventory_scripts = {
|
||||
LABEL: t.s('Inventory Scripts')
|
||||
|
||||
};
|
||||
|
||||
ns.inventory_sources = {
|
||||
LABEL: t.s('Inventory Sources')
|
||||
|
||||
};
|
||||
|
||||
ns.job_templates = {
|
||||
LABEL: t.s('Job Templates')
|
||||
|
||||
};
|
||||
|
||||
ns.organizations = {
|
||||
LABEL: t.s('Organizations')
|
||||
|
||||
};
|
||||
|
||||
ns.projects = {
|
||||
LABEL: t.s('Projects')
|
||||
|
||||
};
|
||||
|
||||
ns.workflow_job_template_nodes = {
|
||||
LABEL: t.s('Workflow Job Template Nodes')
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
ModelsStrings.$inject = ['BaseStringService'];
|
||||
|
||||
export default ModelsStrings;
|
||||
@ -4,7 +4,6 @@ let i18n;
|
||||
|
||||
function BaseStringService (namespace) {
|
||||
const ERROR_NO_NAMESPACE = 'BaseString cannot be extended without providing a namespace';
|
||||
const ERROR_NO_STRING = 'No string exists with this name';
|
||||
|
||||
if (!namespace) {
|
||||
throw new Error(ERROR_NO_NAMESPACE);
|
||||
@ -67,8 +66,6 @@ function BaseStringService (namespace) {
|
||||
* the more globally relevant strings defined here. Strings with with dots as delimeters are
|
||||
* supported to give flexibility to extending classes to nest strings as necessary.
|
||||
*
|
||||
* If no match is found, an error is thrown to alert the developer immediately instead of
|
||||
* failing silently.
|
||||
*
|
||||
* The `t.s` and `t.p` calls should only be used where strings are defined in
|
||||
* <name>.strings.js` files. To use translated strings elsewhere, access them through this
|
||||
@ -88,13 +85,13 @@ function BaseStringService (namespace) {
|
||||
} else {
|
||||
value = value[key];
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
throw new Error(`${ERROR_NO_STRING}: ${name}`);
|
||||
}
|
||||
});
|
||||
|
||||
return typeof value === 'string' ? value : value(...args);
|
||||
if (!value || typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
|
||||
return value(...args);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
function CredentialTypesStrings (BaseString) {
|
||||
BaseString.call(this, 'credential_types');
|
||||
|
||||
let t = this.t;
|
||||
let ns = this.credential_types;
|
||||
|
||||
ns.deleteCredentialType = {
|
||||
CONFIRM: t.s('Are you sure you want to delete this credential type?'),
|
||||
CREDENTIAL_TYPE_IN_USE: t.s('This credential type is currently being used by one or more credentials. Credentials that use this credential type must be deleted before the credential type can be deleted.')
|
||||
};
|
||||
}
|
||||
|
||||
CredentialTypesStrings.$inject = ['BaseStringService'];
|
||||
|
||||
export default CredentialTypesStrings;
|
||||
@ -5,11 +5,16 @@
|
||||
*************************************************/
|
||||
|
||||
export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
|
||||
'GetBasePath', 'Rest', 'ProcessErrors', 'Prompt', '$state', '$filter', 'Dataset', 'rbacUiControlService', 'Alert', '$q',
|
||||
'GetBasePath', 'Rest', 'ProcessErrors', 'Prompt', '$state', '$filter',
|
||||
'Dataset', 'rbacUiControlService', 'Alert', '$q', 'CredentialTypeModel',
|
||||
'CredentialTypesStrings', 'i18n',
|
||||
function(
|
||||
$rootScope, $scope, Wait, CredentialTypesList,
|
||||
GetBasePath, Rest, ProcessErrors, Prompt, $state, $filter, Dataset, rbacUiControlService, Alert, $q
|
||||
GetBasePath, Rest, ProcessErrors, Prompt, $state, $filter,
|
||||
Dataset, rbacUiControlService, Alert, $q, CredentialType,
|
||||
CredentialTypesStrings, i18n
|
||||
) {
|
||||
let credentialType = new CredentialType();
|
||||
var defaultUrl = GetBasePath('credential_types'),
|
||||
list = CredentialTypesList;
|
||||
|
||||
@ -58,8 +63,7 @@ export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
credentialType.request('delete', id)
|
||||
.then(() => {
|
||||
|
||||
let reloadListStateParams = null;
|
||||
@ -83,13 +87,29 @@ export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
|
||||
});
|
||||
};
|
||||
|
||||
var bodyHtml = '<div class="Prompt-bodyQuery">Are you sure you want to delete the credential type below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>';
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: bodyHtml,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
credentialType.getDependentResourceCounts(id)
|
||||
.then((counts) => {
|
||||
let credentialTypeInUse = false;
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialTypesStrings.get('deleteCredentialType.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
credentialTypeInUse = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (credentialTypeInUse) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialTypesStrings.get('deleteCredentialType.CREDENTIAL_TYPE_IN_USE')}</div>`;
|
||||
}
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete') + ' ' + $filter('sanitize')(name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
hideActionButton: credentialTypeInUse ? true : false,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addCredentialType = function() {
|
||||
|
||||
@ -10,6 +10,7 @@ import credentialTypesEdit from './edit/main';
|
||||
import list from './credential-types.list';
|
||||
import form from './credential-types.form';
|
||||
import { N_ } from '../i18n';
|
||||
import CredentialTypesStrings from './credential-types.strings';
|
||||
|
||||
export default
|
||||
angular.module('credentialTypes', [
|
||||
@ -19,6 +20,7 @@ angular.module('credentialTypes', [
|
||||
])
|
||||
.factory('CredentialTypesList', list)
|
||||
.factory('CredentialTypesForm', form)
|
||||
.service('CredentialTypesStrings', CredentialTypesStrings)
|
||||
.config(['$stateProvider', 'stateDefinitionsProvider',
|
||||
function($stateProvider, stateDefinitionsProvider) {
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
@ -6,9 +6,12 @@
|
||||
|
||||
export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', 'GetBasePath',
|
||||
'Wait', '$state', '$filter', 'rbacUiControlService', 'Dataset', 'credentialType', 'i18n',
|
||||
'CredentialModel', 'CredentialsStrings',
|
||||
function($scope, Rest, CredentialList, Prompt,
|
||||
ProcessErrors, GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset,
|
||||
credentialType, i18n) {
|
||||
credentialType, i18n, Credential, CredentialsStrings) {
|
||||
|
||||
let credential = new Credential();
|
||||
|
||||
var list = CredentialList,
|
||||
defaultUrl = GetBasePath('credentials');
|
||||
@ -83,8 +86,7 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
credential.request('delete', id)
|
||||
.then(() => {
|
||||
|
||||
let reloadListStateParams = null;
|
||||
@ -109,12 +111,32 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
|
||||
});
|
||||
};
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete the credential below?') + '</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>',
|
||||
action: action,
|
||||
actionText: i18n._('DELETE')
|
||||
});
|
||||
credential.getDependentResourceCounts(id)
|
||||
.then((counts) => {
|
||||
const invalidateRelatedLines = [];
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialsStrings.get('deleteCredential.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
invalidateRelatedLines.push(`<div><span class="Prompt-warningResourceTitle">${countObj.label}</span><span class="badge List-titleBadge">${countObj.count}</span></div>`);
|
||||
}
|
||||
});
|
||||
|
||||
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${CredentialsStrings.get('deleteCredential.CONFIRM')} ${CredentialsStrings.get('deleteCredential.INVALIDATE')}</div>`;
|
||||
invalidateRelatedLines.forEach(invalidateRelatedLine => {
|
||||
deleteModalBody += invalidateRelatedLine;
|
||||
});
|
||||
}
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
@ -13,7 +13,9 @@
|
||||
function InventoriesList($scope,
|
||||
$filter, Rest, InventoryList, Prompt,
|
||||
ProcessErrors, GetBasePath, Wait, $state,
|
||||
Dataset, canAdd, i18n) {
|
||||
Dataset, canAdd, i18n, Inventory, InventoryHostsStrings) {
|
||||
|
||||
let inventory = new Inventory();
|
||||
|
||||
let list = InventoryList,
|
||||
defaultUrl = GetBasePath('inventory');
|
||||
@ -85,8 +87,7 @@ function InventoriesList($scope,
|
||||
var url = defaultUrl + id + '/';
|
||||
Wait('start');
|
||||
$('#prompt-modal').modal('hide');
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
inventory.request('delete', id)
|
||||
.then(() => {
|
||||
Wait('stop');
|
||||
})
|
||||
@ -97,13 +98,34 @@ function InventoriesList($scope,
|
||||
});
|
||||
};
|
||||
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete the inventory below?') + '</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>' +
|
||||
'<div class="Prompt-bodyNote"><span class="Prompt-bodyNote--emphasis">Note:</span> ' + i18n._('The inventory will be in a pending status until the final delete is processed.') + '</div>',
|
||||
action: action,
|
||||
actionText: i18n._('DELETE')
|
||||
});
|
||||
inventory.getDependentResourceCounts(id)
|
||||
.then((counts) => {
|
||||
const invalidateRelatedLines = [];
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteInventory.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
invalidateRelatedLines.push(`<div><span class="Prompt-warningResourceTitle">${countObj.label}</span><span class="badge List-titleBadge">${countObj.count}</span></div>`);
|
||||
}
|
||||
});
|
||||
|
||||
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteInventory.CONFIRM')} ${InventoryHostsStrings.get('deleteInventory.INVALIDATE')}</div>`;
|
||||
invalidateRelatedLines.forEach(invalidateRelatedLine => {
|
||||
deleteModalBody += invalidateRelatedLine;
|
||||
});
|
||||
}
|
||||
|
||||
deleteModalBody += '<div class="Prompt-bodyNote"><span class="Prompt-bodyNote--emphasis">Note:</span> ' + i18n._('The inventory will be in a pending status until the final delete is processed.') + '</div>';
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on(`ws-inventories`, function(e, data){
|
||||
@ -131,5 +153,6 @@ function InventoriesList($scope,
|
||||
export default ['$scope',
|
||||
'$filter', 'Rest', 'InventoryList', 'Prompt',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait',
|
||||
'$state', 'Dataset', 'canAdd', 'i18n', InventoriesList
|
||||
'$state', 'Dataset', 'canAdd', 'i18n', 'InventoryModel',
|
||||
'InventoryHostsStrings', InventoriesList
|
||||
];
|
||||
|
||||
@ -9,12 +9,15 @@
|
||||
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
||||
'GetSyncStatusMsg', 'Dataset', 'Find', 'QuerySet',
|
||||
'inventoryData', '$filter', 'Prompt', 'Wait', 'SourcesService', 'inventorySourceOptions',
|
||||
'canAdd', 'hasSyncableSources', 'i18n',
|
||||
'canAdd', 'hasSyncableSources', 'i18n', 'InventoryHostsStrings', 'InventorySourceModel',
|
||||
function($scope, $rootScope, $state, $stateParams, SourcesListDefinition,
|
||||
InventoryUpdate, CancelSourceUpdate,
|
||||
ViewUpdateStatus, rbacUiControlService, GetBasePath, GetSyncStatusMsg,
|
||||
Dataset, Find, qs, inventoryData, $filter, Prompt,
|
||||
Wait, SourcesService, inventorySourceOptions, canAdd, hasSyncableSources, i18n){
|
||||
Wait, SourcesService, inventorySourceOptions, canAdd, hasSyncableSources, i18n,
|
||||
InventoryHostsStrings, InventorySource){
|
||||
|
||||
let inventorySource = new InventorySource();
|
||||
|
||||
let list = SourcesListDefinition;
|
||||
var inventory_source;
|
||||
@ -117,7 +120,6 @@
|
||||
$state.go('inventories.edit.inventory_sources.edit', {inventory_source_id: id});
|
||||
};
|
||||
$scope.deleteSource = function(inventory_source){
|
||||
var body = '<div class=\"Prompt-bodyQuery\">' + i18n._('Are you sure you want to permanently delete the inventory source below from the inventory?') + '</div><div class=\"Prompt-bodyTarget\">' + $filter('sanitize')(inventory_source.name) + '</div>';
|
||||
var action = function(){
|
||||
delete $rootScope.promptActionBtnClass;
|
||||
Wait('start');
|
||||
@ -137,14 +139,35 @@
|
||||
Wait('stop');
|
||||
});
|
||||
};
|
||||
// Prompt depends on having $rootScope.promptActionBtnClass available...
|
||||
Prompt({
|
||||
hdr: i18n._('Delete Source'),
|
||||
body: body,
|
||||
action: action,
|
||||
actionText: i18n._('DELETE'),
|
||||
});
|
||||
$rootScope.promptActionBtnClass = 'Modal-errorButton';
|
||||
|
||||
inventorySource.getDependentResourceCounts(inventory_source.id)
|
||||
.then((counts) => {
|
||||
const invalidateRelatedLines = [];
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteSource.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
invalidateRelatedLines.push(`<div><span class="Prompt-warningResourceTitle">${countObj.label}</span><span class="badge List-titleBadge">${countObj.count}</span></div>`);
|
||||
}
|
||||
});
|
||||
|
||||
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryHostsStrings.get('deleteSource.CONFIRM')} ${InventoryHostsStrings.get('deleteSource.INVALIDATE')}</div>`;
|
||||
invalidateRelatedLines.forEach(invalidateRelatedLine => {
|
||||
deleteModalBody += invalidateRelatedLine;
|
||||
});
|
||||
}
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete Source'),
|
||||
resourceName: $filter('sanitize')(inventory_source.name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
$rootScope.promptActionBtnClass = 'Modal-errorButton';
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.updateSource = function(inventory_source) {
|
||||
|
||||
@ -4,6 +4,16 @@ function InventoryHostsStrings (BaseString) {
|
||||
let t = this.t;
|
||||
let ns = this['inventory-hosts'];
|
||||
|
||||
ns.deleteInventory = {
|
||||
CONFIRM: t.s('Are you sure you want to delete this inventory?'),
|
||||
INVALIDATE: t.s('Doing so will invalidate the following:')
|
||||
};
|
||||
|
||||
ns.deleteSource = {
|
||||
CONFIRM: t.s('Are you sure you want to delete this inventory source?'),
|
||||
INVALIDATE: t.s('Doing so will invalidate the following:')
|
||||
};
|
||||
|
||||
ns.deletegroup = {
|
||||
GROUP: count => t.p(count, 'group', 'groups'),
|
||||
HOST: count => t.p(count, 'host', 'hosts'),
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
function InventoryScriptsStrings (BaseString) {
|
||||
BaseString.call(this, 'inventory_scripts');
|
||||
|
||||
let t = this.t;
|
||||
let ns = this.inventory_scripts;
|
||||
|
||||
ns.deleteInventoryScript = {
|
||||
CONFIRM: t.s('Are you sure you want to delete this inventory script?'),
|
||||
INVALIDATE: t.s('Doing so will invalidate the following:')
|
||||
};
|
||||
}
|
||||
|
||||
InventoryScriptsStrings.$inject = ['BaseStringService'];
|
||||
|
||||
export default InventoryScriptsStrings;
|
||||
@ -5,11 +5,16 @@
|
||||
*************************************************/
|
||||
|
||||
export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
|
||||
'GetBasePath', 'Rest', 'ProcessErrors', 'Prompt', '$state', '$filter', 'Dataset', 'rbacUiControlService',
|
||||
'GetBasePath', 'Rest', 'ProcessErrors', 'Prompt', '$state', '$filter',
|
||||
'Dataset', 'rbacUiControlService', 'InventoryScriptModel', 'InventoryScriptsStrings',
|
||||
'i18n',
|
||||
function(
|
||||
$rootScope, $scope, Wait, InventoryScriptsList,
|
||||
GetBasePath, Rest, ProcessErrors, Prompt, $state, $filter, Dataset, rbacUiControlService
|
||||
GetBasePath, Rest, ProcessErrors, Prompt, $state, $filter,
|
||||
Dataset, rbacUiControlService, InventoryScript, InventoryScriptsStrings,
|
||||
i18n
|
||||
) {
|
||||
let inventoryScript = new InventoryScript();
|
||||
var defaultUrl = GetBasePath('inventory_scripts'),
|
||||
list = InventoryScriptsList;
|
||||
|
||||
@ -48,8 +53,7 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
inventoryScript.request('delete', id)
|
||||
.then(() => {
|
||||
|
||||
let reloadListStateParams = null;
|
||||
@ -73,13 +77,32 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
|
||||
});
|
||||
};
|
||||
|
||||
var bodyHtml = '<div class="Prompt-bodyQuery">Are you sure you want to delete the inventory script below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>';
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: bodyHtml,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
inventoryScript.getDependentResourceCounts(id)
|
||||
.then((counts) => {
|
||||
const invalidateRelatedLines = [];
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryScriptsStrings.get('deleteInventoryScript.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
invalidateRelatedLines.push(`<div><span class="Prompt-warningResourceTitle">${countObj.label}</span><span class="badge List-titleBadge">${countObj.count}</span></div>`);
|
||||
}
|
||||
});
|
||||
|
||||
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${InventoryScriptsStrings.get('deleteInventoryScript.CONFIRM')} ${InventoryScriptsStrings.get('deleteInventoryScript.INVALIDATE')}</div>`;
|
||||
invalidateRelatedLines.forEach(invalidateRelatedLine => {
|
||||
deleteModalBody += invalidateRelatedLine;
|
||||
});
|
||||
}
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addCustomInv = function() {
|
||||
|
||||
@ -10,6 +10,7 @@ import inventoryScriptsEdit from './edit/main';
|
||||
import list from './inventory-scripts.list';
|
||||
import form from './inventory-scripts.form';
|
||||
import { N_ } from '../i18n';
|
||||
import InventoryScriptsStrings from './inventory-scripts.strings';
|
||||
|
||||
export default
|
||||
angular.module('inventoryScripts', [
|
||||
@ -19,6 +20,7 @@ angular.module('inventoryScripts', [
|
||||
])
|
||||
.factory('InventoryScriptsList', list)
|
||||
.factory('InventoryScriptsForm', form)
|
||||
.service('InventoryScriptsStrings', InventoryScriptsStrings)
|
||||
.config(['$stateProvider', 'stateDefinitionsProvider',
|
||||
function($stateProvider, stateDefinitionsProvider) {
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
@ -91,11 +91,9 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
|
||||
deleteJob: function(job) {
|
||||
Prompt({
|
||||
hdr: i18n._("Delete Job"),
|
||||
resourceName: `#${job.id} ` + $filter('sanitize')(job.name),
|
||||
body: `<div class='Prompt-bodyQuery'>
|
||||
${i18n._("Are you sure you want to delete the job below?")}
|
||||
</div>
|
||||
<div class='Prompt-bodyTarget'>
|
||||
#${job.id} ${$filter('sanitize')(job.name)}
|
||||
${i18n._("Are you sure you want to delete this job?")}
|
||||
</div>`,
|
||||
action: function() {
|
||||
Wait('start');
|
||||
@ -140,11 +138,9 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Cancel Job'),
|
||||
resourceName: `#${job.id} ` + $filter('sanitize')(job.name),
|
||||
body: `<div class='Prompt-bodyQuery' translate>
|
||||
${i18n._("Are you sure you want to cancel the job below?")}
|
||||
</div>
|
||||
<div class='Prompt-bodyTarget'>
|
||||
#${job.id} ${$filter('sanitize')(job.name)}
|
||||
${i18n._("Are you sure you want to cancel this job?")}
|
||||
</div>`,
|
||||
action: function() {
|
||||
Wait('start');
|
||||
|
||||
@ -106,10 +106,11 @@
|
||||
scope.removeCancelJob();
|
||||
}
|
||||
scope.removeCancelJob = scope.$on('CancelJob', function() {
|
||||
var cancelBody = "<div class=\"Prompt-bodyQuery\">" + i18n._("Submit the request to cancel?") + "</div>";
|
||||
var deleteBody = "<div class=\"Prompt-bodyQuery\">" + i18n._("Are you sure you want to delete the job below?") + "</div><div class=\"Prompt-bodyTarget\" translate>#" + id + " " + $filter('sanitize')(job.name) + "</div>";
|
||||
var cancelBody = "<div class=\"Prompt-bodyQuery\">" + i18n._("Are you sure you want to submit the request to cancel this job?") + "</div>";
|
||||
var deleteBody = "<div class=\"Prompt-bodyQuery\">" + i18n._("Are you sure you want to delete this job?") + "</div>";
|
||||
Prompt({
|
||||
hdr: hdr,
|
||||
resourceName: `#${job.id} ` + $filter('sanitize')(job.name),
|
||||
body: (action_label === 'cancel' || job.status === 'new') ? cancelBody : deleteBody,
|
||||
action: action,
|
||||
actionText: (action_label === 'cancel' || job.status === 'new') ? i18n._("OK") : i18n._("DELETE")
|
||||
|
||||
@ -193,10 +193,11 @@
|
||||
});
|
||||
});
|
||||
};
|
||||
var bodyHtml = '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete the notification template below?') + '</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>';
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
body: bodyHtml,
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete this notification template?') + '</div>',
|
||||
action: action,
|
||||
actionText: i18n._('DELETE')
|
||||
});
|
||||
|
||||
@ -169,7 +169,8 @@ export default ['$stateParams', '$scope', '$rootScope',
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete the organization below?') + '</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>',
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete this organization? This makes everything in this organization unavailable.') + '</div>',
|
||||
action: action,
|
||||
actionText: i18n._('DELETE')
|
||||
});
|
||||
|
||||
@ -7,14 +7,16 @@
|
||||
export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
|
||||
'ProjectList', 'Prompt', 'ProcessErrors', 'GetBasePath', 'ProjectUpdate',
|
||||
'Wait', 'Empty', 'Find', 'GetProjectIcon', 'GetProjectToolTip', '$filter',
|
||||
'$state', 'rbacUiControlService', 'Dataset', 'i18n', 'QuerySet',
|
||||
'$state', 'rbacUiControlService', 'Dataset', 'i18n', 'QuerySet', 'ProjectModel',
|
||||
'ProjectsStrings',
|
||||
function($scope, $rootScope, $log, Rest, Alert, ProjectList,
|
||||
Prompt, ProcessErrors, GetBasePath, ProjectUpdate, Wait, Empty, Find,
|
||||
GetProjectIcon, GetProjectToolTip, $filter, $state, rbacUiControlService,
|
||||
Dataset, i18n, qs) {
|
||||
Dataset, i18n, qs, Project, ProjectsStrings) {
|
||||
|
||||
var list = ProjectList,
|
||||
defaultUrl = GetBasePath('projects');
|
||||
let project = new Project();
|
||||
|
||||
var list = ProjectList;
|
||||
|
||||
init();
|
||||
|
||||
@ -176,9 +178,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
|
||||
var action = function() {
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
project.request('delete', id)
|
||||
.then(() => {
|
||||
|
||||
let reloadListStateParams = null;
|
||||
@ -196,19 +196,39 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
|
||||
msg: i18n.sprintf(i18n._('Call to %s failed. DELETE returned status: '), url) + status });
|
||||
msg: i18n.sprintf(i18n._('Call to %s failed. DELETE returned status: '), `${project.path}${id}/`) + status });
|
||||
})
|
||||
.finally(function() {
|
||||
Wait('stop');
|
||||
});
|
||||
};
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete the project below?') + '</div>' + '<div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>',
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
project.getDependentResourceCounts(id)
|
||||
.then((counts) => {
|
||||
const invalidateRelatedLines = [];
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${ProjectsStrings.get('deleteProject.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
invalidateRelatedLines.push(`<div><span class="Prompt-warningResourceTitle">${countObj.label}</span><span class="badge List-titleBadge">${countObj.count}</span></div>`);
|
||||
}
|
||||
});
|
||||
|
||||
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${ProjectsStrings.get('deleteProject.CONFIRM')} ${ProjectsStrings.get('deleteProject.INVALIDATE')}</div>`;
|
||||
invalidateRelatedLines.forEach(invalidateRelatedLine => {
|
||||
deleteModalBody += invalidateRelatedLine;
|
||||
});
|
||||
}
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
if ($scope.removeCancelUpdate) {
|
||||
|
||||
@ -14,6 +14,7 @@ import GetProjectPath from './factories/get-project-path.factory';
|
||||
import GetProjectIcon from './factories/get-project-icon.factory';
|
||||
import GetProjectToolTip from './factories/get-project-tool-tip.factory';
|
||||
import ProjectsTemplatesRoute from './projects-templates.route';
|
||||
import ProjectsStrings from './projects.strings';
|
||||
|
||||
export default
|
||||
angular.module('Projects', [])
|
||||
@ -25,6 +26,7 @@ angular.module('Projects', [])
|
||||
.factory('GetProjectToolTip', GetProjectToolTip)
|
||||
.factory('ProjectList', ProjectList)
|
||||
.factory('ProjectsForm', ProjectsForm)
|
||||
.service('ProjectsStrings', ProjectsStrings)
|
||||
.config(['$stateProvider', 'stateDefinitionsProvider', '$stateExtenderProvider',
|
||||
function($stateProvider, stateDefinitionsProvider,$stateExtenderProvider) {
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
15
awx/ui/client/src/projects/projects.strings.js
Normal file
15
awx/ui/client/src/projects/projects.strings.js
Normal file
@ -0,0 +1,15 @@
|
||||
function ProjectsStrings (BaseString) {
|
||||
BaseString.call(this, 'projects');
|
||||
|
||||
let t = this.t;
|
||||
let ns = this.projects;
|
||||
|
||||
ns.deleteProject = {
|
||||
CONFIRM: t.s('Are you sure you want to delete this project?'),
|
||||
INVALIDATE: t.s('Doing so will invalidate the following:')
|
||||
};
|
||||
}
|
||||
|
||||
ProjectsStrings.$inject = ['BaseStringService'];
|
||||
|
||||
export default ProjectsStrings;
|
||||
@ -54,7 +54,8 @@ export default
|
||||
|
||||
Prompt({
|
||||
hdr: hdr,
|
||||
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the schedule below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(schedule.name) + '</div>',
|
||||
resourceName: $filter('sanitize')(schedule.name),
|
||||
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete this schedule?</div>',
|
||||
action: action,
|
||||
actionText: 'DELETE',
|
||||
backdrop: false
|
||||
|
||||
@ -123,3 +123,7 @@
|
||||
.Modal-footerButton + .Modal-footerButton {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.Modal-titleResourceName {
|
||||
color: @default-err;
|
||||
}
|
||||
|
||||
@ -39,9 +39,11 @@ angular.module('PromptDialog', ['Utilities'])
|
||||
scope = dialog.scope(), cls, local_backdrop;
|
||||
|
||||
scope.promptHeader = params.hdr;
|
||||
scope.promptResourceName = params.resourceName;
|
||||
scope.promptBody = params.body;
|
||||
scope.promptAction = params.action;
|
||||
scope.promptActionText = (params.actionText === null || params.actionText === undefined || params.actionText === '') ? 'YES' : params.actionText;
|
||||
scope.hideActionButton = params.hideActionButton ? true : false;
|
||||
|
||||
local_backdrop = (params.backdrop === undefined) ? "static" : params.backdrop;
|
||||
|
||||
|
||||
@ -23,3 +23,7 @@
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.Prompt-warningResourceTitle {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
@ -6,9 +6,9 @@
|
||||
|
||||
export default ['$scope', 'Rest', 'TeamList', 'Prompt',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', '$filter',
|
||||
'rbacUiControlService', 'Dataset',
|
||||
'rbacUiControlService', 'Dataset', 'i18n',
|
||||
function($scope, Rest, TeamList, Prompt, ProcessErrors,
|
||||
GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset) {
|
||||
GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset, i18n) {
|
||||
|
||||
var list = TeamList,
|
||||
defaultUrl = GetBasePath('teams');
|
||||
@ -77,7 +77,8 @@ export default ['$scope', 'Rest', 'TeamList', 'Prompt',
|
||||
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the team below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>',
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete this team?') + '</div>',
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
|
||||
@ -8,14 +8,16 @@ export default ['$scope', '$rootScope',
|
||||
'Alert','TemplateList', 'Prompt', 'ProcessErrors',
|
||||
'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter',
|
||||
'Dataset', 'rbacUiControlService', 'TemplatesService','QuerySet',
|
||||
'TemplateCopyService', 'i18n',
|
||||
'TemplateCopyService', 'i18n', 'JobTemplateModel', 'TemplatesStrings',
|
||||
function(
|
||||
$scope, $rootScope, Alert,
|
||||
TemplateList, Prompt, ProcessErrors, GetBasePath,
|
||||
InitiatePlaybookRun, Wait, $state, $filter, Dataset, rbacUiControlService, TemplatesService,
|
||||
qs, TemplateCopyService, i18n
|
||||
qs, TemplateCopyService, i18n, JobTemplate, TemplatesStrings
|
||||
) {
|
||||
|
||||
let jobTemplate = new JobTemplate();
|
||||
|
||||
var list = TemplateList;
|
||||
|
||||
init();
|
||||
@ -98,65 +100,98 @@ export default ['$scope', '$rootScope',
|
||||
|
||||
$scope.deleteJobTemplate = function(template) {
|
||||
if(template) {
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
body: `<div class="Prompt-bodyQuery">${i18n._("Are you sure you want to delete the template below?")}</div><div class="Prompt-bodyTarget">${$filter('sanitize')(template.name)}</div>`,
|
||||
action: function() {
|
||||
var action = function() {
|
||||
function handleSuccessfulDelete(isWorkflow) {
|
||||
let stateParamId = isWorkflow ? $state.params.workflow_job_template_id : $state.params.job_template_id;
|
||||
|
||||
function handleSuccessfulDelete(isWorkflow) {
|
||||
let stateParamId = isWorkflow ? $state.params.workflow_job_template_id : $state.params.job_template_id;
|
||||
let reloadListStateParams = null;
|
||||
|
||||
let reloadListStateParams = null;
|
||||
if($scope.templates.length === 1 && $state.params.template_search && !_.isEmpty($state.params.template_search.page) && $state.params.template_search.page !== '1') {
|
||||
reloadListStateParams = _.cloneDeep($state.params);
|
||||
reloadListStateParams.template_search.page = (parseInt(reloadListStateParams.template_search.page)-1).toString();
|
||||
}
|
||||
|
||||
if($scope.templates.length === 1 && $state.params.template_search && !_.isEmpty($state.params.template_search.page) && $state.params.template_search.page !== '1') {
|
||||
reloadListStateParams = _.cloneDeep($state.params);
|
||||
reloadListStateParams.template_search.page = (parseInt(reloadListStateParams.template_search.page)-1).toString();
|
||||
}
|
||||
if (parseInt(stateParamId) === template.id) {
|
||||
// Move the user back to the templates list
|
||||
$state.go("templates", reloadListStateParams, {reload: true});
|
||||
} else {
|
||||
$state.go(".", reloadListStateParams, {reload: true});
|
||||
}
|
||||
Wait('stop');
|
||||
}
|
||||
|
||||
if (parseInt(stateParamId) === template.id) {
|
||||
// Move the user back to the templates list
|
||||
$state.go("templates", reloadListStateParams, {reload: true});
|
||||
} else {
|
||||
$state.go(".", reloadListStateParams, {reload: true});
|
||||
}
|
||||
Wait('stop');
|
||||
}
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) {
|
||||
TemplatesService.deleteWorkflowJobTemplate(template.id)
|
||||
.then(function () {
|
||||
handleSuccessfulDelete(true);
|
||||
})
|
||||
.catch(function (response) {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, response.data, response.status, null, { hdr: 'Error!',
|
||||
msg: 'Call to delete workflow job template failed. DELETE returned status: ' + response.status + '.'});
|
||||
});
|
||||
}
|
||||
else if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) {
|
||||
TemplatesService.deleteJobTemplate(template.id)
|
||||
.then(function () {
|
||||
handleSuccessfulDelete();
|
||||
})
|
||||
.catch(function (response) {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, response.data, response.status, null, { hdr: 'Error!',
|
||||
msg: 'Call to delete job template failed. DELETE returned status: ' + response.status + '.'});
|
||||
});
|
||||
}
|
||||
else {
|
||||
Wait('stop');
|
||||
Alert('Error: Unable to determine template type', 'We were unable to determine this template\'s type while deleting.');
|
||||
}
|
||||
};
|
||||
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) {
|
||||
TemplatesService.deleteWorkflowJobTemplate(template.id)
|
||||
.then(function () {
|
||||
handleSuccessfulDelete(true);
|
||||
})
|
||||
.catch(function (response) {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, response.data, response.status, null, { hdr: 'Error!',
|
||||
msg: 'Call to delete workflow job template failed. DELETE returned status: ' + response.status + '.'});
|
||||
});
|
||||
}
|
||||
else if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) {
|
||||
TemplatesService.deleteJobTemplate(template.id)
|
||||
.then(function () {
|
||||
handleSuccessfulDelete();
|
||||
})
|
||||
.catch(function (response) {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, response.data, response.status, null, { hdr: 'Error!',
|
||||
msg: 'Call to delete job template failed. DELETE returned status: ' + response.status + '.'});
|
||||
});
|
||||
}
|
||||
else {
|
||||
Wait('stop');
|
||||
Alert('Error: Unable to determine template type', 'We were unable to determine this template\'s type while deleting.');
|
||||
}
|
||||
},
|
||||
actionText: i18n._('DELETE')
|
||||
});
|
||||
}
|
||||
else {
|
||||
Alert('Error: Unable to delete template', 'Template parameter is missing');
|
||||
}
|
||||
if(template.type && (template.type === 'Workflow Job Template' || template.type === 'workflow_job_template')) {
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
resourceName: $filter('sanitize')(template.name),
|
||||
body: TemplatesStrings.get('workflowJobTemplates.deleteWorkflowJobTemplate.CONFIRM'),
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
}
|
||||
else if(template.type && (template.type === 'Job Template' || template.type === 'job_template')) {
|
||||
|
||||
jobTemplate.getDependentResourceCounts(template.id)
|
||||
.then((counts) => {
|
||||
const invalidateRelatedLines = [];
|
||||
let deleteModalBody = `<div class="Prompt-bodyQuery">${TemplatesStrings.get('jobTemplates.deleteJobTemplate.CONFIRM')}</div>`;
|
||||
|
||||
counts.forEach(countObj => {
|
||||
if(countObj.count && countObj.count > 0) {
|
||||
invalidateRelatedLines.push(`<div><span class="Prompt-warningResourceTitle">${countObj.label}</span><span class="badge List-titleBadge">${countObj.count}</span></div>`);
|
||||
}
|
||||
});
|
||||
|
||||
if (invalidateRelatedLines && invalidateRelatedLines.length > 0) {
|
||||
deleteModalBody = `<div class="Prompt-bodyQuery">${TemplatesStrings.get('jobTemplates.deleteJobTemplate.CONFIRM')} ${TemplatesStrings.get('jobTemplates.deleteJobTemplate.INVALIDATE')}</div>`;
|
||||
invalidateRelatedLines.forEach(invalidateRelatedLine => {
|
||||
deleteModalBody += invalidateRelatedLine;
|
||||
});
|
||||
}
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
resourceName: $filter('sanitize')(template.name),
|
||||
body: deleteModalBody,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
Alert('Error: Unable to delete template', 'Template parameter is missing');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.submitJob = function(template) {
|
||||
|
||||
@ -21,6 +21,7 @@ import WorkflowForm from './workflows.form';
|
||||
import CompletedJobsList from './completed-jobs.list';
|
||||
import InventorySourcesList from './inventory-sources.list';
|
||||
import TemplateList from './templates.list';
|
||||
import TemplatesStrings from './templates.strings';
|
||||
|
||||
export default
|
||||
angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.name, labels.name, workflowAdd.name, workflowEdit.name,
|
||||
@ -33,6 +34,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
|
||||
.factory('CompletedJobsList', CompletedJobsList)
|
||||
.factory('TemplateList', TemplateList)
|
||||
.value('InventorySourcesList', InventorySourcesList)
|
||||
.service('TemplatesStrings', TemplatesStrings)
|
||||
.config(['$stateProvider', 'stateDefinitionsProvider', '$stateExtenderProvider',
|
||||
function($stateProvider, stateDefinitionsProvider, $stateExtenderProvider) {
|
||||
let stateTree, addJobTemplate, editJobTemplate, addWorkflow, editWorkflow,
|
||||
|
||||
23
awx/ui/client/src/templates/templates.strings.js
Normal file
23
awx/ui/client/src/templates/templates.strings.js
Normal file
@ -0,0 +1,23 @@
|
||||
function TemplatesStrings (BaseString) {
|
||||
BaseString.call(this, 'templates');
|
||||
|
||||
let t = this.t;
|
||||
let ns = this.templates;
|
||||
|
||||
ns.jobTemplates = {
|
||||
deleteJobTemplate: {
|
||||
CONFIRM: t.s('Are you sure you want to delete this job template?'),
|
||||
INVALIDATE: t.s('Doing so will invalidate the following:')
|
||||
}
|
||||
};
|
||||
|
||||
ns.workflowJobTemplates = {
|
||||
deleteWorkflowJobTemplate: {
|
||||
CONFIRM: t.s('Are you sure you want to delete this workflow job template?')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TemplatesStrings.$inject = ['BaseStringService'];
|
||||
|
||||
export default TemplatesStrings;
|
||||
@ -1,8 +1,12 @@
|
||||
<div id="workflow-modal-dialog" style="display: none;">
|
||||
<div class="WorkflowMaker-deleteOverlay" ng-show="deleteOverlayVisible">
|
||||
<div class="modal-dialog">
|
||||
<div class="Modal-content modal-content">
|
||||
<div class="Modal-header">
|
||||
<div class="Modal-title">REMOVE</div>
|
||||
<div class="Modal-title">
|
||||
<span>DELETE</span>
|
||||
<span class="Modal-titleResourceName" ng-bind="nodeToBeDeleted.unifiedJobTemplate.name"></span>
|
||||
</div>
|
||||
<div class="Modal-exitHolder">
|
||||
<button class="close Modal-exit" ng-click="cancelDeleteNode()">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
@ -10,14 +14,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="Modal-body ng-binding">
|
||||
<div class="Prompt-bodyQuery">Are you sure you want to remove the template below?</div>
|
||||
<div class="Prompt-bodyTarget">{{nodeToBeDeleted.unifiedJobTemplate.name}}</div>
|
||||
<div class="Prompt-bodyQuery">Are you sure you want to delete this workflow node?</div>
|
||||
</div>
|
||||
<div class="Modal-footer">
|
||||
<button ng-click="cancelDeleteNode()" class="btn Modal-defaultButton Modal-footerButton">CANCEL</a>
|
||||
<button ng-click="confirmDeleteNode()" class="btn Modal-footerButton ng-binding Modal-errorButton">DELETE</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="WorkflowMaker-header">
|
||||
<div class="WorkflowMaker-title">
|
||||
|
||||
@ -87,7 +87,8 @@ export default ['$scope', '$rootScope', 'Rest', 'UserList', 'Prompt',
|
||||
|
||||
Prompt({
|
||||
hdr: i18n._('Delete'),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete the user below?') + '</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(name) + '</div>',
|
||||
resourceName: $filter('sanitize')(name),
|
||||
body: '<div class="Prompt-bodyQuery">' + i18n._('Are you sure you want to delete this user?') + '</div>',
|
||||
action: action,
|
||||
actionText: i18n._('DELETE')
|
||||
});
|
||||
|
||||
@ -35,11 +35,9 @@ export default ['$q', 'Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErr
|
||||
deleteJob: function(workflow) {
|
||||
Prompt({
|
||||
hdr: 'Delete Job',
|
||||
resourceName: `#${workflow.id} ` + $filter('sanitize')(workflow.name),
|
||||
body: `<div class='Prompt-bodyQuery'>
|
||||
Are you sure you want to delete the workflow below?
|
||||
</div>
|
||||
<div class='Prompt-bodyTarget'>
|
||||
#${workflow.id} ${$filter('sanitize')(workflow.name)}
|
||||
Are you sure you want to delete this workflow?
|
||||
</div>`,
|
||||
action: function() {
|
||||
Wait('start');
|
||||
@ -84,11 +82,9 @@ export default ['$q', 'Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErr
|
||||
|
||||
Prompt({
|
||||
hdr: 'Cancel Workflow',
|
||||
resourceName: `#${workflow.id} ${$filter('sanitize')(workflow.name)}`,
|
||||
body: `<div class='Prompt-bodyQuery'>
|
||||
Are you sure you want to cancel the workflow below?
|
||||
</div>
|
||||
<div class='Prompt-bodyTarget'>
|
||||
#${workflow.id} ${$filter('sanitize')(workflow.name)}
|
||||
Are you sure you want to cancel this workflow job?
|
||||
</div>`,
|
||||
action: function() {
|
||||
Wait('start');
|
||||
|
||||
@ -20,7 +20,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store.credentialType, 'CredentialTypeModel'],
|
||||
(data, Model) => new Model().http.post(data),
|
||||
(data, Model) => new Model().http.post({ data }),
|
||||
({ data }) => { store.credentialType.response = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ module.exports = {
|
||||
|
||||
client.inject(
|
||||
[store, 'OrganizationModel'],
|
||||
(_store_, Model) => new Model().http.post(_store_.organization),
|
||||
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||
({ data }) => { store.organization = data; }
|
||||
);
|
||||
|
||||
|
||||
@ -14,8 +14,10 @@ describe('Controller: TemplatesList', () => {
|
||||
canAddDeferred,
|
||||
q,
|
||||
TemplatesService,
|
||||
JobTemplateModel,
|
||||
deleteWorkflowJobTemplateDeferred,
|
||||
deleteJobTemplateDeferred,
|
||||
jobTemplateGetDepDeferred,
|
||||
Dataset;
|
||||
|
||||
beforeEach(angular.mock.module('awApp'));
|
||||
@ -78,11 +80,17 @@ describe('Controller: TemplatesList', () => {
|
||||
canAddDeferred = q.defer();
|
||||
deleteWorkflowJobTemplateDeferred = q.defer();
|
||||
deleteJobTemplateDeferred = q.defer();
|
||||
jobTemplateGetDepDeferred = q.defer();
|
||||
|
||||
rbacUiControlService.canAdd = jasmine.createSpy('canAdd').and.returnValue(canAddDeferred.promise);
|
||||
|
||||
TemplatesService.deleteWorkflowJobTemplate = jasmine.createSpy('deleteWorkflowJobTemplate').and.returnValue(deleteWorkflowJobTemplateDeferred.promise);
|
||||
TemplatesService.deleteJobTemplate = jasmine.createSpy('deleteJobTemplate').and.returnValue(deleteJobTemplateDeferred.promise);
|
||||
JobTemplateModel = function () {
|
||||
this.getDependentResourceCounts = function() {
|
||||
return jobTemplateGetDepDeferred.promise;
|
||||
};
|
||||
};
|
||||
|
||||
TemplatesListController = $controller('TemplatesListController', {
|
||||
$scope: scope,
|
||||
@ -94,8 +102,11 @@ describe('Controller: TemplatesList', () => {
|
||||
InitiatePlaybookRun: InitiatePlaybookRun,
|
||||
rbacUiControlService: rbacUiControlService,
|
||||
TemplatesService: TemplatesService,
|
||||
JobTemplateModel: JobTemplateModel,
|
||||
Dataset: Dataset
|
||||
});
|
||||
|
||||
rootScope.$apply();
|
||||
}));
|
||||
|
||||
describe('scope.editJobTemplate()', () => {
|
||||
@ -151,10 +162,13 @@ describe('Controller: TemplatesList', () => {
|
||||
|
||||
var testTemplate = {
|
||||
id: 1,
|
||||
name: "Test Template"
|
||||
name: "Test Template",
|
||||
type: "Job Template"
|
||||
};
|
||||
|
||||
scope.deleteJobTemplate(testTemplate);
|
||||
jobTemplateGetDepDeferred.resolve([]);
|
||||
rootScope.$apply();
|
||||
expect(Prompt).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -169,6 +183,8 @@ describe('Controller: TemplatesList', () => {
|
||||
};
|
||||
|
||||
scope.deleteJobTemplate(testTemplate);
|
||||
jobTemplateGetDepDeferred.resolve([]);
|
||||
rootScope.$apply();
|
||||
expect(TemplatesService.deleteWorkflowJobTemplate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -183,6 +199,8 @@ describe('Controller: TemplatesList', () => {
|
||||
};
|
||||
|
||||
scope.deleteJobTemplate(testTemplate);
|
||||
jobTemplateGetDepDeferred.resolve([]);
|
||||
rootScope.$apply();
|
||||
expect(TemplatesService.deleteJobTemplate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@ -130,8 +130,8 @@ describe('Components | Layout', () => {
|
||||
expect(_ComponentsStrings_.get).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('ComponentsStrings get() method should throw an error if string is not a property name of the layout class', () => {
|
||||
expect(controller.getString.bind(null, 'SUBMISSION_ERROR_TITLE')).toThrow();
|
||||
it('ComponentsStrings get() method should return undefined if string is not a property name of the layout class', () => {
|
||||
expect(controller.getString('SUBMISSION_ERROR_TITLE')).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should return layout string', () => {
|
||||
@ -145,16 +145,6 @@ describe('Components | Layout', () => {
|
||||
expect(controller.getString(key)).toBe(value);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return default string', () => {
|
||||
const defaultStrings = {
|
||||
BRAND_NAME: 'AWX'
|
||||
};
|
||||
|
||||
_.forEach(defaultStrings, (value, key) => {
|
||||
expect(controller.getString(key)).toBe(value);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user