Skip to content

Commit 196ad83

Browse files
authored
Merge branch 'master' into bugfix/5286-health-info-events
2 parents d9e0e13 + bd11a80 commit 196ad83

5 files changed

Lines changed: 87 additions & 25 deletions

File tree

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

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"resize-observer-polyfill": "1.5.1",
6565
"rxjs": "7.8.2",
6666
"sanitize-html": "^2.17.0",
67-
"uuid": "13.0.0",
6867
"v3-infinite-loading": "1.3.2",
6968
"vue": "3.5.32",
7069
"vue-i18n": "11.3.2",

spring-boot-admin-server-ui/src/main/frontend/services/instance.spec.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { AxiosError } from 'axios';
2-
import { describe, expect, test, vi } from 'vitest';
2+
import { http } from 'msw';
3+
import { firstValueFrom } from 'rxjs';
4+
import { describe, expect, it, test, vi } from 'vitest';
35

6+
import { server } from '@/mocks/server';
47
import Instance from '@/services/instance';
58

69
const { useSbaConfig } = vi.hoisted(() => ({
@@ -181,4 +184,38 @@ describe('Instance', () => {
181184
);
182185
});
183186
});
187+
188+
describe('streamLogFile', () => {
189+
const instance = new Instance({
190+
id: 'test-id',
191+
registration: {
192+
name: 'test',
193+
healthUrl: '',
194+
source: '',
195+
},
196+
});
197+
198+
it('should handle single JSON log line correctly', async () => {
199+
const payload = '{"foo":"bar"}';
200+
server.use(
201+
http.get(
202+
'/instances/:instanceId/actuator/logfile',
203+
() =>
204+
// As per Spring Boot definition: https://docs.spring.io/spring-boot/api/rest/actuator/logfile.html
205+
new Response(payload, {
206+
headers: {
207+
'Accept-Ranges': 'bytes',
208+
'Content-Type': 'text/plain;charset=UTF-8',
209+
'Content-Length': payload.length.toString(),
210+
},
211+
}),
212+
),
213+
);
214+
215+
const source = instance.streamLogfile(0);
216+
const { addendum } = await firstValueFrom(source);
217+
218+
expect(addendum).toEqual(payload);
219+
});
220+
});
184221
});

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

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
-->
1616

1717
<template>
18-
<sba-instance-section :error="error" :loading="!hasLoaded">
18+
<sba-instance-section
19+
:error="error"
20+
:loading="!hasLoaded"
21+
:layout-options="{ isFlex: true, noMargin: true }"
22+
class="logfile-section"
23+
>
1924
<template #before>
2025
<sba-sticky-subnav>
2126
<div class="flex items-center justify-end gap-1">
@@ -86,6 +91,7 @@
8691
</template>
8792

8893
<div
94+
ref="scrollContainer"
8995
:class="{ 'wrap-lines': wrapLines }"
9096
class="log-viewer overflow-x-auto text-sm -mx-6 -my-20 pt-14"
9197
>
@@ -143,17 +149,20 @@ export default {
143149
},
144150
created() {
145151
this.ansiUp = new AnsiUp();
146-
this.scrollSubscription = fromEvent(window, 'scroll')
152+
},
153+
mounted() {
154+
const element = this.$refs.scrollContainer;
155+
this.scrollSubscription = fromEvent(element, 'scroll')
147156
.pipe(
148157
debounceTime(25),
149-
map((event) => event.target.scrollingElement.scrollTop),
158+
map(() => element.scrollTop),
150159
)
151160
.subscribe((scrollTop) => {
152161
this.atTop = scrollTop === 0;
153162
this.atBottom =
154-
document.scrollingElement.clientHeight ===
155-
document.scrollingElement.scrollHeight -
156-
document.scrollingElement.scrollTop;
163+
Math.abs(
164+
element.clientHeight - (element.scrollHeight - element.scrollTop),
165+
) <= 1;
157166
});
158167
},
159168
beforeUnmount() {
@@ -204,11 +213,11 @@ export default {
204213
});
205214
},
206215
scrollToTop() {
207-
document.scrollingElement.scrollTop = 0;
216+
this.$refs.scrollContainer.scrollTop = 0;
208217
},
209218
scrollToBottom() {
210-
document.scrollingElement.scrollTop =
211-
document.scrollingElement.scrollHeight;
219+
this.$refs.scrollContainer.scrollTop =
220+
this.$refs.scrollContainer.scrollHeight;
212221
},
213222
downloadLogfile() {
214223
window.open(`instances/${this.instance.id}/actuator/logfile`, '_blank');
@@ -231,6 +240,35 @@ export default {
231240
232241
<style lang="css">
233242
@reference "../../../index.css";
243+
.logfile-section {
244+
display: flex;
245+
flex-direction: column;
246+
max-height: 100%;
247+
}
248+
249+
.logfile-section #subnavigation {
250+
flex: 0 0 auto;
251+
}
252+
253+
.logfile-section .sba-instance-section-content {
254+
min-height: 0;
255+
padding: 0;
256+
overflow: hidden;
257+
flex-direction: column;
258+
}
259+
260+
.logfile-section .sba-instance-section-content [role='alert'] {
261+
margin: 0;
262+
}
263+
264+
.log-viewer {
265+
overflow: auto;
266+
margin: 0;
267+
padding: 0;
268+
width: 100%;
269+
max-height: 100%;
270+
}
271+
234272
.log-viewer pre {
235273
padding: 0 0.75em;
236274
margin-bottom: 1px;
@@ -242,6 +280,7 @@ export default {
242280
243281
.log-viewer.wrap-lines pre {
244282
@apply whitespace-pre-wrap;
283+
word-break: break-all;
245284
}
246285
247286
.log-viewer {

spring-boot-admin-server-ui/src/main/frontend/views/instances/shell/sba-instance-section.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<div
66
:class="
77
classNames({
8+
'sba-instance-section-content': true,
89
'flex-1': true,
910
flex: layoutOptions.isFlex,
1011
'px-2 md:px-6 py-6': !layoutOptions.noMargin,

0 commit comments

Comments
 (0)