. Seems to be a bug in TB3 RC1
+ $(this).remove();
+ });
+ $('.tooltip').each( function() {
+ // close any lingering tool tipss
+ $(this).hide();
+ });
+ elem.attr({
+ "aw-pop-over": html,
+ "data-popover-title": title,
+ "data-placement": "right" });
+ $compile(elem)(scope);
+ elem.on('shown.bs.popover', function() {
+ $('.popover').each(function() {
+ // $compile($(this))(scope); //make nested directives work!
+ });
+ $('.popover-content, .popover-title').click(function() {
+ elem.popover('hide');
+ });
+ });
+ elem.popover('show');
+ }
+
+ scope.showSummary = function(event, id) {
+
+ if (!Empty(id)) {
+ var recent_notifications,
+ html, title = "Recent Notifications";
+
+ scope.notifiers.forEach(function(notifier){
+ if(notifier.id === id){
+ recent_notifications = notifier.summary_fields.recent_notifications;
+ }
+ });
+ Wait('stop');
+ if (recent_notifications.length > 0) {
+ html = "
\n";
+ html += "\n";
+ html += "";
+ html += "| Status | ";
+ html += "Time | ";
+ html += "
\n";
+ html += "\n";
+ html += "\n";
+
+ recent_notifications.forEach(function(row) {
+ html += "\n";
+ html += " | \n";
+ html += "" + ($filter('longDate')(row.created)).replace(/ /,' ') + " | \n";
+ html += "
\n";
+ });
+ html += "\n";
+ html += "
\n";
+ }
+ else {
+ html = "
No recent notifications.
\n";
+ }
+ attachElem(event, html, title);
+ }
+ };
+
+
+
+
+ scope.testNotification = function(){
+ var name = this.notifier.name;
+ Rest.setUrl(defaultUrl + this.notifier.id +'/test/');
+ Rest.post({})
+ .then(function () {
+ ngToast.success({
+ content: `Test Notification Success:
${name} `
+ });
+
+ })
+ .catch(function () {
+ ngToast.danger({
+ content: 'Test Notification Failure'
+ });
+ });
+ };
+
+ scope.addNotification = function(){
+ $state.transitionTo('notifications.add');
+ };
+
+ scope.editNotification = function(){
+ $state.transitionTo('notifications.edit',{
+ notifier_id: this.notifier.id,
+ notifier: this.notifier
+ });
+ };
+
+ 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 = '
Are you sure you want to delete the inventory below?
' + name + '
';
+ Prompt({
+ hdr: 'Delete',
+ body: bodyHtml,
+ action: action,
+ actionText: 'DELETE'
+ });
+ };
+
+
+ }
+ ];
diff --git a/awx/ui/client/src/notifications/list/list.partial.html b/awx/ui/client/src/notifications/notification-templates-list/list.partial.html
similarity index 100%
rename from awx/ui/client/src/notifications/list/list.partial.html
rename to awx/ui/client/src/notifications/notification-templates-list/list.partial.html
diff --git a/awx/ui/client/src/notifications/list/list.route.js b/awx/ui/client/src/notifications/notification-templates-list/list.route.js
similarity index 77%
rename from awx/ui/client/src/notifications/list/list.route.js
rename to awx/ui/client/src/notifications/notification-templates-list/list.route.js
index da76880791..e783b1e2f1 100644
--- a/awx/ui/client/src/notifications/list/list.route.js
+++ b/awx/ui/client/src/notifications/notification-templates-list/list.route.js
@@ -9,8 +9,8 @@ import {templateUrl} from '../../shared/template-url/template-url.factory';
export default {
name: 'notifications',
route: '/notifications',
- templateUrl: templateUrl('notifications/list/list'),
- controller: 'notificationsListController',
+ templateUrl: templateUrl('notifications/notification-templates-list/list'),
+ controller: 'notificationTemplatesListController',
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
diff --git a/awx/ui/client/src/notifications/list/main.js b/awx/ui/client/src/notifications/notification-templates-list/main.js
similarity index 75%
rename from awx/ui/client/src/notifications/list/main.js
rename to awx/ui/client/src/notifications/notification-templates-list/main.js
index 35cab03cef..2db7d37a09 100644
--- a/awx/ui/client/src/notifications/list/main.js
+++ b/awx/ui/client/src/notifications/notification-templates-list/main.js
@@ -8,8 +8,8 @@ import route from './list.route';
import controller from './list.controller';
export default
- angular.module('notificationsList', [])
- .controller('notificationsListController', controller)
+ angular.module('notificationTemplatesList', [])
+ .controller('notificationTemplatesListController', controller)
.run(['$stateExtender', function($stateExtender) {
$stateExtender.addState(route);
}]);
diff --git a/awx/ui/client/src/notifications/notificationTemplates.form.js b/awx/ui/client/src/notifications/notificationTemplates.form.js
new file mode 100644
index 0000000000..eeef07d1c7
--- /dev/null
+++ b/awx/ui/client/src/notifications/notificationTemplates.form.js
@@ -0,0 +1,351 @@
+/*************************************************
+ * 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 Template',
+ editTitle: '{{ name }}',
+ name: 'notifier',
+ showActions: true,
+ subFormTitles: {
+ typeSubForm: 'Type Details',
+ },
+
+ fields: {
+ name: {
+ label: 'Name',
+ type: 'text',
+ addRequired: true,
+ editRequired: true,
+ capitalize: false
+ },
+ description: {
+ label: 'Description',
+ type: 'text',
+ addRequired: false,
+ editRequired: false
+ },
+ organization: {
+ label: 'Organization',
+ type: 'lookup',
+ sourceModel: 'organization',
+ sourceField: 'name',
+ ngClick: 'lookUpOrganization()',
+ awRequiredWhen: {
+ variable: "organizationrequired",
+ init: "true"
+ }
+ },
+ notification_type: {
+ label: 'Type',
+ type: 'select',
+ addRequired: true,
+ editRequired: true,
+ class: 'NotificationsForm-typeSelect prepend-asterisk',
+ ngOptions: 'type.label for type in notification_type_options track by type.value',
+ ngChange: 'typeChange()',
+ hasSubForm: true
+ },
+ username: {
+ label: 'Username',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "email_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'email' ",
+ subForm: 'typeSubForm'
+ },
+ use_tls: {
+ label: 'Use TLS',
+ type: 'checkbox',
+ ngShow: "notification_type.value == 'email' ",
+ subForm: 'typeSubForm'
+ },
+ host: {
+ label: 'Host',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "email_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'email' ",
+ subForm: 'typeSubForm'
+ },
+ sender: {
+ label: 'Sender Email',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "email_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'email' ",
+ subForm: 'typeSubForm'
+ },
+ recipients: {
+ label: 'Recipient List',
+ type: 'textarea',
+ rows: 3,
+ awPopOver: '
Type an option on each line.
'+
+ '
For example:
alias1@email.com
\n alias2@email.com
\n',
+ dataTitle: 'Recipient List',
+ dataPlacement: 'right',
+ dataContainer: "body",
+ awRequiredWhen: {
+ variable: "email_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'email' ",
+ subForm: 'typeSubForm'
+ },
+ password: {
+ labelBind: 'passwordLabel',
+ type: 'sensitive',
+ hasShowInputButton: true,
+ awRequiredWhen: {
+ variable: "password_required" ,
+ init: "false"
+ },
+ // ngRequired:"notification_type.value == 'email' || notification_type.value == 'irc'",
+ ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
+ subForm: 'typeSubForm'
+ },
+ use_ssl: {
+ labelBind: 'sslLabel',
+ type: 'checkbox',
+ ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
+ subForm: 'typeSubForm'
+ },
+ port: {
+ labelBind: 'portLabel',
+ type: 'number',
+ integer: true,
+ spinner: true,
+ 'class': "input-small",
+ min: 0,
+ awRequiredWhen: {
+ variable: "port_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'email' || notification_type.value == 'irc'",
+ subForm: 'typeSubForm'
+ },
+ channels: {
+ label: 'Destination Channels',
+ type: 'textarea',
+ rows: 3,
+ awPopOver: '
Type an option on each line. The pound symbol (#) is not required.
'+
+ '
For example:
engineering
\n support
\n',
+ dataTitle: 'Destination Channels',
+ dataPlacement: 'right',
+ dataContainer: "body",
+ awRequiredWhen: {
+ variable: "channel_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'slack' || notification_type.value == 'hipchat'",
+ subForm: 'typeSubForm'
+ },
+ token: {
+ labelBind: 'tokenLabel',
+ type: 'sensitive',
+ hasShowInputButton: true,
+ awRequiredWhen: {
+ variable: "token_required",
+ init: "false"
+ },
+ // ngRequired:"notification_type.value == 'slack' || notification_type.value == 'pagerduty' || notification_type.value == 'hipchat'",
+ ngShow: "notification_type.value == 'slack' || notification_type.value == 'pagerduty' || notification_type.value == 'hipchat'",
+ subForm: 'typeSubForm'
+ },
+ account_token: {
+ label: 'Account Token',
+ type: 'sensitive',
+ hasShowInputButton: true,
+ awRequiredWhen: {
+ variable: "twilio_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'twilio' ",
+ subForm: 'typeSubForm'
+ },
+ from_number: {
+ label: 'Source Phone Number',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "twilio_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'twilio' ",
+ subForm: 'typeSubForm'
+ },
+ to_numbers: {
+ label: 'Destination SMS Number',
+ type: 'textarea',
+ rows: 3,
+ awPopOver: '
Type an option on each line.
'+
+ '
For example:
alias1@email.com
\n alias2@email.com
\n',
+ dataTitle: 'Destination Channels',
+ dataPlacement: 'right',
+ dataContainer: "body",
+ awRequiredWhen: {
+ variable: "twilio_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'twilio' ",
+ subForm: 'typeSubForm'
+ },
+ account_sid: {
+ label: 'Account SID',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "twilio_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'twilio' ",
+ subForm: 'typeSubForm'
+ },
+ subdomain: {
+ label: 'Pagerduty subdomain',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "pagerduty_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'pagerduty' ",
+ subForm: 'typeSubForm'
+ },
+ service_key: {
+ label: 'API Service/Integration Key',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "pagerduty_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'pagerduty' ",
+ subForm: 'typeSubForm'
+ },
+ client_name: {
+ label: 'Client Identifier',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "pagerduty_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'pagerduty' ",
+ subForm: 'typeSubForm'
+ },
+ message_from: {
+ label: 'Label to be shown with notification',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "hipchat_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'hipchat' ",
+ subForm: 'typeSubForm'
+ },
+ api_url: {
+ label: 'API URL (e.g: https://mycompany.hiptchat.com)',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "hipchat_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'hipchat' ",
+ subForm: 'typeSubForm'
+ },
+ color: {
+ label: 'Notification Color',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "hipchat_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'hipchat' ",
+ subForm: 'typeSubForm'
+ },
+ notify: {
+ label: 'Notify Channel',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "hipchat_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'hipchat' ",
+ subForm: 'typeSubForm'
+ },
+ url: {
+ label: 'Target URL',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "webhook_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'webhook' ",
+ subForm: 'typeSubForm'
+ },
+ headers: {
+ label: 'HTTP Headers',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "webhook_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'webhook' ",
+ subForm: 'typeSubForm'
+ },
+ server: {
+ label: 'IRC Server Address',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "irc_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'irc' ",
+ subForm: 'typeSubForm'
+ },
+ nickname: {
+ label: 'IRC Nick',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "irc_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'irc' ",
+ subForm: 'typeSubForm'
+ },
+ targets: {
+ label: 'Destination Channels or Users',
+ type: 'text',
+ awRequiredWhen: {
+ variable: "irc_required",
+ init: "false"
+ },
+ ngShow: "notification_type.value == 'irc' ",
+ subForm: 'typeSubForm'
+ },
+
+ },
+
+ buttons: { //for now always generates