You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/03/14 21:11:08 UTC

[GitHub] [trafficcontrol] mitchell852 opened a new pull request #5643: Improves cdn notifications functionality

mitchell852 opened a new pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643


   ## What does this PR (Pull Request) do?
   
   - [x] This PR is not related to any Issue 
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - Documentation
   - Traffic Ops
   - Traffic Portal
   
   ## What is the best way to verify this PR?
   
   
   
   ## The following criteria are ALL met by this PR
   
   
   - [x] This PR includes tests OR I have explained why tests are unnecessary
   - [x] This PR includes documentation OR I have explained why documentation is unnecessary
   - [ ] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597029349



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">
+                            <div class="text-center">No {{cdn.name}} notifications</div>
+                        </li>
+                        <li ng-repeat="notification in notifications">
+                            <a ng-click="$event.stopPropagation()">
+                                <span>
+                                    <span>{{::notification.user}}</span>
+                                    <span class="time">{{::getRelativeTime(notification.lastUpdated)}}</span>
+                                </span>
+                                <span class="message">{{::notification.notification}}</span>
+                            </a>
+                        </li>
+                        <li>
+                            <div class="text-center">
+                                <a>
+                                    <strong><a ng-click="navigateToPath('/cdns/' + cdn.id + '/notifications')">Manage {{cdn.name}} notifications</a></strong>

Review comment:
       fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597300700



