Add a separate endpoint for frontend time format (#2847)
This commit is contained in:
parent
a8ccbc96c8
commit
cb8049e769
4 changed files with 25 additions and 3 deletions
|
@ -17,9 +17,16 @@ public class InfoController extends AbstractController implements TimeStampForma
|
||||||
|
|
||||||
@Value("${timestamp.format:dd.MM.YYYY HH:mm:ss}")
|
@Value("${timestamp.format:dd.MM.YYYY HH:mm:ss}")
|
||||||
private String timeStampFormat;
|
private String timeStampFormat;
|
||||||
|
@Value("${timestamp.format:DD.MM.YYYY HH:mm:ss}")
|
||||||
|
private String timeStampFormatIso;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<ResponseEntity<TimeStampFormatDTO>> getTimeStampFormat(ServerWebExchange exchange) {
|
public Mono<ResponseEntity<TimeStampFormatDTO>> getTimeStampFormat(ServerWebExchange exchange) {
|
||||||
return Mono.just(ResponseEntity.ok(new TimeStampFormatDTO().timeStampFormat(timeStampFormat)));
|
return Mono.just(ResponseEntity.ok(new TimeStampFormatDTO().timeStampFormat(timeStampFormat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<ResponseEntity<TimeStampFormatDTO>> getTimeStampFormatISO(ServerWebExchange exchange) {
|
||||||
|
return Mono.just(ResponseEntity.ok(new TimeStampFormatDTO().timeStampFormat(timeStampFormatIso)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1733,7 +1733,7 @@ paths:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- TimeStampFormat
|
- TimeStampFormat
|
||||||
summary: getTimeStampFormat
|
summary: get system default datetime format
|
||||||
operationId: getTimeStampFormat
|
operationId: getTimeStampFormat
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
|
@ -1742,6 +1742,21 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/TimeStampFormat'
|
$ref: '#/components/schemas/TimeStampFormat'
|
||||||
|
|
||||||
|
/api/info/timestampformat/iso:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- TimeStampFormat
|
||||||
|
summary: get system default datetime format (in ISO format, for JS)
|
||||||
|
operationId: getTimeStampFormatISO
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/TimeStampFormat'
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
TopicSerdeSuggestion:
|
TopicSerdeSuggestion:
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { expectQueryWorks, renderQueryHook } from 'lib/testHelpers';
|
||||||
import * as hooks from 'lib/hooks/api/timeFormat';
|
import * as hooks from 'lib/hooks/api/timeFormat';
|
||||||
import { timeFormatPayload } from 'lib/fixtures/timeFormat';
|
import { timeFormatPayload } from 'lib/fixtures/timeFormat';
|
||||||
|
|
||||||
const timeFormatPath = '/api/info/timestampformat';
|
const timeFormatPath = '/api/info/timestampformat/iso';
|
||||||
|
|
||||||
describe('Time format hooks', () => {
|
describe('Time format hooks', () => {
|
||||||
beforeEach(() => fetchMock.restore());
|
beforeEach(() => fetchMock.restore());
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { QUERY_REFETCH_OFF_OPTIONS } from 'lib/constants';
|
||||||
export function useTimeFormat() {
|
export function useTimeFormat() {
|
||||||
return useQuery(
|
return useQuery(
|
||||||
['settings', 'timestampformat'],
|
['settings', 'timestampformat'],
|
||||||
() => api.getTimeStampFormat(),
|
() => api.getTimeStampFormatISO(),
|
||||||
QUERY_REFETCH_OFF_OPTIONS
|
QUERY_REFETCH_OFF_OPTIONS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue