Skip to content

Commit 25075d0

Browse files
committed
Show total instance count in detail instance header
1 parent 67ae7c2 commit 25075d0

File tree

13 files changed

+135
-65
lines changed

13 files changed

+135
-65
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<url>https://github.com/codecentric/spring-boot-admin/</url>
2828
<properties>
2929
<revision>2.0.0-SNAPSHOT</revision>
30-
<spring-boot.version>2.0.0.RC2</spring-boot.version>
30+
<spring-boot.version>2.0.0.RELEASE</spring-boot.version>
3131
<spring-cloud.version>Finchley.M7</spring-cloud.version>
3232
<hazelcast-tests.version>3.9.2</hazelcast-tests.version>
3333
<java.version>1.8</java.version>

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

Lines changed: 23 additions & 22 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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@fortawesome/fontawesome": "^1.1.4",
13-
"@fortawesome/fontawesome-free-brands": "^5.0.7",
14-
"@fortawesome/fontawesome-free-regular": "^5.0.7",
15-
"@fortawesome/fontawesome-free-solid": "^5.0.7",
13+
"@fortawesome/fontawesome-free-brands": "^5.0.8",
14+
"@fortawesome/fontawesome-free-regular": "^5.0.8",
15+
"@fortawesome/fontawesome-free-solid": "^5.0.8",
1616
"@fortawesome/vue-fontawesome": "0.0.22",
1717
"axios": "^0.18.0",
1818
"bulma": "^0.6.2",
@@ -49,15 +49,15 @@
4949
"babel-preset-stage-2": "^6.24.1",
5050
"clean-webpack-plugin": "^0.1.18",
5151
"cross-env": "^5.1.3",
52-
"css-hot-loader": "^1.3.7",
52+
"css-hot-loader": "^1.3.8",
5353
"css-loader": "^0.28.10",
5454
"css-mqpacker": "^6.0.2",
5555
"eslint": "^4.18.1",
5656
"eslint-loader": "^1.9.0",
5757
"eslint-plugin-html": "^4.0.2",
5858
"eslint-plugin-vue": "^4.3.0",
5959
"extract-text-webpack-plugin": "^3.0.2",
60-
"file-loader": "^1.1.10",
60+
"file-loader": "^1.1.11",
6161
"glob": "^7.1.2",
6262
"html-loader": "^0.5.5",
6363
"html-webpack-plugin": "^2.30.0",
@@ -75,7 +75,7 @@
7575
"vue-svg-loader": "^0.5.0",
7676
"vue-template-compiler": "^2.5.13",
7777
"webpack": "^3.11.0",
78-
"webpack-bundle-analyzer": "^2.11.0"
78+
"webpack-bundle-analyzer": "^2.11.1"
7979
},
8080
"browserslist": [
8181
"> 2%",

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ new Vue({
5959
router,
6060
el: '#app',
6161
render(h) {
62-
return h(sbaShell);
62+
return h(sbaShell, {
63+
props: {
64+
applications: this.applications,
65+
error: this.error
66+
}
67+
});
6368
},
6469
data: {
6570
views: createViews(router),

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class Application {
2626
this.name = name;
2727
}
2828

29+
findInstance(instanceId) {
30+
return this.instances.find(instance => instance.id === instanceId);
31+
}
32+
2933
get isUnregisterable() {
3034
return this.instances.findIndex(i => i.isUnregisterable) >= 0;
3135
}
@@ -77,4 +81,4 @@ class Application {
7781
}
7882
}
7983

80-
export default Application;
84+
export default Application;

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,29 @@ import {Observable} from '@/utils/rxjs';
1919
export default class {
2020
constructor() {
2121
this.applications = [];
22+
this.applications.findInstance = (instanceId) => {
23+
for (let application of this.applications) {
24+
const instance = application.findInstance(instanceId);
25+
if (instance) {
26+
return instance;
27+
}
28+
}
29+
return undefined;
30+
};
31+
this.applications.findApplicationForInstance = (instanceId) => {
32+
return this.applications.find(application => !!application.findInstance(instanceId));
33+
};
34+
this.applications.indexOfApplication = (name) => {
35+
return this.applications.findIndex(application => application.name === name);
36+
};
37+
2238
this._listeners = {
2339
added: [],
2440
updated: [],
2541
removed: []
2642
};
2743
}
2844

29-
indexOf(name) {
30-
return this.applications.findIndex(application => application.name === name);
31-
}
32-
3345
addEventListener(type, listener) {
3446
if (!(type in this._listeners)) {
3547
this._listeners[type] = [];
@@ -68,7 +80,7 @@ export default class {
6880
.delay(5000)
6981
).subscribe({
7082
next: application => {
71-
const idx = this.indexOf(application.name);
83+
const idx = this.applications.indexOfApplication(application.name);
7284
if (idx >= 0) {
7385
const oldApplication = this.applications[idx];
7486
if (application.instances.length > 0) {
@@ -95,4 +107,4 @@ export default class {
95107
}
96108
}
97109
}
98-
}
110+
}

spring-boot-admin-server-ui/src/main/frontend/views/applications/handle.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@
3030
import logoOk from '@/assets/img/favicon.png';
3131
3232
export default {
33-
computed: {
34-
error() {
35-
return this.$root.error;
33+
props: {
34+
applications: {
35+
type: Array,
36+
default: () => [],
3637
},
38+
error: {
39+
type: Object,
40+
default: null
41+
}
42+
},
43+
computed: {
3744
downCount() {
38-
return this.$root.applications.reduce((current, next) => {
45+
return this.applications.reduce((current, next) => {
3946
return current + (next.instances.filter(instance => instance.statusInfo.status !== 'UP').length);
4047
}, 0);
4148
}

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,20 @@
6767
import handle from './handle';
6868
6969
const component = {
70+
props: {
71+
applications: {
72+
type: Array,
73+
default: () => [],
74+
},
75+
error: {
76+
type: Object,
77+
default: null
78+
}
79+
},
7080
components: {
7181
applicationsList,
7282
},
7383
computed: {
74-
applications() {
75-
return this.$root.applications;
76-
},
77-
error() {
78-
return this.$root.error;
79-
},
8084
statusGroups() {
8185
const byStatus = _.groupBy(this.applications, application => application.status);
8286
const list = _.transform(byStatus, (result, value, key) => {

spring-boot-admin-server-ui/src/main/frontend/views/instances/shell/header.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
<div class="columns">
2222
<div class="column is-narrow">
2323
<h1 class="title" v-if="instance" v-text="instance.registration.name"/>
24-
<h2 class="subtitle" v-if="instance" v-text="instance.id"/>
24+
<h2 class="subtitle" v-if="instance">
25+
Instance <strong v-text="instance.id"/> (of <span v-text="application.instances.length"/>)
26+
</h2>
2527
</div>
2628
<div class="column">
2729
<sba-status v-if="instance" :status="instance.statusInfo.status"
@@ -44,13 +46,18 @@
4446
</template>
4547

4648
<script>
49+
import Application from '@/services/application';
4750
import Instance from '@/services/instance';
4851
4952
export default {
5053
props: {
5154
instance: {
5255
type: Instance,
5356
default: null
57+
},
58+
application: {
59+
type: Application,
60+
default: null
5461
}
5562
}
5663
}

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616

1717
<template>
1818
<div>
19-
<sba-instance-header :instance="instance"/>
20-
<sba-instance-tabs :views="instanceViews" :instance="instance"/>
19+
<sba-instance-header :instance="instance" :application="application"/>
20+
<sba-instance-tabs :views="instanceViews" :instance="instance" :application="application"/>
2121
<router-view v-if="instance" :instance="instance"/>
2222
</div>
2323
</template>
2424

2525
<script>
26-
import instance from '@/services/instance'
2726
import sbaInstanceHeader from './header';
2827
import sbaInstanceTabs from './tabs';
2928
@@ -33,19 +32,26 @@
3332
instanceId: {
3433
type: String,
3534
required: true
35+
},
36+
applications: {
37+
type: Array,
38+
default: () => [],
39+
},
40+
error: {
41+
type: Object,
42+
default: null
3643
}
3744
},
38-
data: () => ({
39-
instance: null
40-
}),
4145
computed: {
46+
instance() {
47+
return this.applications.findInstance(this.instanceId);
48+
},
49+
application() {
50+
return this.applications.findApplicationForInstance(this.instanceId);
51+
},
4252
instanceViews() {
4353
return this.$root.views.filter(view => view.name.lastIndexOf('instance/') === 0);
4454
}
45-
},
46-
async created() {
47-
const res = await instance.get(this.instanceId);
48-
this.instance = res.data;
4955
}
5056
}
5157
</script>

0 commit comments

Comments
 (0)