mirror of
https://github.com/unraid/api.git
synced 2026-01-18 06:30:03 -06:00
feat(web): restart unraid-api after sign out
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user