diff --git a/komga-webui/src/main.ts b/komga-webui/src/main.ts index 174244f97..1782653d1 100644 --- a/komga-webui/src/main.ts +++ b/komga-webui/src/main.ts @@ -5,6 +5,7 @@ import * as lineClamp from 'vue-line-clamp' import Vuelidate from 'vuelidate' import { sync } from 'vuex-router-sync' import App from './App.vue' +import actuator from './plugins/actuator.plugin' import httpPlugin from './plugins/http.plugin' import komgaBooks from './plugins/komga-books.plugin' import komgaFileSystem from './plugins/komga-filesystem.plugin' @@ -24,6 +25,7 @@ Vue.use(komgaSeries, { http: Vue.prototype.$http }) Vue.use(komgaBooks, { http: Vue.prototype.$http }) Vue.use(komgaUsers, { store: store, http: Vue.prototype.$http }) Vue.use(komgaLibraries, { store: store, http: Vue.prototype.$http }) +Vue.use(actuator, { http: Vue.prototype.$http }) Vue.prototype.$_ = _ diff --git a/komga-webui/src/plugins/actuator.plugin.ts b/komga-webui/src/plugins/actuator.plugin.ts new file mode 100644 index 000000000..3f4267c1a --- /dev/null +++ b/komga-webui/src/plugins/actuator.plugin.ts @@ -0,0 +1,17 @@ +import ActuatorService from '@/services/actuator.service' +import { AxiosInstance } from 'axios' +import _Vue from 'vue' + +export default { + install ( + Vue: typeof _Vue, + { http }: { http: AxiosInstance }) { + Vue.prototype.$actuator = new ActuatorService(http) + } +} + +declare module 'vue/types/vue' { + interface Vue { + $actuator: ActuatorService; + } +} diff --git a/komga-webui/src/services/actuator.service.ts b/komga-webui/src/services/actuator.service.ts new file mode 100644 index 000000000..f8232fe3d --- /dev/null +++ b/komga-webui/src/services/actuator.service.ts @@ -0,0 +1,23 @@ +import { AxiosInstance } from 'axios' + +const API_ACTUATOR = '/actuator' + +export default class ActuatorService { + private http: AxiosInstance; + + constructor (http: AxiosInstance) { + this.http = http + } + + async getInfo (): Promise { + try { + return (await this.http.get(`${API_ACTUATOR}/info`)).data + } catch (e) { + let msg = 'An error occurred while trying to retrieve actuator info' + if (e.response.data.message) { + msg += `: ${e.response.data.message}` + } + throw new Error(msg) + } + } +} diff --git a/komga-webui/src/types/actuator.ts b/komga-webui/src/types/actuator.ts new file mode 100644 index 000000000..c592d6102 --- /dev/null +++ b/komga-webui/src/types/actuator.ts @@ -0,0 +1,22 @@ +interface ActuatorInfo { + git: ActuatorGit, + build: ActuatorBuild +} + +interface ActuatorGit { + commit: ActuatorGitCommit, + branch: string +} + +interface ActuatorGitCommit { + time: Date, + id: string +} + +interface ActuatorBuild { + version: string, + artifact: string, + name: string, + group: string, + time: Date +} diff --git a/komga-webui/src/views/Home.vue b/komga-webui/src/views/Home.vue index 2b93c3c07..7f0218362 100644 --- a/komga-webui/src/views/Home.vue +++ b/komga-webui/src/views/Home.vue @@ -96,6 +96,16 @@ + + + + @@ -115,7 +125,13 @@ export default Vue.extend({ data: function () { return { drawerVisible: this.$vuetify.breakpoint.lgAndUp, - modalAddLibrary: false + modalAddLibrary: false, + info: {} as ActuatorInfo + } + }, + async created () { + if (this.isAdmin) { + this.info = await this.$actuator.getInfo() } }, computed: {