Skip to content

Commit

Permalink
feat: display version in UI
Browse files Browse the repository at this point in the history
closes #42
  • Loading branch information
gotson committed Jan 6, 2020
1 parent 1f9b7cf commit 4085f1f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions komga-webui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.$_ = _

Expand Down
17 changes: 17 additions & 0 deletions komga-webui/src/plugins/actuator.plugin.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
23 changes: 23 additions & 0 deletions komga-webui/src/services/actuator.service.ts
Original file line number Diff line number Diff line change
@@ -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<ActuatorInfo> {
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)
}
}
}
22 changes: 22 additions & 0 deletions komga-webui/src/types/actuator.ts
Original file line number Diff line number Diff line change
@@ -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
}
18 changes: 17 additions & 1 deletion komga-webui/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@
</v-list-item-content>
</v-list-item>
</v-list>

<v-spacer/>

<template v-slot:append>
<div v-if="isAdmin && !$_.isEmpty(info)"
class="pa-2 pb-6 caption"
>
<div>v{{ info.build.version }}-{{ info.git.branch }}</div>
</div>
</template>
</v-navigation-drawer>

<v-content>
Expand All @@ -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: {
Expand Down

0 comments on commit 4085f1f

Please sign in to comment.