diff --git a/web/components/UserProfile/CallbackFeedback.vue b/web/components/UserProfile/CallbackFeedback.vue index 86985afe6..cc9486f82 100644 --- a/web/components/UserProfile/CallbackFeedback.vue +++ b/web/components/UserProfile/CallbackFeedback.vue @@ -1,6 +1,6 @@ @@ -237,38 +255,69 @@ const accountActionStatusCopy = computed((): { text: string; } => { :text="t('Enhance your experience with Unraid Connect')" /> --> + + + + + + {{ t('Current Version: Unraid {0}', [osVersion]) }} + + + + {{ t('New Version: {0}', [callbackUpdateRelease?.name]) }} + + + {{ t('This update will require a reboot') }} + + + + - + - - - + - + + + + + + + - + + + + diff --git a/web/locales/en_US.json b/web/locales/en_US.json index 9309a0a4b..1f0815a1c 100644 --- a/web/locales/en_US.json +++ b/web/locales/en_US.json @@ -60,6 +60,7 @@ "No thanks": "No thanks", "Learn more": "Learn more", "Install Connect": "Install Connect", + "Installing Connect": "Installing Connect", "Close Modal": "Close Modal", "Close": "Close", "Reload": "Reload", @@ -203,5 +204,11 @@ "Signing Out": "Signing Out", "Sign In requires the local unraid-api to be running": "Sign In requires the local unraid-api to be running", "Sign Out requires the local unraid-api to be running": "Sign Out requires the local unraid-api to be running", - "Unraid OS Update Available": "Unraid OS Update Available" + "Unraid OS Update Available": "Unraid OS Update Available", + "Update Unraid OS confirmation required": "Update Unraid OS confirmation required", + "Please confirm the update details below": "Please confirm the update details below", + "Current Version: Unraid {0}": "Current Version: Unraid {0}", + "New Version: {0}": "New Version: {0}", + "This update will require a reboot": "This update will require a reboot", + "Confirm and start update": "Confirm and start update" } diff --git a/web/store/updateOs.ts b/web/store/updateOs.ts index e9f88ff78..7ae843212 100644 --- a/web/store/updateOs.ts +++ b/web/store/updateOs.ts @@ -2,11 +2,14 @@ import { BellAlertIcon } from '@heroicons/vue/24/solid'; import { defineStore, createPinia, setActivePinia } from 'pinia'; import gt from 'semver/functions/gt'; +import useInstallPlugin from '~/composables/installPlugin'; import { request } from '~/composables/services/request'; import { ACCOUNT_CALLBACK, OS_RELEASES } from '~/helpers/urls'; import { useCallbackStore } from '~/store/callbackActions'; import { useErrorsStore } from '~/store/errors'; import { useServerStore } from '~/store/server'; +import type { InstallPluginPayload } from '~/composables/installPlugin'; +import type { OsRelease } from '~/store/callback'; import type { ServerStateDataAction } from '~/types/server'; /** @@ -15,29 +18,17 @@ import type { ServerStateDataAction } from '~/types/server'; */ setActivePinia(createPinia()); -export interface OsRelease { - basefile: string; // "unRAIDServer-6.12.4-x86_64.zip" - changelog: string; // "https://unraid-dl.sfo2.cdn.digitaloceanspaces.com/stable/unRAIDServer-6.12.4-x86_64.txt" - date: string; // "2023-08-31" - md5: string; // "df6e5859d28c14617efde36d59458206" - name: string; // "Unraid 6.12.4" - size: string; // "439999418" - url: string; // "https://unraid-dl.sfo2.cdn.digitaloceanspaces.com/stable/unRAIDServer-6.12.4-x86_64.zip" -} - export const useUpdateOsStore = defineStore('updateOs', () => { const callbackStore = useCallbackStore(); const errorsStore = useErrorsStore(); const serverStore = useServerStore(); + const { install: installPlugin } = useInstallPlugin(); + // State - const status = ref<'failed' | 'ready' | 'success' | 'updating' | 'downgrading'>('ready'); - const updateAvailable = ref(); - watchEffect(() => { - if (updateAvailable.value) { - console.debug('[useUpdateOsStore] updateAvailable', updateAvailable.value); - } - }); + const status = ref<'confirming' | 'failed' | 'ready' | 'success' | 'updating' | 'downgrading'>('ready'); + const callbackUpdateRelease = ref(); // used when coming back from callback, this will be the release to install + const updateAvailable = ref(); // used locally to show update action button const downgradeAvailable = ref(false); // Getters @@ -66,16 +57,6 @@ export const useUpdateOsStore = defineStore('updateOs', () => { } }; - const downgradeOs = async () => { - console.debug('[downgradeOs]'); - status.value = 'downgrading'; - }; - - const installOsUpdate = (plgUrl: string) => { - console.debug('[installOsUpdate]', plgUrl); - status.value = 'updating'; - }; - const initUpdateOsCallback = computed((): ServerStateDataAction => { return { click: () => { @@ -98,14 +79,46 @@ export const useUpdateOsStore = defineStore('updateOs', () => { } }); + const confirmUpdateOs = (payload: OsRelease) => { + console.debug('[confirmUpdateOs]'); + callbackUpdateRelease.value = payload; + setStatus('confirming'); + }; + + const installOsUpdate = () => { + console.debug('[installOsUpdate]', callbackUpdateRelease.value); + if (!callbackUpdateRelease.value) { + return console.error('[installOsUpdate] release not found'); + } + + status.value = 'updating'; + installPlugin({ + modalTitle: `${callbackUpdateRelease.value.name} Update`, + pluginUrl: callbackUpdateRelease.value.url, + update: true, + }); + }; + + const downgradeOs = async () => { + console.debug('[downgradeOs]'); + setStatus('downgrading'); + }; + + const setStatus = (payload: typeof status.value) => { + status.value = payload; + }; + return { // State + callbackUpdateRelease, status, updateAvailable, // Actions checkForOsUpdate, + confirmUpdateOs, downgradeOs, installOsUpdate, initUpdateOsCallback, + setStatus, }; });
+ {{ t('Current Version: Unraid {0}', [osVersion]) }} +
+ {{ t('New Version: {0}', [callbackUpdateRelease?.name]) }} +
+ {{ t('This update will require a reboot') }} +