1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Changes to notifications after API naming change

The API changed the /notifier endpoint to /noticiation_templates to match up with the terminology used with the UI
This commit is contained in:
Jared Tabor 2016-05-06 11:45:48 -04:00
parent 3170c1b8b8
commit b974422c6e
15 changed files with 56 additions and 56 deletions

View File

@ -312,7 +312,7 @@ export default
return { return {
notifications: { notifications: {
iterator: 'notification', iterator: 'notification',
url: 'api/v1/notifiers/' url: 'api/v1/notification_templates/'
} }
}; };
} }

View File

@ -383,7 +383,7 @@ export default
}, },
notifications: { notifications: {
iterator: 'notification', iterator: 'notification',
url: '/api/v1/notifiers/' url: '/api/v1/notification_templates/'
} }
}; };
} }

View File

@ -92,7 +92,7 @@ export default
}, },
notifications: { notifications: {
iterator: 'notification', iterator: 'notification',
url: '/api/v1/notifiers/' url: '/api/v1/notification_templates/'
} }
}; };
} }

View File

@ -277,7 +277,7 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
}, },
notifications: { notifications: {
iterator: 'notification', iterator: 'notification',
url: '/api/v1/notifiers/' url: '/api/v1/notification_templates/'
} }
}; };
} }

View File

@ -17,7 +17,7 @@ export default
$compile, $filter, ToggleNotification, NotificationsListInit, $compile, $filter, ToggleNotification, NotificationsListInit,
$stateParams, management_job) { $stateParams, management_job) {
var scope = $rootScope.$new(), var scope = $rootScope.$new(),
url = GetBasePath('notifiers'), url = GetBasePath('notification_templates'),
defaultUrl = GetBasePath('system_job_templates'), defaultUrl = GetBasePath('system_job_templates'),
list = NotificationsList, list = NotificationsList,
view = GenerateList, view = GenerateList,

View File

@ -19,7 +19,7 @@ export default
) { ) {
var generator = GenerateForm, var generator = GenerateForm,
form = NotificationsFormObject, form = NotificationsFormObject,
url = GetBasePath('notifiers'); url = GetBasePath('notification_templates');
generator.inject(form, { generator.inject(form, {
mode: 'add' , mode: 'add' ,
@ -40,7 +40,7 @@ export default
} }
} }
CreateSelect2({ CreateSelect2({
element: '#notifier_notification_type', element: '#notification_template_notification_type',
multiple: false multiple: false
}); });
}); });
@ -66,7 +66,7 @@ export default
for(var fld in form.fields){ for(var fld in form.fields){
if(form.fields[fld] && form.fields[fld].subForm){ if(form.fields[fld] && form.fields[fld].subForm){
$scope[fld] = null; $scope[fld] = null;
$scope.notifier_form[fld].$setPristine(); $scope.notification_template_form[fld].$setPristine();
} }
} }

View File

@ -18,6 +18,6 @@ export default {
}, },
ncyBreadcrumb: { ncyBreadcrumb: {
parent: 'notifications', parent: 'notifications',
label: 'Create Notifier' label: 'Create Notification Template'
} }
}; };

View File

