mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 02:17:37 -02:30
Adds approval toggles to wf and org notif lists
This commit is contained in:
@@ -35,6 +35,19 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){
|
|||||||
excludeModal: true,
|
excludeModal: true,
|
||||||
columnClass: 'd-none d-sm-flex col-md-4 col-sm-3'
|
columnClass: 'd-none d-sm-flex col-md-4 col-sm-3'
|
||||||
},
|
},
|
||||||
|
notification_templates_approvals: {
|
||||||
|
label: i18n._('Approval'),
|
||||||
|
columnClass: 'd-none d-md-flex justify-content-start col-md-1',
|
||||||
|
flag: 'notification_templates_approvals',
|
||||||
|
type: "toggle",
|
||||||
|
ngClick: "toggleNotification($event, notification.id, 'notification_templates_approvals')",
|
||||||
|
ngDisabled: "!sufficientRoleForNotifToggle",
|
||||||
|
awToolTip: "{{ schedule.play_tip }}",
|
||||||
|
dataTipWatch: "schedule.play_tip",
|
||||||
|
dataPlacement: "right",
|
||||||
|
nosort: true,
|
||||||
|
ngIf: "showApprovalColumn"
|
||||||
|
},
|
||||||
notification_templates_started: {
|
notification_templates_started: {
|
||||||
label: i18n._("Start"),
|
label: i18n._("Start"),
|
||||||
flag: 'notification_templates_started',
|
flag: 'notification_templates_started',
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
|
|||||||
url = params.url,
|
url = params.url,
|
||||||
id = params.id;
|
id = params.id;
|
||||||
|
|
||||||
|
if ($state.includes('templates.editWorkflowJobTemplate') || $state.includes('organizations.edit')) {
|
||||||
|
scope.showApprovalColumn = true;
|
||||||
|
}
|
||||||
|
|
||||||
scope.addNotificationTemplate = function() {
|
scope.addNotificationTemplate = function() {
|
||||||
var org_id;
|
var org_id;
|
||||||
if($stateParams.hasOwnProperty('project_id')){
|
if($stateParams.hasOwnProperty('project_id')){
|
||||||
@@ -51,6 +55,10 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
|
|||||||
scope.relatednotificationsRemove = scope.$on('relatednotifications', function () {
|
scope.relatednotificationsRemove = scope.$on('relatednotifications', function () {
|
||||||
var columns = ['/notification_templates_started/', '/notification_templates_success/', '/notification_templates_error/'];
|
var columns = ['/notification_templates_started/', '/notification_templates_success/', '/notification_templates_error/'];
|
||||||
|
|
||||||
|
if ($state.includes('templates.editWorkflowJobTemplate') || $state.includes('organizations.edit')) {
|
||||||
|
columns.push('/notification_templates_approvals');
|
||||||
|
}
|
||||||
|
|
||||||
GetChoices({
|
GetChoices({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
url: GetBasePath('notifications'),
|
url: GetBasePath('notifications'),
|
||||||
@@ -64,9 +72,17 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
|
|||||||
Rest.setUrl(notifier_url);
|
Rest.setUrl(notifier_url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
let checkForSuccessOrError = response.config.url.indexOf('success') > 0 ? "notification_templates_success" : "notification_templates_error";
|
let type;
|
||||||
|
|
||||||
let type = response.config.url.indexOf('started') > 0 ? "notification_templates_started" : checkForSuccessOrError;
|
if (response.config.url.indexOf('started') > 0) {
|
||||||
|
type = "notification_templates_started";
|
||||||
|
} else if (response.config.url.indexOf('success') > 0) {
|
||||||
|
type = "notification_templates_success";
|
||||||
|
} else if (response.config.url.indexOf('error') > 0) {
|
||||||
|
type = "notification_templates_error";
|
||||||
|
} else if (response.config.url.indexOf('approvals') > 0) {
|
||||||
|
type = "notification_templates_approvals";
|
||||||
|
}
|
||||||
|
|
||||||
if (response.data.results) {
|
if (response.data.results) {
|
||||||
_.forEach(response.data.results, function(result){
|
_.forEach(response.data.results, function(result){
|
||||||
|
|||||||
@@ -527,8 +527,9 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
} else if (field.type === 'template') {
|
} else if (field.type === 'template') {
|
||||||
html = Template(field);
|
html = Template(field);
|
||||||
} else if (field.type === 'toggle') {
|
} else if (field.type === 'toggle') {
|
||||||
|
const ngIf = field.ngIf ? `ng-if="${field.ngIf}"` : '';
|
||||||
html += `
|
html += `
|
||||||
<div class="atSwitch-listTableCell ${field}-column ${field['class']} ${field.columnClass}">
|
<div class="atSwitch-listTableCell ${field['class']} ${field.columnClass}" ${ngIf}>
|
||||||
<at-switch on-toggle="${field.ngClick}" switch-on="${"flag" in field} ? ${list.iterator}.${field.flag} : ${list.iterator}.enabled" switch-disabled="${"ngDisabled" in field} ? ${field.ngDisabled} : false" tooltip-string="${field.awToolTip}" tooltip-placement="${field.dataPlacement ? field.dataPlacement : 'right'}" tooltip-watch="${field.dataTipWatch}"></at-switch>
|
<at-switch on-toggle="${field.ngClick}" switch-on="${"flag" in field} ? ${list.iterator}.${field.flag} : ${list.iterator}.enabled" switch-disabled="${"ngDisabled" in field} ? ${field.ngDisabled} : false" tooltip-string="${field.awToolTip}" tooltip-placement="${field.dataPlacement ? field.dataPlacement : 'right'}" tooltip-watch="${field.dataTipWatch}"></at-switch>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -546,7 +546,9 @@ export default ['$compile', 'Attr', 'Icon',
|
|||||||
for (fld in list.fields) {
|
for (fld in list.fields) {
|
||||||
if (options.mode !== 'lookup' || (options.mode === 'lookup' && (fld === 'name' || _.has(list.fields[fld], 'includeModal')))){
|
if (options.mode !== 'lookup' || (options.mode === 'lookup' && (fld === 'name' || _.has(list.fields[fld], 'includeModal')))){
|
||||||
let customClass = list.fields[fld].columnClass || '';
|
let customClass = list.fields[fld].columnClass || '';
|
||||||
|
const ngIf = list.fields[fld].ngIf ? `ng-if="${list.fields[fld].ngIf}"` : '';
|
||||||
html += `<div
|
html += `<div
|
||||||
|
${ngIf}
|
||||||
base-path="${list.basePath || list.name}"
|
base-path="${list.basePath || list.name}"
|
||||||
collection="${list.name}"
|
collection="${list.name}"
|
||||||
dataset="${list.iterator}_dataset"
|
dataset="${list.iterator}_dataset"
|
||||||
|
|||||||
Reference in New Issue
Block a user