Skip to content

Commit b994cc8

Browse files
committed
feat(AuditEvents): migrate to new UI
1 parent 4a21b7d commit b994cc8

File tree

8 files changed

+113
-78
lines changed

8 files changed

+113
-78
lines changed

spring-boot-admin-server-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@
120120
"npm": ">=8"
121121
},
122122
"msw": {
123-
"workerDirectory": "src/main/frontend/assets"
123+
"workerDirectory": "./public"
124124
}
125125
}

spring-boot-admin-server-ui/src/main/frontend/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import {createApp, h, reactive} from 'vue';
2626
import i18n from './i18n';
2727
import router from './router.js';
2828
import {createApplicationStore, useApplicationStore} from "./composables/useApplicationStore.js";
29-
import {createViewRegistry, useViewRegistry} from "./composables/ViewRegistry.js";
30-
import about from "./views/about/index.vue";
29+
import {createViewRegistry} from "./composables/ViewRegistry.js";
30+
import { worker } from './mocks/browser';
3131

3232
moment.locale(navigator.language.split('-')[0]);
3333

@@ -40,6 +40,14 @@ const installables = [
4040
...sbaConfig.extensions
4141
];
4242

43+
if (process.env.NODE_ENV === 'development') {
44+
worker.start({
45+
serviceWorker: {
46+
url: "./mockServiceWorker.js"
47+
}
48+
})
49+
}
50+
4351
installables.forEach(installable => {
4452
installable.install({
4553
viewRegistry,

spring-boot-admin-server-ui/src/main/frontend/mocks/browser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import {setupWorker} from 'msw'
22
import mappingsEndpoint from "./instance/mappings/index.js";
33
import liquibaseEndpoints from "./instance/liquibase/index.js";
44
import flywayEndpoints from "./instance/flyway/index.js";
5+
import auditEventsEndpoint from "./instance/auditevents/index.js";
56

67
const handler = [
78
...mappingsEndpoint,
89
...liquibaseEndpoints,
9-
...flywayEndpoints
10+
...flywayEndpoints,
11+
...auditEventsEndpoint
1012
];
1113

1214
export const worker = setupWorker(...handler)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export default {
2+
"events": [
3+
{
4+
"timestamp": "2017-03-14T22:59:58+0000",
5+
"principal": "user",
6+
"type": "AUTHENTICATION_FAILURE",
7+
"data": {
8+
"details": {
9+
"remoteAddress": "0:0:0:0:0:0:0:1",
10+
"sessionId": null
11+
},
12+
"type": "org.springframework.security.authentication.BadCredentialsException",
13+
"message": "Bad credentials"
14+
}
15+
},
16+
{
17+
"timestamp": "2017-03-14T23:00:07+0000",
18+
"principal": "user",
19+
"type": "AUTHENTICATION_SUCCESS",
20+
"data": {
21+
"details": {
22+
"remoteAddress": "0:0:0:0:0:0:0:1",
23+
"sessionId": null
24+
}
25+
}
26+
}
27+
]
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {rest} from "msw";
2+
import data from "./data.js";
3+
4+
const endpoints = [
5+
rest.get(
6+
'/instances/:instanceId/actuator/auditevents',
7+
(req, res, ctx) => {
8+
console.log("[Auditevents] received request.")
9+
return res(ctx.status(200), ctx.json(data));
10+
}
11+
),
12+
];
13+
14+
export default endpoints;

spring-boot-admin-server-ui/src/main/frontend/views/instances/auditevents/auditevents-list.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
-->
1616

1717
<template>
18-
<table class="auditevents table is-hoverable is-fullwidth">
18+
<table class="auditevents table w-full">
1919
<thead>
2020
<tr>
2121
<th v-html="$t('instances.auditevents.timestamp')" />

spring-boot-admin-server-ui/src/main/frontend/views/instances/auditevents/index.vue

Lines changed: 56 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,81 +15,60 @@
1515
-->
1616

1717
<template>
18-
<section class="section">
19-
<div class="field is-horizontal">
20-
<div class="field-body">
21-
<div class="field">
22-
<p class="control is-expanded">
23-
<input
24-
v-model.trim="filter.principal"
25-
class="input"
26-
type="search"
27-
:placeholder="$t('instances.auditevents.principal')"
28-
>
29-
</p>
30-
</div>
31-
<div class="field">
32-
<p class="control is-expanded">
33-
<input
34-
v-model="filter.type"
35-
list="auditevent-type"
36-
class="input"
37-
type="search"
38-
:placeholder="$t('instances.auditevents.type')"
39-
>
40-
<datalist id="auditevent-type">
41-
<option value="AUTHENTICATION_FAILURE" />
42-
<option value="AUTHENTICATION_SUCCESS" />
43-
<option value="AUTHENTICATION_SWITCH" />
44-
<option value="AUTHORIZATION_FAILURE" />
45-
</datalist>
46-
</p>
47-
</div>
48-
<div class="field">
49-
<p class="control is-expanded">
50-
<input
51-
class="input"
52-
type="datetime-local"
53-
placeholder="Date"
54-
:value="formatDate(filter.after)"
55-
@input="filter.after = parseDate($event.target.value)"
56-
>
57-
</p>
58-
</div>
59-
</div>
60-
</div>
61-
<template>
62-
<div
63-
v-if="error"
64-
class="message is-danger"
65-
>
66-
<div class="message-body">
67-
<strong>
68-
<font-awesome-icon
69-
class="has-text-danger"
70-
icon="exclamation-triangle"
71-
/>
72-
<span v-text="$t('term.fetch_failed')" />
73-
</strong>
74-
<p v-text="error.message" />
18+
<sba-instance-section
19+
:error="error"
20+
:loading="isLoading"
21+
>
22+
<template #before>
23+
<sba-sticky-subnav>
24+
<div class="flex gap-2">
25+
<sba-input
26+
name="filter_principal"
27+
v-model.trim="filter.principal"
28+
type="search"
29+
:placeholder="$t('instances.auditevents.principal')"
30+
/>
31+
<sba-input
32+
name="filter_type"
33+
v-model="filter.type"
34+
:list="[
35+
'AUTHENTICATION_FAILURE',
36+
'AUTHENTICATION_SUCCESS',
37+
'AUTHENTICATION_SWITCH',
38+
'AUTHORIZATION_FAILURE',
39+
]"
40+
type="search"
41+
:placeholder="$t('instances.auditevents.type')"
42+
/>
43+
44+
<sba-input
45+
name="filter_datetime"
46+
type="datetime-local"
47+
placeholder="Date"
48+
:value="formatDate(filter.after)"
49+
@input="filter.after = parseDate($event.target.value)"
50+
/>
7551
</div>
76-
</div>
77-
<div
78-
v-if="isOldAuditevents"
79-
class="message is-warning"
80-
>
52+
</sba-sticky-subnav>
53+
</template>
54+
55+
<sba-panel :seamless="true">
8156
<div
82-
class="message-body"
83-
v-html="$t('instances.auditevents.audit_log_not_supported_spring_boot_1')"
57+
v-if="isOldAuditevents"
58+
class="message is-warning"
59+
>
60+
<div
61+
class="message-body"
62+
v-html="$t('instances.auditevents.audit_log_not_supported_spring_boot_1')"
63+
/>
64+
</div>
65+
<auditevents-list
66+
:instance="instance"
67+
:events="events"
68+
:is-loading="isLoading"
8469
/>
85-
</div>
86-
<auditevents-list
87-
:instance="instance"
88-
:events="events"
89-
:is-loading="isLoading"
90-
/>
91-
</template>
92-
</section>
70+
</sba-panel>
71+
</sba-instance-section>
9372
</template>
9473

9574
<script>
@@ -100,6 +79,10 @@ import AuditeventsList from './auditevents-list.vue';
10079
import {uniqBy} from 'lodash-es';
10180
import moment from 'moment';
10281
import {VIEW_GROUP} from '../../ViewGroup.js';
82+
import SbaInstanceSection from "../shell/sba-instance-section.vue";
83+
import SbaStickySubnav from "../../../components/sba-sticky-subnav.vue";
84+
import SbaPanel from "../../../components/sba-panel.vue";
85+
import SbaInput from "../../../components/sba-input.vue";
10386
10487
class Auditevent {
10588
constructor({timestamp, ...event}) {
@@ -130,7 +113,7 @@ class Auditevent {
130113
}
131114
132115
export default {
133-
components: {AuditeventsList},
116+
components: {SbaInput, SbaInstanceSection, SbaStickySubnav, SbaPanel, AuditeventsList},
134117
mixins: [subscribing],
135118
props: {
136119
instance: {

0 commit comments

Comments
 (0)