##########
File path: traffic_ops/testing/api/v4/cdnnotifications_test.go
##########
@@ -54,9 +54,17 @@ func CreateTestCDNNotifications(t *testing.T) {
 
 func DeleteTestCDNNotifications(t *testing.T) {
 	for _, cdn := range testData.CDNs {
-		_, _, err := TOSession.DeleteCDNNotification(cdn.Name)
+		// Retrieve the notifications for a cdn
+		resp, _, err := TOSession.GetCDNNotifications(cdn.Name, nil)
 		if err != nil {
-			t.Errorf("cannot DELETE CDN notification: '%s' %v", cdn.Name, err)
+			t.Errorf("cannot GET notifications for a CDN: %v - %v", cdn.Name, err)
+		}
+		if len(resp) > 0 {
+			respNotification := resp[0]

Review comment:
       That's going to work for now, but any modifications to the notifications-related testing will need to keep this in mind for the forseeable future.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597032275



##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;
+
+CREATE TABLE cdn_notification (
+    id BIGSERIAL PRIMARY KEY,
+    cdn text NOT NULL,
+    "user" text NOT NULL,
+    notification text,

Review comment:
       fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596420208



##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       right. i prefer ng-if as well. i'll use it if it works. tbh i only tried ng-show as i was thinking it was needed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597009136



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">

Review comment:
       yeah, it works great. the `loadingNotifications` flag is set and reset in the getNotifications() call as well as the `$scope.notifications` is reset specific to that cdn.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596401051



##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       maybe i'll try ng-if but remember that notificaitons get refreshed so sometimes it needs to dynamically re-dismiss if you dismissed it earlier...

##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       i'll try ng-if but remember that notificaitons get refreshed so sometimes it needs to dynamically re-dismiss if you dismissed it earlier...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597299416



##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;

Review comment:
       That's technically correct, but generally I'd consider an inability to goose up/down through the migrations without destroying data bad practice.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597134827



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">

Review comment:
       My bad, missed it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596403795



##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       Do they? Then it's probably a wash in performance gains between the DOM insertion/deletion work and the creation/deletion of data binding event handlers and DOM slots.
   
   I'd guess - without measuring - it'd save memory to use `ng-if` but save some processing time to use `ng-show`. Probably not a big deal either way, but generally I tend to prefer `ng-if` because any given DOM insertion work is typically far less disruptive on a large scale than the memory usage of child scopes.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596400524



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">

Review comment:
       its seems to work perfect but i'll rethink my logic on this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596399448



##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;

Review comment:
       i think it's fine. we're between releases.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597031982



##########
File path: traffic_ops/testing/api/v4/cdnnotifications_test.go
##########
@@ -54,9 +54,17 @@ func CreateTestCDNNotifications(t *testing.T) {
 
 func DeleteTestCDNNotifications(t *testing.T) {
 	for _, cdn := range testData.CDNs {
-		_, _, err := TOSession.DeleteCDNNotification(cdn.Name)
+		// Retrieve the notifications for a cdn
+		resp, _, err := TOSession.GetCDNNotifications(cdn.Name, nil)
 		if err != nil {
-			t.Errorf("cannot DELETE CDN notification: '%s' %v", cdn.Name, err)
+			t.Errorf("cannot GET notifications for a CDN: %v - %v", cdn.Name, err)
+		}
+		if len(resp) > 0 {
+			respNotification := resp[0]

Review comment:
       i think this is correct. i only created one notification per cdn and this deletes the first one for each cdn.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597014707



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">

Review comment:
       switched to ng-if




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597014190



##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       switched to ng-if




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597009136



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">

Review comment:
       yeah, it works great. the `loadingNotifications` flag is set and reset in the getNotifications() call.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 merged pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 merged pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596401051



##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       i'll try ng-if but remember that notificaitons get refreshed (every 30 seconds) so sometimes it needs to dynamically re-dismiss if you dismissed it earlier...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596399448



##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;

Review comment:
       i think it's fine. we're between releases. blast any/all data....




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597019263



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">

Review comment:
       the button on line 85 has type=button already.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596447869



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">

Review comment:
       I could be wrong, it's just what it looks like to me, without testing




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596214237



##########
File path: traffic_ops/testing/api/v4/cdnnotifications_test.go
##########
@@ -54,9 +54,17 @@ func CreateTestCDNNotifications(t *testing.T) {
 
 func DeleteTestCDNNotifications(t *testing.T) {
 	for _, cdn := range testData.CDNs {
-		_, _, err := TOSession.DeleteCDNNotification(cdn.Name)
+		// Retrieve the notifications for a cdn
+		resp, _, err := TOSession.GetCDNNotifications(cdn.Name, nil)
 		if err != nil {
-			t.Errorf("cannot DELETE CDN notification: '%s' %v", cdn.Name, err)
+			t.Errorf("cannot GET notifications for a CDN: %v - %v", cdn.Name, err)
+		}
+		if len(resp) > 0 {
+			respNotification := resp[0]

Review comment:
       Wont' this only delete one notification? Shouldn't this be cleaning up all notifications?

##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;
+
+CREATE TABLE cdn_notification (
+    id BIGSERIAL PRIMARY KEY,
+    cdn text NOT NULL,
+    "user" text NOT NULL,
+    notification text,
+    last_updated timestamp with time zone DEFAULT now() NOT NULL,
+    CONSTRAINT fk_notification_cdn FOREIGN KEY (cdn) REFERENCES cdn(name) ON DELETE CASCADE ON UPDATE CASCADE,
+    CONSTRAINT fk_notification_user FOREIGN KEY ("user") REFERENCES tm_user(username) ON DELETE CASCADE ON UPDATE CASCADE
+);
+DROP TRIGGER IF EXISTS on_update_current_timestamp ON cdn_notification;
+CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON cdn_notification FOR EACH ROW EXECUTE PROCEDURE on_update_current_timestamp_last_updated();
+
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+DROP TABLE IF EXISTS cdn_notification;

Review comment:
       Same as above

##########
File path: traffic_ops/traffic_ops_golang/cdnnotification/cdnnotifications.go
##########
@@ -44,16 +45,18 @@ INNER JOIN tm_user ON tm_user.username = cn.user
 const insertQuery = `
 INSERT INTO cdn_notification (cdn, "user", notification)
 VALUES ($1, $2, $3)
-RETURNING cdn_notification.cdn,
+RETURNING cdn_notification.id,
+cdn_notification.cdn,

Review comment:
       nit but the alignment here doesn't match the following lines

##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">

Review comment:
       button should have `type=button` since it isn't part of a `form`

##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">

Review comment:
       I think this check will cause it to say there are no notifications for every CDN if and only if there are no notifications for _any_ CDN. So if you have a notification for CDN A and none for CDN B, CDN B won't show this.

##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>

Review comment:
       I think this should use `ng-if`, since after the http request resolves the value will never change again, so there's no need to clutter the DOM with this element.

##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;

Review comment:
       This will delete all existing data on upgrade. Which is funny because one use I could think of for a CDN notification is "An upgrade is in progress, please don't snap/queue"

##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>
+                        <li ng-show="notifications.length === 0">
+                            <div class="text-center">No {{cdn.name}} notifications</div>
+                        </li>
+                        <li ng-repeat="notification in notifications">
+                            <a ng-click="$event.stopPropagation()">
+                                <span>
+                                    <span>{{::notification.user}}</span>
+                                    <span class="time">{{::getRelativeTime(notification.lastUpdated)}}</span>
+                                </span>
+                                <span class="message">{{::notification.notification}}</span>
+                            </a>
+                        </li>
+                        <li>
+                            <div class="text-center">
+                                <a>
+                                    <strong><a ng-click="navigateToPath('/cdns/' + cdn.id + '/notifications')">Manage {{cdn.name}} notifications</a></strong>

Review comment:
       anchors should use `href` attributes, not click handlers

##########
File path: traffic_portal/app/src/common/modules/notifications/notifications.tpl.html
##########
@@ -18,7 +18,8 @@
 -->
 
 <div id="notificationsContainer">
-    <div class="alert alert-info" ng-repeat="n in notifications">
+    <div ng-show="!dismissedNotifications.includes(n.id)" class="alert alert-dismissable alert-info" ng-repeat="n in notifications | orderBy: 'cdn'">

Review comment:
       This should be using `ng-if`, since a notification can't be un-dismissed

##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;
+
+CREATE TABLE cdn_notification (
+    id BIGSERIAL PRIMARY KEY,
+    cdn text NOT NULL,
+    "user" text NOT NULL,
+    notification text,

Review comment:
       Shouldn't this also be `NOT NULL`? I can't think of a good reason to create a notification with no... notification.

##########
File path: traffic_ops/traffic_ops_golang/cdnnotification/cdnnotifications.go
##########
@@ -44,16 +45,18 @@ INNER JOIN tm_user ON tm_user.username = cn.user
 const insertQuery = `
 INSERT INTO cdn_notification (cdn, "user", notification)
 VALUES ($1, $2, $3)
-RETURNING cdn_notification.cdn,
+RETURNING cdn_notification.id,
+cdn_notification.cdn,
           cdn_notification.last_updated,
           cdn_notification.user,
           cdn_notification.notification
 `
 
 const deleteQuery = `
 DELETE FROM cdn_notification
-WHERE cdn_notification.cdn = $1
-RETURNING cdn_notification.cdn,
+WHERE cdn_notification.id = $1
+RETURNING cdn_notification.id,
+		cdn_notification.cdn,

Review comment:
       same as above RE: alignment




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r596399771



##########
File path: traffic_ops/app/db/migrations/2021031400000000_cdn_notifications_multiple.sql
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+DROP TABLE IF EXISTS cdn_notification;
+
+CREATE TABLE cdn_notification (
+    id BIGSERIAL PRIMARY KEY,
+    cdn text NOT NULL,
+    "user" text NOT NULL,
+    notification text,

Review comment:
       good point




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #5643: Improves cdn notifications functionality

Posted by GitBox <gi...@apache.org>.
mitchell852 commented on a change in pull request #5643:
URL: https://github.com/apache/trafficcontrol/pull/5643#discussion_r597014960



##########
File path: traffic_portal/app/src/common/modules/header/header.tpl.html
##########
@@ -80,9 +80,34 @@
                     <button type="button" class="btn btn-link" ng-if="hasCapability('cdns-snapshot')" ng-click="snapshot()"><i class="fa fa-camera"></i></button>
                 </div>
             </li>
-            <li ng-repeat="cdn in cdns">
-                <div class="btn-group" title="{{(cdn.notificationCreatedBy) ? 'Delete Global ' + cdn.name + ' Notification' : 'Create Global ' + cdn.name + ' Notification'}}">
-                    <button type="button" class="notification btn btn-link" ng-click="toggleNotification(cdn)">{{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.notificationCreatedBy, 'fa-bell-o': !cdn.notificationCreatedBy }"></i> <i ng-show="cdn.notificationCreatedBy" class="fa fa-times"></i></button>
+            <li role="presentation" class="dropdown" ng-repeat="cdn in cdns | orderBy: '-name'">
+                <div class="btn-group" title="{{cdn.name}} Notifications" uib-dropdown is-open="{{cdn.name}}-notifications.isopen">
+                    <button id="{{cdn.name}}-notifications" type="button" class="btn btn-link" ng-click="getNotifications(cdn)" uib-dropdown-toggle>
+                        {{cdn.name}} <i class="fa" ng-class="{ 'fa-bell': cdn.hasNotifications, 'fa-bell-o': !cdn.hasNotifications }"></i>
+                    </button>
+                    <ul class="uib-dropdown-menu list-unstyled msg_list animated fadeInDown" role="menu">
+                        <li ng-show="loadingNotifications" style="text-align: center"><i class="fa fa-refresh fa-spin fa-1x fa-fw"></i></li>

Review comment:
       switched to ng-if




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org