@ -8,24 +8,24 @@ export default
[ 'Rest', 'Wait', [ 'Rest', 'Wait',
'NotificationsFormObject', 'ProcessErrors', 'GetBasePath', 'NotificationsFormObject', 'ProcessErrors', 'GetBasePath',
'GenerateForm', 'SearchInit' , 'PaginateInit', 'GenerateForm', 'SearchInit' , 'PaginateInit',
'LookUpInit', 'OrganizationList', 'notifier', 'LookUpInit', 'OrganizationList', 'notification_template',
'$scope', '$state', 'GetChoices', 'CreateSelect2', 'Empty', '$scope', '$state', 'GetChoices', 'CreateSelect2', 'Empty',
'$rootScope', 'NotificationsTypeChange', '$rootScope', 'NotificationsTypeChange',
function( function(
Rest, Wait, Rest, Wait,
NotificationsFormObject, ProcessErrors, GetBasePath, NotificationsFormObject, ProcessErrors, GetBasePath,
GenerateForm, SearchInit, PaginateInit, GenerateForm, SearchInit, PaginateInit,
LookUpInit, OrganizationList, notifier, LookUpInit, OrganizationList, notification_template,
$scope, $state, GetChoices, CreateSelect2, Empty, $scope, $state, GetChoices, CreateSelect2, Empty,
$rootScope, NotificationsTypeChange $rootScope, NotificationsTypeChange
) { ) {
var generator = GenerateForm, var generator = GenerateForm,
id = notifier.id, id = notification_template.id,
form = NotificationsFormObject, form = NotificationsFormObject,
master = {}, master = {},
url = GetBasePath('notifiers'); url = GetBasePath('notification_templates');
$scope.notifier = notifier; $scope.notification_template = notification_template;
generator.inject(form, { generator.inject(form, {
mode: 'edit' , mode: 'edit' ,
scope:$scope, scope:$scope,
@ -81,7 +81,7 @@ export default
master.notification_type = $scope.notification_type; master.notification_type = $scope.notification_type;
CreateSelect2({ CreateSelect2({
element: '#notifier_notification_type', element: '#notification_template_notification_typex',
multiple: false multiple: false
}); });
NotificationsTypeChange.getDetailFields($scope.notification_type.value).forEach(function(field) { NotificationsTypeChange.getDetailFields($scope.notification_type.value).forEach(function(field) {
@ -115,7 +115,7 @@ export default
for(var fld in form.fields){ for(var fld in form.fields){
if(form.fields[fld] && form.fields[fld].subForm){ if(form.fields[fld] && form.fields[fld].subForm){
$scope[fld] = null; $scope[fld] = null;
$scope.notifier_form[fld].$setPristine(); $scope.notification_template_form[fld].$setPristine();
} }
} }
@ -162,7 +162,7 @@ export default
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, form, { hdr: 'Error!', ProcessErrors($scope, data, status, form, { hdr: 'Error!',
msg: 'Failed to add new notifier. POST returned status: ' + status }); msg: 'Failed to add new notification template. POST returned status: ' + status });
}); });
}; };

View File

@ -8,11 +8,11 @@ import {templateUrl} from '../../shared/template-url/template-url.factory';
export default { export default {
name: 'notifications.edit', name: 'notifications.edit',
route: '/:notifier_id', route: '/:notification_template_id',
templateUrl: templateUrl('notifications/edit/edit'), templateUrl: templateUrl('notifications/edit/edit'),
controller: 'notificationsEditController', controller: 'notificationsEditController',
resolve: { resolve: {
notifier: notification_template:
[ '$state', [ '$state',
'$stateParams', '$stateParams',
'$q', '$q',
@ -20,13 +20,13 @@ export default {
'GetBasePath', 'GetBasePath',
'ProcessErrors', 'ProcessErrors',
function($state, $stateParams, $q, rest, getBasePath, ProcessErrors) { function($state, $stateParams, $q, rest, getBasePath, ProcessErrors) {
if ($stateParams.notifier) { if ($stateParams.notification_template) {
return $q.when($stateParams.notifier); return $q.when($stateParams.notification_template);
} }
var notifierId = $stateParams.notifier_id; var notificationTemplateId = $stateParams.notification_template_id;
var url = getBasePath('notifiers') + notifierId + '/'; var url = getBasePath('notification_templates') + notificationTemplateId + '/';
rest.setUrl(url); rest.setUrl(url);
return rest.get() return rest.get()
.then(function(data) { .then(function(data) {
@ -43,6 +43,6 @@ export default {
}, },
ncyBreadcrumb: { ncyBreadcrumb: {
parent: 'notifications', parent: 'notifications',
label: 'Edit Notifier' label: 'Edit Notification Template'
} }
}; };

View File

@ -15,7 +15,7 @@ export default
ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast, ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast,
$compile, $filter) { $compile, $filter) {
var scope = $rootScope.$new(), var scope = $rootScope.$new(),
defaultUrl = GetBasePath('notifiers'), defaultUrl = GetBasePath('notification_templates'),
list = NotificationTemplatesList, list = NotificationTemplatesList,
view = GenerateList; view = GenerateList;
@ -30,12 +30,12 @@ export default
} }
scope.removePostRefresh = scope.$on('PostRefresh', function () { scope.removePostRefresh = scope.$on('PostRefresh', function () {
Wait('stop'); Wait('stop');
if (scope.notifiers) { if (scope.notification_templates) {
scope.notifiers.forEach(function(notifier, i) { scope.notification_templates.forEach(function(notification_template, i) {
scope.notification_type_options.forEach(function(type) { scope.notification_type_options.forEach(function(type) {
if (type.value === notifier.notification_type) { if (type.value === notification_template.notification_type) {
scope.notifiers[i].notification_type = type.label; scope.notification_templates[i].notification_type = type.label;
scope.notifiers[i].status = notifier.summary_fields.recent_notifications[0].status; scope.notification_templates[i].status = notification_template.summary_fields.recent_notifications[0].status;
} }
}); });
}); });
@ -50,7 +50,7 @@ export default
SearchInit({ SearchInit({
scope: scope, scope: scope,
set: 'notifiers', set: 'notification_templates',
list: list, list: list,
url: defaultUrl url: defaultUrl
}); });
@ -117,9 +117,9 @@ export default
var recent_notifications, var recent_notifications,
html, title = "Recent Notifications"; html, title = "Recent Notifications";
scope.notifiers.forEach(function(notifier){ scope.notification_templates.forEach(function(notification_template){
if(notifier.id === id){ if(notification_template.id === id){
recent_notifications = notifier.summary_fields.recent_notifications; recent_notifications = notification_template.summary_fields.recent_notifications;
} }
}); });
Wait('stop'); Wait('stop');
@ -150,8 +150,8 @@ export default
}; };
scope.testNotification = function(){ scope.testNotification = function(){
var name = this.notifier.name; var name = this.notification_template.name;
Rest.setUrl(defaultUrl + this.notifier.id +'/test/'); Rest.setUrl(defaultUrl + this.notification_template.id +'/test/');
Rest.post({}) Rest.post({})
.then(function () { .then(function () {
ngToast.success({ ngToast.success({
@ -172,8 +172,8 @@ export default
scope.editNotification = function(){ scope.editNotification = function(){
$state.transitionTo('notifications.edit',{ $state.transitionTo('notifications.edit',{
notifier_id: this.notifier.id, notification_template_id: this.notification_template.id,
notifier: this.notifier notification_template: this.notification_templates
}); });
}; };

View File

@ -15,7 +15,7 @@ export default function() {
addTitle: 'New Notification Template', addTitle: 'New Notification Template',
editTitle: '{{ name }}', editTitle: '{{ name }}',
name: 'notifier', name: 'notification_template',
showActions: true, showActions: true,
subFormTitles: { subFormTitles: {
typeSubForm: 'Type Details', typeSubForm: 'Type Details',

View File

@ -8,9 +8,9 @@
export default function(){ export default function(){
return { return {
name: 'notifiers' , name: 'notification_templates' ,
listTitle: 'Notification Templates', listTitle: 'Notification Templates',
iterator: 'notifier', iterator: 'notification_template',
index: false, index: false,
hover: false, hover: false,
@ -24,10 +24,10 @@ export default function(){
iconOnly: true, iconOnly: true,
excludeModal: true, excludeModal: true,
icons: [{ icons: [{
icon: "{{ 'icon-job-' + notifier.status }}", icon: "{{ 'icon-job-' + notification_template.status }}",
awToolTip: "Click for recent notifications", awToolTip: "Click for recent notifications",
awTipPlacement: "right", awTipPlacement: "right",
ngClick: "showSummary($event, notifier.id)", ngClick: "showSummary($event, notification_templates.id)",
ngClass: "" ngClass: ""
}] }]
}, },
@ -35,7 +35,7 @@ export default function(){
key: true, key: true,
label: 'Name', label: 'Name',
columnClass: 'col-md-3 col-sm-9 col-xs-9', columnClass: 'col-md-3 col-sm-9 col-xs-9',
linkTo: '/#/notifications/{{notifier.id}}' linkTo: '/#/notifications/{{notification_template.id}}'
}, },
notification_type: { notification_type: {
label: 'Type', label: 'Type',
@ -60,7 +60,7 @@ export default function(){
columnClass: 'col-md-2 col-sm-3 col-xs-3', columnClass: 'col-md-2 col-sm-3 col-xs-3',
test: { test: {
ngClick: "testNotification(notification.id)", ngClick: "testNotification(notification_template.id)",
icon: 'fa-bell-o', icon: 'fa-bell-o',
label: 'Edit', label: 'Edit',
"class": 'btn-sm', "class": 'btn-sm',
@ -68,7 +68,7 @@ export default function(){
dataPlacement: 'top' dataPlacement: 'top'
}, },
edit: { edit: {
ngClick: "editNotification(notification.id)", ngClick: "editNotification(notification_template.id)",
icon: 'fa-edit', icon: 'fa-edit',
label: 'Edit', label: 'Edit',
"class": 'btn-sm', "class": 'btn-sm',
@ -76,7 +76,7 @@ export default function(){
dataPlacement: 'top' dataPlacement: 'top'
}, },
"delete": { "delete": {
ngClick: "deleteNotification(notifier.id, notifier.name)", ngClick: "deleteNotification(notification_template.id, notification_template.name)",
icon: 'fa-trash', icon: 'fa-trash',
label: 'Delete', label: 'Delete',
"class": 'btn-sm', "class": 'btn-sm',

View File

@ -26,23 +26,23 @@ export default function(){
excludeModal: true, excludeModal: true,
columnClass: 'col-md-4 hidden-sm hidden-xs' columnClass: 'col-md-4 hidden-sm hidden-xs'
}, },
notifiers_success: { notification_templates_success: {
label: 'Successful', label: 'Successful',
flag: 'notifiers_success', flag: 'notification_templates_success',
type: "toggle", type: "toggle",
ngClick: "toggleNotification($event, notification.id, \"notifiers_success\")", ngClick: "toggleNotification($event, notification.id, \"notification_templates_success\")",
awToolTip: "{{ schedule.play_tip }}", awToolTip: "{{ schedule.play_tip }}",
dataTipWatch: "schedule.play_tip", dataTipWatch: "schedule.play_tip",
dataPlacement: "right", dataPlacement: "right",
searchable: false, searchable: false,
nosort: true, nosort: true,
}, },
notifiers_error: { notification_templates_error: {
label: 'Failed', label: 'Failed',
columnClass: 'NotifierList-lastColumn', columnClass: 'NotifierList-lastColumn',
flag: 'notifiers_error', flag: 'notification_templates_error',
type: "toggle", type: "toggle",
ngClick: "toggleNotification($event, notification.id, \"notifiers_error\")", ngClick: "toggleNotification($event, notification.id, \"notification_templates_error\")",
awToolTip: "{{ schedule.play_tip }}", awToolTip: "{{ schedule.play_tip }}",
dataTipWatch: "schedule.play_tip", dataTipWatch: "schedule.play_tip",
dataPlacement: "right", dataPlacement: "right",

View File

@ -25,14 +25,14 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest',
scope.relatednotificationsRemove(); scope.relatednotificationsRemove();
} }
scope.relatednotificationsRemove = scope.$on('relatednotifications', function () { scope.relatednotificationsRemove = scope.$on('relatednotifications', function () {
var columns = ['/notifiers_success/', '/notifiers_error/']; var columns = ['/notification_templates_success/', '/notification_templates_error/'];
_.map(columns, function(column){ _.map(columns, function(column){
var notifier_url = url + id + column; var notifier_url = url + id + column;
Rest.setUrl(notifier_url); Rest.setUrl(notifier_url);
Rest.get() Rest.get()
.success( function(data, i, j, obj) { .success( function(data, i, j, obj) {
var type = (obj.url.indexOf('success')>0) ? "notifiers_success" : "notifiers_error"; var type = (obj.url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error";
if (data.results) { if (data.results) {
_.forEach(data.results, function(result){ _.forEach(data.results, function(result){
_.forEach(scope.notifications, function(notification){ _.forEach(scope.notifications, function(notification){

View File

@ -22,7 +22,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest',
id = params.id, id = params.id,
notifier_id = params.notifier.id, notifier_id = params.notifier.id,
callback = params.callback, callback = params.callback,
column = params.column, // notifiers_success/notifiers_error column = params.column, // notification_template_success/notification_template__error
url = params.url+ id+ "/"+ column + '/'; url = params.url+ id+ "/"+ column + '/';
if(!notifier[column]){ if(!notifier[column]){