diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js index edbd0cb42f..861fa18d98 100644 --- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js +++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js @@ -109,41 +109,41 @@ export default } scope.showSummary = function(event, id) { + setTimeout(function(){ + if (!Empty(id)) { + var recent_notifications, + html, title = "Recent Notifications"; - if (!Empty(id)) { - var recent_notifications, - html, title = "Recent Notifications"; - - scope.notification_templates.forEach(function(notification_template){ - if(notification_template.id === id){ - recent_notifications = notification_template.summary_fields.recent_notifications; - } - }); - Wait('stop'); - if (recent_notifications.length > 0) { - html = "\n"; - html += "\n"; - html += ""; - html += ""; - html += ""; - html += "\n"; - html += "\n"; - html += "\n"; - - recent_notifications.forEach(function(row) { - html += "\n"; - html += "\n"; - html += "\n"; - html += "\n"; + scope.notification_templates.forEach(function(notification_template){ + if(notification_template.id === id){ + recent_notifications = notification_template.summary_fields.recent_notifications; + } }); - html += "\n"; - html += "
StatusTime
" + ($filter('longDate')(row.created)).replace(/ /,'
') + "
\n"; + if (recent_notifications.length > 0) { + html = "\n"; + html += "\n"; + html += ""; + html += ""; + html += ""; + html += "\n"; + html += "\n"; + html += "\n"; + + recent_notifications.forEach(function(row) { + html += "\n"; + html += "\n"; + html += "\n"; + html += "\n"; + }); + html += "\n"; + html += "
StatusTime
" + ($filter('longDate')(row.created)).replace(/ /,'
') + "
\n"; + } + else { + html = "

No recent notifications.

\n"; + } + attachElem(event, html, title); } - else { - html = "

No recent notifications.

\n"; - } - attachElem(event, html, title); - } + }, 100); }; scope.testNotification = function(){ diff --git a/awx/ui/client/src/notifications/notificationTemplates.list.js b/awx/ui/client/src/notifications/notificationTemplates.list.js index f365112b4e..5046f4a192 100644 --- a/awx/ui/client/src/notifications/notificationTemplates.list.js +++ b/awx/ui/client/src/notifications/notificationTemplates.list.js @@ -27,7 +27,7 @@ export default function(){ icon: "{{ 'icon-job-' + notification_template.status }}", awToolTip: "Click for recent notifications", awTipPlacement: "right", - ngClick: "showSummary($event, notification_templates.id)", + ngClick: "showSummary($event, notification_template.id)", ngClass: "" }] }, diff --git a/awx/ui/client/src/setup-menu/setup-menu.partial.html b/awx/ui/client/src/setup-menu/setup-menu.partial.html index f03ae05d08..ae1cdb0ee2 100644 --- a/awx/ui/client/src/setup-menu/setup-menu.partial.html +++ b/awx/ui/client/src/setup-menu/setup-menu.partial.html @@ -36,7 +36,8 @@ Create and edit scripts to dynamically load hosts from any source.

- +

Notifications

Create templates for sending notifications with Email, HipChat, Slack, and SMS. diff --git a/awx/ui/client/src/setup-menu/setup.route.js b/awx/ui/client/src/setup-menu/setup.route.js index fc080251ba..aac58a64cb 100644 --- a/awx/ui/client/src/setup-menu/setup.route.js +++ b/awx/ui/client/src/setup-menu/setup.route.js @@ -6,5 +6,39 @@ export default { ncyBreadcrumb: { label: "SETTINGS" }, - templateUrl: templateUrl('setup-menu/setup-menu') + templateUrl: templateUrl('setup-menu/setup-menu'), + controller: function(orgAdmin, $scope){ + $scope.orgAdmin = orgAdmin; + }, + resolve: { + orgAdmin: + ['$rootScope', 'ProcessErrors', 'Rest', + function($rootScope, ProcessErrors, Rest){ + + return $rootScope.loginConfig.promise.then(function () { + if($rootScope.current_user.related.admin_of_organizations){ + $rootScope.orgAdmin = false; + if ($rootScope.current_user.is_superuser) { + return true; + } else { + Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`); + return Rest.get().then(function(data){ + if(data.data.count){ + return true; + } + else{ + return false; + } + }) + .catch(function (data, status) { + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', msg: 'Failed to find if users is admin of org' + status }); + }); + } + } + else{ + return false; + } + }); + }] + } };