Skip to content

Commit b4286e8

Browse files
authored
fix(#1986): improve UX for JMX view (#2015)
1 parent 2846a07 commit b4286e8

File tree

5 files changed

+120
-5
lines changed

5 files changed

+120
-5
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
<li>
7777
<a v-for="domain in domains" :key="domain.domain" :class="{'is-active' : domain === selectedDomain}"
7878
class=""
79-
@click="select(domain)" v-text="domain.domain"
79+
:title="domain.domain"
80+
@click="select(domain)" v-text="truncatePackageName(domain.domain, 25)"
8081
/>
8182
</li>
8283
</ul>
@@ -98,6 +99,7 @@ import {directive as onClickaway} from 'vue-clickaway2';
9899
import mBeanAttributes from './m-bean-attributes';
99100
import mBeanOperations from './m-bean-operations';
100101
import {VIEW_GROUP} from '../../index';
102+
import {truncatePackageName} from '@/views/instances/jolokia/utils';
101103
102104
const getOperationName = (name, descriptor) => {
103105
const params = descriptor.args.map(arg => arg.type).join(',');
@@ -151,6 +153,7 @@ export default {
151153
hasLoaded: false,
152154
error: null,
153155
domains: [],
156+
truncatePackageName,
154157
selected: {
155158
domain: null,
156159
mBean: null,

spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/m-bean-operation-invocation.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<div class="modal-background" @click="abort" />
2020
<div class="modal-content">
2121
<div class="modal-card">
22-
<header class="modal-card-head">
22+
<header class="modal-card-head is-block">
2323
<p class="modal-card-title" v-text="name" />
2424
</header>
2525

@@ -28,7 +28,7 @@
2828
<div class="field" v-for="(arg, idx) in descriptor.args" :key="arg.name">
2929
<label class="label">
3030
<span v-text="arg.name" />
31-
<small class="is-muted has-text-weight-normal" v-text="arg.type" />
31+
<small class="is-muted has-text-weight-normal pl-1" v-text="arg.type" />
3232
</label>
3333
<div class="control">
3434
<input type="text" class="input" v-model="args[idx]">
@@ -214,3 +214,9 @@
214214
},
215215
}
216216
</script>
217+
218+
<style scoped>
219+
.modal-card-title {
220+
word-break: break-all;
221+
}
222+
</style>

spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/m-bean-operation.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
<template>
1818
<div class="field">
1919
<div class="control">
20-
<button class="button is-light is-fullwidth" @click="$emit('click', $event)">
21-
<small class="is-light is-muted" v-text="descriptor.ret" />&nbsp;<span v-text="name" />
20+
<button class="button is-light is-fullwidth columns has-text-left" @click="$emit('click', $event)">
21+
<small class="is-light is-muted column is-flex-grow-0 is-flex-shrink-0 p-1" v-text="shortenedRet" :title="descriptor.ret" />
22+
<span class="column is-flex-grow-1 is-flex-shrink-0 p-1 is-truncated" v-text="shortenedName" :title="name" />
2223
</button>
2324
<p class="help" v-text="descriptor.desc" />
2425
</div>
2526
</div>
2627
</template>
2728

2829
<script>
30+
import {truncateJavaType} from '@/views/instances/jolokia/utils';
31+
2932
export default {
3033
props: {
3134
name: {
@@ -37,5 +40,20 @@
3740
required: true
3841
}
3942
},
43+
computed: {
44+
shortenedName() {
45+
return truncateJavaType(this.name);
46+
},
47+
shortenedRet() {
48+
return truncateJavaType(this.descriptor.ret);
49+
}
50+
}
4051
}
4152
</script>
53+
54+
<style>
55+
.is-truncated {
56+
overflow: hidden;
57+
text-overflow: ellipsis;
58+
}
59+
</style>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2014-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export function truncateJavaType(javaType) {
18+
return javaType.replace(/java\.[^A-Z]*/g, '');
19+
}
20+
21+
/**
22+
* Truncates the given package name to the given length.
23+
*
24+
* It works similar to {@link https://logback.qos.ch/manual/layouts.html#conversionWord}
25+
*
26+
* @param javaType
27+
* @param length
28+
* @returns {string|*}
29+
*/
30+
export function truncatePackageName(javaType, length) {
31+
const split = javaType.split('.');
32+
if (length > 0) {
33+
const clazzName = split.pop();
34+
35+
let shortened;
36+
for (let i = 0; i <= split.length; i++) {
37+
shortened = [
38+
...[...split].splice(0, i).map(p => p.charAt(0)),
39+
...[...split].splice(i),
40+
clazzName
41+
].join('.');
42+
43+
if (shortened.length <= length) {
44+
return shortened;
45+
}
46+
}
47+
48+
return shortened;
49+
} else {
50+
return split?.pop();
51+
}
52+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2014-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {truncateJavaType, truncatePackageName} from '@/views/instances/jolokia/utils';
18+
19+
describe('utils.js', () => {
20+
it('truncateJavaType', () => {
21+
expect(truncateJavaType('java.lang.String')).toEqual('String');
22+
});
23+
24+
it.each`
25+
length | expected
26+
${0} | ${'Bar'}
27+
${5} | ${'m.s.s.Bar'}
28+
${10} | ${'m.s.s.Bar'}
29+
${15} | ${'m.s.sample.Bar'}
30+
${16} | ${'m.sub.sample.Bar'}
31+
${26} | ${'mainPackage.sub.sample.Bar'}
32+
`('truncatePackageName having length $length', ({expected, length}) => {
33+
const result = truncatePackageName('mainPackage.sub.sample.Bar', length);
34+
expect(result).toEqual(expected);
35+
});
36+
});

0 commit comments

Comments
 (0)