You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ho...@apache.org on 2026/10/24 00:24:18 UTC
(streampipes) branch dev updated: feat(#5092): add export feature to audit logs (#5095)
This is an automated email from the ASF dual-hosted git repository.
JHoelli 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 db0d573d69 feat(#5092): add export feature to audit logs (#5095)
db0d573d69 is described below
commit db0d573d691707f99ba1db6734a968319888abc5
Author: Jacqueline Höllig <78...@users.noreply.github.com>
AuthorDate: Sat Oct 24 02:24:12 2026 +0200
feat(#5092): add export feature to audit logs (#5095)
Co-authored-by: Dominik Riemer <do...@gmail.com>
---
pom.xml | 1 +
.../streampipes/audit/api/AuditExportColumn.java | 91 ++++++++++++++
.../audit/api/AuditExportConfiguration.java | 45 +++++++
.../streampipes/audit/api/AuditExportFormat.java | 49 +++-----
.../apache/streampipes/audit/api/AuditService.java | 7 ++
streampipes-audit-management/pom.xml | 5 +
.../audit/management/DefaultAuditService.java | 9 ++
.../management/export/AuditCsvOutputWriter.java | 72 +++++++++++
.../management/export/AuditExcelOutputWriter.java | 75 +++++++++++
.../management/export/AuditExportService.java | 66 ++++++++++
.../management/export/AuditJsonOutputWriter.java | 58 +++++++++
.../audit/management/export/AuditOutputWriter.java | 53 +++-----
.../export/AuditOutputWriterFactory.java | 47 ++-----
.../management/export/AuditExportServiceTest.java | 113 +++++++++++++++++
.../streampipes/rest/impl/admin/AuditResource.java | 50 ++++++++
.../utils/configuration/ConfigurationBtns.ts | 26 ++++
.../utils/configuration/ConfigurationUtils.ts | 4 +
.../audit-log/audit-log-download.spec.ts | 79 ++++++++++++
ui/deployment/i18n/de.json | 10 ++
ui/deployment/i18n/en.json | 10 ++
ui/deployment/i18n/pl.json | 10 ++
.../src/lib/apis/audit.service.ts | 34 +++++
.../download-status/download-status.component.html | 49 ++++++++
.../download-status.component.scss} | 37 +-----
.../download-status/download-status.component.ts | 60 +++++++++
.../components/download/download.component.html | 33 ++---
.../components/download/download.component.ts | 22 +---
.../export-format-selection.component.html | 68 ++++++++++
.../export-format-selection.component.scss} | 40 ++----
.../export-format-selection.component.ts | 47 +++++++
.../select-format/select-format.component.html | 52 +-------
.../select-format/select-format.component.ts | 2 +
.../streampipes/shared-ui/src/public-api.ts | 3 +
.../audit-log/audit-log.component.html | 11 ++
.../audit-log/audit-log.component.spec.ts | 19 ++-
.../configuration/audit-log/audit-log.component.ts | 46 +++++--
.../audit-download-dialog.component.html | 104 +++++++++++++++
.../audit-download-dialog.component.ts | 124 ++++++++++++++++++
.../select-data/select-data.component.html | 93 ++++++++++++++
.../select-data/select-data.component.scss} | 51 +++-----
.../select-data/select-data.component.ts | 140 +++++++++++++++++++++
.../model/audit-download-dialog.model.ts} | 50 +++-----
.../model/audit-export-config.model.ts} | 45 ++-----
.../model/format-export-config.model.ts} | 43 ++-----
.../services/audit-export.service.ts | 96 ++++++++++++++
.../audit-log/audit-dialog.component.html | 0
.../audit-log/audit-dialog.component.scss | 0
.../audit-log/audit-dialog.component.spec.ts | 0
.../audit-log/audit-dialog.component.ts | 2 +-
49 files changed, 1746 insertions(+), 405 deletions(-)
diff --git a/pom.xml b/pom.xml
index d454ea4755..a858477e98 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
<spring-boot.version>4.0.2</spring-boot.version>
<plc4x.version>0.13.1</plc4x.version>
+ <apache-poi.version>5.4.0</apache-poi.version>
<apache-sis-referencing.version>1.6</apache-sis-referencing.version>
<antlr4.version>4.11.1</antlr4.version>
<bcprov-jdk18on.version>1.86</bcprov-jdk18on.version>
diff --git a/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportColumn.java b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportColumn.java
new file mode 100644
index 0000000000..7db3930d98
--- /dev/null
+++ b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportColumn.java
@@ -0,0 +1,91 @@
+/*
+ * 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.audit.api;
+
+import java.util.Arrays;
+
+public enum AuditExportColumn {
+ EVENT_ID("eventId") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.eventId();
+ }
+ },
+ STORED_AT("storedAt") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.storedAt();
+ }
+ },
+ EVENT_TYPE("eventType") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.eventType();
+ }
+ },
+ OUTCOME("outcome") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.outcome();
+ }
+ },
+ ACTOR("actor") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.actor();
+ }
+ },
+ RESOURCE_TYPE("resourceType") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.resourceType();
+ }
+ },
+ RESOURCE_ID("resourceId") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.resourceId();
+ }
+ },
+ LOCATOR("locator") {
+ @Override
+ public String value(AuditEntry entry) {
+ return entry.locator();
+ }
+ };
+
+ private final String id;
+
+ AuditExportColumn(String id) {
+ this.id = id;
+ }
+
+ public static AuditExportColumn fromId(String id) {
+ return Arrays.stream(values())
+ .filter(column -> column.id.equals(id))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("Unknown audit export column"));
+ }
+
+ public String id() {
+ return id;
+ }
+
+ public abstract String value(AuditEntry entry);
+}
diff --git a/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportConfiguration.java b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportConfiguration.java
new file mode 100644
index 0000000000..db8d989cd2
--- /dev/null
+++ b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * 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.audit.api;
+
+import java.util.HashSet;
+import java.util.List;
+
+public record AuditExportConfiguration(AuditExportFormat format, List<AuditExportColumn> columns,
+ List<String> headers, char delimiter) {
+ private static final int MAX_HEADER_LENGTH = 128;
+
+ public AuditExportConfiguration {
+ if (format == null || delimiter != ',' && delimiter != ';') {
+ throw new IllegalArgumentException("Invalid audit export configuration");
+ }
+ columns = List.copyOf(columns);
+ headers = List.copyOf(headers);
+ if (columns.isEmpty() || columns.size() != headers.size()
+ || new HashSet<>(columns).size() != columns.size()
+ || headers.stream().anyMatch(AuditExportConfiguration::invalidHeader)) {
+ throw new IllegalArgumentException("Invalid audit export configuration");
+ }
+ }
+
+ private static boolean invalidHeader(String header) {
+ return header == null || header.length() > MAX_HEADER_LENGTH
+ || header.chars().anyMatch(Character::isISOControl);
+ }
+}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportFormat.java
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportFormat.java
index b048ab9bbe..bc767bd10a 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditExportFormat.java
@@ -16,38 +16,19 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+package org.apache.streampipes.audit.api;
+
+import java.util.Arrays;
+
+public enum AuditExportFormat {
+ CSV,
+ JSON,
+ XLSX;
+
+ public static AuditExportFormat fromString(String value) {
+ return Arrays.stream(values())
+ .filter(format -> format.name().equalsIgnoreCase(value))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("Unknown audit export format"));
+ }
}
diff --git a/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditService.java b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditService.java
index 7d7c0aec57..1fd4eb2145 100644
--- a/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditService.java
+++ b/streampipes-audit-api/src/main/java/org/apache/streampipes/audit/api/AuditService.java
@@ -18,6 +18,8 @@
package org.apache.streampipes.audit.api;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@@ -37,6 +39,11 @@ public interface AuditService extends AutoCloseable {
throw new IllegalStateException("Audit reading unavailable");
}
+ default void export(AuditQuery query, AuditExportConfiguration configuration, OutputStream outputStream)
+ throws IOException {
+ throw new IllegalStateException("Audit exporting unavailable");
+ }
+
default Optional<AuditEntryDetails> find(UUID eventId, String locator) {
throw new IllegalStateException("Audit reading unavailable");
}
diff --git a/streampipes-audit-management/pom.xml b/streampipes-audit-management/pom.xml
index e6545ee59a..482482e6d9 100644
--- a/streampipes-audit-management/pom.xml
+++ b/streampipes-audit-management/pom.xml
@@ -45,6 +45,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <version>${apache-poi.version}</version>
+ </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
diff --git a/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/DefaultAuditService.java b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/DefaultAuditService.java
index 905f16bc58..424b7c3ffc 100644
--- a/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/DefaultAuditService.java
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/DefaultAuditService.java
@@ -25,11 +25,13 @@ import org.apache.streampipes.audit.api.AuditEventDefinition;
import org.apache.streampipes.audit.api.AuditEventProvider;
import org.apache.streampipes.audit.api.AuditEventReader;
import org.apache.streampipes.audit.api.AuditEventStore;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
import org.apache.streampipes.audit.api.AuditOutcome;
import org.apache.streampipes.audit.api.AuditPage;
import org.apache.streampipes.audit.api.AuditQuery;
import org.apache.streampipes.audit.api.AuditService;
import org.apache.streampipes.audit.api.AuditStatus;
+import org.apache.streampipes.audit.management.export.AuditExportService;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -38,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.io.OutputStream;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
@@ -224,6 +227,12 @@ public final class DefaultAuditService implements AuditService {
return reader().query(query);
}
+ @Override
+ public void export(AuditQuery query, AuditExportConfiguration configuration, OutputStream outputStream)
+ throws IOException {
+ new AuditExportService(reader()).export(query, configuration, outputStream);
+ }
+
@Override
public Optional<AuditEntryDetails> find(UUID eventId, String locator) {
return reader().find(eventId, locator);
diff --git a/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditCsvOutputWriter.java b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditCsvOutputWriter.java
new file mode 100644
index 0000000000..f38ac2eb10
--- /dev/null
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditCsvOutputWriter.java
@@ -0,0 +1,72 @@
+/*
+ * 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.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditEntry;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+final class AuditCsvOutputWriter implements AuditOutputWriter {
+ private final AuditExportConfiguration configuration;
+ private BufferedWriter writer;
+
+ AuditCsvOutputWriter(AuditExportConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ @Override
+ public void beforeFirstItem(OutputStream outputStream) throws IOException {
+ writer = new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
+ writeRow(configuration.headers());
+ }
+
+ @Override
+ public void writeItem(AuditEntry entry) throws IOException {
+ writeRow(configuration.columns().stream().map(column -> column.value(entry)).toList());
+ }
+
+ @Override
+ public void afterLastItem(OutputStream outputStream) throws IOException {
+ writer.flush();
+ }
+
+ private void writeRow(List<String> values) throws IOException {
+ for (var index = 0; index < values.size(); index++) {
+ if (index > 0) {
+ writer.write(configuration.delimiter());
+ }
+ writer.write(escape(values.get(index)));
+ }
+ writer.write("\r\n");
+ }
+
+ private String escape(String value) {
+ String escapedValue = value == null ? "" : value;
+ if (!escapedValue.isEmpty() && "=+-@".indexOf(escapedValue.charAt(0)) >= 0) {
+ escapedValue = "'" + escapedValue;
+ }
+ return "\"" + escapedValue.replace("\"", "\"\"") + "\"";
+ }
+}
diff --git a/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditExcelOutputWriter.java b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditExcelOutputWriter.java
new file mode 100644
index 0000000000..d2149da67b
--- /dev/null
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditExcelOutputWriter.java
@@ -0,0 +1,75 @@
+/*
+ * 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.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditEntry;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+final class AuditExcelOutputWriter implements AuditOutputWriter {
+ private final AuditExportConfiguration configuration;
+ private SXSSFWorkbook workbook;
+ private Sheet sheet;
+ private int rowIndex;
+
+ AuditExcelOutputWriter(AuditExportConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ @Override
+ public void beforeFirstItem(OutputStream outputStream) {
+ workbook = new SXSSFWorkbook();
+ workbook.setCompressTempFiles(true);
+ sheet = workbook.createSheet("Audit log");
+ var header = sheet.createRow(rowIndex++);
+ for (var index = 0; index < configuration.headers().size(); index++) {
+ header.createCell(index).setCellValue(configuration.headers().get(index));
+ }
+ }
+
+ @Override
+ public void writeItem(AuditEntry entry) {
+ var row = sheet.createRow(rowIndex++);
+ for (var index = 0; index < configuration.columns().size(); index++) {
+ String value = configuration.columns().get(index).value(entry);
+ row.createCell(index).setCellValue(value == null ? "" : value);
+ }
+ }
+
+ @Override
+ public void afterLastItem(OutputStream outputStream) throws IOException {
+ workbook.write(outputStream);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (workbook != null) {
+ try {
+ workbook.close();
+ } finally {
+ workbook.dispose();
+ }
+ }
+ }
+}
diff --git a/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditExportService.java b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditExportService.java
new file mode 100644
index 0000000000..86b5585020
--- /dev/null
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditExportService.java
@@ -0,0 +1,66 @@
+/*
+ * 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.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditEventReader;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+import org.apache.streampipes.audit.api.AuditPage;
+import org.apache.streampipes.audit.api.AuditQuery;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public final class AuditExportService {
+ private final AuditEventReader reader;
+ private final AuditOutputWriterFactory writerFactory;
+
+ public AuditExportService(AuditEventReader reader) {
+ this(reader, new AuditOutputWriterFactory());
+ }
+
+ AuditExportService(AuditEventReader reader, AuditOutputWriterFactory writerFactory) {
+ this.reader = reader;
+ this.writerFactory = writerFactory;
+ }
+
+ public void export(AuditQuery query, AuditExportConfiguration configuration, OutputStream outputStream)
+ throws IOException {
+ try (var writer = writerFactory.create(configuration)) {
+ writer.beforeFirstItem(outputStream);
+
+ AuditQuery pageQuery = query;
+ do {
+ AuditPage page = reader.query(pageQuery);
+ for (var entry : page.items()) {
+ writer.writeItem(entry);
+ }
+ pageQuery = nextPageQuery(query, page);
+ } while (pageQuery != null);
+
+ writer.afterLastItem(outputStream);
+ }
+ }
+
+ private AuditQuery nextPageQuery(AuditQuery query, AuditPage page) {
+ return page.nextCursor() == null
+ ? null
+ : new AuditQuery(query.from(), query.to(), query.eventType(), query.actor(), query.outcome(),
+ query.limit(), page.nextCursor());
+ }
+}
diff --git a/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditJsonOutputWriter.java b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditJsonOutputWriter.java
new file mode 100644
index 0000000000..6f51482cd0
--- /dev/null
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditJsonOutputWriter.java
@@ -0,0 +1,58 @@
+/*
+ * 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.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditEntry;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+final class AuditJsonOutputWriter implements AuditOutputWriter {
+ private final AuditExportConfiguration configuration;
+ private JsonGenerator generator;
+
+ AuditJsonOutputWriter(AuditExportConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ @Override
+ public void beforeFirstItem(OutputStream outputStream) throws IOException {
+ generator = new JsonFactory().createGenerator(outputStream);
+ generator.writeStartArray();
+ }
+
+ @Override
+ public void writeItem(AuditEntry entry) throws IOException {
+ generator.writeStartObject();
+ for (var column : configuration.columns()) {
+ generator.writeStringField(column.id(), column.value(entry));
+ }
+ generator.writeEndObject();
+ }
+
+ @Override
+ public void afterLastItem(OutputStream outputStream) throws IOException {
+ generator.writeEndArray();
+ generator.flush();
+ }
+}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditOutputWriter.java
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditOutputWriter.java
index b048ab9bbe..e0ddde5bd3 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditOutputWriter.java
@@ -16,38 +16,23 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+package org.apache.streampipes.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditEntry;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+interface AuditOutputWriter extends AutoCloseable {
+
+ void beforeFirstItem(OutputStream outputStream) throws IOException;
+
+ void writeItem(AuditEntry entry) throws IOException;
+
+ void afterLastItem(OutputStream outputStream) throws IOException;
+
+ @Override
+ default void close() throws IOException {
+ // Most output writers do not hold resources beyond the response stream.
+ }
}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditOutputWriterFactory.java
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditOutputWriterFactory.java
index b048ab9bbe..ec2b510ab7 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/streampipes-audit-management/src/main/java/org/apache/streampipes/audit/management/export/AuditOutputWriterFactory.java
@@ -16,38 +16,17 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+package org.apache.streampipes.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+
+final class AuditOutputWriterFactory {
+
+ AuditOutputWriter create(AuditExportConfiguration configuration) {
+ return switch (configuration.format()) {
+ case CSV -> new AuditCsvOutputWriter(configuration);
+ case JSON -> new AuditJsonOutputWriter(configuration);
+ case XLSX -> new AuditExcelOutputWriter(configuration);
+ };
+ }
}
diff --git a/streampipes-audit-management/src/test/java/org/apache/streampipes/audit/management/export/AuditExportServiceTest.java b/streampipes-audit-management/src/test/java/org/apache/streampipes/audit/management/export/AuditExportServiceTest.java
new file mode 100644
index 0000000000..bca21e7b18
--- /dev/null
+++ b/streampipes-audit-management/src/test/java/org/apache/streampipes/audit/management/export/AuditExportServiceTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.audit.management.export;
+
+import org.apache.streampipes.audit.api.AuditEntry;
+import org.apache.streampipes.audit.api.AuditEntryDetails;
+import org.apache.streampipes.audit.api.AuditEventReader;
+import org.apache.streampipes.audit.api.AuditExportColumn;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+import org.apache.streampipes.audit.api.AuditExportFormat;
+import org.apache.streampipes.audit.api.AuditPage;
+import org.apache.streampipes.audit.api.AuditQuery;
+
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class AuditExportServiceTest {
+
+ @Test
+ void exportsSelectedColumnsWithProvidedHeaders() throws Exception {
+ var entry = new AuditEntry("event-1", "2026-10-16T10:00:00Z", "user.login", "succeeded", "admin",
+ null, null, "locator-1");
+ var configuration = new AuditExportConfiguration(
+ AuditExportFormat.XLSX, List.of(AuditExportColumn.EVENT_ID, AuditExportColumn.ACTOR),
+ List.of("Event ID", "Actor"), ',');
+ var output = new ByteArrayOutputStream();
+
+ new AuditExportService(reader(entry)).export(query(), configuration, output);
+
+ try (var workbook = WorkbookFactory.create(new ByteArrayInputStream(output.toByteArray()))) {
+ var sheet = workbook.getSheetAt(0);
+ assertEquals("Event ID", sheet.getRow(0).getCell(0).getStringCellValue());
+ assertEquals("Actor", sheet.getRow(0).getCell(1).getStringCellValue());
+ assertEquals("event-1", sheet.getRow(1).getCell(0).getStringCellValue());
+ assertEquals("admin", sheet.getRow(1).getCell(1).getStringCellValue());
+ }
+ }
+
+ @Test
+ void exportsCsvWithConfiguredDelimiterAndSafeFormulaValues() throws Exception {
+ var entry = new AuditEntry("=event-1", "2026-10-16T10:00:00Z", "user.login", "succeeded", "ad\"min",
+ null, null, "locator-1");
+ var configuration = new AuditExportConfiguration(
+ AuditExportFormat.CSV, List.of(AuditExportColumn.EVENT_ID, AuditExportColumn.ACTOR),
+ List.of("Event ID", "Actor"), ';');
+ var output = new ByteArrayOutputStream();
+
+ new AuditExportService(reader(entry)).export(query(), configuration, output);
+
+ assertEquals("\"Event ID\";\"Actor\"\r\n\"'=event-1\";\"ad\"\"min\"\r\n",
+ output.toString(StandardCharsets.UTF_8));
+ }
+
+ @Test
+ void exportsJsonWithTheSelectedColumnIds() throws Exception {
+ var entry = new AuditEntry("event-1", "2026-10-16T10:00:00Z", "user.login", "succeeded", "admin",
+ null, null, "locator-1");
+ var configuration = new AuditExportConfiguration(
+ AuditExportFormat.JSON, List.of(AuditExportColumn.EVENT_ID, AuditExportColumn.ACTOR),
+ List.of("Ignored", "Ignored"), ',');
+ var output = new ByteArrayOutputStream();
+
+ new AuditExportService(reader(entry)).export(query(), configuration, output);
+
+ assertEquals("[{\"eventId\":\"event-1\",\"actor\":\"admin\"}]",
+ output.toString(StandardCharsets.UTF_8));
+ }
+
+ private AuditEventReader reader(AuditEntry entry) {
+ return new AuditEventReader() {
+ @Override
+ public AuditPage query(AuditQuery query) {
+ return new AuditPage(List.of(entry), null);
+ }
+
+ @Override
+ public Optional<AuditEntryDetails> find(UUID eventId, String locator) {
+ return Optional.empty();
+ }
+ };
+ }
+
+ private AuditQuery query() {
+ return new AuditQuery(Instant.parse("2026-10-16T00:00:00Z"), Instant.parse("2026-10-17T00:00:00Z"),
+ null, null, null, 200, null);
+ }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/AuditResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/AuditResource.java
index 4c2520bf76..0312e7d439 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/AuditResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/admin/AuditResource.java
@@ -19,6 +19,9 @@
package org.apache.streampipes.rest.impl.admin;
import org.apache.streampipes.audit.api.AuditEntryDetails;
+import org.apache.streampipes.audit.api.AuditExportColumn;
+import org.apache.streampipes.audit.api.AuditExportConfiguration;
+import org.apache.streampipes.audit.api.AuditExportFormat;
import org.apache.streampipes.audit.api.AuditPage;
import org.apache.streampipes.audit.api.AuditQuery;
import org.apache.streampipes.audit.api.AuditStatus;
@@ -27,8 +30,10 @@ import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResourc
import org.apache.streampipes.rest.security.AuthConstants;
import io.swagger.v3.oas.annotations.Operation;
+import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -36,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
+import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
import java.time.Instant;
import java.util.List;
@@ -80,6 +86,50 @@ public class AuditResource extends AbstractAuthGuardedRestResource {
}
}
+ @GetMapping(path = "/events/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+ @PreAuthorize(AuthConstants.IS_ADMIN_ROLE)
+ @Operation(summary = "Download filtered audit events", tags = {"Audit"})
+ public ResponseEntity<StreamingResponseBody> download(@RequestParam String from, @RequestParam String to,
+ @RequestParam(required = false) String eventType,
+ @RequestParam(required = false) String actor,
+ @RequestParam(required = false) String outcome,
+ @RequestParam(defaultValue = "xlsx") String format,
+ @RequestParam(required = false) String delimiter,
+ @RequestParam List<String> columns,
+ @RequestParam List<String> headers) {
+ final AuditQuery query;
+ final AuditExportConfiguration configuration;
+ try {
+ query = new AuditQuery(Instant.parse(from), Instant.parse(to), eventType, actor, outcome, 200, null);
+ var exportFormat = AuditExportFormat.fromString(format);
+ configuration = new AuditExportConfiguration(
+ exportFormat, columns.stream().map(AuditExportColumn::fromId).toList(), headers,
+ delimiter(exportFormat, delimiter));
+ } catch (RuntimeException e) {
+ throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid audit export request");
+ }
+
+ StreamingResponseBody body = outputStream -> resourceManager.getAuditService()
+ .export(query, configuration, outputStream);
+ HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+ responseHeaders.setContentDispositionFormData(
+ "attachment", "audit-log." + configuration.format().name().toLowerCase());
+ return ResponseEntity.ok()
+ .headers(responseHeaders)
+ .body(body);
+ }
+
+ private char delimiter(AuditExportFormat format, String delimiter) {
+ if (format != AuditExportFormat.CSV || delimiter == null || delimiter.equals("comma")) {
+ return ',';
+ }
+ if (delimiter.equals("semicolon")) {
+ return ';';
+ }
+ throw new IllegalArgumentException("Invalid audit export delimiter");
+ }
+
@GetMapping(path = "/events/{eventId}", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.IS_ADMIN_ROLE)
@Operation(summary = "Fetch audit event details", tags = {"Audit"})
diff --git a/ui/cypress/support/utils/configuration/ConfigurationBtns.ts b/ui/cypress/support/utils/configuration/ConfigurationBtns.ts
index b4e58b6890..e07fe13e56 100644
--- a/ui/cypress/support/utils/configuration/ConfigurationBtns.ts
+++ b/ui/cypress/support/utils/configuration/ConfigurationBtns.ts
@@ -57,4 +57,30 @@ export class ConfigurationBtns {
public static inputGroupName(groupName: string) {
return cy.dataCy('group-name-input').type(groupName);
}
+
+ public static auditLogDownloadBtn() {
+ return cy.dataCy('audit-log-download-button');
+ }
+
+ public static auditDownloadDialog() {
+ return cy.dataCy('audit-download-dialog');
+ }
+
+ public static auditDownloadNextBtn() {
+ return cy.dataCy('audit-download-next-button');
+ }
+
+ public static auditDownloadBtn() {
+ return cy.dataCy('audit-download-download-button');
+ }
+
+ public static auditDownloadFormat(format: 'csv' | 'json' | 'xlsx') {
+ return cy.dataCy(`audit-download-format-${format}`).find('.mdc-radio');
+ }
+
+ public static auditDownloadDelimiter(delimiter: 'comma' | 'semicolon') {
+ return cy
+ .dataCy(`audit-download-delimiter-${delimiter}`)
+ .find('.mdc-radio');
+ }
}
diff --git a/ui/cypress/support/utils/configuration/ConfigurationUtils.ts b/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
index 095981a646..6077903bf7 100644
--- a/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
+++ b/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
@@ -35,6 +35,10 @@ export class ConfigurationUtils {
cy.visit('#/configuration/labels');
}
+ public static goToAuditLogConfiguration() {
+ cy.visit('#/configuration/audit-log');
+ }
+
public static addNewLabel(name: string, description: string = '') {
cy.dataCy('new-label-button').click();
cy.dataCy('label-name')
diff --git a/ui/cypress/tests/configuration/audit-log/audit-log-download.spec.ts b/ui/cypress/tests/configuration/audit-log/audit-log-download.spec.ts
new file mode 100644
index 0000000000..3692ad740d
--- /dev/null
+++ b/ui/cypress/tests/configuration/audit-log/audit-log-download.spec.ts
@@ -0,0 +1,79 @@
+/*
+ * 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 { ConfigurationBtns } from '../../../support/utils/configuration/ConfigurationBtns';
+import { ConfigurationUtils } from '../../../support/utils/configuration/ConfigurationUtils';
+
+describe('Download audit log', () => {
+ const auditEntry = {
+ eventId: 'audit-event-1',
+ locator: 'audit-event-1',
+ storedAt: '2026-10-15T10:00:00.000Z',
+ eventType: 'pipeline.started',
+ outcome: 'succeeded',
+ actor: 'admin',
+ resourceId: 'pipeline-1',
+ };
+
+ beforeEach('Setup test', () => {
+ cy.initStreamPipesTest();
+ cy.intercept('GET', '**/admin/audit/status', { enabled: true });
+ cy.intercept('GET', '**/admin/audit/event-types', [
+ auditEntry.eventType,
+ ]);
+ cy.intercept('GET', '**/admin/audit/events*', {
+ items: [auditEntry],
+ nextCursor: null,
+ }).as('getAuditEvents');
+
+ ConfigurationUtils.goToAuditLogConfiguration();
+ cy.wait('@getAuditEvents');
+ });
+
+ const downloadAuditLog = (
+ format: 'csv' | 'json',
+ delimiter?: 'comma' | 'semicolon',
+ ) => {
+ ConfigurationBtns.auditLogDownloadBtn().should('be.enabled').click();
+ ConfigurationBtns.auditDownloadDialog().should('be.visible');
+
+ ConfigurationBtns.auditDownloadNextBtn().click();
+ ConfigurationBtns.auditDownloadFormat(format).click();
+ if (format === 'csv' && delimiter) {
+ ConfigurationBtns.auditDownloadDelimiter(delimiter).click();
+ }
+ ConfigurationBtns.auditDownloadBtn().click();
+
+ ConfigurationBtns.auditDownloadDialog().should(
+ 'contain.text',
+ 'Download successful',
+ );
+ };
+
+ it('shows a confirmation after downloading the audit log as JSON', () => {
+ downloadAuditLog('json');
+ });
+
+ it('shows a confirmation after downloading the audit log as CSV with commas', () => {
+ downloadAuditLog('csv', 'comma');
+ });
+
+ it('shows a confirmation after downloading the audit log as CSV with semicolons', () => {
+ downloadAuditLog('csv', 'semicolon');
+ });
+});
diff --git a/ui/deployment/i18n/de.json b/ui/deployment/i18n/de.json
index ef3d1aec2e..1c0d06d375 100644
--- a/ui/deployment/i18n/de.json
+++ b/ui/deployment/i18n/de.json
@@ -94,6 +94,7 @@
"Aggregate raw data by time unit or value.": "Rohdaten nach Zeiteinheit oder Wert aggregieren.",
"Aggregated": "Aggregiert",
"All": "Alle",
+ "All actors": "Alle Akteure",
"All assets": "Alle Assets",
"All data in custom time interval": "Alle Daten im vorgegebenen Zeitintervall",
"All data in database": "Alle Daten in der Datenbank",
@@ -135,6 +136,7 @@
"Assign additional labels to better discover your assets": "Weisen Sie zusätzliche Labels zu, um Ihre Assets besser zu finden",
"Attach adapters, dashboards, or pipelines in the asset editor to surface them here.": "Fügen Sie Adapter, Dashboards oder Pipelines im Asset-Editor hinzu, um sie hier anzuzeigen.",
"Audit Log": "Audit-Protokoll",
+ "Audit events could not be downloaded. Try again.": "Audit-Ereignisse konnten nicht heruntergeladen werden. Versuche es erneut.",
"Audit events could not be loaded. Check the filters and storage availability, then retry.": "Audit-Ereignisse konnten nicht geladen werden. Prüfe die Filter und die Speicherverfügbarkeit und versuche es erneut.",
"Audit pages": "Audit-Seiten",
"Audit recording is disabled. Enable auditing in the Core deployment configuration.": "Die Audit-Aufzeichnung ist deaktiviert. Aktiviere sie in der Bereitstellungskonfiguration des Core.",
@@ -211,6 +213,7 @@
"Choose existing file": "Vorhandene Datei auswählen",
"Choose target dataset": "Ziel-Dataset auswählen",
"Choose template": "Vorlage auswählen",
+ "Choose the columns to include in the export.": "Wähle die Spalten aus, die in den Export aufgenommen werden sollen.",
"Choose the new location for this asset.": "Wählen Sie den neuen Speicherort für dieses Asset.",
"Clamp to 0-100%": "Auf 0-100 % begrenzen",
"Clean code": "Code aufräumen",
@@ -234,6 +237,7 @@
"Color used above the high threshold.": "Farbe, die oberhalb des hohen Schwellenwerts verwendet wird.",
"Color used between low and high thresholds.": "Farbe, die zwischen niedrigem und hohem Schwellenwert verwendet wird.",
"Color used from min up to the low threshold.": "Farbe, die von Min bis zum niedrigen Schwellenwert verwendet wird.",
+ "Columns": "Spalten",
"Compatible Elements": "Kompatible Elemente",
"Configuration": "Konfiguration",
"Configuration required": "Konfiguration erforderlich",
@@ -288,6 +292,7 @@
"Current hour": "Aktuelle Stunde",
"Current month": "Aktueller Monat",
"Current password": "Aktuelles Passwort",
+ "Current selection": "Aktuelle Auswahl",
"Current value field": "Feld für aktuellen Wert",
"Current week": "Aktuelle Woche",
"Current year": "Aktuelles Jahr",
@@ -296,6 +301,7 @@
"Custom Value": "Benutzerdefinierter Wert",
"Custom color mapping": "Benutzerdefiniertes Farb-Mapping",
"Custom fields": "Benutzerdefinierte Felder",
+ "Custom selection": "Benutzerdefinierte Auswahl",
"Dark mode": "Dunkel",
"Dashboard": "Dashboard",
"Dashboard title": "Dashboardtitel",
@@ -397,6 +403,7 @@
"Download": "Download",
"Download File": "Datei herunterladen",
"Download Format": "Download-Format",
+ "Download audit log": "Audit-Protokoll herunterladen",
"Download data": "Daten herunterladen",
"Download export": "Export herunterladen",
"Download successful": "Download erfolgreich",
@@ -500,6 +507,7 @@
"Filter": "Filter",
"Filter Preview": "Filtervorschau",
"Filter assets": "Assets filtern",
+ "Filters": "Filter",
"Find Element": "Element finden",
"Find element": "Element finden",
"First": "Erster",
@@ -873,6 +881,7 @@
"Please wait while the pipeline is stopping": "Bitte warten Sie, während die Pipeline gestoppt wird",
"Port": "Port",
"Possible placeholders:": "Mögliche Platzhalter:",
+ "Preparing download...": "Download wird vorbereitet...",
"Preparing pipeline editor...": "Pipeline-Editor vorbereiten...",
"Press 'Next' to start the process.": "Auf \"Weiter\" drücken, um den Vorgang zu starten.",
"Press Next to start the process.": "Klicken Sie auf Weiter, um den Vorgang zu starten.",
@@ -1390,6 +1399,7 @@
"You need to delete those pipelines first before deleting the adapter.": "Sie müssen diese Pipelines zuerst löschen, bevor Sie den Adapter löschen können.",
"Your Assets were successfully added.": "Assets erfolgreich hinzugefügt.",
"Your Assets were successfully deleted.": "Assets erfolgreich gelöscht.",
+ "Your audit log is being downloaded.": "Dein Audit-Protokoll wird heruntergeladen.",
"Your new API key has been created. Please copy the key now - you won't be able to see the key again.": "Ihr neuer API-Schlüssel wurde erstellt. Bitte kopieren Sie den Schlüssel jetzt - Sie werden ihn nicht mehr sehen können.",
"Your new data stream is now available in the pipeline editor.": "Ihr neuer Datenstrom ist nun im Pipeline-Editor verfügbar.",
"Your password successfully changed.": "Ihr Passwort wurde erfolgreich geändert.",
diff --git a/ui/deployment/i18n/en.json b/ui/deployment/i18n/en.json
index 26177579c7..5681083c41 100644
--- a/ui/deployment/i18n/en.json
+++ b/ui/deployment/i18n/en.json
@@ -94,6 +94,7 @@
"Aggregate raw data by time unit or value.": null,
"Aggregated": null,
"All": null,
+ "All actors": null,
"All assets": null,
"All data in custom time interval": null,
"All data in database": null,
@@ -135,6 +136,7 @@
"Assign additional labels to better discover your assets": null,
"Attach adapters, dashboards, or pipelines in the asset editor to surface them here.": null,
"Audit Log": "Audit Log",
+ "Audit events could not be downloaded. Try again.": null,
"Audit events could not be loaded. Check the filters and storage availability, then retry.": "Audit events could not be loaded. Check the filters and storage availability, then retry.",
"Audit pages": "Audit pages",
"Audit recording is disabled. Enable auditing in the Core deployment configuration.": "Audit recording is disabled. Enable auditing in the Core deployment configuration.",
@@ -211,6 +213,7 @@
"Choose existing file": null,
"Choose target dataset": null,
"Choose template": null,
+ "Choose the columns to include in the export.": null,
"Choose the new location for this asset.": "Choose the new location for this asset.",
"Clamp to 0-100%": null,
"Clean code": null,
@@ -234,6 +237,7 @@
"Color used above the high threshold.": null,
"Color used between low and high thresholds.": null,
"Color used from min up to the low threshold.": null,
+ "Columns": null,
"Compatible Elements": null,
"Configuration": null,
"Configuration required": null,
@@ -288,6 +292,7 @@
"Current hour": null,
"Current month": null,
"Current password": null,
+ "Current selection": null,
"Current value field": null,
"Current week": null,
"Current year": null,
@@ -296,6 +301,7 @@
"Custom Value": null,
"Custom color mapping": null,
"Custom fields": null,
+ "Custom selection": null,
"Dark mode": null,
"Dashboard": null,
"Dashboard title": null,
@@ -397,6 +403,7 @@
"Download": null,
"Download File": null,
"Download Format": null,
+ "Download audit log": null,
"Download data": null,
"Download export": null,
"Download successful": null,
@@ -500,6 +507,7 @@
"Filter": null,
"Filter Preview": null,
"Filter assets": null,
+ "Filters": null,
"Find Element": null,
"Find element": null,
"First": null,
@@ -873,6 +881,7 @@
"Please wait while the pipeline is stopping": null,
"Port": null,
"Possible placeholders:": null,
+ "Preparing download...": null,
"Preparing pipeline editor...": null,
"Press 'Next' to start the process.": null,
"Press Next to start the process.": null,
@@ -1390,6 +1399,7 @@
"You need to delete those pipelines first before deleting the adapter.": null,
"Your Assets were successfully added.": null,
"Your Assets were successfully deleted.": null,
+ "Your audit log is being downloaded.": null,
"Your new API key has been created. Please copy the key now - you won't be able to see the key again.": null,
"Your new data stream is now available in the pipeline editor.": null,
"Your password successfully changed.": null,
diff --git a/ui/deployment/i18n/pl.json b/ui/deployment/i18n/pl.json
index feb3eceb9a..9903c3a0f3 100644
--- a/ui/deployment/i18n/pl.json
+++ b/ui/deployment/i18n/pl.json
@@ -94,6 +94,7 @@
"Aggregate raw data by time unit or value.": "Agreguj surowe dane według jednostki czasu lub wartości.",
"Aggregated": "Agregowane",
"All": "Wszystkie",
+ "All actors": "Wszyscy wykonawcy",
"All assets": "Wszystkie zasoby",
"All data in custom time interval": "Wszystkie dane w niestandardowym interwale czasowym",
"All data in database": "Wszystkie dane w bazie",
@@ -135,6 +136,7 @@
"Assign additional labels to better discover your assets": "Przypisz dodatkowe etykiety, aby łatwiej odnajdywać zasoby",
"Attach adapters, dashboards, or pipelines in the asset editor to surface them here.": "Dołącz adaptery, pulpity lub strumienie w edytorze zasobu, aby wyświetlały się tutaj.",
"Audit Log": "Dziennik audytu",
+ "Audit events could not be downloaded. Try again.": "Nie udało się pobrać zdarzeń audytu. Spróbuj ponownie.",
"Audit events could not be loaded. Check the filters and storage availability, then retry.": "Nie udało się wczytać zdarzeń audytu. Sprawdź filtry i dostępność magazynu, a następnie spróbuj ponownie.",
"Audit pages": "Strony audytu",
"Audit recording is disabled. Enable auditing in the Core deployment configuration.": "Rejestrowanie audytu jest wyłączone. Włącz je w konfiguracji wdrożenia Core.",
@@ -211,6 +213,7 @@
"Choose existing file": "Wybierz istniejący plik",
"Choose target dataset": "Wybierz docelowy zbiór danych",
"Choose template": "Wybierz szablon",
+ "Choose the columns to include in the export.": "Wybierz kolumny, które mają zostać uwzględnione w eksporcie.",
"Choose the new location for this asset.": "Wybierz nową lokalizację tego zasobu.",
"Clamp to 0-100%": "Ogranicz do 0-100%",
"Clean code": "Wyczyść kod",
@@ -234,6 +237,7 @@
"Color used above the high threshold.": "Kolor używany powyżej wysokiego progu.",
"Color used between low and high thresholds.": "Kolor używany między niskim a wysokim progiem.",
"Color used from min up to the low threshold.": "Kolor używany od minimum do niskiego progu.",
+ "Columns": "Kolumny",
"Compatible Elements": "Kompatybilne elementy",
"Configuration": "Konfiguracja",
"Configuration required": "Wymagana konfiguracja",
@@ -288,6 +292,7 @@
"Current hour": "Bieżąca godzina",
"Current month": "Bieżący miesiąc",
"Current password": "Obecne hasło",
+ "Current selection": "Bieżący wybór",
"Current value field": "Pole bieżącej wartości",
"Current week": "Bieżący tydzień",
"Current year": "Bieżący rok",
@@ -296,6 +301,7 @@
"Custom Value": "Wartość niestandardowa",
"Custom color mapping": "Własne mapowanie kolorów",
"Custom fields": "Pola niestandardowe",
+ "Custom selection": "Niestandardowy wybór",
"Dark mode": "Ciemny",
"Dashboard": "Pulpit",
"Dashboard title": "Tytuł pulpitu",
@@ -397,6 +403,7 @@
"Download": "Pobierz",
"Download File": "Pobierz plik",
"Download Format": "Format pobierania",
+ "Download audit log": "Pobierz dziennik audytu",
"Download data": "Pobierz dane",
"Download export": "Pobierz eksport",
"Download successful": "Pobieranie zakończone powodzeniem",
@@ -500,6 +507,7 @@
"Filter": "Filtr",
"Filter Preview": "Podgląd filtra",
"Filter assets": "Filtruj zasoby",
+ "Filters": "Filtry",
"Find Element": "Znajdź element",
"Find element": "Znajdź element",
"First": "Pierwszy",
@@ -873,6 +881,7 @@
"Please wait while the pipeline is stopping": "Proszę czekać, trwa zatrzymywanie strumienia",
"Port": "Port",
"Possible placeholders:": "Możliwe zastępniki:",
+ "Preparing download...": "Przygotowywanie pobierania...",
"Preparing pipeline editor...": "Przygotowywanie edytora strumieni...",
"Press 'Next' to start the process.": "Naciśnij „Dalej”, aby rozpocząć proces.",
"Press Next to start the process.": "Kliknij Dalej, aby rozpocząć proces.",
@@ -1390,6 +1399,7 @@
"You need to delete those pipelines first before deleting the adapter.": "Przed usunięciem adaptera najpierw usuń te strumienie.",
"Your Assets were successfully added.": "Twoje zasoby zostały pomyślnie dodane.",
"Your Assets were successfully deleted.": "Twoje zasoby zostały pomyślnie usunięte.",
+ "Your audit log is being downloaded.": "Twój dziennik audytu jest pobierany.",
"Your new API key has been created. Please copy the key now - you won't be able to see the key again.": "Twój nowy klucz API został utworzony. Skopiuj go teraz - później nie będzie już widoczny.",
"Your new data stream is now available in the pipeline editor.": "Twój nowy strumień danych jest teraz dostępny w edytorze strumieńów.",
"Your password successfully changed.": "Twoje hasło zostało pomyślnie zmienione.",
diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/audit.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/audit.service.ts
index 1e7981ce4c..f0f8177930 100644
--- a/ui/projects/streampipes/platform-services/src/lib/apis/audit.service.ts
+++ b/ui/projects/streampipes/platform-services/src/lib/apis/audit.service.ts
@@ -51,6 +51,40 @@ export class AuditService {
return this.http.get<AuditPage>(`${this.baseUrl}/events`, { params });
}
+ download(
+ query: AuditQuery,
+ columns: string[],
+ headers: string[],
+ format: 'csv' | 'json' | 'xlsx',
+ delimiter?: 'comma' | 'semicolon',
+ ): Observable<Blob> {
+ let params = new HttpParams();
+ Object.entries(query).forEach(([key, value]) => {
+ if (
+ key !== 'limit' &&
+ key !== 'cursor' &&
+ value !== undefined &&
+ value !== ''
+ ) {
+ params = params.set(key, String(value));
+ }
+ });
+ columns.forEach(column => {
+ params = params.append('columns', column);
+ });
+ headers.forEach(header => {
+ params = params.append('headers', header);
+ });
+ params = params.set('format', format);
+ if (delimiter) {
+ params = params.set('delimiter', delimiter);
+ }
+ return this.http.get(`${this.baseUrl}/events/download`, {
+ params,
+ responseType: 'blob',
+ });
+ }
+
getDetails(event: AuditEntry): Observable<AuditEntryDetails> {
return this.http.get<AuditEntryDetails>(
`${this.baseUrl}/events/${encodeURIComponent(event.eventId)}`,
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.html b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.html
new file mode 100644
index 0000000000..66e1d34b40
--- /dev/null
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.html
@@ -0,0 +1,49 @@
+<!--
+ ~ 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 fxFlex="100">
+ @if (downloading) {
+ <div fxLayout="column" fxLayoutAlign="center center" class="mt-35">
+ <mat-spinner [diameter]="30" color="accent" />
+ @if (downloadedMBs !== undefined) {
+ <label>{{ downloadedMBs | number: '1.0-2' }} Mb</label>
+ }
+ @if (cancelable) {
+ <button
+ mat-button
+ class="btn-warn"
+ (click)="downloadCancelled.emit()"
+ >
+ {{ 'Cancel' | translate }}
+ </button>
+ }
+ </div>
+ } @else if (failed) {
+ <div fxLayout="column" fxLayoutAlign="center center">
+ <mat-icon class="download-error-icon">error</mat-icon>
+ <p class="download-error" role="alert">
+ {{ errorMessage | translate }}
+ </p>
+ </div>
+ } @else if (finished) {
+ <div fxLayout="column" fxLayoutAlign="center center">
+ <mat-icon class="icon-check">check</mat-icon>
+ <h5>{{ 'Download successful' | translate }}</h5>
+ </div>
+ }
+</div>
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.scss
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.scss
index b048ab9bbe..fbab1e04d6 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.scss
@@ -16,38 +16,7 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+.download-error,
+.download-error-icon {
+ color: var(--color-error);
}
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.ts b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.ts
new file mode 100644
index 0000000000..28383087b3
--- /dev/null
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download-status/download-status.component.ts
@@ -0,0 +1,60 @@
+/*
+ * 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 { DecimalPipe } from '@angular/common';
+import {
+ ChangeDetectionStrategy,
+ Component,
+ EventEmitter,
+ Input,
+ Output,
+} from '@angular/core';
+import { MatButton } from '@angular/material/button';
+import { MatIcon } from '@angular/material/icon';
+import { MatProgressSpinner } from '@angular/material/progress-spinner';
+import {
+ FlexDirective,
+ LayoutAlignDirective,
+ LayoutDirective,
+} from '@ngbracket/ngx-layout/flex';
+import { TranslatePipe } from '@ngx-translate/core';
+
+@Component({
+ selector: 'sp-download-status',
+ templateUrl: './download-status.component.html',
+ styleUrls: ['./download-status.component.scss'],
+ changeDetection: ChangeDetectionStrategy.Eager,
+ imports: [
+ FlexDirective,
+ LayoutDirective,
+ LayoutAlignDirective,
+ MatProgressSpinner,
+ MatButton,
+ MatIcon,
+ DecimalPipe,
+ TranslatePipe,
+ ],
+})
+export class DownloadStatusComponent {
+ @Input({ required: true }) downloading: boolean;
+ @Input({ required: true }) finished: boolean;
+ @Input() failed = false;
+ @Input() downloadedMBs?: number;
+ @Input() cancelable = false;
+ @Input() errorMessage = '';
+ @Output() downloadCancelled = new EventEmitter<void>();
+}
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.html b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.html
index 58af736f75..0b3ed0e6c2 100644
--- a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.html
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.html
@@ -15,28 +15,11 @@
~ limitations under the License.
~
-->
-<div fxFlex="100">
- <ng-template matStepLabel>{{ 'Download' | translate }}</ng-template>
- @if (!downloadProgress.finished) {
- <div fxLayout="column" fxLayoutAlign="center center" class="mt-35">
- <mat-spinner [diameter]="30" color="accent"></mat-spinner>
- @if (downloadProgress.downloadedMBs !== undefined) {
- <label
- >{{
- downloadProgress.downloadedMBs | number: '1.0-2'
- }}
- Mb</label
- >
- }
- <button mat-button class="btn-warn" (click)="cancelDownload()">
- {{ 'Cancel' | translate }}
- </button>
- </div>
- }
- @if (downloadProgress.finished) {
- <div fxLayout="column" fxLayoutAlign="center center">
- <mat-icon class="icon-check">check</mat-icon>
- <h5>{{ 'Download successful' | translate }}</h5>
- </div>
- }
-</div>
+<ng-template matStepLabel>{{ 'Download' | translate }}</ng-template>
+<sp-download-status
+ [downloading]="!downloadProgress.finished"
+ [finished]="downloadProgress.finished"
+ [downloadedMBs]="downloadProgress.downloadedMBs"
+ [cancelable]="true"
+ (downloadCancelled)="cancelDownload()"
+/>
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.ts b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.ts
index eefa43da9b..37ae642750 100644
--- a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.ts
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/download/download.component.ts
@@ -26,16 +26,8 @@ import {
import { DataExportService } from '../../services/data-export.service';
import { DownloadProgress } from '../../model/download-progress.model';
import { Subscription } from 'rxjs';
-import {
- FlexDirective,
- LayoutAlignDirective,
- LayoutDirective,
-} from '@ngbracket/ngx-layout/flex';
import { MatStepLabel } from '@angular/material/stepper';
-import { MatProgressSpinner } from '@angular/material/progress-spinner';
-import { MatButton } from '@angular/material/button';
-import { MatIcon } from '@angular/material/icon';
-import { DecimalPipe } from '@angular/common';
+import { DownloadStatusComponent } from '../download-status/download-status.component';
import { TranslatePipe } from '@ngx-translate/core';
@Component({
@@ -43,17 +35,7 @@ import { TranslatePipe } from '@ngx-translate/core';
templateUrl: './download.component.html',
styleUrls: ['./download.component.scss'],
changeDetection: ChangeDetectionStrategy.Eager,
- imports: [
- FlexDirective,
- MatStepLabel,
- LayoutDirective,
- LayoutAlignDirective,
- MatProgressSpinner,
- MatButton,
- MatIcon,
- DecimalPipe,
- TranslatePipe,
- ],
+ imports: [MatStepLabel, DownloadStatusComponent, TranslatePipe],
})
export class DownloadComponent implements OnInit, OnDestroy {
dataExportService = inject(DataExportService);
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.html b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.html
new file mode 100644
index 0000000000..dd928db611
--- /dev/null
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.html
@@ -0,0 +1,68 @@
+<!--
+ ~ 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-split-section [level]="3" [title]="'Download Format' | translate">
+ <mat-radio-group
+ class="sp-radio-group"
+ [(ngModel)]="formatExportConfig.format"
+ >
+ <mat-radio-button
+ value="json"
+ class="sp-radio-button"
+ [attr.data-cy]="dataCyPrefix + '-json'"
+ >
+ JSON
+ </mat-radio-button>
+ <mat-radio-button
+ value="csv"
+ class="sp-radio-button"
+ [attr.data-cy]="dataCyPrefix + '-csv'"
+ >
+ CSV
+ </mat-radio-button>
+ <mat-radio-button
+ value="xlsx"
+ class="sp-radio-button"
+ [attr.data-cy]="dataCyPrefix + '-xlsx'"
+ >
+ EXCEL (XLSX)
+ </mat-radio-button>
+ </mat-radio-group>
+</sp-split-section>
+
+@if (formatExportConfig.format === 'csv') {
+ <sp-split-section [level]="3" [title]="'Delimiter' | translate">
+ <mat-radio-group
+ [(ngModel)]="formatExportConfig.delimiter"
+ class="sp-radio-group"
+ >
+ <mat-radio-button
+ value="comma"
+ class="sp-radio-button"
+ [attr.data-cy]="delimiterDataCyPrefix + '-delimiter-comma'"
+ >,</mat-radio-button
+ >
+ <mat-radio-button
+ value="semicolon"
+ class="sp-radio-button"
+ [attr.data-cy]="delimiterDataCyPrefix + '-delimiter-semicolon'"
+ >;</mat-radio-button
+ >
+ </mat-radio-group>
+ </sp-split-section>
+}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.scss
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.scss
index b048ab9bbe..2ab2164089 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.scss
@@ -16,38 +16,12 @@
*
*/
-:host {
- display: block;
- height: 100%;
+.sp-radio-group {
+ display: flex;
+ flex-direction: column;
}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+
+.sp-radio-button {
+ margin: var(--space-xs);
+ width: 100%;
}
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.ts b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.ts
new file mode 100644
index 0000000000..292f217583
--- /dev/null
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component.ts
@@ -0,0 +1,47 @@
+/*
+ * 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 { ChangeDetectionStrategy, Component, Input } from '@angular/core';
+import { FormsModule } from '@angular/forms';
+import { MatRadioButton, MatRadioGroup } from '@angular/material/radio';
+import { TranslatePipe } from '@ngx-translate/core';
+import { SplitSectionComponent } from '../../../../components/split-section/split-section.component';
+
+export interface BasicFormatExportConfig {
+ format: 'json' | 'csv' | 'xlsx';
+ delimiter?: 'comma' | 'semicolon';
+}
+
+@Component({
+ selector: 'sp-export-format-selection',
+ templateUrl: './export-format-selection.component.html',
+ styleUrls: ['./export-format-selection.component.scss'],
+ changeDetection: ChangeDetectionStrategy.Eager,
+ imports: [
+ FormsModule,
+ MatRadioGroup,
+ MatRadioButton,
+ SplitSectionComponent,
+ TranslatePipe,
+ ],
+})
+export class ExportFormatSelectionComponent {
+ @Input({ required: true }) formatExportConfig: BasicFormatExportConfig;
+ @Input() dataCyPrefix = 'download-configuration';
+ @Input() delimiterDataCyPrefix = this.dataCyPrefix;
+}
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.html b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.html
index 2a578383d2..7441476e8b 100644
--- a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.html
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.html
@@ -17,57 +17,7 @@
-->
<ng-template matStepLabel>{{ 'Select Format' | translate }}</ng-template>
-<div>
- <sp-split-section [level]="3" [title]="'Download Format' | translate">
- <mat-radio-group
- class="sp-radio-group"
- [(ngModel)]="formatExportConfig.format"
- >
- <mat-radio-button
- value="json"
- class="sp-radio-button"
- data-cy="download-configuration-json"
- >
- JSON
- </mat-radio-button>
- <mat-radio-button
- value="csv"
- class="sp-radio-button"
- data-cy="download-configuration-csv"
- >
- CSV
- </mat-radio-button>
- <mat-radio-button
- value="xlsx"
- class="sp-radio-button"
- data-cy="download-configuration-xlsx"
- >
- EXCEL (XLSX)
- </mat-radio-button>
- </mat-radio-group>
- </sp-split-section>
-</div>
-@if (formatExportConfig.format === 'csv') {
- <sp-split-section [level]="3" [title]="'Delimiter' | translate">
- <mat-radio-group
- [(ngModel)]="formatExportConfig.delimiter"
- class="sp-radio-group"
- >
- <mat-radio-button
- value="comma"
- class="sp-radio-button"
- data-cy="download-configuration-delimiter-comma"
- > ,
- </mat-radio-button>
- <mat-radio-button
- value="semicolon"
- class="sp-radio-button"
- data-cy="download-configuration-delimiter-semicolon"
- > ;
- </mat-radio-button>
- </mat-radio-group>
- </sp-split-section>
-}
+<sp-export-format-selection [formatExportConfig]="formatExportConfig" />
@if (formatExportConfig.format === 'xlsx' && hasReadFilePrivilege) {
<div fxLayout="column">
<sp-split-section [level]="3" [title]="'Excel template' | translate">
diff --git a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.ts b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.ts
index aaffca51cf..8cc6b75de9 100644
--- a/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.ts
+++ b/ui/projects/streampipes/shared-ui/src/lib/dialog/data-download-dialog/components/select-format/select-format.component.ts
@@ -36,6 +36,7 @@ import { MatFormField, MatLabel } from '@angular/material/form-field';
import { MatOption, MatSelect } from '@angular/material/select';
import { MatInput } from '@angular/material/input';
import { TranslatePipe } from '@ngx-translate/core';
+import { ExportFormatSelectionComponent } from '../export-format-selection/export-format-selection.component';
@Component({
selector: 'sp-select-format',
@@ -59,6 +60,7 @@ import { TranslatePipe } from '@ngx-translate/core';
MatLabel,
MatInput,
TranslatePipe,
+ ExportFormatSelectionComponent,
],
})
export class SelectFormatComponent implements OnInit {
diff --git a/ui/projects/streampipes/shared-ui/src/public-api.ts b/ui/projects/streampipes/shared-ui/src/public-api.ts
index 0b1ee7a89f..f9dd701a08 100644
--- a/ui/projects/streampipes/shared-ui/src/public-api.ts
+++ b/ui/projects/streampipes/shared-ui/src/public-api.ts
@@ -20,6 +20,9 @@ export * from './lib/dialog/base-dialog/base-dialog.model';
export * from './lib/dialog/base-dialog/base-dialog.service';
export * from './lib/dialog/base-dialog/dialog-ref';
export * from './lib/dialog/data-download-dialog/data-download-dialog.component';
+export * from './lib/dialog/data-download-dialog/components/select-format/select-format.component';
+export * from './lib/dialog/data-download-dialog/components/export-format-selection/export-format-selection.component';
+export * from './lib/dialog/data-download-dialog/components/download-status/download-status.component';
export * from './lib/dialog/data-download-dialog/model/export-config.model';
export * from './lib/dialog/data-download-dialog/model/format-export-config.model';
export * from './lib/dialog/data-download-dialog/model/data-export-config.model';
diff --git a/ui/src/app/configuration/audit-log/audit-log.component.html b/ui/src/app/configuration/audit-log/audit-log.component.html
index 8dcd5b3eca..3e42c42fb4 100644
--- a/ui/src/app/configuration/audit-log/audit-log.component.html
+++ b/ui/src/app/configuration/audit-log/audit-log.component.html
@@ -20,6 +20,17 @@
[title]="'Audit Log' | translate"
[subtitle]="'Review who changed what in your platform.' | translate"
>
+ <button
+ section-actions
+ mat-icon-button
+ data-cy="audit-log-download-button"
+ [attr.aria-label]="'Download audit log' | translate"
+ [matTooltip]="'Download audit log' | translate"
+ (click)="openDownloadDialog()"
+ [disabled]="!status?.enabled"
+ >
+ <mat-icon>download</mat-icon>
+ </button>
<button
section-actions
mat-icon-button
diff --git a/ui/src/app/configuration/audit-log/audit-log.component.spec.ts b/ui/src/app/configuration/audit-log/audit-log.component.spec.ts
index 9820c0c902..05cd1e0532 100644
--- a/ui/src/app/configuration/audit-log/audit-log.component.spec.ts
+++ b/ui/src/app/configuration/audit-log/audit-log.component.spec.ts
@@ -17,7 +17,8 @@
*/
import { TranslateService } from '@ngx-translate/core';
-import { AuditDialogComponent } from './audit-dialog.component';
+import { AuditDialogComponent } from '../dialog/audit-log/audit-dialog.component';
+import { AuditDownloadDialogComponent } from '../dialog/audit-log-download/audit-download-dialog.component';
import { TestBed } from '@angular/core/testing';
import {
AuditService,
@@ -189,6 +190,22 @@ describe('AuditLogComponent', () => {
);
});
+ it('opens a download dialog with the active audit filters', () => {
+ component.ngOnInit();
+ component.openDownloadDialog();
+ expect(dialogs.open).toHaveBeenCalledWith(
+ AuditDownloadDialogComponent,
+ expect.objectContaining({
+ data: expect.objectContaining({
+ query: expect.objectContaining({
+ from: expect.any(String),
+ to: expect.any(String),
+ }),
+ }),
+ }),
+ );
+ });
+
it('distinguishes storage failure from empty results and allows retry', () => {
api.getEvents.mockReturnValueOnce(throwError(() => ({ status: 503 })));
component.ngOnInit();
diff --git a/ui/src/app/configuration/audit-log/audit-log.component.ts b/ui/src/app/configuration/audit-log/audit-log.component.ts
index b4c90f64ba..370f735f1d 100644
--- a/ui/src/app/configuration/audit-log/audit-log.component.ts
+++ b/ui/src/app/configuration/audit-log/audit-log.component.ts
@@ -60,17 +60,16 @@ import {
} from '@streampipes/shared-ui';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Subscription } from 'rxjs';
-import { AuditDialogComponent } from './audit-dialog.component';
+import { AuditDialogComponent } from '../dialog/audit-log/audit-dialog.component';
+import { AuditDownloadDialogComponent } from '../dialog/audit-log-download/audit-download-dialog.component';
+import {
+ AuditActorOption,
+ AuditExportColumn,
+} from '../dialog/audit-log-download/model/audit-download-dialog.model';
import { SpConfigurationRoutes } from '../configuration.breadcrumb';
import { auditOutcomeTone } from './audit-outcome';
-interface AuditActorOption {
- id: string;
- label: string;
- username?: string;
-}
-
@Component({
selector: 'sp-audit-log',
templateUrl: './audit-log.component.html',
@@ -175,11 +174,27 @@ export class AuditLogComponent implements OnInit {
failed = false;
dataSource = new MatTableDataSource<AuditEntry>([]);
columns = ['time', 'eventType', 'outcome', 'actor', 'resource', 'preview'];
+ readonly exportColumnByTableColumn: Record<
+ string,
+ AuditExportColumn | undefined
+ > = {
+ time: { id: 'storedAt', label: 'Stored at' },
+ eventType: { id: 'eventType', label: 'Event type' },
+ outcome: { id: 'outcome', label: 'Outcome' },
+ actor: { id: 'actor', label: 'Actor username' },
+ resource: { id: 'resourceId', label: 'Resource' },
+ };
page = 0;
nextCursor: string | null = null;
private cursors: (string | undefined)[] = [undefined];
private query?: AuditQuery;
+ get exportColumns(): AuditExportColumn[] {
+ return this.columns.flatMap(
+ column => this.exportColumnByTableColumn[column] ?? [],
+ );
+ }
+
ngOnInit(): void {
this.breadcrumbs.updateBreadcrumb([
SpConfigurationRoutes.BASE,
@@ -325,6 +340,23 @@ export class AuditLogComponent implements OnInit {
});
}
+ openDownloadDialog(): void {
+ if (!this.query) {
+ return;
+ }
+ this.dialogs.open(AuditDownloadDialogComponent, {
+ panelType: PanelType.SLIDE_IN_PANEL,
+ title: this.translate.instant('Download audit log'),
+ width: '50vw',
+ data: {
+ query: { ...this.query },
+ eventTypes: this.types,
+ actors: this.actorOptions,
+ availableColumns: this.exportColumns,
+ },
+ });
+ }
+
outcomeLabel(outcome: string): string {
const labels: Record<string, string> = {
succeeded: 'Succeeded',
diff --git a/ui/src/app/configuration/dialog/audit-log-download/audit-download-dialog.component.html b/ui/src/app/configuration/dialog/audit-log-download/audit-download-dialog.component.html
new file mode 100644
index 0000000000..89ae4752cc
--- /dev/null
+++ b/ui/src/app/configuration/dialog/audit-log-download/audit-download-dialog.component.html
@@ -0,0 +1,104 @@
+<!--
+ ~ 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="sp-dialog-container" data-cy="audit-download-dialog">
+ @if (dialogModel && exportConfig) {
+ <div class="sp-dialog-content">
+ <mat-horizontal-stepper #stepper>
+ <mat-step>
+ <sp-audit-select-data
+ [dialogModel]="dialogModel"
+ [exportConfig]="exportConfig"
+ />
+ <ng-template matStepLabel>{{
+ 'Select Data' | translate
+ }}</ng-template>
+ </mat-step>
+ <mat-step>
+ <sp-export-format-selection
+ [formatExportConfig]="exportConfig.formatExportConfig"
+ dataCyPrefix="audit-download-format"
+ delimiterDataCyPrefix="audit-download"
+ />
+ <ng-template matStepLabel>{{
+ 'Export Format' | translate
+ }}</ng-template>
+ </mat-step>
+ <mat-step>
+ <sp-download-status
+ [downloading]="downloading"
+ [finished]="!downloading && !downloadFailed"
+ [failed]="downloadFailed"
+ errorMessage="Audit events could not be downloaded. Try again."
+ />
+ <ng-template matStepLabel>{{
+ 'Download' | translate
+ }}</ng-template>
+ </mat-step>
+ </mat-horizontal-stepper>
+ </div>
+
+ <mat-divider />
+ <div class="sp-dialog-actions actions-align-left">
+ <button
+ mat-button
+ mat-flat-button
+ class="mat-basic"
+ data-cy="audit-download-close-button"
+ (click)="close()"
+ >
+ {{ 'Close' | translate }}
+ </button>
+ @if (stepper.selectedIndex === 0) {
+ <button
+ mat-button
+ mat-flat-button
+ color="accent"
+ data-cy="audit-download-next-button"
+ [disabled]="!hasSelectedColumns"
+ (click)="stepper.next()"
+ >
+ {{ 'Next' | translate }}
+ </button>
+ }
+ @if (stepper.selectedIndex > 0) {
+ <button
+ mat-button
+ mat-flat-button
+ class="mat-basic"
+ data-cy="audit-download-previous-button"
+ (click)="stepper.previous()"
+ >
+ {{ 'Previous' | translate }}
+ </button>
+ }
+ @if (stepper.selectedIndex === 1) {
+ <button
+ mat-button
+ mat-flat-button
+ color="accent"
+ data-cy="audit-download-download-button"
+ [disabled]="downloading"
+ (click)="download(stepper)"
+ >
+ {{ 'Download' | translate }}
+ </button>
+ }
+ </div>
+ }
+</div>
diff --git a/ui/src/app/configuration/dialog/audit-log-download/audit-download-dialog.component.ts b/ui/src/app/configuration/dialog/audit-log-download/audit-download-dialog.component.ts
new file mode 100644
index 0000000000..cbe747cb7c
--- /dev/null
+++ b/ui/src/app/configuration/dialog/audit-log-download/audit-download-dialog.component.ts
@@ -0,0 +1,124 @@
+/*
+ * 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 {
+ ChangeDetectionStrategy,
+ Component,
+ Input,
+ OnInit,
+ inject,
+} from '@angular/core';
+import { MatButtonModule } from '@angular/material/button';
+import { MatDividerModule } from '@angular/material/divider';
+import { MatStep, MatStepLabel, MatStepper } from '@angular/material/stepper';
+import {
+ DialogRef,
+ DownloadStatusComponent,
+ ExportFormatSelectionComponent,
+} from '@streampipes/shared-ui';
+import { TranslatePipe } from '@ngx-translate/core';
+import { AuditSelectDataComponent } from './components/select-data/select-data.component';
+import {
+ AuditActorOption,
+ AuditDownloadDialogModel,
+ AuditExportColumn,
+} from './model/audit-download-dialog.model';
+import { AuditExportConfig } from './model/audit-export-config.model';
+import { AuditExportService } from './services/audit-export.service';
+
+@Component({
+ selector: 'sp-audit-download-dialog',
+ templateUrl: './audit-download-dialog.component.html',
+ changeDetection: ChangeDetectionStrategy.Eager,
+ imports: [
+ MatButtonModule,
+ MatDividerModule,
+ MatStepper,
+ MatStep,
+ MatStepLabel,
+ AuditSelectDataComponent,
+ ExportFormatSelectionComponent,
+ DownloadStatusComponent,
+ TranslatePipe,
+ ],
+})
+export class AuditDownloadDialogComponent implements OnInit {
+ private dialogRef =
+ inject<DialogRef<AuditDownloadDialogComponent>>(DialogRef);
+ private auditExportService = inject(AuditExportService);
+
+ @Input({ required: true }) query: AuditDownloadDialogModel['query'];
+ @Input() eventTypes: string[] = [];
+ @Input() actors: AuditActorOption[] = [];
+ @Input() availableColumns: AuditExportColumn[] = [];
+
+ dialogModel: AuditDownloadDialogModel;
+ exportConfig: AuditExportConfig;
+ downloading = false;
+ downloadFailed = false;
+
+ get hasSelectedColumns(): boolean {
+ return this.exportConfig.columns.some(column => column.selected);
+ }
+
+ ngOnInit(): void {
+ this.dialogModel = {
+ query: { ...this.query },
+ eventTypes: this.eventTypes,
+ actors: this.actors,
+ availableColumns: this.availableColumns,
+ };
+ this.exportConfig = {
+ dateRangeSelection: 'current',
+ fromDate: new Date(this.query.from),
+ toDate: new Date(this.query.to),
+ columns: this.availableColumns.map(column => ({
+ ...column,
+ selected: true,
+ })),
+ formatExportConfig: {
+ format: 'csv',
+ delimiter: 'comma',
+ headerColumnName: 'label',
+ },
+ };
+ }
+
+ close(): void {
+ this.dialogRef.close();
+ }
+
+ download(stepper: MatStepper): void {
+ if (this.downloading || !this.hasSelectedColumns) {
+ return;
+ }
+
+ this.downloading = true;
+ this.downloadFailed = false;
+ stepper.next();
+ this.auditExportService
+ .download(this.dialogModel, this.exportConfig)
+ .subscribe({
+ next: () => (this.downloading = false),
+ error: () => {
+ this.downloading = false;
+ this.downloadFailed = true;
+ },
+ });
+ }
+}
diff --git a/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.html b/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.html
new file mode 100644
index 0000000000..2ff1709d9e
--- /dev/null
+++ b/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.html
@@ -0,0 +1,93 @@
+<!--
+ ~ 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-split-section [level]="3" [title]="'Data Range' | translate">
+ <mat-radio-group
+ class="sp-radio-group audit-date-range-selection"
+ [ngModel]="exportConfig.dateRangeSelection"
+ (ngModelChange)="onDateRangeSelectionChange($event)"
+ >
+ <mat-radio-button value="current" class="sp-radio-button">
+ {{ 'Current selection' | translate }}
+ </mat-radio-button>
+ <mat-radio-button value="custom" class="sp-radio-button">
+ {{ 'Custom selection' | translate }}
+ </mat-radio-button>
+ </mat-radio-group>
+ @if (exportConfig.dateRangeSelection === 'custom') {
+ <div class="audit-date-range">
+ <div>
+ <h5>{{ 'From' | translate }}</h5>
+ <sp-date-input [(date)]="exportConfig.fromDate" />
+ </div>
+ <div>
+ <h5>{{ 'To' | translate }}</h5>
+ <sp-date-input [(date)]="exportConfig.toDate" />
+ </div>
+ </div>
+ }
+</sp-split-section>
+
+<sp-split-section [level]="3" [title]="'Filters' | translate">
+ <div class="audit-download-filters">
+ <sp-form-field
+ [level]="3"
+ [label]="'Event type' | translate"
+ margin="0"
+ >
+ <sp-search-select
+ [items]="dialogModel.eventTypes"
+ [value]="dialogModel.query.eventType || undefined"
+ [freeTextValue]="eventTypeFromText"
+ [placeholder]="'All event types' | translate"
+ (valueChange)="onEventTypeChange($event)"
+ />
+ </sp-form-field>
+ <sp-form-field
+ [level]="3"
+ [label]="'Actor username' | translate"
+ margin="0"
+ >
+ <sp-search-select
+ [items]="dialogModel.actors"
+ [value]="selectedActor"
+ [freeTextValue]="actorFromText"
+ [searchTextFor]="actorSearchText"
+ [placeholder]="'All actors' | translate"
+ (valueChange)="onActorChange($event)"
+ />
+ </sp-form-field>
+ <sp-form-field [level]="3" [label]="'Outcome' | translate" margin="0">
+ <sp-search-select
+ [items]="outcomeOptions"
+ [value]="selectedOutcome"
+ [placeholder]="'All outcomes' | translate"
+ (valueChange)="onOutcomeChange($event)"
+ />
+ </sp-form-field>
+ </div>
+</sp-split-section>
+
+<sp-split-section [level]="3" [title]="'Columns' | translate">
+ <p>{{ 'Choose the columns to include in the export.' | translate }}</p>
+ @for (column of exportConfig.columns; track column.id) {
+ <mat-checkbox [(ngModel)]="column.selected">
+ {{ column.label | translate }}
+ </mat-checkbox>
+ }
+</sp-split-section>
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.scss
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.scss
index b048ab9bbe..15b2ccc4c8 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.scss
@@ -16,38 +16,27 @@
*
*/
-:host {
- display: block;
- height: 100%;
+.audit-date-range,
+.audit-download-filters {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-start;
+ flex-direction: column;
+ gap: var(--space-sm);
}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
+
+.audit-date-range {
+ flex-direction: row;
}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
+
+.audit-date-range-selection {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+
+.audit-download-filters {
+ flex-direction: column;
+ justify-content: flex-start;
+ gap: 0;
}
diff --git a/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.ts b/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.ts
new file mode 100644
index 0000000000..b9c567ffd5
--- /dev/null
+++ b/ui/src/app/configuration/dialog/audit-log-download/components/select-data/select-data.component.ts
@@ -0,0 +1,140 @@
+/*
+ * 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 {
+ ChangeDetectionStrategy,
+ Component,
+ Input,
+ OnInit,
+} from '@angular/core';
+import { FormsModule } from '@angular/forms';
+import { MatCheckboxModule } from '@angular/material/checkbox';
+import { MatRadioButton, MatRadioGroup } from '@angular/material/radio';
+import {
+ DateInputComponent,
+ FormFieldComponent,
+ SearchSelectComponent,
+ SplitSectionComponent,
+} from '@streampipes/shared-ui';
+import { TranslatePipe } from '@ngx-translate/core';
+import {
+ AuditActorOption,
+ AuditDownloadDialogModel,
+} from '../../model/audit-download-dialog.model';
+import {
+ AuditDateRangeSelection,
+ AuditExportConfig,
+} from '../../model/audit-export-config.model';
+
+interface AuditOutcomeOption {
+ id: string;
+ label: string;
+}
+
+@Component({
+ selector: 'sp-audit-select-data',
+ templateUrl: './select-data.component.html',
+ styleUrls: ['./select-data.component.scss'],
+ changeDetection: ChangeDetectionStrategy.Eager,
+ imports: [
+ FormsModule,
+ MatCheckboxModule,
+ MatRadioGroup,
+ MatRadioButton,
+ SplitSectionComponent,
+ FormFieldComponent,
+ SearchSelectComponent,
+ DateInputComponent,
+ TranslatePipe,
+ ],
+})
+export class AuditSelectDataComponent implements OnInit {
+ @Input({ required: true }) dialogModel: AuditDownloadDialogModel;
+ @Input({ required: true }) exportConfig: AuditExportConfig;
+
+ private initialFromDate: Date;
+ private initialToDate: Date;
+
+ readonly eventTypeFromText = (text: string): string => text.trim();
+ readonly actorSearchText = (actor: AuditActorOption): string =>
+ `${actor.label} ${actor.id}`;
+ readonly actorFromText = (text: string): AuditActorOption => {
+ const value = text.trim();
+ const byId = this.dialogModel.actors.find(actor => actor.id === value);
+ const byUsername = this.dialogModel.actors.filter(
+ actor => actor.username?.toLowerCase() === value.toLowerCase(),
+ );
+ return (
+ byId ??
+ (byUsername.length === 1
+ ? byUsername[0]
+ : { id: value, label: value })
+ );
+ };
+ readonly outcomeOptions: AuditOutcomeOption[] = [
+ { id: 'succeeded', label: 'Succeeded' },
+ { id: 'failed', label: 'Failed' },
+ { id: 'partial', label: 'Partial' },
+ { id: 'requested', label: 'Requested' },
+ { id: 'denied', label: 'Denied' },
+ ];
+
+ get selectedActor(): AuditActorOption | undefined {
+ return this.dialogModel.query.actor
+ ? this.actorFromText(this.dialogModel.query.actor)
+ : undefined;
+ }
+
+ get selectedOutcome(): AuditOutcomeOption | undefined {
+ return this.outcomeOptions.find(
+ option => option.id === this.dialogModel.query.outcome,
+ );
+ }
+
+ ngOnInit(): void {
+ this.initialFromDate = new Date(this.exportConfig.fromDate);
+ this.initialToDate = new Date(this.exportConfig.toDate);
+ }
+
+ onDateRangeSelectionChange(selection: AuditDateRangeSelection): void {
+ this.exportConfig.dateRangeSelection = selection;
+ if (selection === 'current') {
+ this.exportConfig.fromDate = new Date(this.initialFromDate);
+ this.exportConfig.toDate = new Date(this.initialToDate);
+ }
+ }
+
+ onEventTypeChange(value: string | string[] | undefined): void {
+ this.dialogModel.query.eventType =
+ typeof value === 'string' ? value : '';
+ }
+
+ onActorChange(
+ value: AuditActorOption | AuditActorOption[] | undefined,
+ ): void {
+ this.dialogModel.query.actor =
+ value && !Array.isArray(value) ? value.id : '';
+ }
+
+ onOutcomeChange(
+ value: AuditOutcomeOption | AuditOutcomeOption[] | undefined,
+ ): void {
+ this.dialogModel.query.outcome =
+ value && !Array.isArray(value) ? value.id : '';
+ }
+}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/src/app/configuration/dialog/audit-log-download/model/audit-download-dialog.model.ts
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to ui/src/app/configuration/dialog/audit-log-download/model/audit-download-dialog.model.ts
index b048ab9bbe..4fd5b7fc5f 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/ui/src/app/configuration/dialog/audit-log-download/model/audit-download-dialog.model.ts
@@ -16,38 +16,26 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
+import { AuditEntry, AuditQuery } from '@streampipes/platform-services';
+
+export interface AuditActorOption {
+ id: string;
+ label: string;
+ username?: string;
}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
+
+export interface AuditExportColumn {
+ id: keyof AuditEntry;
+ label: string;
}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
+
+export interface SelectedAuditExportColumn extends AuditExportColumn {
+ selected: boolean;
}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+
+export interface AuditDownloadDialogModel {
+ query: AuditQuery;
+ eventTypes: string[];
+ actors: AuditActorOption[];
+ availableColumns: AuditExportColumn[];
}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/src/app/configuration/dialog/audit-log-download/model/audit-export-config.model.ts
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to ui/src/app/configuration/dialog/audit-log-download/model/audit-export-config.model.ts
index b048ab9bbe..52ee356150 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/ui/src/app/configuration/dialog/audit-log-download/model/audit-export-config.model.ts
@@ -16,38 +16,15 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
+import { SelectedAuditExportColumn } from './audit-download-dialog.model';
+import { AuditFormatExportConfig } from './format-export-config.model';
+
+export type AuditDateRangeSelection = 'current' | 'custom';
+
+export interface AuditExportConfig {
+ dateRangeSelection: AuditDateRangeSelection;
+ fromDate: Date;
+ toDate: Date;
+ columns: SelectedAuditExportColumn[];
+ formatExportConfig: AuditFormatExportConfig;
}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/src/app/configuration/dialog/audit-log-download/model/format-export-config.model.ts
similarity index 55%
copy from ui/src/app/configuration/audit-log/audit-dialog.component.scss
copy to ui/src/app/configuration/dialog/audit-log-download/model/format-export-config.model.ts
index b048ab9bbe..2a034baa12 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.scss
+++ b/ui/src/app/configuration/dialog/audit-log-download/model/format-export-config.model.ts
@@ -16,38 +16,11 @@
*
*/
-:host {
- display: block;
- height: 100%;
-}
-.sp-dialog-content {
- padding: var(--space-lg);
-}
-dl {
- margin: 0;
-}
-dt {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
- margin-top: var(--space-lg);
-}
-dt:first-child {
- margin-top: 0;
-}
-dd {
- margin: var(--space-xs) 0 0;
- overflow-wrap: anywhere;
-}
-.secondary {
- color: var(--mat-sys-on-surface-variant);
- font-size: var(--font-size-sm);
-}
-pre {
- font-size: var(--font-size-sm);
- line-height: 1.5;
- white-space: pre-wrap;
- overflow-wrap: anywhere;
- background: var(--color-bg-1);
- padding: var(--space-md);
- margin: 0;
-}
+export type AuditFormatExportConfig =
+ | { format: 'json' }
+ | {
+ format: 'csv';
+ delimiter: 'comma' | 'semicolon';
+ headerColumnName: 'key' | 'label';
+ }
+ | { format: 'xlsx'; headerColumnName: 'key' | 'label' };
diff --git a/ui/src/app/configuration/dialog/audit-log-download/services/audit-export.service.ts b/ui/src/app/configuration/dialog/audit-log-download/services/audit-export.service.ts
new file mode 100644
index 0000000000..bb839b9af8
--- /dev/null
+++ b/ui/src/app/configuration/dialog/audit-log-download/services/audit-export.service.ts
@@ -0,0 +1,96 @@
+/*
+ * 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 { AuditService } from '@streampipes/platform-services';
+import { TranslateService } from '@ngx-translate/core';
+import { Observable, map, tap } from 'rxjs';
+import { AuditDownloadDialogModel } from '../model/audit-download-dialog.model';
+import { AuditExportConfig } from '../model/audit-export-config.model';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class AuditExportService {
+ private auditService = inject(AuditService);
+ private translate = inject(TranslateService);
+
+ download(
+ dialogModel: AuditDownloadDialogModel,
+ exportConfig: AuditExportConfig,
+ ): Observable<void> {
+ const query = {
+ ...dialogModel.query,
+ from: exportConfig.fromDate.toISOString(),
+ to: exportConfig.toDate.toISOString(),
+ limit: 200,
+ cursor: undefined,
+ };
+
+ const selectedColumns = exportConfig.columns.filter(
+ column => column.selected,
+ );
+ const formatConfig = exportConfig.formatExportConfig;
+ const headers = selectedColumns.map(column =>
+ formatConfig.format === 'json' ||
+ formatConfig.headerColumnName === 'key'
+ ? column.id
+ : this.translate.instant(column.label),
+ );
+ const delimiter =
+ formatConfig.format === 'csv' ? formatConfig.delimiter : undefined;
+ return this.auditService
+ .download(
+ query,
+ selectedColumns.map(column => column.id),
+ headers,
+ formatConfig.format,
+ delimiter,
+ )
+ .pipe(
+ tap(file =>
+ this.saveFile(
+ file,
+ this.contentType(formatConfig.format),
+ `audit-log.${formatConfig.format}`,
+ ),
+ ),
+ map(() => undefined),
+ );
+ }
+
+ private saveFile(data: BlobPart, type: string, filename: string): void {
+ const link = document.createElement('a');
+ const url = URL.createObjectURL(new Blob([data], { type }));
+ link.href = url;
+ link.download = filename;
+ link.click();
+ URL.revokeObjectURL(url);
+ }
+
+ private contentType(format: 'csv' | 'json' | 'xlsx'): string {
+ switch (format) {
+ case 'csv':
+ return 'text/csv;charset=utf-8';
+ case 'json':
+ return 'application/json;charset=utf-8';
+ case 'xlsx':
+ return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
+ }
+ }
+}
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.html b/ui/src/app/configuration/dialog/audit-log/audit-dialog.component.html
similarity index 100%
rename from ui/src/app/configuration/audit-log/audit-dialog.component.html
rename to ui/src/app/configuration/dialog/audit-log/audit-dialog.component.html
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.scss b/ui/src/app/configuration/dialog/audit-log/audit-dialog.component.scss
similarity index 100%
rename from ui/src/app/configuration/audit-log/audit-dialog.component.scss
rename to ui/src/app/configuration/dialog/audit-log/audit-dialog.component.scss
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.spec.ts b/ui/src/app/configuration/dialog/audit-log/audit-dialog.component.spec.ts
similarity index 100%
rename from ui/src/app/configuration/audit-log/audit-dialog.component.spec.ts
rename to ui/src/app/configuration/dialog/audit-log/audit-dialog.component.spec.ts
diff --git a/ui/src/app/configuration/audit-log/audit-dialog.component.ts b/ui/src/app/configuration/dialog/audit-log/audit-dialog.component.ts
similarity index 98%
rename from ui/src/app/configuration/audit-log/audit-dialog.component.ts
rename to ui/src/app/configuration/dialog/audit-log/audit-dialog.component.ts
index 93a7194464..75588e29a2 100644
--- a/ui/src/app/configuration/audit-log/audit-dialog.component.ts
+++ b/ui/src/app/configuration/dialog/audit-log/audit-dialog.component.ts
@@ -47,7 +47,7 @@ import {
SpLabelComponent,
} from '@streampipes/shared-ui';
-import { auditOutcomeTone } from './audit-outcome';
+import { auditOutcomeTone } from '../../audit-log/audit-outcome';
@Component({
selector: 'sp-audit-dialog',