From 91d132f612497f03f52a9238d1b9ce387f2ec8ad Mon Sep 17 00:00:00 2001 From: hay-kot Date: Sun, 28 Mar 2021 16:11:12 -0800 Subject: [PATCH] add version tag --- frontend/src/App.vue | 2 +- .../src/components/Admin/AdminSidebar.vue | 67 +++++++++++++++++-- frontend/src/pages/Admin/index.vue | 43 ++---------- 3 files changed, 65 insertions(+), 47 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 3584609a3..7169d457b 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -34,8 +34,8 @@ - + diff --git a/frontend/src/components/Admin/AdminSidebar.vue b/frontend/src/components/Admin/AdminSidebar.vue index 381e2946c..fec699d86 100644 --- a/frontend/src/components/Admin/AdminSidebar.vue +++ b/frontend/src/components/Admin/AdminSidebar.vue @@ -72,6 +72,32 @@ {{ nav.title }} + + + + + + mdi-information + + + + + {{ $t("settings.current") }} + {{ version }} + + + + {{ $t("settings.latest") }} + {{ latestVersion }} + + + + + @@ -80,10 +106,14 @@ import { validators } from "@/mixins/validators"; import { initials } from "@/mixins/initials"; import { user } from "@/mixins/user"; +import api from "@/api"; +import axios from "axios"; export default { mixins: [validators, initials, user], data() { return { + latestVersion: null, + version: null, hideImage: false, showSidebar: false, mobile: false, @@ -92,39 +122,39 @@ export default { { icon: "mdi-cog", to: "/admin/settings", - title: this.$t('settings.site-settings'), + title: this.$t("settings.site-settings"), }, { icon: "mdi-account-group", to: "/admin/manage-users", - title: this.$t('settings.manage-users'), + title: this.$t("settings.manage-users"), }, { icon: "mdi-backup-restore", to: "/admin/backups", - title: this.$t('settings.backup-and-exports'), + title: this.$t("settings.backup-and-exports"), }, { icon: "mdi-database-import", to: "/admin/migrations", - title: this.$t('settings.migrations'), + title: this.$t("settings.migrations"), }, ], baseLinks: [ { icon: "mdi-account", to: "/admin/profile", - title: this.$t('settings.profile'), + title: this.$t("settings.profile"), }, { icon: "mdi-format-color-fill", to: "/admin/themes", - title: this.$t('general.themes'), + title: this.$t("general.themes"), }, { icon: "mdi-food", to: "/admin/meal-planner", - title: this.$t('meal-plan.meal-planner'), + title: this.$t("meal-plan.meal-planner"), }, ], }; @@ -132,12 +162,18 @@ export default { async mounted() { this.mobile = this.viewScale(); this.showSidebar = !this.viewScale(); + this.getVersion(); + let versionData = await api.meta.get_version(); + this.version = versionData.version; }, computed: { userProfileImage() { return `api/users/${this.user.id}/image`; }, + newVersionAvailable() { + return this.latestVersion == this.version ? false : true; + }, }, methods: { @@ -151,9 +187,26 @@ export default { return false; } }, + async getVersion() { + let response = await axios.get( + "https://api.github.com/repos/hay-kot/mealie/releases/latest", + { + headers: { + "content-type": "application/json", + Authorization: null, + }, + } + ); + this.latestVersion = response.data.tag_name; + }, }, }; \ No newline at end of file diff --git a/frontend/src/pages/Admin/index.vue b/frontend/src/pages/Admin/index.vue index b4743cffe..f59fe48af 100644 --- a/frontend/src/pages/Admin/index.vue +++ b/frontend/src/pages/Admin/index.vue @@ -1,12 +1,12 @@