1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Merge pull request #6349 from jaredevantabor/source-notifications

adding notifications to sources edit
This commit is contained in:
Jared Tabor 2017-05-25 11:54:53 -04:00 committed by GitHub
commit fa13557174
2 changed files with 91 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import { copyMoveGroupRoute, copyMoveHostRoute } from './copy-move/copy-move.rou
import copyMove from './copy-move/main';
import completedJobsRoute from './completed_jobs/completed_jobs.route';
import inventorySourceEditRoute from './sources/edit/sources-edit.route';
import inventorySourceEditNotificationsRoute from './sources/edit/sources-notifications.route';
import inventorySourceAddRoute from './sources/add/sources-add.route';
import inventorySourceListRoute from './sources/list/sources-list.route';
import inventorySourceListScheduleRoute from './sources/list/schedule/sources-schedule.route';
@ -230,6 +231,7 @@ angular.module('inventory', [
stateExtender.buildDefinition(inventorySourceListRoute),
stateExtender.buildDefinition(inventorySourceAddRoute),
stateExtender.buildDefinition(inventorySourceEditRoute),
stateExtender.buildDefinition(inventorySourceEditNotificationsRoute),
stateExtender.buildDefinition(inventoryCompletedJobsRoute),
stateExtender.buildDefinition(smartInventoryCompletedJobsRoute),
stateExtender.buildDefinition(addSourceCredential),

View File

@ -0,0 +1,89 @@
import { N_ } from '../../../i18n';
export default {
searchPrefix: 'notification',
name: "inventories.edit.inventory_sources.edit.notifications",
url: `/notifications`,
ncyBreadcrumb: {
parent: "inventories.edit.inventory_sources.edit",
label: N_("NOTIFICATIONS")
},
params: {
[ 'notification_search']: {
value: { order_by: 'name' }
}
},
views: {
'related': {
templateProvider: function(FormDefinition, GenerateForm, $stateParams, SourcesFormDefinition) {
var form, html;
if($stateParams && $stateParams.inventory_source_id){
form = SourcesFormDefinition;
}
else {
form = typeof(FormDefinition) === 'function' ?
FormDefinition() : FormDefinition;
}
html = GenerateForm.buildCollection({
mode: 'edit',
related: `notifications`,
form: form
});
return html;
},
controller: ['$scope', 'NotificationsList', 'Dataset', 'ToggleNotification', 'NotificationsListInit', 'GetBasePath', '$stateParams',
function($scope, list, Dataset, ToggleNotification, NotificationsListInit, GetBasePath, $stateParams) {
var params = $stateParams,
id = params.inventory_source_id,
url = GetBasePath('inventory_sources');
function init() {
$scope.list = list;
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
NotificationsListInit({
scope: $scope,
url: url,
id: id
});
$scope.$watch(`${list.iterator}_dataset`, function() {
// The list data has changed and we need to update which notifications are on/off
$scope.$emit('relatednotifications');
});
}
$scope.toggleNotification = function(event, notifier_id, column) {
var notifier = this.notification;
try {
$(event.target).tooltip('hide');
}
catch(e) {
// ignore
}
ToggleNotification({
scope: $scope,
url: url + id,
notifier: notifier,
column: column,
callback: 'NotificationRefresh'
});
};
init();
}
]
}
},
resolve: {
Dataset: ['NotificationsList', 'QuerySet', '$stateParams', 'GetBasePath',
(list, qs, $stateParams, GetBasePath) => {
let path = GetBasePath(list.basePath);
return qs.search(path, $stateParams[`${list.iterator}_search`]);
}
]
}
};