You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2026/03/31 15:01:39 UTC
(streampipes) branch dev updated: fix(#4298): remove the current notifications module (#4335)
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 77172c74d7 fix(#4298): remove the current notifications module (#4335)
77172c74d7 is described below
commit 77172c74d72508756d37ff8e2eb0eaed32b95f89
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Tue Mar 31 17:01:33 2026 +0200
fix(#4298): remove the current notifications module (#4335)
---
.../streampipes/client/api/INotificationsApi.java | 25 --
.../streampipes/client/api/IStreamPipesClient.java | 2 -
.../streampipes/client/StreamPipesClient.java | 7 -
.../streampipes/client/api/NotificationsApi.java | 43 ---
.../jvm/InternalSinksExtensionModuleExports.java | 4 +-
.../InternalStreamPipesNotificationSink.java | 120 --------
.../documentation.md | 57 ----
.../icon.png | Bin 11738 -> 0 bytes
.../strings.en | 25 --
.../org/apache/streampipes/model/Notification.java | 123 --------
.../streampipes/model/NotificationCount.java | 39 ---
.../manager/pipeline/PipelineManager.java | 2 -
.../manager/setup/CouchDbInstallationStep.java | 49 ---
.../management/NotificationsResourceManager.java | 75 -----
.../rest/core/base/impl/AbstractRestResource.java | 5 -
.../rest/impl/NotificationResource.java | 99 ------
.../core/migrations/AvailableMigrations.java | 4 +-
.../RemoveInternalNotificationSinkMigration.java | 155 ++++++++++
...emoveInternalNotificationSinkMigrationTest.java | 122 ++++++++
.../storage/api/core/INoSqlStorage.java | 3 -
.../storage/api/system/INotificationStorage.java | 46 ---
.../storage/couchdb/CouchDbStorageManager.java | 7 -
.../impl/system/NotificationStorageImpl.java | 143 ---------
.../streampipes/storage/couchdb/utils/Utils.java | 4 -
ui/deployment/app.routes.mst | 2 -
ui/deployment/base-navigation.component.mst | 5 -
ui/deployment/home.service.mst | 25 +-
.../core/components/toolbar/toolbar.component.html | 36 ---
.../core/components/toolbar/toolbar.component.ts | 32 +-
ui/src/app/core/navigation/page-name.enum.ts | 1 -
.../components/notification-item.component.html | 29 --
.../components/notification-item.component.scss | 53 ----
.../components/notification-item.component.ts | 40 ---
.../app/notifications/model/notifications.model.ts | 39 ---
.../app/notifications/notifications.component.html | 148 ---------
.../app/notifications/notifications.component.scss | 120 --------
.../app/notifications/notifications.component.ts | 335 ---------------------
.../notifications/service/notifications.service.ts | 96 ------
.../app/notifications/utils/notifications.utils.ts | 34 ---
ui/src/app/services/notification-count-service.ts | 54 ----
ui/src/app/services/rest-api.service.ts | 6 -
41 files changed, 288 insertions(+), 1926 deletions(-)
diff --git a/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/INotificationsApi.java b/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/INotificationsApi.java
deleted file mode 100644
index ee74d5f5f4..0000000000
--- a/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/INotificationsApi.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.client.api;
-
-import org.apache.streampipes.model.Notification;
-
-public interface INotificationsApi {
- void add(Notification notification);
-}
diff --git a/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/IStreamPipesClient.java b/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/IStreamPipesClient.java
index 90b37b5a1d..80a689778b 100644
--- a/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/IStreamPipesClient.java
+++ b/streampipes-client-api/src/main/java/org/apache/streampipes/client/api/IStreamPipesClient.java
@@ -52,8 +52,6 @@ public interface IStreamPipesClient extends Serializable {
IAdminApi adminApi();
- INotificationsApi notificationsApi();
-
IDataLakeMeasureApi dataLakeMeasureApi();
void deliverEmail(SpEmail email);
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/StreamPipesClient.java b/streampipes-client/src/main/java/org/apache/streampipes/client/StreamPipesClient.java
index 59f3d4fee2..9525bb81bb 100644
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/StreamPipesClient.java
+++ b/streampipes-client/src/main/java/org/apache/streampipes/client/StreamPipesClient.java
@@ -31,7 +31,6 @@ import org.apache.streampipes.client.api.IAdminApi;
import org.apache.streampipes.client.api.ICustomRequestApi;
import org.apache.streampipes.client.api.IPipelineElementTemplateApi;
import org.apache.streampipes.client.api.IStreamPipesClient;
-import org.apache.streampipes.client.api.NotificationsApi;
import org.apache.streampipes.client.api.PipelineApi;
import org.apache.streampipes.client.api.PipelineElementTemplateApi;
import org.apache.streampipes.client.api.config.ClientConnectionUrlResolver;
@@ -216,12 +215,6 @@ public class StreamPipesClient implements
return new AdminApi(config);
}
- @Override
- @ExposedToScripts
- public NotificationsApi notificationsApi() {
- return new NotificationsApi(config);
- }
-
@Override
@ExposedToScripts
public DataLakeMeasureApi dataLakeMeasureApi() {
diff --git a/streampipes-client/src/main/java/org/apache/streampipes/client/api/NotificationsApi.java b/streampipes-client/src/main/java/org/apache/streampipes/client/api/NotificationsApi.java
deleted file mode 100644
index 5c0553727b..0000000000
--- a/streampipes-client/src/main/java/org/apache/streampipes/client/api/NotificationsApi.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.client.api;
-
-import org.apache.streampipes.client.model.StreamPipesClientConfig;
-import org.apache.streampipes.client.util.StreamPipesApiPath;
-import org.apache.streampipes.model.Notification;
-import org.apache.streampipes.model.shared.annotation.ExposedToScripts;
-
-public class NotificationsApi extends AbstractTypedClientApi<Notification> implements INotificationsApi {
-
- public NotificationsApi(StreamPipesClientConfig clientConfig) {
- super(clientConfig, Notification.class);
- }
-
- @Override
- protected StreamPipesApiPath getBaseResourcePath() {
- return StreamPipesApiPath.fromBaseApiPath()
- .addToPath("notifications");
- }
-
- @Override
- @ExposedToScripts
- public void add(Notification notification) {
- post(getBaseResourcePath(), notification);
- }
-}
diff --git a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/InternalSinksExtensionModuleExports.java b/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/InternalSinksExtensionModuleExports.java
index 72bcbcb7d1..a22d3f4d91 100644
--- a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/InternalSinksExtensionModuleExports.java
+++ b/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/InternalSinksExtensionModuleExports.java
@@ -25,7 +25,6 @@ import org.apache.streampipes.extensions.api.pe.IStreamPipesPipelineElement;
import org.apache.streampipes.sinks.internal.jvm.datalake.DataLakeSink;
import org.apache.streampipes.sinks.internal.jvm.datalake.migrations.DataLakeSinkMigrationV1;
import org.apache.streampipes.sinks.internal.jvm.datalake.migrations.DataLakeSinkMigrationV2;
-import org.apache.streampipes.sinks.internal.jvm.notification.InternalStreamPipesNotificationSink;
import java.util.Collections;
import java.util.List;
@@ -39,8 +38,7 @@ public class InternalSinksExtensionModuleExports implements IExtensionModuleExpo
@Override
public List<IStreamPipesPipelineElement<?>> pipelineElements() {
return List.of(
- new DataLakeSink(),
- new InternalStreamPipesNotificationSink()
+ new DataLakeSink()
);
}
diff --git a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/notification/InternalStreamPipesNotificationSink.java b/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/notification/InternalStreamPipesNotificationSink.java
deleted file mode 100644
index ba946c7f92..0000000000
--- a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/notification/InternalStreamPipesNotificationSink.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.sinks.internal.jvm.notification;
-
-
-import org.apache.streampipes.client.api.IStreamPipesClient;
-import org.apache.streampipes.extensions.api.pe.config.IDataSinkConfiguration;
-import org.apache.streampipes.extensions.api.pe.context.EventSinkRuntimeContext;
-import org.apache.streampipes.extensions.api.pe.param.IDataSinkParameters;
-import org.apache.streampipes.model.DataSinkType;
-import org.apache.streampipes.model.Notification;
-import org.apache.streampipes.model.extensions.ExtensionAssetType;
-import org.apache.streampipes.model.runtime.Event;
-import org.apache.streampipes.pe.shared.PlaceholderExtractor;
-import org.apache.streampipes.sdk.builder.DataSinkBuilder;
-import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
-import org.apache.streampipes.sdk.builder.sink.DataSinkConfiguration;
-import org.apache.streampipes.sdk.helpers.EpRequirements;
-import org.apache.streampipes.sdk.helpers.Labels;
-import org.apache.streampipes.sdk.helpers.Locales;
-import org.apache.streampipes.wrapper.standalone.StreamPipesNotificationSink;
-
-import java.util.Date;
-import java.util.UUID;
-
-public class InternalStreamPipesNotificationSink extends StreamPipesNotificationSink {
-
- private static final String TITLE_KEY = "title";
- private static final String CONTENT_KEY = "content";
-
- private String title;
- private String content;
- private String correspondingPipelineId;
- private String correspondingUser;
-
- private IStreamPipesClient client;
-
-
- @Override
- public void onPipelineStarted(IDataSinkParameters parameters, EventSinkRuntimeContext context) {
- super.onPipelineStarted(parameters, context);
- this.title = parameters.extractor()
- .singleValueParameter(TITLE_KEY, String.class);
- this.content = parameters.extractor()
- .singleValueParameter(CONTENT_KEY, String.class);
- this.correspondingPipelineId = parameters.getModel()
- .getCorrespondingPipeline();
- this.correspondingUser = parameters.getModel()
- .getCorrespondingUser();
- this.client = context.getStreamPipesClient();
- }
-
- @Override
- public void onNotificationEvent(Event inputEvent) {
-
- Date currentDate = new Date();
- Notification notification = new Notification();
- notification.setId(UUID.randomUUID()
- .toString());
- notification.setRead(false);
- notification.setTitle(title);
- notification.setMessage(PlaceholderExtractor.replacePlaceholders(inputEvent, content));
- notification.setCreatedAt(currentDate);
- notification.setCreatedAtTimestamp(currentDate.getTime());
- notification.setCorrespondingPipelineId(correspondingPipelineId);
- notification.setTargetedAt(correspondingUser);
-
- client.notificationsApi()
- .add(notification);
-
- }
-
-
- @Override
- public void onPipelineStopped() {
-
- }
-
- @Override
- public IDataSinkConfiguration declareConfig() {
- var builder = declareModelWithoutSilentPeriod();
- addSilentPeriodParameter(builder);
-
- return DataSinkConfiguration.create(
- InternalStreamPipesNotificationSink::new,
- builder.build()
- );
- }
-
- @Override
- public DataSinkBuilder declareModelWithoutSilentPeriod() {
- return DataSinkBuilder
- .create("org.apache.streampipes.sinks.internal.jvm.notification", 0)
- .withLocales(Locales.EN)
- .withAssets(ExtensionAssetType.DOCUMENTATION, ExtensionAssetType.ICON)
- .category(DataSinkType.INTERNAL, DataSinkType.NOTIFICATION)
- .requiredStream(StreamRequirementsBuilder
- .create()
- .requiredProperty(EpRequirements.anyProperty())
- .build())
- .requiredTextParameter(Labels.withId(TITLE_KEY))
- .requiredHtmlInputParameter(Labels.withId(CONTENT_KEY));
- }
-}
diff --git a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/documentation.md b/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/documentation.md
deleted file mode 100644
index 3ed06571d7..0000000000
--- a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/documentation.md
+++ /dev/null
@@ -1,57 +0,0 @@
-<!--
- ~ 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.
- ~
- -->
-
-## Notification
-
-<p align="center">
- <img src="icon.png" width="150px;" class="pe-image-documentation"/>
-</p>
-
-***
-
-## Description
-
-Displays a notification in the UI panel of StreamPipes.
-
-***
-
-## Required input
-
-This sink does not have any requirements and works with any incoming event type.
-
-***
-
-## Configuration
-
-### Notification Title
-
-The title of the notification.
-
-### Content
-
-The notification message.
-
-### Silent Period
-
-The *Silent Period* is the duration, expressed in minutes, during which notifications are temporarily disabled after one
-has been sent. This feature is implemented to prevent overwhelming the target with frequent notifications, avoiding
-potential spam behavior.
-
-## Output
-
-(not applicable for data sinks)
\ No newline at end of file
diff --git a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/icon.png b/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/icon.png
deleted file mode 100644
index 57d1d63988..0000000000
Binary files a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/icon.png and /dev/null differ
diff --git a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/strings.en b/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/strings.en
deleted file mode 100644
index 026db15f98..0000000000
--- a/streampipes-extensions/streampipes-sinks-internal-jvm/src/main/resources/org.apache.streampipes.sinks.internal.jvm.notification/strings.en
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# 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.
-#
-
-org.apache.streampipes.sinks.internal.jvm.notification.title=Notification
-org.apache.streampipes.sinks.internal.jvm.notification.description=Publish a notification directly to the notification pane.
-
-title.title=Notification Title
-title.description=
-
-content.title=Content
-content.description=Enter the notification text. You can use placeholders like #fieldName# to add the value of a stream variable.
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/Notification.java b/streampipes-model/src/main/java/org/apache/streampipes/model/Notification.java
deleted file mode 100644
index 3b9f47f84c..0000000000
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/Notification.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.model;
-
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.gson.annotations.SerializedName;
-
-import java.util.Date;
-
-public class Notification {
-
- private @JsonProperty("_id") @SerializedName("_id") String id;
- private @JsonProperty("_rev") @SerializedName("_rev") String rev;
-
- private String title;
- private Date createdAt;
- private long createdAtTimestamp;
- private String targetedAt;
- private String correspondingPipelineId;
-
- private String message;
-
- private Boolean read;
-
- public Notification(String title, Date createdAt, String targetedAt, String message) {
- this.title = title;
- this.createdAt = createdAt;
- this.targetedAt = targetedAt;
- this.message = message;
- }
-
- public Notification() {
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public Date getCreatedAt() {
- return createdAt;
- }
-
- public void setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- }
-
- public String getTargetedAt() {
- return targetedAt;
- }
-
- public void setTargetedAt(String targetedAt) {
- this.targetedAt = targetedAt;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getRev() {
- return rev;
- }
-
- public void setRev(String rev) {
- this.rev = rev;
- }
-
- public Boolean isRead() {
- return read != null ? read : false;
- }
-
- public void setRead(Boolean read) {
- this.read = read;
- }
-
- public String getCorrespondingPipelineId() {
- return correspondingPipelineId;
- }
-
- public void setCorrespondingPipelineId(String correspondingPipelineId) {
- this.correspondingPipelineId = correspondingPipelineId;
- }
-
- public long getCreatedAtTimestamp() {
- return createdAtTimestamp;
- }
-
- public void setCreatedAtTimestamp(long createdAtTimestamp) {
- this.createdAtTimestamp = createdAtTimestamp;
- }
-}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/NotificationCount.java b/streampipes-model/src/main/java/org/apache/streampipes/model/NotificationCount.java
deleted file mode 100644
index 50748eb636..0000000000
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/NotificationCount.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.model;
-
-public class NotificationCount {
-
- private Integer count;
-
- public NotificationCount(Integer count) {
- this.count = count;
- }
-
- public NotificationCount() {
- }
-
- public Integer getCount() {
- return count;
- }
-
- public void setCount(Integer count) {
- this.count = count;
- }
-}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java
index 79602f5522..0da4b65eca 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java
@@ -28,7 +28,6 @@ import org.apache.streampipes.model.client.user.Permission;
import org.apache.streampipes.model.pipeline.Pipeline;
import org.apache.streampipes.model.pipeline.PipelineOperationStatus;
import org.apache.streampipes.resource.management.CrudResourceManager;
-import org.apache.streampipes.resource.management.NotificationsResourceManager;
import org.apache.streampipes.storage.api.pipeline.IPipelineStorage;
import org.apache.streampipes.storage.api.user.IPermissionStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
@@ -129,7 +128,6 @@ public class PipelineManager {
var pipeline = getPipeline(pipelineId);
if (Objects.nonNull(pipeline)) {
pipelineCrudResourceManager.delete(pipelineId);
- new NotificationsResourceManager().deleteNotificationsForPipeline(pipeline);
}
}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/CouchDbInstallationStep.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/CouchDbInstallationStep.java
index 89fed8172a..5f4efa2f63 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/CouchDbInstallationStep.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/CouchDbInstallationStep.java
@@ -39,8 +39,6 @@ import static org.apache.streampipes.manager.setup.design.DesignDocumentUtils.pr
public class CouchDbInstallationStep extends InstallationStep {
- private static final String PREPARING_NOTIFICATIONS_TEXT = "Preparing database "
- + "'notifications'...";
private static final String PREPARING_USERS_TEXT = "Preparing database 'users'...";
public CouchDbInstallationStep() {
@@ -67,7 +65,6 @@ public class CouchDbInstallationStep extends InstallationStep {
// Set up streampipes internal databases
Utils.getCouchDbUserClient();
Utils.getCouchDbPipelineClient();
- Utils.getCouchDbNotificationClient();
logSuccess(getTitle());
} catch (Exception e) {
@@ -77,7 +74,6 @@ public class CouchDbInstallationStep extends InstallationStep {
private void createViews() {
addUserView();
- addNotificationView();
addPipelineView();
new AddDataLakeMeasureViewTask().execute();
new AddAssetManagementViewTask().execute();
@@ -85,51 +81,6 @@ public class CouchDbInstallationStep extends InstallationStep {
new AddFunctionStateViewTask().execute();
}
- private void addNotificationView() {
- try {
- DesignDocument userDocument = prepareDocument("_design/notificationtypes");
- DesignDocument notificationCountDocument = prepareDocument("_design/unread");
-
- Map<String, MapReduce> notificationTypeViews = new HashMap<>();
- MapReduce notificationTypeFunction = new MapReduce();
- notificationTypeFunction.setMap(
- "function (doc) { var vizName = doc.title.replace(/\\s/g, '-'); "
- + "var indexName = doc.correspondingPipelineId + '-' + vizName; "
- + "emit([indexName, doc.createdAtTimestamp], doc);}");
- notificationTypeViews.put("notificationtypes", notificationTypeFunction);
- userDocument.setViews(notificationTypeViews);
- Response resp = Utils.getCouchDbNotificationClient().design().synchronizeWithDb(userDocument);
-
- Map<String, MapReduce> notificationCountTypeViews = new HashMap<>();
- MapReduce countFunction = new MapReduce();
- countFunction.setMap("function (doc) {\n"
- + " var user = doc.targetedAt; \n"
- + " if (!doc.read) {\n"
- + " emit(user, 1);\n"
- + " }\n"
- + "}");
- countFunction.setReduce("function (keys, values, rereduce) {\n"
- + " if (rereduce) {\n"
- + " return sum(values);\n"
- + " } else {\n"
- + " return values.length;\n"
- + " }\n"
- + "}");
- notificationCountTypeViews.put("unread", countFunction);
- notificationCountDocument.setViews(notificationCountTypeViews);
- Response countResp =
- Utils.getCouchDbNotificationClient().design().synchronizeWithDb(notificationCountDocument);
-
- if (resp.getError() != null && countResp != null) {
- logFailure(PREPARING_NOTIFICATIONS_TEXT);
- } else {
- logSuccess(PREPARING_NOTIFICATIONS_TEXT);
- }
- } catch (Exception e) {
- logFailure(PREPARING_NOTIFICATIONS_TEXT, e);
- }
- }
-
private void addPipelineView() {
DesignDocument pipelineDocument = prepareDocument("_design/adapters");
DesignDocument allPipelinesDocument = prepareDocument("_design/pipelines");
diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/NotificationsResourceManager.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/NotificationsResourceManager.java
deleted file mode 100644
index d91b03ebed..0000000000
--- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/NotificationsResourceManager.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.resource.management;
-
-import org.apache.streampipes.model.pipeline.Pipeline;
-import org.apache.streampipes.model.staticproperty.FreeTextStaticProperty;
-import org.apache.streampipes.model.staticproperty.StaticProperty;
-import org.apache.streampipes.storage.api.system.INotificationStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class NotificationsResourceManager extends AbstractResourceManager<INotificationStorage> {
-
- private static final String InternalNotificationsAppId = "org.apache.streampipes.sinks.internal.jvm.notification";
- private static final String InternalNotificationsTitleKey = "title";
-
- private static final Logger LOG = LoggerFactory.getLogger(NotificationsResourceManager.class);
-
- public NotificationsResourceManager() {
- super(StorageDispatcher.INSTANCE.getNoSqlStore().getNotificationStorageApi());
- }
-
- public void deleteNotificationsForPipeline(Pipeline pipeline) {
- try {
- List<String> notificationTypes = getAllNotificationTypesForPipeline(pipeline);
- notificationTypes.forEach(notificationType -> {
- var notifications = db.getAllNotifications(notificationType);
- notifications.forEach(notification -> db.deleteNotification(notification.getId()));
- });
- } catch (IllegalArgumentException e) {
- LOG.error("Could not find a notification type which is part of the pipeline.");
- }
- }
-
- private List<String> getAllNotificationTypesForPipeline(Pipeline pipeline) {
- return pipeline
- .getActions()
- .stream()
- .filter(sink -> sink.getAppId().equals(InternalNotificationsAppId))
- .map(sink -> sink.getCorrespondingPipeline() + "-" + extractNotificationTitle(sink.getStaticProperties()))
- .toList();
- }
-
- private String extractNotificationTitle(List<StaticProperty> staticProperties) {
- return staticProperties
- .stream()
- .filter(sp -> sp instanceof FreeTextStaticProperty)
- .filter(sp -> sp.getInternalName().equals(InternalNotificationsTitleKey))
- .map(sp -> ((FreeTextStaticProperty) sp).getValue())
- .findFirst()
- .orElseThrow(IllegalArgumentException::new);
- }
-
-
-}
diff --git a/streampipes-rest-core-base/src/main/java/org/apache/streampipes/rest/core/base/impl/AbstractRestResource.java b/streampipes-rest-core-base/src/main/java/org/apache/streampipes/rest/core/base/impl/AbstractRestResource.java
index 5a65adffa2..5b41613eec 100644
--- a/streampipes-rest-core-base/src/main/java/org/apache/streampipes/rest/core/base/impl/AbstractRestResource.java
+++ b/streampipes-rest-core-base/src/main/java/org/apache/streampipes/rest/core/base/impl/AbstractRestResource.java
@@ -28,7 +28,6 @@ import org.apache.streampipes.storage.api.core.INoSqlStorage;
import org.apache.streampipes.storage.api.pipeline.IPipelineElementDescriptionStorage;
import org.apache.streampipes.storage.api.pipeline.IPipelineElementTemplateStorage;
import org.apache.streampipes.storage.api.pipeline.IPipelineStorage;
-import org.apache.streampipes.storage.api.system.INotificationStorage;
import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
import org.apache.streampipes.storage.api.user.IUserStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
@@ -57,10 +56,6 @@ public class AbstractRestResource extends AbstractSharedRestInterface {
return getNoSqlStorage().getUserStorageAPI();
}
- protected INotificationStorage getNotificationStorage() {
- return getNoSqlStorage().getNotificationStorageApi();
- }
-
protected IPipelineElementTemplateStorage getPipelineElementTemplateStorage() {
return getNoSqlStorage().getPipelineElementTemplateStorage();
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/NotificationResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/NotificationResource.java
deleted file mode 100644
index 07ce2e7e84..0000000000
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/NotificationResource.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.rest.impl;
-
-import org.apache.streampipes.model.Notification;
-import org.apache.streampipes.model.NotificationCount;
-import org.apache.streampipes.model.message.Message;
-import org.apache.streampipes.model.message.Notifications;
-import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
-
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-@RestController
-@RequestMapping("/api/v2/notifications")
-public class NotificationResource extends AbstractAuthGuardedRestResource {
-
- @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<Void> addNotification(@RequestBody Notification notification) {
- getNotificationStorage().addNotification(notification);
- return ok();
- }
-
- @GetMapping(path = "/offset", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<List<Notification>> getNotifications(@RequestParam("notificationType") String notTypeId,
- @RequestParam("offset") Integer offset,
- @RequestParam("count") Integer count) {
- return ok(getNotificationStorage()
- .getAllNotifications(notTypeId, offset, count));
- }
-
- @GetMapping(path = "/time", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<List<Notification>> getNotifications(@RequestParam("startTime") long startTime) {
- return ok(getNotificationStorage()
- .getAllNotificationsFromTimestamp(startTime));
- }
-
- @GetMapping(path = "/count", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<NotificationCount> getUnreadNotificationsCount() {
- return ok(getNotificationStorage()
- .getUnreadNotificationsCount(getAuthenticatedUserSid()));
- }
-
- @GetMapping(path = "/unread")
- public ResponseEntity<List<Notification>> getUnreadNotifications() {
- return ok(getNotificationStorage()
- .getUnreadNotifications());
- }
-
- @DeleteMapping(path = "/{notificationId}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<? extends Message> deleteNotification(@PathVariable("notificationId") String notificationId) {
- boolean success = getNotificationStorage()
- .deleteNotification(notificationId);
- if (success) {
- return ok(Notifications.success("Notification deleted"));
- } else {
- return ok(Notifications.error("Could not delete notification"));
- }
-
- }
-
- @PutMapping(path = "/{notificationId}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<?> modifyNotificationStatus(@PathVariable("notificationId") String notificationId) {
- boolean success = getNotificationStorage()
- .changeNotificationStatus(notificationId);
- if (success) {
- return ok(Notifications.success("Ok"));
- } else {
- return ok(Notifications.error("Error"));
- }
- }
-}
diff --git a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
index e0d189ac59..ad093e185e 100644
--- a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
+++ b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
@@ -35,6 +35,7 @@ import org.apache.streampipes.service.core.migrations.v099.ModifyAssetLinkIconMi
import org.apache.streampipes.service.core.migrations.v099.MoveAssetContentMigration;
import org.apache.streampipes.service.core.migrations.v099.RemoveAssetUserRoleMigration;
import org.apache.streampipes.service.core.migrations.v099.RemoveDuplicatedAssetPermissions;
+import org.apache.streampipes.service.core.migrations.v099.RemoveInternalNotificationSinkMigration;
import org.apache.streampipes.service.core.migrations.v099.RemoveObsoletePrivilegesMigration;
import org.apache.streampipes.service.core.migrations.v099.UniqueDashboardIdMigration;
import org.apache.streampipes.service.core.migrations.v099.connect.MigrateAdaptersToUseScript;
@@ -64,7 +65,8 @@ public class AvailableMigrations {
new RemoveDuplicatedAssetPermissions(),
new AddFunctionStateViewMigration(),
new AddRefreshTokenViewsMigration(),
- new RemoveAssetUserRoleMigration()
+ new RemoveAssetUserRoleMigration(),
+ new RemoveInternalNotificationSinkMigration()
);
}
}
diff --git a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/RemoveInternalNotificationSinkMigration.java b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/RemoveInternalNotificationSinkMigration.java
new file mode 100644
index 0000000000..985bfe2ef4
--- /dev/null
+++ b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/RemoveInternalNotificationSinkMigration.java
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.streampipes.service.core.migrations.v099;
+
+import org.apache.streampipes.model.graph.DataSinkInvocation;
+import org.apache.streampipes.model.pipeline.Pipeline;
+import org.apache.streampipes.model.pipeline.PipelineHealthStatus;
+import org.apache.streampipes.service.core.migrations.Migration;
+import org.apache.streampipes.storage.api.pipeline.IDataSinkStorage;
+import org.apache.streampipes.storage.api.pipeline.IPipelineStorage;
+import org.apache.streampipes.storage.couchdb.utils.Utils;
+import org.apache.streampipes.storage.management.StorageDispatcher;
+
+import org.apache.http.HttpStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+public class RemoveInternalNotificationSinkMigration implements Migration {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RemoveInternalNotificationSinkMigration.class);
+
+ static final String INTERNAL_NOTIFICATION_SINK_APP_ID =
+ "org.apache.streampipes.sinks.internal.jvm.notification";
+ static final String NOTIFICATION_DB_NAME = "notification";
+ static final String PIPELINE_WARNING =
+ "Internal notification sink was removed during migration. Review and update this pipeline before using it again.";
+
+ private final IPipelineStorage pipelineStorage;
+ private final IDataSinkStorage dataSinkStorage;
+
+ public RemoveInternalNotificationSinkMigration(IPipelineStorage pipelineStorage,
+ IDataSinkStorage dataSinkStorage) {
+ this.pipelineStorage = pipelineStorage;
+ this.dataSinkStorage = dataSinkStorage;
+ }
+
+ public RemoveInternalNotificationSinkMigration() {
+ this(StorageDispatcher.INSTANCE.getNoSqlStore().getPipelineStorageAPI(),
+ StorageDispatcher.INSTANCE.getNoSqlStore().getDataSinkStorage());
+ }
+
+ @Override
+ public boolean shouldExecute() {
+ return databaseExists()
+ || containsDeprecatedSinkInPipelines()
+ || !dataSinkStorage.getDataSinksByAppId(INTERNAL_NOTIFICATION_SINK_APP_ID).isEmpty();
+ }
+
+ @Override
+ public void executeMigration() throws IOException {
+ migratePipelines();
+ removeSinkDescriptions();
+ removeDatabase();
+ }
+
+ @Override
+ public String getDescription() {
+ return "Remove deprecated internal notification sink and notification database";
+ }
+
+ private boolean containsDeprecatedSinkInPipelines() {
+ return pipelineStorage.findAll()
+ .stream()
+ .map(Pipeline::getActions)
+ .filter(Objects::nonNull)
+ .flatMap(List::stream)
+ .map(DataSinkInvocation::getAppId)
+ .anyMatch(INTERNAL_NOTIFICATION_SINK_APP_ID::equals);
+ }
+
+ private void migratePipelines() {
+ pipelineStorage.findAll().forEach(pipeline -> {
+ var actions = pipeline.getActions();
+ if (actions == null || actions.isEmpty()) {
+ return;
+ }
+
+ var remainingActions = actions.stream()
+ .filter(action -> !INTERNAL_NOTIFICATION_SINK_APP_ID.equals(action.getAppId()))
+ .toList();
+
+ if (remainingActions.size() != actions.size()) {
+ pipeline.setActions(remainingActions);
+ pipeline.setRunning(false);
+ pipeline.setValid(false);
+ pipeline.setRestartOnSystemReboot(false);
+ pipeline.setHealthStatus(PipelineHealthStatus.REQUIRES_ATTENTION);
+ pipeline.setPipelineNotifications(appendMigrationWarning(pipeline.getPipelineNotifications()));
+ pipelineStorage.updateElement(pipeline);
+ LOG.info("Removed deprecated internal notification sink from pipeline '{}'", pipeline.getPipelineId());
+ }
+ });
+ }
+
+ private List<String> appendMigrationWarning(List<String> existingWarnings) {
+ var warnings = existingWarnings == null ? new ArrayList<String>() : new ArrayList<>(existingWarnings);
+ if (!warnings.contains(PIPELINE_WARNING)) {
+ warnings.add(PIPELINE_WARNING);
+ }
+ return warnings;
+ }
+
+ private void removeSinkDescriptions() {
+ dataSinkStorage.getDataSinksByAppId(INTERNAL_NOTIFICATION_SINK_APP_ID)
+ .forEach(dataSinkStorage::deleteElement);
+ }
+
+ protected boolean databaseExists() {
+ try {
+ var response = Utils.getRequest(Utils.getDatabaseRoute(NOTIFICATION_DB_NAME))
+ .execute()
+ .returnResponse();
+ int statusCode = response.getStatusLine().getStatusCode();
+ return statusCode == HttpStatus.SC_OK;
+ } catch (IOException e) {
+ LOG.warn("Could not determine whether notification database exists", e);
+ return false;
+ }
+ }
+
+ protected void removeDatabase() throws IOException {
+ var response = Utils.deleteRequest(Utils.getDatabaseRoute(NOTIFICATION_DB_NAME))
+ .execute()
+ .returnResponse();
+ int statusCode = response.getStatusLine().getStatusCode();
+
+ if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED
+ || statusCode == HttpStatus.SC_NOT_FOUND) {
+ LOG.info("Notification database removal finished with status {}", statusCode);
+ } else {
+ throw new IOException("Unexpected response while deleting notification database: " + statusCode);
+ }
+ }
+}
diff --git a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/RemoveInternalNotificationSinkMigrationTest.java b/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/RemoveInternalNotificationSinkMigrationTest.java
new file mode 100644
index 0000000000..650aa580c7
--- /dev/null
+++ b/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/RemoveInternalNotificationSinkMigrationTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.streampipes.service.core.migrations.v099;
+
+import org.apache.streampipes.model.graph.DataSinkDescription;
+import org.apache.streampipes.model.graph.DataSinkInvocation;
+import org.apache.streampipes.model.pipeline.Pipeline;
+import org.apache.streampipes.model.pipeline.PipelineHealthStatus;
+import org.apache.streampipes.storage.api.pipeline.IDataSinkStorage;
+import org.apache.streampipes.storage.api.pipeline.IPipelineStorage;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class RemoveInternalNotificationSinkMigrationTest {
+
+ private IPipelineStorage pipelineStorage;
+ private IDataSinkStorage dataSinkStorage;
+ private RemoveInternalNotificationSinkMigration migration;
+ private boolean databaseExists;
+ private boolean databaseRemoved;
+
+ @BeforeEach
+ void setUp() {
+ this.pipelineStorage = mock(IPipelineStorage.class);
+ this.dataSinkStorage = mock(IDataSinkStorage.class);
+ this.databaseExists = false;
+ this.databaseRemoved = false;
+ this.migration = new RemoveInternalNotificationSinkMigration(pipelineStorage, dataSinkStorage) {
+ @Override
+ protected boolean databaseExists() {
+ return RemoveInternalNotificationSinkMigrationTest.this.databaseExists;
+ }
+
+ @Override
+ protected void removeDatabase() {
+ RemoveInternalNotificationSinkMigrationTest.this.databaseRemoved = true;
+ }
+ };
+ }
+
+ @Test
+ void shouldExecuteReturnsTrueWhenNotificationDatabaseExists() {
+ this.databaseExists = true;
+ when(pipelineStorage.findAll()).thenReturn(List.of());
+ when(dataSinkStorage.getDataSinksByAppId(RemoveInternalNotificationSinkMigration.INTERNAL_NOTIFICATION_SINK_APP_ID))
+ .thenReturn(List.of());
+
+ assertTrue(migration.shouldExecute());
+ }
+
+ @Test
+ void executeMigrationRemovesDeprecatedSinkAndMarksPipeline() throws IOException {
+ var deprecatedSink = new DataSinkInvocation();
+ deprecatedSink.setAppId(RemoveInternalNotificationSinkMigration.INTERNAL_NOTIFICATION_SINK_APP_ID);
+
+ var retainedSink = new DataSinkInvocation();
+ retainedSink.setAppId("org.apache.streampipes.sinks.notifications.jvm.email");
+
+ var affectedPipeline = new Pipeline();
+ affectedPipeline.setPipelineId("pipeline-1");
+ affectedPipeline.setActions(List.of(deprecatedSink, retainedSink));
+ affectedPipeline.setRunning(true);
+ affectedPipeline.setValid(true);
+
+ var unaffectedPipeline = new Pipeline();
+ unaffectedPipeline.setPipelineId("pipeline-2");
+ unaffectedPipeline.setActions(List.of(retainedSink));
+ unaffectedPipeline.setRunning(true);
+ unaffectedPipeline.setValid(true);
+
+ var sinkDescription = new DataSinkDescription();
+ sinkDescription.setAppId(RemoveInternalNotificationSinkMigration.INTERNAL_NOTIFICATION_SINK_APP_ID);
+
+ when(pipelineStorage.findAll()).thenReturn(List.of(affectedPipeline, unaffectedPipeline));
+ when(dataSinkStorage.getDataSinksByAppId(RemoveInternalNotificationSinkMigration.INTERNAL_NOTIFICATION_SINK_APP_ID))
+ .thenReturn(List.of(sinkDescription));
+
+ migration.executeMigration();
+
+ assertEquals(1, affectedPipeline.getActions().size());
+ assertEquals("org.apache.streampipes.sinks.notifications.jvm.email",
+ affectedPipeline.getActions().get(0).getAppId());
+ assertFalse(affectedPipeline.isRunning());
+ assertFalse(affectedPipeline.isValid());
+ assertEquals(PipelineHealthStatus.REQUIRES_ATTENTION, affectedPipeline.getHealthStatus());
+ assertEquals(List.of(RemoveInternalNotificationSinkMigration.PIPELINE_WARNING),
+ affectedPipeline.getPipelineNotifications());
+
+ verify(pipelineStorage).updateElement(affectedPipeline);
+ verify(pipelineStorage, never()).updateElement(unaffectedPipeline);
+ verify(dataSinkStorage).deleteElement(sinkDescription);
+ assertTrue(databaseRemoved);
+ }
+}
diff --git a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/core/INoSqlStorage.java b/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/core/INoSqlStorage.java
index 3f7c1ca222..3d616f1449 100644
--- a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/core/INoSqlStorage.java
+++ b/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/core/INoSqlStorage.java
@@ -36,7 +36,6 @@ import org.apache.streampipes.storage.api.system.IExtensionsServiceStorage;
import org.apache.streampipes.storage.api.system.IFileMetadataStorage;
import org.apache.streampipes.storage.api.system.IGenericStorage;
import org.apache.streampipes.storage.api.system.IImageStorage;
-import org.apache.streampipes.storage.api.system.INotificationStorage;
import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
import org.apache.streampipes.storage.api.system.ITransformationScriptTemplateStorage;
import org.apache.streampipes.storage.api.user.IPasswordRecoveryTokenStorage;
@@ -64,8 +63,6 @@ public interface INoSqlStorage {
IUserStorage getUserStorageAPI();
- INotificationStorage getNotificationStorageApi();
-
IDataLakeMeasureStorage getDataLakeStorage();
IFileMetadataStorage getFileMetadataStorage();
diff --git a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/system/INotificationStorage.java b/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/system/INotificationStorage.java
deleted file mode 100644
index 7cdbe7e443..0000000000
--- a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/system/INotificationStorage.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.storage.api.system;
-
-import org.apache.streampipes.model.Notification;
-import org.apache.streampipes.model.NotificationCount;
-
-import java.util.List;
-
-public interface INotificationStorage {
-
- Notification getNotification(String notificationId);
-
- List<Notification> getAllNotifications(String notificationTypeId, Integer offset, Integer count);
-
- List<Notification> getAllNotifications(String notificationTypeId);
-
- List<Notification> getAllNotificationsFromTimestamp(long startTime);
-
- List<Notification> getUnreadNotifications();
-
- NotificationCount getUnreadNotificationsCount(String username);
-
- boolean addNotification(Notification notification);
-
- boolean changeNotificationStatus(String notificationId);
-
- boolean deleteNotification(String notificationId);
-
-}
diff --git a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java
index a682385ac3..b75019c472 100644
--- a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java
+++ b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java
@@ -38,7 +38,6 @@ import org.apache.streampipes.storage.api.system.IExtensionsServiceStorage;
import org.apache.streampipes.storage.api.system.IFileMetadataStorage;
import org.apache.streampipes.storage.api.system.IGenericStorage;
import org.apache.streampipes.storage.api.system.IImageStorage;
-import org.apache.streampipes.storage.api.system.INotificationStorage;
import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
import org.apache.streampipes.storage.api.system.ITransformationScriptTemplateStorage;
import org.apache.streampipes.storage.api.user.IPasswordRecoveryTokenStorage;
@@ -70,7 +69,6 @@ import org.apache.streampipes.storage.couchdb.impl.system.ExtensionsServiceStora
import org.apache.streampipes.storage.couchdb.impl.system.FileMetadataStorageImpl;
import org.apache.streampipes.storage.couchdb.impl.system.GenericStorageImpl;
import org.apache.streampipes.storage.couchdb.impl.system.ImageStorageImpl;
-import org.apache.streampipes.storage.couchdb.impl.system.NotificationStorageImpl;
import org.apache.streampipes.storage.couchdb.impl.system.TransformationScriptTemplateStorageImpl;
import org.apache.streampipes.storage.couchdb.impl.user.PasswordRecoveryTokenStorageImpl;
import org.apache.streampipes.storage.couchdb.impl.user.PermissionStorageImpl;
@@ -119,11 +117,6 @@ public class CouchDbStorageManager implements INoSqlStorage {
return new UserStorage();
}
- @Override
- public INotificationStorage getNotificationStorageApi() {
- return new NotificationStorageImpl();
- }
-
@Override
public IDataLakeMeasureStorage getDataLakeStorage() {
return new DataLakeMeasureStorage(
diff --git a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/system/NotificationStorageImpl.java b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/system/NotificationStorageImpl.java
deleted file mode 100644
index 01c08efc6b..0000000000
--- a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/system/NotificationStorageImpl.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.streampipes.storage.couchdb.impl.system;
-
-import org.apache.streampipes.model.Notification;
-import org.apache.streampipes.model.NotificationCount;
-import org.apache.streampipes.storage.api.system.INotificationStorage;
-import org.apache.streampipes.storage.couchdb.dao.AbstractDao;
-import org.apache.streampipes.storage.couchdb.utils.Utils;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import org.lightcouch.View;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class NotificationStorageImpl extends AbstractDao<Notification> implements
- INotificationStorage {
-
- public NotificationStorageImpl() {
- super(Utils::getCouchDbNotificationClient, Notification.class);
- }
-
- @Override
- public Notification getNotification(String notificationId) {
- return findWithNullIfEmpty(notificationId);
- }
-
- @Override
- public List<Notification> getAllNotifications(String notificationTypeId,
- Integer offset,
- Integer count) {
- List<JsonObject> notifications =
- getQuery(notificationTypeId)
- .includeDocs(true)
- .skip(offset)
- .limit(count)
- .query(JsonObject.class);
-
- return map(notifications);
- }
-
- @Override
- public List<Notification> getAllNotifications(String notificationTypeId) {
- List<JsonObject> notifications =
- getQuery(notificationTypeId)
- .includeDocs(true)
- .query(JsonObject.class);
-
- return map(notifications);
- }
-
- private View getQuery(String notificationTypeId) {
- return couchDbClientSupplier
- .get()
- .view("notificationtypes/notificationtypes")
- .startKey(Arrays.asList(notificationTypeId, "\ufff0"))
- .endKey(Arrays.asList(notificationTypeId, 0))
- .descending(true)
- .includeDocs(true);
- }
-
- @Override
- public List<Notification> getAllNotificationsFromTimestamp(long startTime) {
-
- return couchDbClientSupplier
- .get()
- .findDocs("{\"selector\": {\"createdAtTimestamp\": {\"$gt\": " + startTime + "}}}", Notification.class);
- }
-
- private List<Notification> map(List<JsonObject> jsonObjects) {
- Gson gson = couchDbClientSupplier.get().getGson();
- return jsonObjects
- .stream()
- .map(notification -> gson.fromJson(notification, Notification.class))
- .collect(Collectors.toList());
- }
-
- @Override
- public boolean addNotification(Notification notification) {
- persist(notification);
- return true;
- }
-
- @Override
- public boolean changeNotificationStatus(String notificationId) {
- Notification msg = getNotification(notificationId);
- msg.setRead(!msg.isRead());
-
- return update(msg);
- }
-
- @Override
- public boolean deleteNotification(String notificationId) {
- return delete(notificationId);
- }
-
- @Override
- public List<Notification> getUnreadNotifications() {
- List<Notification> msgs = findAll();
-
- return msgs
- .stream()
- .filter(m -> !m.isRead())
- .collect(Collectors.toList());
- }
-
- @Override
- public NotificationCount getUnreadNotificationsCount(String username) {
- List<JsonObject> count =
- couchDbClientSupplier
- .get()
- .view("unread/unread")
- .key(username)
- .group(true)
- .query(JsonObject.class);
-
- if (!count.isEmpty()) {
- Integer countValue = count.get(0).get("value").getAsInt();
- return new NotificationCount(countValue);
- } else {
- return new NotificationCount(0);
- }
- }
-}
diff --git a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/utils/Utils.java b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/utils/Utils.java
index b98d8bafef..d0eabc1a5c 100644
--- a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/utils/Utils.java
+++ b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/utils/Utils.java
@@ -91,10 +91,6 @@ public class Utils {
return getCouchDbPrincipalClient(USER_DB_NAME);
}
- public static CouchDbClient getCouchDbNotificationClient() {
- return getCouchDbStandardSerializerClient("notification");
- }
-
public static CouchDbClient getCouchDbGsonClient(String dbname) {
CouchDbClient dbClient = new CouchDbClient(props(dbname));
dbClient.setGsonBuilder(GsonSerializer.getGsonBuilder());
diff --git a/ui/deployment/app.routes.mst b/ui/deployment/app.routes.mst
index 9e7e8c4c7f..8e5aab5505 100644
--- a/ui/deployment/app.routes.mst
+++ b/ui/deployment/app.routes.mst
@@ -22,7 +22,6 @@ import {AuthCanActivateChildrenGuard} from "./core/auth/guards/auth.can-activate
import {ConfiguredCanActivateGuard} from "./core/setup/guards/configured.can-activate.guard";
import {StartupComponent} from "./login/components/startup/startup.component";
import {InfoComponent} from "./info/info.component";
-import {NotificationsComponent} from "./notifications/notifications.component";
import {ProfileComponent} from "./profile/profile.component";
import {ApidocsComponent} from "./apidocs/apidocs.component";
import { PageName } from './core/navigation/page-name.enum';
@@ -72,7 +71,6 @@ export const routes: Routes = [
loadChildren: () => import('{{{routesPath}}}').then(m => m.{{{routesName}}})
},
{{/modulesActive}}
- { path: 'notifications', component: NotificationsComponent },
{ path: 'info', component: InfoComponent },
{ path: 'profile', component: ProfileComponent},
], canActivateChild: [AuthCanActivateChildrenGuard, PageAuthGuard, TermsCanActivateChildrenGuard] }
diff --git a/ui/deployment/base-navigation.component.mst b/ui/deployment/base-navigation.component.mst
index bd9fca0589..3a95aa2ffc 100644
--- a/ui/deployment/base-navigation.component.mst
+++ b/ui/deployment/base-navigation.component.mst
@@ -56,7 +56,6 @@ export abstract class BaseNavigationComponent {
authenticated = true;
topItems: MenuItem[] = [];
menuGroups: MenuGroup[] = [];
- notificationsVisible = false;
public categories: MenuCategory[] = [
{{#categoriesActive}}
@@ -103,10 +102,6 @@ export abstract class BaseNavigationComponent {
this.topItems = menuGroups.find(m => m.title === 'top')?.items || [];
this.menuGroups = menuGroups.filter(m => m.title !== 'top');
- this.notificationsVisible = this.isNavItemVisible([
- UserPrivilege.PRIVILEGE_READ_PIPELINE,
- UserPrivilege.PRIVILEGE_WRITE_PIPELINE
- ]);
});
this.activePage = this.router.url.replace('/', '');
this.activePageName = this.getPageTitle(this.activePage);
diff --git a/ui/deployment/home.service.mst b/ui/deployment/home.service.mst
index 71fd0d88dd..b0717b5644 100644
--- a/ui/deployment/home.service.mst
+++ b/ui/deployment/home.service.mst
@@ -71,23 +71,8 @@ export class HomeService {
assetLinkTypeId: '{{{assetLinkTypeId}}}'
}
{{/statusBox}}
- },
- {{/modulesActive}}
- {
- name: "Notifications",
- description: "The notification module lets you view all notifications generated by pipelines.",
- icon: "notifications",
- pageNames: [PageName.NOTIFICATIONS],
- privileges: [
- UserPrivilege.PRIVILEGE_READ_PIPELINE,
- UserPrivilege.PRIVILEGE_WRITE_PIPELINE
- ],
- link: {
- newWindow: false,
- value: "notifications"
- },
- showStatusBox: false
- }
- ];
- }
-}
+ },
+ {{/modulesActive}}
+ ];
+ }
+}
diff --git a/ui/src/app/core/components/toolbar/toolbar.component.html b/ui/src/app/core/components/toolbar/toolbar.component.html
index 54c25f9809..cc51e45da5 100644
--- a/ui/src/app/core/components/toolbar/toolbar.component.html
+++ b/ui/src/app/core/components/toolbar/toolbar.component.html
@@ -37,42 +37,6 @@
<!-- >-->
<!-- </div>-->
<sp-asset-browser-toolbar> </sp-asset-browser-toolbar>
- @if (notificationsVisible) {
- <div
- [ngClass]="
- 'notifications' === activePage
- ? 'sp-navbar-item-selected'
- : 'sp-navbar-item'
- "
- class="h-100"
- >
- <button
- mat-icon-button
- class="md-icon-button button-margin-iconbar iconbar-size"
- (click)="go('notifications')"
- fxLayout
- fxLayoutAlign="center center"
- matTooltip="Notifications"
- matTooltipPosition="below"
- >
- <mat-icon
- [matBadge]="unreadNotificationCount"
- matBadgeColor="accent"
- matBadgePosition="below after"
- [matBadgeHidden]="
- unreadNotificationCount === 0
- "
- [ngClass]="
- 'notifications' === activePage
- ? 'sp-navbar-icon-selected'
- : 'sp-navbar-icon'
- "
- data-cy="navigation-icon"
- >notifications
- </mat-icon>
- </button>
- </div>
- }
<div style="height: 100%">
<div
[ngClass]="
diff --git a/ui/src/app/core/components/toolbar/toolbar.component.ts b/ui/src/app/core/components/toolbar/toolbar.component.ts
index cf379496cf..20850ff82a 100644
--- a/ui/src/app/core/components/toolbar/toolbar.component.ts
+++ b/ui/src/app/core/components/toolbar/toolbar.component.ts
@@ -16,16 +16,12 @@
*
*/
-import { Component, inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
+import { Component, inject, OnInit, ViewChild } from '@angular/core';
import { BaseNavigationComponent } from '../base-navigation.component';
-import { RestApi } from '../../../services/rest-api.service';
import { MatMenu, MatMenuItem, MatMenuTrigger } from '@angular/material/menu';
import { UntypedFormControl } from '@angular/forms';
import { OverlayContainer } from '@angular/cdk/overlay';
import { ProfileService } from '../../../profile/profile.service';
-import { Subscription, timer } from 'rxjs';
-import { exhaustMap } from 'rxjs/operators';
-import { NotificationCountService } from '../../../services/notification-count-service';
import { LoginService } from '../../../login/services/login.service';
import {
AssetBrowserToolbarComponent,
@@ -44,7 +40,6 @@ import { ClassDirective } from '@ngbracket/ngx-layout/extended';
import { MatIconButton } from '@angular/material/button';
import { MatTooltip } from '@angular/material/tooltip';
import { MatIcon } from '@angular/material/icon';
-import { MatBadge } from '@angular/material/badge';
import { MatDivider } from '@angular/material/divider';
import { ShortenPipe } from '../../pipes/shorten.pipe';
@@ -65,7 +60,6 @@ import { ShortenPipe } from '../../pipes/shorten.pipe';
MatIconButton,
MatTooltip,
MatIcon,
- MatBadge,
MatMenuTrigger,
MatMenu,
MatDivider,
@@ -75,7 +69,7 @@ import { ShortenPipe } from '../../pipes/shorten.pipe';
})
export class ToolbarComponent
extends BaseNavigationComponent
- implements OnInit, OnDestroy
+ implements OnInit
{
@ViewChild('feedbackOpen') feedbackOpen: MatMenuTrigger;
@ViewChild('accountMenuOpen') accountMenuOpen: MatMenuTrigger;
@@ -85,34 +79,16 @@ export class ToolbarComponent
appearanceControl: UntypedFormControl;
- unreadNotificationCount = 0;
- unreadNotificationsSubscription: Subscription;
-
documentationLinkActive = false;
documentationLink = '';
private loginService = inject(LoginService);
private profileService = inject(ProfileService);
- private restApi = inject(RestApi);
private overlay = inject(OverlayContainer);
- public notificationCountService = inject(NotificationCountService);
private assetFilterService = inject(SpAssetBrowserService);
ngOnInit(): void {
this.assetFilterService.applyAssetLinkType('');
- this.unreadNotificationsSubscription = timer(0, 10000)
- .pipe(exhaustMap(() => this.restApi.getUnreadNotificationsCount()))
- .subscribe(response => {
- this.notificationCountService.unreadNotificationCount$.next(
- response.count,
- );
- });
-
- this.notificationCountService.unreadNotificationCount$.subscribe(
- count => {
- this.unreadNotificationCount = count;
- },
- );
this.currentUserService.user$.subscribe(user => {
const displayName = user.displayName;
this.userEmail =
@@ -177,8 +153,4 @@ export class ToolbarComponent
this.authService.logout();
this.router.navigate(['login']);
}
-
- ngOnDestroy() {
- this.unreadNotificationsSubscription.unsubscribe();
- }
}
diff --git a/ui/src/app/core/navigation/page-name.enum.ts b/ui/src/app/core/navigation/page-name.enum.ts
index 9197e00f55..ec29c414c4 100644
--- a/ui/src/app/core/navigation/page-name.enum.ts
+++ b/ui/src/app/core/navigation/page-name.enum.ts
@@ -25,7 +25,6 @@ export enum PageName {
DASHBOARD,
DATA_EXPLORER,
APPS,
- NOTIFICATIONS,
INSTALL_PIPELINE_ELEMENTS,
FILE_UPLOAD,
PROFILE,
diff --git a/ui/src/app/notifications/components/notification-item.component.html b/ui/src/app/notifications/components/notification-item.component.html
deleted file mode 100644
index 39df6b3cbc..0000000000
--- a/ui/src/app/notifications/components/notification-item.component.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<div class="notification-item">
- <div class="i">
- <div class="head">
- <span class="time">{{
- notification.createdAt | date: 'yyyy-MM-dd HH:mm:ss'
- }}</span>
- </div>
- <div class="notification-box sp-primary-bg">
- <div [innerHTML]="sanitizedMessage"></div>
- </div>
- </div>
-</div>
diff --git a/ui/src/app/notifications/components/notification-item.component.scss b/ui/src/app/notifications/components/notification-item.component.scss
deleted file mode 100644
index bdca94e9fd..0000000000
--- a/ui/src/app/notifications/components/notification-item.component.scss
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.
- */
-
-.head {
- font-size: 13px;
-}
-.name {
- font-weight: 600;
- position: relative;
-}
-
-.time {
- color: var(--color-primary);
-}
-.notification-box {
- margin-top: 20px;
- color: #fff;
- font-size: 15px;
- border-radius: 5px;
- padding: 20px;
- line-height: 25px;
- max-width: 400px;
- word-wrap: break-word;
- position: relative;
-}
-.notification-box:before {
- content: '';
- position: absolute;
- width: 0;
- height: 0;
- top: -12px;
- border-bottom: 12px solid #1b1464;
- border-left: 10px solid transparent;
- border-right: 10px solid transparent;
-}
-
-.notification-item {
- margin-top: 30px;
-}
diff --git a/ui/src/app/notifications/components/notification-item.component.ts b/ui/src/app/notifications/components/notification-item.component.ts
deleted file mode 100644
index af3b4b52c8..0000000000
--- a/ui/src/app/notifications/components/notification-item.component.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-
-import { Component, Input, OnInit, inject } from '@angular/core';
-import { NotificationItem } from '../model/notifications.model';
-import { DomSanitizer } from '@angular/platform-browser';
-import { DatePipe } from '@angular/common';
-
-@Component({
- selector: 'sp-notification-item',
- templateUrl: './notification-item.component.html',
- styleUrls: ['./notification-item.component.scss'],
- imports: [DatePipe],
-})
-export class NotificationItemComponent implements OnInit {
- private domSanitizer = inject(DomSanitizer);
-
- @Input() notification: NotificationItem;
- sanitizedMessage;
-
- ngOnInit(): void {
- this.sanitizedMessage = this.domSanitizer.bypassSecurityTrustHtml(
- this.notification.message,
- );
- }
-}
diff --git a/ui/src/app/notifications/model/notifications.model.ts b/ui/src/app/notifications/model/notifications.model.ts
deleted file mode 100644
index f7fbb8e8ef..0000000000
--- a/ui/src/app/notifications/model/notifications.model.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-
-export interface NotificationItem {
- _id: string;
- _rev: string;
- title: string;
- createdAt: Date;
- createdAtTimestamp: number;
- targetedAt: string;
- correspondingPipelineId: string;
- message: string;
- read: boolean;
-}
-
-export interface ExistingNotification {
- pipelineName: string;
- notificationTitle: string;
- pipelineId: string;
- notificationId: string;
-}
-
-export interface NotificationCount {
- count: number;
-}
diff --git a/ui/src/app/notifications/notifications.component.html b/ui/src/app/notifications/notifications.component.html
deleted file mode 100644
index 74c744ac77..0000000000
--- a/ui/src/app/notifications/notifications.component.html
+++ /dev/null
@@ -1,148 +0,0 @@
-<!--
-~ 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.
-~
--->
-
-<sp-basic-view class="page-container-max-height">
- <div fxLayout="row" nav>
- <div fxFlex="100" class="page-container-nav">
- <div fxFlex="100" fxLayout="row">
- <div fxFlex fxLayoutAlign="start center">
- <mat-tab-group color="accent">
- <mat-tab label="My Notifications"></mat-tab>
- </mat-tab-group>
- </div>
- <div fxFlex fxLayoutAlign="end center" class="mr-20"></div>
- </div>
- </div>
- </div>
- @if (notificationsLoading) {
- <div
- class="container-fluid marketplace-container"
- fxFlex="100"
- fxLayoutAlign="center center"
- fxLayout="column"
- >
- <mat-spinner [mode]="'indeterminate'" [diameter]="20"></mat-spinner>
- <h4>Loading notifications...</h4>
- </div>
- }
- @if (!notificationsLoading && !pipelinesWithNotificationsPresent) {
- <div
- class="fixed-height page-container-padding-inner"
- fxFlex="100"
- fxLayoutAlign="center center"
- fxLayout="row"
- >
- <h4>
- No notifications available. Create a new pipeline using the
- Notification Sink to create your first notification!
- </h4>
- </div>
- }
- @if (!notificationsLoading && pipelinesWithNotificationsPresent) {
- <div
- class="fixed-height page-container-padding-inner"
- fxLayout="row"
- fxFlex="100"
- >
- <div fxFlex="30" class="notifications-overview scrolling-auto">
- <mat-list>
- @for (
- existingNotification of existingNotifications;
- track existingNotification
- ) {
- <mat-list-item
- (click)="selectNotification(existingNotification)"
- class="list-item"
- [ngClass]="{
- 'selected-notification':
- existingNotification.notificationId ===
- currentlySelectedNotificationId,
- }"
- >
- <div
- matListItemAvatar
- class="notification-avatar sp-primary-bg"
- style="background: var(--color-primary)"
- >
- {{
- elementIconText.getElementIconText(
- existingNotification.pipelineName
- )
- }}
- </div>
- <h4 matListItemTitle>
- {{ existingNotification.pipelineName }}
- </h4>
- <p matListItemLine>
- {{ existingNotification.notificationTitle }}
- </p>
- <div class="new-notification-info-panel">
- @if (
- currentlySelectedNotificationId !==
- existingNotification.notificationId &&
- newNotificationInfo[
- existingNotification.notificationId
- ]
- ) {
- <div class="new-notification-info"></div>
- }
- </div>
- </mat-list-item>
- }
- </mat-list>
- </div>
- <div fxFlex="70" class="notifications-details">
- <div class="notification-details-wrapper">
- <div
- class="notification-header"
- fxLayout="column"
- fxLayoutAlign="center start"
- >
- <div class="notification-header-pipeline-name">
- {{ currentlySelectedNotification.pipelineName }}
- </div>
- <div class="notification-header-notification-name">
- {{
- currentlySelectedNotification.notificationTitle
- }}
- </div>
- <hr class="header-divider" />
- </div>
- @if (currentlySelectedNotificationId) {
- <div
- #notificationPane
- class="notification-pane"
- (scroll)="onScroll()"
- >
- @for (
- notification of allNotifications.get(
- currentlySelectedNotificationId
- );
- track notification
- ) {
- <sp-notification-item
- [notification]="notification"
- ></sp-notification-item>
- }
- </div>
- }
- </div>
- </div>
- </div>
- }
-</sp-basic-view>
diff --git a/ui/src/app/notifications/notifications.component.scss b/ui/src/app/notifications/notifications.component.scss
deleted file mode 100644
index 0cd6028705..0000000000
--- a/ui/src/app/notifications/notifications.component.scss
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.
- */
-
-.fixed-height {
- flex-direction: row;
- box-sizing: border-box;
- display: flex;
- flex: 1 1 100%;
- max-height: 100%;
- overflow-y: auto;
-}
-
-.page-container-max-height {
- max-height: calc(100% - 20px);
- //overflow: hidden;
-}
-
-.mr-20 {
- margin-right: 20px;
-}
-
-.notifications-overview {
- border-right: 5px solid var(--color-primary);
-}
-
-.notifications-details {
- padding-top: 20px;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- flex: 1;
-}
-
-.notification-details-wrapper {
- display: flex;
- flex-direction: column;
- overflow: hidden;
-}
-
-.notification-header {
- min-height: 75px;
- padding: 10px 10px 10px 20px;
- color: var(--color-primary);
-}
-
-.header-divider {
- display: flex;
- align-self: center;
- margin: 10px 20px;
- width: 100%;
- border-top: 2px solid var(--color-primary);
-}
-
-.notification-header-pipeline-name {
- font-size: 14pt;
-}
-
-.notification-header-notification-name {
- font-weight: 600;
-}
-
-.notification-avatar {
- align-items: center;
- justify-content: center;
- display: flex;
- color: white;
-}
-
-.list-item:hover {
- background: #e0e0e0;
- cursor: pointer;
-}
-
-.selected-notification {
- background: #e0e0e0;
- cursor: pointer;
-}
-
-.list-item {
- border-bottom: 1px solid #bdbdbd;
-}
-
-.notification-pane {
- display: flex;
- align-items: flex-end;
- flex-direction: column;
- overflow-y: auto;
- padding: 0px 30px 30px 0px;
- overflow-x: hidden;
-}
-
-.notification-item {
- margin-bottom: 30px;
-}
-
-.scrolling-auto {
- overflow: auto;
- width: 100%;
-}
-
-.new-notification-info {
- background: var(--color-secondary);
- width: 10px;
- height: 10px;
- border-radius: 50%;
-}
diff --git a/ui/src/app/notifications/notifications.component.ts b/ui/src/app/notifications/notifications.component.ts
deleted file mode 100644
index 4a38330aad..0000000000
--- a/ui/src/app/notifications/notifications.component.ts
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * 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.
- *
- */
-
-import {
- Component,
- ElementRef,
- OnDestroy,
- OnInit,
- ViewChild,
- inject,
-} from '@angular/core';
-import {
- ExistingNotification,
- NotificationItem,
-} from './model/notifications.model';
-import { NotificationsService } from './service/notifications.service';
-import { Subscription, timer } from 'rxjs';
-import { NotificationUtils } from './utils/notifications.utils';
-import { NotificationCountService } from '../services/notification-count-service';
-import {
- FreeTextStaticProperty,
- Pipeline,
- PipelineElementIconTextService,
- PipelineService,
-} from '@streampipes/platform-services';
-import { AuthService } from '../services/auth.service';
-import { filter, switchMap } from 'rxjs/operators';
-import {
- SpBasicViewComponent,
- SpBreadcrumbService,
-} from '@streampipes/shared-ui';
-import {
- FlexDirective,
- LayoutAlignDirective,
- LayoutDirective,
-} from '@ngbracket/ngx-layout/flex';
-import { MatTab, MatTabGroup } from '@angular/material/tabs';
-import { MatProgressSpinner } from '@angular/material/progress-spinner';
-import { NgClass } from '@angular/common';
-import { ClassDirective } from '@ngbracket/ngx-layout/extended';
-import { NotificationItemComponent } from './components/notification-item.component';
-
-@Component({
- selector: 'sp-notifications',
- templateUrl: './notifications.component.html',
- styleUrls: ['./notifications.component.scss'],
- imports: [
- SpBasicViewComponent,
- LayoutDirective,
- FlexDirective,
- LayoutAlignDirective,
- MatTabGroup,
- MatTab,
- MatProgressSpinner,
- NgClass,
- ClassDirective,
- NotificationItemComponent,
- ],
-})
-export class NotificationsComponent implements OnInit, OnDestroy {
- private authService = inject(AuthService);
- private pipelineService = inject(PipelineService);
- elementIconText = inject(PipelineElementIconTextService);
- private notificationService = inject(NotificationsService);
- private notificationCountService = inject(NotificationCountService);
- private breadcrumbService = inject(SpBreadcrumbService);
-
- static readonly NOTIFICATIONS_APP_ID =
- 'org.apache.streampipes.sinks.internal.jvm.notification';
- static readonly NOTIFICATION_TITLE_KEY = 'title';
-
- @ViewChild('notificationPane') private notificationContainer: ElementRef;
-
- allNotifications: Map<string, NotificationItem[]> = new Map();
- unreadNotifications: any;
- existingNotifications: ExistingNotification[] = [];
- currentlySelectedNotification: ExistingNotification;
- currentlySelectedNotificationId: string;
-
- pipelinesWithNotificationsPresent = false;
- notificationsLoading = false;
-
- currentOffset = 0;
- liveOffset = 0;
- previousScrollHeight: number;
-
- subscription: Subscription;
- notificationTopic: string;
-
- newNotificationInfo: boolean[] = [];
-
- newEventArriving = false;
- lastFetchTime = new Date().getTime();
-
- constructor() {
- this.unreadNotifications = [];
- }
-
- ngOnInit() {
- this.breadcrumbService.updateBreadcrumb([{ label: 'Notifications' }]);
- this.getPipelinesWithNotifications();
- this.subscription = timer(0, 5000)
- .pipe(
- filter(
- () =>
- this.currentlySelectedNotification !== undefined &&
- this.allNotifications.size > 0,
- ),
- switchMap(() =>
- this.notificationService.getNotificationsFromTime(
- this.lastFetchTime,
- ),
- ),
- )
- .subscribe(notifications => {
- let scrollToBottom = false;
- if (notifications.length > 0) {
- if (
- this.notificationContainer.nativeElement.scrollHeight -
- this.notificationContainer.nativeElement
- .scrollTop <=
- this.notificationContainer.nativeElement
- .clientHeight +
- 10 &&
- this.notificationContainer.nativeElement.scrollHeight -
- this.notificationContainer.nativeElement
- .scrollTop >=
- this.notificationContainer.nativeElement
- .clientHeight -
- 10
- ) {
- scrollToBottom = true;
- }
- this.newEventArriving = true;
- notifications.forEach(notification => {
- const notificationId =
- NotificationUtils.makeNotificationId(
- notification.correspondingPipelineId,
- notification.title,
- );
- const existingNots =
- this.allNotifications.get(notificationId);
- existingNots.push(notification);
- this.allNotifications.set(notificationId, existingNots);
- if (
- this.currentlySelectedNotificationId ===
- notificationId
- ) {
- this.liveOffset++;
- notification.read = true;
- setTimeout(() => {
- this.notificationService
- .updateNotification(notification)
- .subscribe();
- }, 500);
- } else {
- this.newNotificationInfo[notificationId] = true;
- }
- });
-
- if (scrollToBottom) {
- setTimeout(() => {
- this.scrollToBottom();
- });
- }
- }
- this.lastFetchTime = new Date().getTime();
- this.newEventArriving = false;
- });
- }
-
- scrollToBottom() {
- setTimeout(() => {
- this.notificationContainer.nativeElement.scrollTop =
- this.notificationContainer.nativeElement.scrollHeight + 100;
- }, 200);
- }
-
- getPipelinesWithNotifications() {
- this.notificationsLoading = true;
- this.pipelineService.getPipelines().subscribe(pipelines => {
- this.existingNotifications =
- this.getAllExistingNotifications(pipelines);
- this.notificationsLoading = false;
- if (this.existingNotifications.length > 0) {
- this.pipelinesWithNotificationsPresent = true;
- this.selectNotification(this.existingNotifications[0]);
- this.existingNotifications.forEach(notification => {
- this.getNotifications(
- notification,
- this.currentOffset,
- 10,
- true,
- );
- });
- }
- });
- }
-
- getAllExistingNotifications(pipelines: Pipeline[]): ExistingNotification[] {
- const existingNotifications = [];
- pipelines.forEach(pipeline => {
- const notificationActions = pipeline.actions.filter(
- sink =>
- sink.appId === NotificationsComponent.NOTIFICATIONS_APP_ID,
- );
- notificationActions.forEach(notificationAction => {
- const notificationName = notificationAction.staticProperties
- .filter(
- sp =>
- sp.internalName ===
- NotificationsComponent.NOTIFICATION_TITLE_KEY,
- )
- .map(sp => (sp as FreeTextStaticProperty).value)[0];
- const pipelineName = pipeline.name;
- existingNotifications.push({
- notificationTitle: notificationName,
- pipelineName,
- pipelineId: pipeline._id,
- notificationId: NotificationUtils.makeNotificationId(
- pipeline._id,
- notificationName,
- ),
- });
- });
- });
- return existingNotifications;
- }
-
- 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;
- });
- const notificationId = NotificationUtils.makeNotificationId(
- notification.pipelineId,
- notification.notificationTitle,
- );
- if (!this.allNotifications.has(notificationId)) {
- this.allNotifications.set(notificationId, []);
- }
- this.allNotifications
- .get(notificationId)
- .unshift(...notifications);
- if (scrollToBottom) {
- setTimeout(() => {
- this.scrollToBottom();
- }, 500);
- } else {
- setTimeout(() => {
- this.notificationContainer.nativeElement.scrollTop =
- this.notificationContainer.nativeElement
- .scrollHeight - this.previousScrollHeight;
- });
- }
- this.updateUnreadNotifications(notifications);
- });
- }
-
- updateUnreadNotifications(notifications: NotificationItem[]) {
- notifications.forEach(n => {
- if (!n.read) {
- n.read = true;
- this.notificationCountService.decreaseNotificationCount();
- this.notificationService.updateNotification(n).subscribe();
- }
- });
- }
-
- selectNotification(notification: ExistingNotification) {
- this.currentOffset = 0;
- this.liveOffset = 0;
- this.currentlySelectedNotification = notification;
- this.currentlySelectedNotificationId =
- NotificationUtils.makeNotificationIdFromNotification(notification);
- if (this.allNotifications.has(this.currentlySelectedNotificationId)) {
- this.updateUnreadNotifications(
- this.allNotifications.get(this.currentlySelectedNotificationId),
- );
- }
- this.newNotificationInfo[this.currentlySelectedNotificationId] = false;
- this.notificationCountService.lockIncreaseUpdateForId(
- this.currentlySelectedNotificationId,
- );
- if (this.notificationContainer) {
- this.scrollToBottom();
- }
- }
-
- onScroll() {
- if (this.notificationContainer.nativeElement.scrollTop === 0) {
- this.currentOffset += 10;
- this.previousScrollHeight =
- this.notificationContainer.nativeElement.scrollHeight;
- const currentNotifications = this.allNotifications.get(
- this.currentlySelectedNotificationId,
- );
- this.getNotifications(
- this.currentlySelectedNotification,
- currentNotifications.length + this.liveOffset,
- 10,
- false,
- );
- }
- }
-
- ngOnDestroy(): void {
- if (this.subscription) {
- this.subscription.unsubscribe();
- }
- this.notificationCountService.unlockIncreaseUpdate();
- }
-}
diff --git a/ui/src/app/notifications/service/notifications.service.ts b/ui/src/app/notifications/service/notifications.service.ts
deleted file mode 100644
index 006a167c87..0000000000
--- a/ui/src/app/notifications/service/notifications.service.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- */
-
-import { HttpClient, HttpContext } from '@angular/common/http';
-import { Observable } from 'rxjs';
-import {
- ExistingNotification,
- NotificationItem,
-} from '../model/notifications.model';
-import { Injectable, inject } from '@angular/core';
-import { NotificationUtils } from '../utils/notifications.utils';
-import { map } from 'rxjs/operators';
-import { PlatformServicesCommons } from '@streampipes/platform-services';
-import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
-
-@Injectable({ providedIn: 'root' })
-export class NotificationsService {
- private http = inject(HttpClient);
- private platformServicesCommons = inject(PlatformServicesCommons);
-
- getNotificationsFromTime(
- startTime: number,
- ): Observable<NotificationItem[]> {
- return this.http
- .get(
- this.notificationUrl + '/time' + '?' + 'startTime=' + startTime,
- {
- context: new HttpContext().set(
- NGX_LOADING_BAR_IGNORED,
- true,
- ),
- },
- )
- .pipe(
- map(data => {
- return data as NotificationItem[];
- }),
- );
- }
-
- getNotifications(
- existingNotification: ExistingNotification,
- offset: number,
- limit: number,
- ): Observable<NotificationItem[]> {
- return this.http
- .get(
- this.notificationUrl +
- '/offset' +
- '?' +
- 'notificationType=' +
- NotificationUtils.makeNotificationIdFromNotification(
- existingNotification,
- ) +
- '&' +
- 'offset=' +
- offset +
- '&' +
- 'count=' +
- limit,
- )
- .pipe(
- map(data => {
- return data as NotificationItem[];
- }),
- );
- }
-
- updateNotification(notificationItem: NotificationItem): Observable<any> {
- return this.http.put(
- this.notificationUrl + '/' + notificationItem._id,
- notificationItem,
- {
- context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
- },
- );
- }
-
- private get notificationUrl() {
- return this.platformServicesCommons.apiBasePath + '/notifications';
- }
-}
diff --git a/ui/src/app/notifications/utils/notifications.utils.ts b/ui/src/app/notifications/utils/notifications.utils.ts
deleted file mode 100644
index da7cda8399..0000000000
--- a/ui/src/app/notifications/utils/notifications.utils.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-import { ExistingNotification } from '../model/notifications.model';
-
-export class NotificationUtils {
- static makeNotificationIdFromNotification(
- existingNotification: ExistingNotification,
- ): string {
- return this.makeNotificationId(
- existingNotification.pipelineId,
- existingNotification.notificationTitle,
- );
- }
-
- static makeNotificationId(pipelineId: string, notificationTitle: string) {
- const vizName = notificationTitle.replace(/\s/g, '-');
- return pipelineId + '-' + vizName;
- }
-}
diff --git a/ui/src/app/services/notification-count-service.ts b/ui/src/app/services/notification-count-service.ts
deleted file mode 100644
index 46dfb60498..0000000000
--- a/ui/src/app/services/notification-count-service.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-
-import { Injectable, inject } from '@angular/core';
-import { RestApi } from './rest-api.service';
-import { BehaviorSubject } from 'rxjs';
-
-@Injectable({ providedIn: 'root' })
-export class NotificationCountService {
- private restApi = inject(RestApi);
-
- public unreadNotificationCount$ = new BehaviorSubject(0);
- lockNotificationId: string;
- lockActive = false;
-
- loadUnreadNotifications() {
- this.restApi.getUnreadNotificationsCount().subscribe(response => {
- this.unreadNotificationCount$.next(response.count);
- });
- }
-
- decreaseNotificationCount() {
- const newValue = Math.max(this.unreadNotificationCount$.value - 1, 0);
- this.unreadNotificationCount$.next(newValue);
- }
-
- lockIncreaseUpdateForId(notificationId: string) {
- this.lockNotificationId = notificationId;
- this.lockActive = true;
- }
-
- unlockIncreaseUpdate() {
- this.lockActive = false;
- }
-
- makeId(pipelineId: string, notificationTitle: string) {
- const vizName = notificationTitle.replace(/\\s/g, '-');
- return pipelineId + '-' + vizName;
- }
-}
diff --git a/ui/src/app/services/rest-api.service.ts b/ui/src/app/services/rest-api.service.ts
index 6b23228e86..1e2b3d1b80 100644
--- a/ui/src/app/services/rest-api.service.ts
+++ b/ui/src/app/services/rest-api.service.ts
@@ -41,12 +41,6 @@ export class RestApi {
});
}
- getUnreadNotificationsCount(): Observable<any> {
- return this.$http.get(this.urlApiBase() + '/notifications/count', {
- context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true),
- });
- }
-
updateCachedPipeline(rawPipelineModel: any) {
return this.$http.post(
this.urlApiBase() + '/pipeline-cache',