diff --git a/web/src/lib/components/shared-components/announcement-box.svelte b/web/src/lib/components/shared-components/announcement-box.svelte deleted file mode 100644 index e6f378909a..0000000000 --- a/web/src/lib/components/shared-components/announcement-box.svelte +++ /dev/null @@ -1,64 +0,0 @@ - - -
- console.log('Click outside')}> -
-

🎉 NEW VERSION AVAILABLE 🎉

-
- -
-
- Hi friend, there is a new release of IMMICH, please take your time to visit the - release note - and ensure your docker-compose, and .env setup is up-to-date to prevent - any misconfigurations, especially if you use WatchTower or any mechanism that handles updating - your application automatically. -
- - {#if remoteVersion == 'v1.11.0_17-dev'} -
- This specific version v1.11.0_17-dev includes changes in - the docker-compose setup that added additional containters. Please make sure to update the - docker-compose file, pull new images and check your setup for the latest features and bug - fixes. -
- {/if} -
- -
Your friend, Alex
-
- Local Version {localVersion} -
- Remote Version {remoteVersion} -
- -
- -
-
-
-
diff --git a/web/src/lib/components/shared-components/version-announcement-box.svelte b/web/src/lib/components/shared-components/version-announcement-box.svelte new file mode 100644 index 0000000000..fde48ba3e0 --- /dev/null +++ b/web/src/lib/components/shared-components/version-announcement-box.svelte @@ -0,0 +1,82 @@ + + +{#if showModal} + (showModal = false)}> +
+

🎉 NEW VERSION AVAILABLE 🎉

+ +
+ Hi friend, there is a new release of + IMMICH, please take your time to visit the + release notes + and ensure your docker-compose, and .env setup is up-to-date to prevent + any misconfigurations, especially if you use WatchTower or any mechanism that handles updating + your application automatically. +
+ +
Your friend, Alex
+ +
+ Server Version: {serverVersionName} +
+ Latest Version: {githubVersion} +
+ +
+ +
+
+
+{/if} diff --git a/web/src/lib/utils/check-app-version.ts b/web/src/lib/utils/check-app-version.ts deleted file mode 100644 index cacf56dfd3..0000000000 --- a/web/src/lib/utils/check-app-version.ts +++ /dev/null @@ -1,50 +0,0 @@ -type CheckAppVersionReponse = { - shouldShowAnnouncement: boolean; - localVersion?: string; - remoteVersion?: string; -}; - -type GithubRelease = { - tag_name: string; -}; - -export const checkAppVersion = async (): Promise => { - const res = await fetch('https://api.github.com/repos/immich-app/immich/releases/latest', { - headers: { - Accept: 'application/vnd.github.v3+json' - } - }); - - if (res.status == 200) { - const latestRelease = (await res.json()) as GithubRelease; - const appVersion = localStorage.getItem('appVersion'); - - if (!appVersion) { - return { - shouldShowAnnouncement: false, - remoteVersion: latestRelease.tag_name, - localVersion: 'empty' - }; - } - - if (appVersion != latestRelease.tag_name) { - return { - shouldShowAnnouncement: true, - remoteVersion: latestRelease.tag_name, - localVersion: appVersion - }; - } - - return { - shouldShowAnnouncement: false, - remoteVersion: latestRelease.tag_name, - localVersion: appVersion - }; - } else { - return { - shouldShowAnnouncement: false, - remoteVersion: '0', - localVersion: '0' - }; - } -}; diff --git a/web/src/lib/utils/get-github-version.ts b/web/src/lib/utils/get-github-version.ts new file mode 100644 index 0000000000..e3ae98190e --- /dev/null +++ b/web/src/lib/utils/get-github-version.ts @@ -0,0 +1,18 @@ +import axios from 'axios'; + +type GithubRelease = { + tag_name: string; +}; + +export const getGithubVersion = async (): Promise => { + const { data } = await axios.get( + 'https://api.github.com/repos/immich-app/immich/releases/latest', + { + headers: { + Accept: 'application/vnd.github.v3+json' + } + } + ); + + return data.tag_name; +}; diff --git a/web/src/routes/+layout.server.ts b/web/src/routes/+layout.server.ts index 08b7f2518c..bf504b7efa 100644 --- a/web/src/routes/+layout.server.ts +++ b/web/src/routes/+layout.server.ts @@ -1,5 +1,7 @@ import type { LayoutServerLoad } from './$types'; -export const load = (async ({ locals: { user } }) => { - return { user }; +export const load = (async ({ locals: { api, user } }) => { + const { data: serverVersion } = await api.serverInfoApi.getServerVersion(); + + return { serverVersion, user }; }) satisfies LayoutServerLoad; diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 748d5078cf..7d3bf9ccf9 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -7,7 +7,9 @@ import DownloadPanel from '$lib/components/asset-viewer/download-panel.svelte'; import UploadPanel from '$lib/components/shared-components/upload-panel.svelte'; import NotificationList from '$lib/components/shared-components/notification/notification-list.svelte'; + import VersionAnnouncementBox from '$lib/components/shared-components/version-announcement-box.svelte'; import faviconUrl from '$lib/assets/favicon.png'; + import type { LayoutData } from './$types'; let showNavigationLoadingBar = false; @@ -18,6 +20,8 @@ afterNavigate(() => { showNavigationLoadingBar = false; }); + + export let data: LayoutData; @@ -50,3 +54,7 @@ + +{#if data.user?.isAdmin} + +{/if}