1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #1630 from jaredevantabor/notifications

Add notifications to Management Jobs
This commit is contained in:
Jared Tabor 2016-04-21 09:21:58 -07:00
commit 718b5019b6
9 changed files with 198 additions and 2 deletions

View File

@ -159,6 +159,13 @@ export default
});
};
$scope.goToNotifications = function(card){
$state.transitionTo('managementJobsList.notifications',{
card: card,
management_id: card.id
});
};
$scope.submitJob = function (id, name, card) {
Wait('start');
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';

View File

@ -1,4 +1,5 @@
<div class="tab-pane" id="management_jobs">
<div ui-view></div>
<div class="MgmtCards">
<div class="MgmtCards-card"
ng-repeat="card in mgmtCards track by card.id">
@ -6,6 +7,10 @@
<div class="MgmtCards-header">
<h3 class="MgmtCards-label"> {{ card.name }}</h3>
<div class="MgmtCards-actionItems">
<button class="MgmtCards-actionItem List-actionButton"
ng-click='goToNotifications(card, card.id)'>
<i class="MgmtCards-actionItemIcon fa fa-bell-o"></i>
</button>
<button class="MgmtCards-actionItem List-actionButton"
ng-click='chooseRunJob(card.id, card.name)'>
<i class="MgmtCards-actionItemIcon fa fa-rocket"></i>

View File

@ -7,10 +7,12 @@
import managementJobsCard from './card/main';
import managementJobsScheduler from './scheduler/main';
import list from './management-jobs.list';
import managementJobsNotifications from './notifications/main';
export default
angular.module('managementJobs', [
managementJobsCard.name,
managementJobsScheduler.name
managementJobsScheduler.name,
managementJobsNotifications.name
])
.factory('managementJobsListObject', list);

View File

@ -0,0 +1,15 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
import route from './notification.route';
import controller from './notification.controller';
export default
angular.module('managementJobsNotifications', [])
.controller('managementJobsNotificationsController', controller)
.run(['$stateExtender', function($stateExtender) {
$stateExtender.addState(route);
}]);

View File

@ -0,0 +1,105 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default
[ '$rootScope','Wait', 'generateList', 'NotificationsList',
'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' ,
'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find',
'ngToast', '$compile', '$filter','ToggleNotification',
'NotificationsListInit', '$stateParams', 'management_job',
function(
$rootScope,Wait, GenerateList, NotificationsList,
GetBasePath, SearchInit, PaginateInit, Rest,
ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast,
$compile, $filter, ToggleNotification, NotificationsListInit,
$stateParams, management_job) {
var scope = $rootScope.$new(),
url = GetBasePath('notifiers'),
defaultUrl = GetBasePath('system_job_templates'),
list = NotificationsList,
view = GenerateList,
id = $stateParams.management_id;
list.listTitle = `${management_job.name} | Notifications`;
view.inject( list, {
mode: 'edit',
cancelButton: true,
scope: scope
});
NotificationsListInit({
scope: scope,
url: defaultUrl,
id: id
});
scope.formCancel = function() {
$state.go('managementJobsList');
};
scope.toggleNotification = function(event, notifier_id, column) {
var notifier = this.notification;
try {
$(event.target).tooltip('hide');
}
catch(e) {
// ignore
}
ToggleNotification({
scope: scope,
url: defaultUrl,
id: id,
notifier: notifier,
column: column,
callback: 'NotificationRefresh'
});
};
if (scope.removePostRefresh) {
scope.removePostRefresh();
}
scope.removePostRefresh = scope.$on('PostRefresh', function () {
scope.$emit('relatednotifications');
});
if (scope.removeChoicesHere) {
scope.removeChoicesHere();
}
scope.removeChoicesHere = scope.$on('choicesReadyNotifierList', function () {
list.fields.notification_type.searchOptions = scope.notification_type_options;
SearchInit({
scope: scope,
set: 'notifications',
list: list,
url: url
});
if ($rootScope.addedItem) {
scope.addedItem = $rootScope.addedItem;
delete $rootScope.addedItem;
}
PaginateInit({
scope: scope,
list: list,
url: url
});
scope.search(list.iterator);
});
GetChoices({
scope: scope,
url: url,
field: 'notification_type',
variable: 'notification_type_options',
callback: 'choicesReadyNotifierList'
});
}
];

View File

@ -0,0 +1,52 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
import {templateUrl} from '../../shared/template-url/template-url.factory';
export default {
name: 'managementJobsList.notifications',
route: '/:management_id/notifications',
templateUrl: templateUrl('management-jobs/notifications/notifications'),
controller: 'managementJobsNotificationsController',
params: {card: null},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}],
management_job:
[ '$stateParams',
'$q',
'Rest',
'GetBasePath',
'ProcessErrors',
function($stateParams, $q, rest, getBasePath, ProcessErrors) {
if ($stateParams.card) {
return $q.when($stateParams.card);
}
var managementJobId = $stateParams.management_id;
var url = getBasePath('system_job_templates') + managementJobId + '/';
rest.setUrl(url);
return rest.get()
.then(function(data) {
return data.data;
}).catch(function (response) {
ProcessErrors(null, response.data, response.status, null, {
hdr: 'Error!',
msg: 'Failed to get management job info. GET returned status: ' +
response.status
});
});
}
]
},
ncyBreadcrumb: {
parent: 'setup',
label: 'MANAGEMENT JOBS'
},
};

View File

@ -0,0 +1,4 @@
<div class="tab-pane" id="notifications">
<div ui-view></div>
<div ng-cloak id="htmlTemplate" class="Panel"></div>
</div>

View File

@ -40,7 +40,7 @@ export default function(){
notification_type: {
label: 'Type',
searchType: 'select',
searchOptions: [], // will be set by Options call to projects resource
searchOptions: [],
excludeModal: true,
columnClass: 'col-md-4 hidden-sm hidden-xs'
}

View File

@ -316,6 +316,12 @@ export default ['$location', '$compile', '$rootScope', 'SearchWidget', 'Paginate
}
html += "</div>";
if(options.cancelButton === true) {
html += "<div class=\"Form-exitHolder\">";
html += "<button class=\"Form-exit\" ng-click=\"formCancel()\">";
html += "<i class=\"fa fa-times-circle\"></i>";
html += "</button></div>\n";
}
html += "<div class=\"List-actionHolder\">";
if(list.toolbarAuxAction) {
html += "<div class=\"List-auxAction\">";