Skip to content

fix: standardize date formatting across components using useDateTimeF… #4311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<sba-button :disabled="modelValue >= pageCount" @click="goNext">
<span class="sr-only" v-text="$t('term.go_to_next_page')" />
<font-awesome-icon
class="h-5 w-10"
class="h-5 w-5"
:icon="['fas', 'angle-double-right']"
/>
</sba-button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
type DateFormatterOptions = {
dateTimeFormat?: Intl.DateTimeFormatOptions;
timeFormat?: Intl.DateTimeFormatOptions;
};

export const useDateTimeFormatter = (options?: DateFormatterOptions) => {
const userLocale = navigator.languages
? navigator.languages[0]
: navigator.language;

const dateTimeFormat = new Intl.DateTimeFormat(userLocale, {
...{ dateStyle: 'medium', timeStyle: 'medium' },
...(options?.dateTimeFormat ?? {}),
});

return {
formatDateTime: (date: Date) => {
return dateTimeFormat.format(date);
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ import { setupWorker } from 'msw/browser';

import auditEventsEndpoint from './instance/auditevents/index.js';
import flywayEndpoints from './instance/flyway/index.js';
import httpTraceEndpoints from './instance/httptrace/index.js';
import liquibaseEndpoints from './instance/liquibase/index.js';
import mappingsEndpoint from './instance/mappings/index.js';
import metricsEndpoint from './instance/metrics/index.js';
import sessionEndpoints from './instance/sessions/index.js';

const handler = [
...mappingsEndpoint,
...liquibaseEndpoints,
...flywayEndpoints,
...auditEventsEndpoint,
...metricsEndpoint,
...httpTraceEndpoints,
...sessionEndpoints,
];

export const worker = setupWorker(...handler);
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const now = new Date();
const today =
now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
const today = [
now.getFullYear(),
String(now.getMonth() + 1).padStart(2, '0'),
String(now.getDate()).padStart(2, '0'),
].join('-');

export const auditeventsresponse = {
events: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
const now = new Date();
const today = [
now.getFullYear(),
String(now.getMonth() + 1).padStart(2, '0'),
String(now.getDate()).padStart(2, '0'),
].join('-');

export const httptraceresponse = {
traces: [
{
timestamp: today + 'T09:12:34.567Z',
principal: 'admin',
session: 'D43F6A32C1E34A7B',
request: {
method: 'GET',
uri: 'http://localhost:8080/api/users',
headers: {
accept: ['application/json'],
'user-agent': [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
],
authorization: ['Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'],
},
remoteAddress: '192.168.1.105',
},
response: {
status: 200,
headers: {
'content-type': ['application/json'],
'content-length': ['1024'],
'cache-control': ['no-cache, no-store, max-age=0, must-revalidate'],
},
timeTaken: 125,
},
},
{
timestamp: today + 'T09:13:45.678Z',
principal: 'user123',
session: 'E54G7B43D2F45B8C',
request: {
method: 'POST',
uri: 'http://localhost:8080/api/orders',
headers: {
'content-type': ['application/json'],
'user-agent': ['PostmanRuntime/7.29.2'],
authorization: ['Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'],
},
remoteAddress: '192.168.1.110',
},
response: {
status: 201,
headers: {
'content-type': ['application/json'],
location: ['/api/orders/12345'],
'content-length': ['256'],
},
timeTaken: 187,
},
},
{
timestamp: today + today + 'T09:14:56.789Z',
principal: null,
session: null,
request: {
method: 'GET',
uri: 'http://localhost:8080/api/products',
headers: {
accept: ['application/json'],
'user-agent': ['curl/7.68.0'],
},
remoteAddress: '192.168.1.115',
},
response: {
status: 200,
headers: {
'content-type': ['application/json'],
'content-length': ['2048'],
'cache-control': ['max-age=3600'],
},
timeTaken: 95,
},
},
{
timestamp: today + 'T09:15:23.456Z',
principal: 'user456',
session: 'F65H8C54E3G56D9E',
request: {
method: 'PUT',
uri: 'http://localhost:8080/api/users/profile',
headers: {
'content-type': ['application/json'],
'user-agent': ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'],
authorization: ['Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'],
},
remoteAddress: '192.168.1.120',
},
response: {
status: 200,
headers: {
'content-type': ['application/json'],
'content-length': ['512'],
},
timeTaken: 143,
},
},
{
timestamp: today + 'T09:16:34.567Z',
principal: null,
session: null,
request: {
method: 'GET',
uri: 'http://localhost:8080/actuator/health',
headers: {
accept: ['application/json'],
'user-agent': ['Prometheus/2.40.0'],
},
remoteAddress: '192.168.1.200',
},
response: {
status: 200,
headers: {
'content-type': ['application/json'],
'content-length': ['15'],
},
timeTaken: 12,
},
},
{
timestamp: today + 'T09:17:45.678Z',
principal: 'admin',
session: 'D43F6A32C1E34A7B',
request: {
method: 'DELETE',
uri: 'http://localhost:8080/api/products/54321',
headers: {
'user-agent': [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
],
authorization: ['Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'],
},
remoteAddress: '192.168.1.105',
},
response: {
status: 204,
headers: {
'cache-control': ['no-cache, no-store, max-age=0, must-revalidate'],
},
timeTaken: 78,
},
},
{
timestamp: today + 'T09:18:56.789Z',
principal: null,
session: null,
request: {
method: 'OPTIONS',
uri: 'http://localhost:8080/api/users',
headers: {
origin: ['https://example.com'],
'access-control-request-method': ['GET'],
'user-agent': [
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)',
],
},
remoteAddress: '192.168.1.130',
},
response: {
status: 200,
headers: {
'access-control-allow-origin': ['https://example.com'],
'access-control-allow-methods': ['GET, POST, PUT, DELETE'],
'access-control-allow-headers': ['Authorization, Content-Type'],
'access-control-max-age': ['3600'],
},
timeTaken: 5,
},
},
{
timestamp: today + 'T09:19:23.456Z',
principal: 'user789',
session: 'G76I9D65F4H67E0F',
request: {
method: 'GET',
uri: 'http://localhost:8080/api/orders/history?page=0&size=10',
headers: {
accept: ['application/json'],
'user-agent': ['Mozilla/5.0 (Android 12; Mobile)'],
authorization: ['Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'],
},
remoteAddress: '192.168.1.140',
},
response: {
status: 200,
headers: {
'content-type': ['application/json'],
'content-length': ['1536'],
'x-total-count': ['45'],
},
timeTaken: 167,
},
},
{
timestamp: today + 'T09:20:34.567Z',
principal: null,
session: null,
request: {
method: 'GET',
uri: 'http://localhost:8080/api/nonexistent',
headers: {
accept: ['application/json'],
'user-agent': ['curl/7.68.0'],
},
remoteAddress: '192.168.1.150',
},
response: {
status: 404,
headers: {
'content-type': ['application/json'],
'content-length': ['64'],
},
timeTaken: 23,
},
},
{
timestamp: today + 'T09:21:45.678Z',
principal: 'user123',
session: 'E54G7B43D2F45B8C',
request: {
method: 'POST',
uri: 'http://localhost:8080/api/checkout',
headers: {
'content-type': ['application/json'],
'user-agent': ['PostmanRuntime/7.29.2'],
authorization: ['Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'],
},
remoteAddress: '192.168.1.110',
},
response: {
status: 400,
headers: {
'content-type': ['application/json'],
'content-length': ['128'],
},
timeTaken: 45,
},
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { HttpResponse, http } from 'msw';

import { httptraceresponse } from '@/mocks/instance/httptrace/data';

const endpoints = [
http.get('/instances/:instanceId/actuator/httptrace', () => {
return HttpResponse.json(httptraceresponse);
}),
];

export default endpoints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export const scheduledtasksResponse = {
cron: [
{
runnable: {
target: 'com.example.Processor.processOrders',
},
expression: '0 0 0/3 1/1 * ?',
nextExecution: {
time: '2025-05-22T20:59:59.999087966Z',
},
},
],
fixedDelay: [
{
runnable: {
target: 'com.example.Processor.purge',
},
initialDelay: 0,
interval: 5000,
nextExecution: {
time: '2025-05-22T20:03:39.767908889Z',
},
lastExecution: {
time: '2025-05-22T20:03:34.761508282Z',
status: 'SUCCESS',
},
},
],
fixedRate: [
{
runnable: {
target: 'com.example.Processor.retrieveIssues',
},
initialDelay: 10000,
interval: 3000,
nextExecution: {
time: '2025-05-22T20:03:44.755151650Z',
},
},
],
custom: [
{
runnable: {
target: 'com.example.Processor$CustomTriggeredRunnable@6e5b7446',
},
trigger: 'com.example.Processor$CustomTrigger@513ad29e',
lastExecution: {
exception: {
message: 'Failed while running custom task',
type: 'java.lang.IllegalStateException',
},
time: '2025-05-22T20:03:34.807437342Z',
status: 'ERROR',
},
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { HttpResponse, http } from 'msw';

import { scheduledtasksResponse } from '@/mocks/instance/sessions/data';

const endpoints = [
http.get('/instances/:instanceId/actuator/sessions', () => {
return HttpResponse.json(scheduledtasksResponse);
}),
];

export default endpoints;
Loading
Loading