diff --git a/web/composables/services/webgui.ts b/web/composables/services/webgui.ts index cc7f0b62b..d8104f0f0 100644 --- a/web/composables/services/webgui.ts +++ b/web/composables/services/webgui.ts @@ -40,7 +40,7 @@ export const WebguiState = request.url('/plugins/dynamix.my.servers/data/server- */ export interface WebguiUnraidApiCommandPayload { csrf_token: string; - command: 'report' | 'start'; + command: 'report' | 'restart' | 'start'; param1?: '-v'|'-vv'; } export const WebguiUnraidApiCommand = async (payload: WebguiUnraidApiCommandPayload) => { diff --git a/web/store/account.ts b/web/store/account.ts index 8e89e2d5e..fa7688720 100644 --- a/web/store/account.ts +++ b/web/store/account.ts @@ -211,6 +211,8 @@ export const useAccountStore = defineStore('account', () => { console.debug('[connectSignOutMutation]', res); accountActionStatus.value = 'success'; setQueueConnectSignOut(false); // reset + // Restarting the unraid api client to see if this helps remedy the unpredictable issue of needing to sign in twice + unraidApiStore.restartUnraidApiClient(); }); onError((error) => { diff --git a/web/store/server.ts b/web/store/server.ts index 24b885f31..35baa46d6 100644 --- a/web/store/server.ts +++ b/web/store/server.ts @@ -719,10 +719,14 @@ export const useServerStore = defineStore('server', () => { const mutateServerStateFromApi = (data: serverStateQuery): Server => { const mutatedData = { // if we get an owners obj back and the username is root we don't want to overwrite the values - ...(data.owner && data.owner.username !== 'root' && { + ...(data.owner && data.owner.username !== 'root' ? { // avatar: data.owner.avatar, username: data.owner.username, registered: true, + } : { // handles sign outs + // avatar: data.owner.avatar, + username: '', + registered: false, }), name: (data.info && data.info.os) ? data.info.os.hostname : null, keyfile: (data.registration && data.registration.keyFile) ? data.registration.keyFile.contents : null, diff --git a/web/store/unraidApi.ts b/web/store/unraidApi.ts index 5fd956863..9d5436649 100644 --- a/web/store/unraidApi.ts +++ b/web/store/unraidApi.ts @@ -168,13 +168,17 @@ export const useUnraidApiStore = defineStore('unraidApi', () => { unraidApiClient.value = undefined; unraidApiStatus.value = 'offline'; }; - + /** + * Can both start and restart the unraid-api depending on it's current status + */ const restartUnraidApiClient = async () => { + const command = unraidApiStatus.value === 'offline' ? 'start' : 'restart'; + console.debug('[restartUnraidApiClient]', { command }); unraidApiStatus.value = 'restarting'; try { const response = await WebguiUnraidApiCommand({ csrf_token: serverStore.csrf, - command: 'start', + command, }); console.debug('[restartUnraidApiClient] response', response); return setTimeout(() => {