mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Adding initial notifications files
This commit is contained in:
parent
29e0652bfc
commit
a35368f558
@ -30,6 +30,7 @@ import inventoryScripts from './inventory-scripts/main';
|
||||
import permissions from './permissions/main';
|
||||
import managementJobs from './management-jobs/main';
|
||||
import jobDetail from './job-detail/main';
|
||||
import notifications from './notifications/main';
|
||||
|
||||
// modules
|
||||
import about from './about/main';
|
||||
@ -98,6 +99,7 @@ var tower = angular.module('Tower', [
|
||||
activityStream.name,
|
||||
footer.name,
|
||||
jobDetail.name,
|
||||
notifications.name,
|
||||
standardOut.name,
|
||||
'templates',
|
||||
'Utilities',
|
||||
@ -882,13 +884,13 @@ var tower = angular.module('Tower', [
|
||||
}]);
|
||||
}])
|
||||
|
||||
.run(['$q', '$compile', '$cookieStore', '$rootScope', '$log', '$state', 'CheckLicense',
|
||||
.run(['$q', '$compile', '$cookieStore', '$rootScope', '$log', '$state', 'CheckLicense',
|
||||
'$location', 'Authorization', 'LoadBasePaths', 'Timer', 'ClearScope', 'Socket',
|
||||
'LoadConfig', 'Store', 'ShowSocketHelp', 'pendoService',
|
||||
function (
|
||||
$q, $compile, $cookieStore, $rootScope, $log, $state, CheckLicense,
|
||||
$q, $compile, $cookieStore, $rootScope, $log, $state, CheckLicense,
|
||||
$location, Authorization, LoadBasePaths, Timer, ClearScope, Socket,
|
||||
LoadConfig, Store, ShowSocketHelp, pendoService)
|
||||
LoadConfig, Store, ShowSocketHelp, pendoService)
|
||||
{
|
||||
var sock;
|
||||
|
||||
|
67
awx/ui/client/src/notifications/add/add.controller.js
Normal file
67
awx/ui/client/src/notifications/add/add.controller.js
Normal file
@ -0,0 +1,67 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
export default
|
||||
[ '$rootScope', 'pagination', '$compile','SchedulerInit', 'Rest', 'Wait',
|
||||
'notificationsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty',
|
||||
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
||||
'LookUpInit', 'OrganizationList', '$scope', '$state',
|
||||
function(
|
||||
$rootScope, pagination, $compile, SchedulerInit, Rest, Wait,
|
||||
notificationsFormObject, ProcessErrors, GetBasePath, Empty,
|
||||
GenerateForm, SearchInit, PaginateInit,
|
||||
LookUpInit, OrganizationList, $scope, $state
|
||||
) {
|
||||
var scope = $scope,
|
||||
generator = GenerateForm,
|
||||
form = notificationsFormObject,
|
||||
url = GetBasePath('notifications');
|
||||
|
||||
generator.inject(form, {
|
||||
mode: 'add' ,
|
||||
scope:scope,
|
||||
related: false
|
||||
});
|
||||
generator.reset();
|
||||
|
||||
LookUpInit({
|
||||
url: GetBasePath('organization'),
|
||||
scope: scope,
|
||||
form: form,
|
||||
list: OrganizationList,
|
||||
field: 'organization',
|
||||
input_type: 'radio'
|
||||
});
|
||||
|
||||
// Save
|
||||
scope.formSave = function () {
|
||||
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.post({
|
||||
name: scope.name,
|
||||
description: scope.description,
|
||||
organization: scope.organization,
|
||||
script: scope.script
|
||||
})
|
||||
.success(function (data) {
|
||||
$rootScope.addedItem = data.id;
|
||||
$state.go('inventoryScripts', {}, {reload: true});
|
||||
Wait('stop');
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to add new inventory script. POST returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
scope.formCancel = function () {
|
||||
$state.transitionTo('inventoryScripts');
|
||||
};
|
||||
|
||||
}
|
||||
];
|
3
awx/ui/client/src/notifications/add/add.partial.html
Normal file
3
awx/ui/client/src/notifications/add/add.partial.html
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="tab-pane" id="notifications_add">
|
||||
<div ng-cloak id="htmlTemplate" class="Panel"></div>
|
||||
</div>
|
23
awx/ui/client/src/notifications/add/add.route.js
Normal file
23
awx/ui/client/src/notifications/add/add.route.js
Normal file
@ -0,0 +1,23 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||
|
||||
export default {
|
||||
name: 'notifications.add',
|
||||
route: '/add',
|
||||
templateUrl: templateUrl('notifications/add/add'),
|
||||
controller: 'notificationsAddController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
parent: 'notifications',
|
||||
label: 'Create Notification'
|
||||
}
|
||||
};
|
15
awx/ui/client/src/notifications/add/main.js
Normal file
15
awx/ui/client/src/notifications/add/main.js
Normal file
@ -0,0 +1,15 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
import route from './add.route';
|
||||
import controller from './add.controller';
|
||||
|
||||
export default
|
||||
angular.module('notificationsAdd', [])
|
||||
.controller('notificationsAddController', controller)
|
||||
.run(['$stateExtender', function($stateExtender) {
|
||||
$stateExtender.addState(route);
|
||||
}]);
|
97
awx/ui/client/src/notifications/edit/edit.controller.js
Normal file
97
awx/ui/client/src/notifications/edit/edit.controller.js
Normal file
@ -0,0 +1,97 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
export default
|
||||
[ 'Rest', 'Wait',
|
||||
'notificationsFormObject', 'ProcessErrors', 'GetBasePath',
|
||||
'GenerateForm', 'SearchInit' , 'PaginateInit',
|
||||
'LookUpInit', 'OrganizationList', 'inventory_script',
|
||||
'$scope', '$state',
|
||||
function(
|
||||
Rest, Wait,
|
||||
notificationsFormObject, ProcessErrors, GetBasePath,
|
||||
GenerateForm, SearchInit, PaginateInit,
|
||||
LookUpInit, OrganizationList, inventory_script,
|
||||
$scope, $state
|
||||
) {
|
||||
var generator = GenerateForm,
|
||||
id = inventory_script.id,
|
||||
form = notificationsFormObject,
|
||||
master = {},
|
||||
url = GetBasePath('notifications');
|
||||
|
||||
$scope.inventory_script = inventory_script;
|
||||
generator.inject(form, {
|
||||
mode: 'edit' ,
|
||||
scope:$scope,
|
||||
related: false,
|
||||
activityStream: false
|
||||
});
|
||||
generator.reset();
|
||||
LookUpInit({
|
||||
url: GetBasePath('organization'),
|
||||
scope: $scope,
|
||||
form: form,
|
||||
// hdr: "Select Custom Inventory",
|
||||
list: OrganizationList,
|
||||
field: 'organization',
|
||||
input_type: 'radio'
|
||||
});
|
||||
|
||||
// Retrieve detail record and prepopulate the form
|
||||
Wait('start');
|
||||
Rest.setUrl(url + id+'/');
|
||||
Rest.get()
|
||||
.success(function (data) {
|
||||
var fld;
|
||||
for (fld in form.fields) {
|
||||
if (data[fld]) {
|
||||
$scope[fld] = data[fld];
|
||||
master[fld] = data[fld];
|
||||
}
|
||||
|
||||
if (form.fields[fld].sourceModel && data.summary_fields &&
|
||||
data.summary_fields[form.fields[fld].sourceModel]) {
|
||||
$scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||
}
|
||||
}
|
||||
Wait('stop');
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to retrieve inventory script: ' + id + '. GET status: ' + status });
|
||||
});
|
||||
|
||||
$scope.formSave = function () {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
Rest.setUrl(url+ id+'/');
|
||||
Rest.put({
|
||||
name: $scope.name,
|
||||
description: $scope.description,
|
||||
organization: $scope.organization,
|
||||
script: $scope.script
|
||||
})
|
||||
.success(function () {
|
||||
$state.transitionTo('inventoryScriptsList');
|
||||
Wait('stop');
|
||||
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to add new inventory script. PUT returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
$scope.formCancel = function () {
|
||||
$state.transitionTo('inventoryScripts');
|
||||
};
|
||||
|
||||
}
|
||||
];
|
3
awx/ui/client/src/notifications/edit/edit.partial.html
Normal file
3
awx/ui/client/src/notifications/edit/edit.partial.html
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="tab-pane" id="notficiations_edit">
|
||||
<div ng-cloak id="htmlTemplate" class="Panel"></div>
|
||||
</div>
|
23
awx/ui/client/src/notifications/edit/edit.route.js
Normal file
23
awx/ui/client/src/notifications/edit/edit.route.js
Normal file
@ -0,0 +1,23 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||
|
||||
export default {
|
||||
name: 'notifications.edit',
|
||||
route: '/edit',
|
||||
templateUrl: templateUrl('notifications/edit/edit'),
|
||||
controller: 'notificationsEditController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
parent: 'notifications',
|
||||
label: 'Edit Notification'
|
||||
}
|
||||
};
|
15
awx/ui/client/src/notifications/edit/main.js
Normal file
15
awx/ui/client/src/notifications/edit/main.js
Normal file
@ -0,0 +1,15 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
import route from './edit.route';
|
||||
import controller from './edit.controller';
|
||||
|
||||
export default
|
||||
angular.module('notificationsEdit', [])
|
||||
.controller('notificationsEditController', controller)
|
||||
.run(['$stateExtender', function($stateExtender) {
|
||||
$stateExtender.addState(route);
|
||||
}]);
|
83
awx/ui/client/src/notifications/list/list.controller.js
Normal file
83
awx/ui/client/src/notifications/list/list.controller.js
Normal file
@ -0,0 +1,83 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
export default
|
||||
[ '$rootScope','Wait', 'generateList', 'notificationsListObject',
|
||||
'GetBasePath' , 'SearchInit' , 'PaginateInit',
|
||||
'Rest' , 'ProcessErrors', 'Prompt', '$state',
|
||||
function(
|
||||
$rootScope,Wait, GenerateList, notificationsListObject,
|
||||
GetBasePath, SearchInit, PaginateInit,
|
||||
Rest, ProcessErrors, Prompt, $state
|
||||
) {
|
||||
var scope = $rootScope.$new(),
|
||||
defaultUrl = GetBasePath('notifications'),
|
||||
list = notificationsListObject,
|
||||
view = GenerateList;
|
||||
|
||||
view.inject( list, {
|
||||
mode: 'edit',
|
||||
scope: scope
|
||||
});
|
||||
|
||||
// SearchInit({
|
||||
// scope: scope,
|
||||
// set: 'notifications',
|
||||
// list: list,
|
||||
// url: defaultUrl
|
||||
// });
|
||||
//
|
||||
// if ($rootScope.addedItem) {
|
||||
// scope.addedItem = $rootScope.addedItem;
|
||||
// delete $rootScope.addedItem;
|
||||
// }
|
||||
// PaginateInit({
|
||||
// scope: scope,
|
||||
// list: list,
|
||||
// url: defaultUrl
|
||||
// });
|
||||
//
|
||||
// scope.search(list.iterator);
|
||||
|
||||
scope.editNotification = function(){
|
||||
$state.transitionTo('notifications.edit',{
|
||||
inventory_script_id: this.inventory_script.id,
|
||||
inventory_script: this.inventory_script
|
||||
});
|
||||
};
|
||||
|
||||
scope.deleteNotification = function(id, name){
|
||||
|
||||
var action = function () {
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
.success(function () {
|
||||
scope.search(list.iterator);
|
||||
})
|
||||
.error(function (data, status) {
|
||||
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
var bodyHtml = '<div class="Prompt-bodyQuery">Are you sure you want to delete the inventory script below?</div><div class="Prompt-bodyTarget">' + name + '</div>';
|
||||
Prompt({
|
||||
hdr: 'Delete',
|
||||
body: bodyHtml,
|
||||
action: action,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
};
|
||||
|
||||
scope.addNotification = function(){
|
||||
$state.transitionTo('notifications.add');
|
||||
};
|
||||
|
||||
}
|
||||
];
|
4
awx/ui/client/src/notifications/list/list.partial.html
Normal file
4
awx/ui/client/src/notifications/list/list.partial.html
Normal file
@ -0,0 +1,4 @@
|
||||
<div class="tab-pane" id="notifications">
|
||||
<div ui-view></div>
|
||||
<div ng-cloak id="htmlTemplate" class="Panel"></div>
|
||||
</div>
|
19
awx/ui/client/src/notifications/list/list.route.js
Normal file
19
awx/ui/client/src/notifications/list/list.route.js
Normal file
@ -0,0 +1,19 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||
|
||||
export default {
|
||||
name: 'notifications',
|
||||
route: '/notifications',
|
||||
templateUrl: templateUrl('notifications/list/list'),
|
||||
controller: 'notificationsListController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
};
|
15
awx/ui/client/src/notifications/list/main.js
Normal file
15
awx/ui/client/src/notifications/list/main.js
Normal file
@ -0,0 +1,15 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
import route from './list.route';
|
||||
import controller from './list.controller';
|
||||
|
||||
export default
|
||||
angular.module('notificationsList', [])
|
||||
.controller('notificationsListController', controller)
|
||||
.run(['$stateExtender', function($stateExtender) {
|
||||
$stateExtender.addState(route);
|
||||
}]);
|
22
awx/ui/client/src/notifications/main.js
Normal file
22
awx/ui/client/src/notifications/main.js
Normal file
@ -0,0 +1,22 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2016 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
|
||||
import notificationsList from './list/main';
|
||||
import notificationsAdd from './add/main';
|
||||
import notificationsEdit from './edit/main';
|
||||
|
||||
import list from './notifications.list';
|
||||
import form from './notifications.form';
|
||||
|
||||
export default
|
||||
angular.module('notifications', [
|
||||
notificationsList.name,
|
||||
notificationsAdd.name,
|
||||
notificationsEdit.name
|
||||
])
|
||||
.factory('notificationsListObject', list)
|
||||
.factory('notificationsFormObject', form);
|
47
awx/ui/client/src/notifications/notifications.form.js
Normal file
47
awx/ui/client/src/notifications/notifications.form.js
Normal file
@ -0,0 +1,47 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name forms.function:CustomInventory
|
||||
* @description This form is for adding/editing an organization
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
return {
|
||||
|
||||
addTitle: 'New Notification',
|
||||
editTitle: '{{ name }}',
|
||||
name: 'notification',
|
||||
showActions: true,
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
label: 'Name',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
capitalize: false
|
||||
},
|
||||
description: {
|
||||
label: 'Description',
|
||||
type: 'text',
|
||||
addRequired: false,
|
||||
editRequired: false
|
||||
}
|
||||
},
|
||||
|
||||
buttons: { //for now always generates <button> tags
|
||||
save: {
|
||||
ngClick: 'formSave()', //$scope.function to call on click, optional
|
||||
ngDisabled: true //Disable when $pristine or $invalid, optional
|
||||
},
|
||||
cancel: {
|
||||
ngClick: 'formCancel()',
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
63
awx/ui/client/src/notifications/notifications.list.js
Normal file
63
awx/ui/client/src/notifications/notifications.list.js
Normal file
@ -0,0 +1,63 @@
|
||||
/*************************************************
|
||||
* Copyright (c) 2015 Ansible, Inc.
|
||||
*
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
|
||||
|
||||
export default function(){
|
||||
return {
|
||||
name: 'notifications' ,
|
||||
listTitle: 'Notifications',
|
||||
iterator: 'notification',
|
||||
index: false,
|
||||
hover: false,
|
||||
|
||||
fields: {
|
||||
name: {
|
||||
key: true,
|
||||
label: 'Name',
|
||||
columnClass: 'col-md-3 col-sm-9 col-xs-9',
|
||||
modalColumnClass: 'col-md-8'
|
||||
},
|
||||
description: {
|
||||
label: 'Description',
|
||||
excludeModal: true,
|
||||
columnClass: 'col-md-4 hidden-sm hidden-xs'
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
add: {
|
||||
mode: 'all', // One of: edit, select, all
|
||||
ngClick: 'addNotification()',
|
||||
awToolTip: 'Create a new custom inventory',
|
||||
actionClass: 'btn List-buttonSubmit',
|
||||
buttonContent: '+ ADD'
|
||||
}
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
|
||||
columnClass: 'col-md-2 col-sm-3 col-xs-3',
|
||||
|
||||
edit: {
|
||||
ngClick: "editNotification(inventory_script.id)",
|
||||
icon: 'fa-edit',
|
||||
label: 'Edit',
|
||||
"class": 'btn-sm',
|
||||
awToolTip: 'Edit credential',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
"delete": {
|
||||
ngClick: "deleteNotification(notification.id, notification.name)",
|
||||
icon: 'fa-trash',
|
||||
label: 'Delete',
|
||||
"class": 'btn-sm',
|
||||
awToolTip: 'Delete credential',
|
||||
dataPlacement: 'top'
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
@ -36,6 +36,12 @@
|
||||
Create and edit scripts to dynamically load hosts from any source.
|
||||
</p>
|
||||
</a>
|
||||
<a ui-sref="notifications" class="SetupItem">
|
||||
<h4 class="SetupItem-title">Notifications</h4>
|
||||
<p class="SetupItem-description">
|
||||
Create templates for sending notifications with Email, HipChat, Slack, and SMS.
|
||||
</p>
|
||||
</a>
|
||||
<a ui-sref="license" class="SetupItem">
|
||||
<h4 class="SetupItem-title">View Your License</h4>
|
||||
<p class="SetupItem-description">
|
||||
|
Loading…
Reference in New Issue
Block a user