浏览代码

Make message timestamp format configurable (backend) (#2277)

* [2163] Make message timestamp format configurable

* [2163] Make message timestamp format configurable - PR comments update

Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com>
Sergiy-provectus 2 年之前
父节点
当前提交
085dfec389

+ 25 - 0
kafka-ui-api/src/main/java/com/provectus/kafka/ui/controller/InfoController.java

@@ -0,0 +1,25 @@
+package com.provectus.kafka.ui.controller;
+
+import com.provectus.kafka.ui.api.TimeStampFormatApi;
+import com.provectus.kafka.ui.model.TimeStampFormatDTO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+public class InfoController extends AbstractController implements TimeStampFormatApi {
+
+  @Value("${timestamp.format:dd.MM.YYYY HH:mm:ss}")
+  private String timeStampFormat;
+
+  @Override
+  public Mono<ResponseEntity<TimeStampFormatDTO>> getTimeStampFormat(ServerWebExchange exchange) {
+    return Mono.just(ResponseEntity.ok(new TimeStampFormatDTO().timeStampFormat(timeStampFormat)));
+  }
+}

+ 19 - 1
kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml

@@ -1750,7 +1750,19 @@ paths:
                 $ref: '#/components/schemas/PartitionsIncreaseResponse'
         404:
           description: Not found
-
+  /api/info/timestampformat:
+    get:
+      tags:
+        - TimeStampFormat
+      summary: getTimeStampFormat
+      operationId: getTimeStampFormat
+      responses:
+        200:
+          description: OK
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/TimeStampFormat'
 components:
   schemas:
     ErrorResponse:
@@ -2353,6 +2365,12 @@ components:
         name:
           type: string
 
+    TimeStampFormat:
+      type: object
+      properties:
+        timeStampFormat:
+          type: string
+
     TopicMessageConsuming:
       type: object
       properties: