You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2020/03/16 19:44:38 UTC

[incubator-streampipes] branch dev updated: Add query to sort notifications by timestamp

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 2647a62  Add query to sort notifications by timestamp
2647a62 is described below

commit 2647a6229888ca3bdf084b142b734a53ecc5813e
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Mar 16 20:44:25 2020 +0100

    Add query to sort notifications by timestamp
---
 .../apache/streampipes/rest/notifications/NotificationListener.java  | 3 ++-
 .../streampipes/storage/couchdb/impl/NotificationStorageImpl.java    | 5 ++++-
 ui/src/app/notifications/model/notifications.model.ts                | 1 +
 ui/src/app/notifications/notifications.component.html                | 4 +++-
 ui/src/app/notifications/notifications.component.scss                | 5 +++++
 ui/src/app/notifications/notifications.component.ts                  | 3 +++
 6 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java
index 4e59eee..ea3c84a 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java
@@ -25,7 +25,8 @@ import javax.servlet.ServletContextListener;
 
 public class NotificationListener implements ServletContextListener {
 
-  private static final String internalNotificationTopic = "org.apache.streampipes.notifications.*";
+  private static final String internalNotificationTopic = "org.apache.streampipes.notifications" +
+          ".riemer@fzi.de";
 
 
   @Override
diff --git a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/NotificationStorageImpl.java b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/NotificationStorageImpl.java
index dfc8e11..6afc10a 100644
--- a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/NotificationStorageImpl.java
+++ b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/NotificationStorageImpl.java
@@ -27,6 +27,7 @@ import org.apache.streampipes.storage.couchdb.utils.Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -53,7 +54,9 @@ public class NotificationStorageImpl extends AbstractDao<Notification> implement
             couchDbClientSupplier
                     .get()
                     .view("notificationtypes/notificationtypes")
-                    .key(notificationTypeId)
+                    .startKey(Arrays.asList(notificationTypeId, "\ufff0"))
+                    .endKey("\ufff0")
+                    .descending(true)
                     .includeDocs(true)
                     .skip(offset)
                     .limit(count)
diff --git a/ui/src/app/notifications/model/notifications.model.ts b/ui/src/app/notifications/model/notifications.model.ts
index 7d1ce57..a25b9a8 100644
--- a/ui/src/app/notifications/model/notifications.model.ts
+++ b/ui/src/app/notifications/model/notifications.model.ts
@@ -18,6 +18,7 @@
 export interface NotificationItem {
     title: string;
     createdAt: Date;
+    createdAtTimestamp: number;
     targetedAt: string;
     correspondingPipelineId: string;
     message: string;
diff --git a/ui/src/app/notifications/notifications.component.html b/ui/src/app/notifications/notifications.component.html
index 1180323..ea1e100 100644
--- a/ui/src/app/notifications/notifications.component.html
+++ b/ui/src/app/notifications/notifications.component.html
@@ -36,7 +36,9 @@
         <div fxFlex="30" class="notifications-overview scrolling-auto">
             <mat-list>
                 <mat-list-item *ngFor="let existingNotification of existingNotifications"
-                               (click)="selectNotification(existingNotification)" class="list-item">
+                               (click)="selectNotification(existingNotification)" class="list-item"
+                               [ngClass]="{'selected-notification':
+                               existingNotification.notificationId === currentlySelectedNotificationId}">
                     <div mat-list-avatar
                          class="notification-avatar sp-accent-bg">{{elementIconText.getElementIconText(existingNotification.pipelineName)}}
                     </div>
diff --git a/ui/src/app/notifications/notifications.component.scss b/ui/src/app/notifications/notifications.component.scss
index 7287acd..49c15af 100644
--- a/ui/src/app/notifications/notifications.component.scss
+++ b/ui/src/app/notifications/notifications.component.scss
@@ -87,6 +87,11 @@
     cursor: pointer;
 }
 
+.selected-notification {
+    background: #E0E0E0;
+    cursor: pointer;
+}
+
 .list-item {
     border-bottom: 1px solid #BDBDBD;
 }
diff --git a/ui/src/app/notifications/notifications.component.ts b/ui/src/app/notifications/notifications.component.ts
index 7fa96a4..4d9d7f0 100644
--- a/ui/src/app/notifications/notifications.component.ts
+++ b/ui/src/app/notifications/notifications.component.ts
@@ -105,6 +105,9 @@ export class NotificationsComponent implements OnInit {
 
     getNotifications(notification: ExistingNotification, offset: number, count: number, scrollToBottom: boolean) {
         this.notificationService.getNotifications(notification, offset, count).subscribe(notifications => {
+            notifications.sort((a, b) => {
+                return (a.createdAtTimestamp - b.createdAtTimestamp);
+            });
             this.notifications.unshift(...notifications);
             if (scrollToBottom) {
                 setTimeout(() => {