mirror of
https://github.com/unraid/api.git
synced 2026-01-08 17:49:59 -06:00
chore(web): remove console debugs
This commit is contained in:
@@ -156,7 +156,6 @@ function registerServer(button) {
|
||||
"api_extraOrigins": validateExtraOrigins(),
|
||||
};
|
||||
|
||||
// console.debug(JSON.stringify(postobj,null,2))
|
||||
$(button).prop("disabled", true).html("_(Applying)_ <i class=\"fa fa-spinner fa-spin\" aria-hidden=\"true\"></i>");
|
||||
$.post('/webGui/include/Dispatcher.php', postobj, function(data2) {
|
||||
<?if(!$isRegistered):?>
|
||||
|
||||
@@ -19,12 +19,10 @@ let nonDefaultLocale = false;
|
||||
*/
|
||||
const windowLocaleData = (window as any).LOCALE_DATA || null;
|
||||
if (windowLocaleData) {
|
||||
console.debug('[I18nHost] parsing messages');
|
||||
try {
|
||||
parsedMessages = JSON.parse(decodeURIComponent(windowLocaleData));
|
||||
parsedLocale = Object.keys(parsedMessages)[0];
|
||||
nonDefaultLocale = parsedLocale !== defaultLocale;
|
||||
console.debug('[I18nHost] messages parsed. Now setting up vue-i18n', nonDefaultLocale, parsedLocale, parsedMessages);
|
||||
} catch (error) {
|
||||
console.error('[I18nHost] error parsing messages', error);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,9 @@ const trialStatusCopy = computed((): TrialStatusCopy | null => {
|
||||
});
|
||||
|
||||
const close = () => {
|
||||
if (trialStatus.value === 'trialStart') { return console.debug('[close] not allowed'); }
|
||||
if (trialStatus.value === 'trialStart') {
|
||||
return;
|
||||
}
|
||||
trialStore.setTrialStatus('ready');
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -33,7 +33,6 @@ onBeforeMount(() => {
|
||||
watchEffect(async () => {
|
||||
// if we don't have a client WAN IP AND we have the server WAN IP then we fetch
|
||||
if (!wanIp.value && props.phpWanIp) {
|
||||
console.debug('[watch] wanIp');
|
||||
loading.value = true;
|
||||
|
||||
const response = await request.url('https://wanip4.unraid.net/')
|
||||
@@ -41,7 +40,6 @@ watchEffect(async () => {
|
||||
.text();
|
||||
|
||||
if (response) {
|
||||
console.debug('[watch] wanIp response', response);
|
||||
loading.value = false;
|
||||
wanIp.value = response as string; // response returns text nothing to traverse
|
||||
// save in sessionStorage so we only make this request once per webGUI session
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
const useInstallPlugin = () => {
|
||||
const install = (payload = { staging: false, update: false }) => {
|
||||
console.debug('[useInstallPlugin.install]', { payload });
|
||||
try {
|
||||
const file = `https://sfo2.digitaloceanspaces.com/unraid-dl/unraid-api/dynamix.unraid.net${payload?.staging ? '.staging.plg' : '.plg'}`;
|
||||
console.debug('[useInstallPlugin.install]', file);
|
||||
|
||||
if (!payload.update) {
|
||||
// after initial install, the dropdown store looks for this to automatically open the launchpad dropdown
|
||||
@@ -13,7 +11,6 @@ const useInstallPlugin = () => {
|
||||
|
||||
// @ts-ignore – `openPlugin` will be included in 6.10.4+ DefaultPageLayout
|
||||
if (typeof openPlugin === 'function') {
|
||||
console.debug('[useInstallPlugin.install] using openPlugin', file);
|
||||
|
||||
// @ts-ignore
|
||||
openPlugin(
|
||||
@@ -23,7 +20,6 @@ const useInstallPlugin = () => {
|
||||
'refresh',
|
||||
);
|
||||
} else {
|
||||
console.debug('[useInstallPlugin.install] using openBox', file);
|
||||
// `openBox()` is defined in the webgui's DefaultPageLayout.php and used when openPlugin is not available
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
@@ -44,7 +44,6 @@ export interface WebguiUnraidApiCommandPayload {
|
||||
param1?: '-v'|'-vv';
|
||||
}
|
||||
export const WebguiUnraidApiCommand = async (payload: WebguiUnraidApiCommandPayload) => {
|
||||
console.debug('[WebguiUnraidApiCommand]', payload);
|
||||
if (!payload) { return console.error('[WebguiUnraidApiCommand] payload is required'); }
|
||||
|
||||
try {
|
||||
@@ -53,13 +52,12 @@ export const WebguiUnraidApiCommand = async (payload: WebguiUnraidApiCommandPayl
|
||||
.formUrl(payload)
|
||||
.post()
|
||||
.json((json) => {
|
||||
console.debug('[WebguiUnraidApiCommand]', json);
|
||||
return json;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(`[WebguiUnraidApiCommand] catch failed to execute unraid-api ${command}`, error);
|
||||
console.error(`[WebguiUnraidApiCommand] catch failed to execute unraid-api ${payload}`, error);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`[WebguiUnraidApiCommand] catch failed to execute unraid-api ${command}`, error);
|
||||
console.error(`[WebguiUnraidApiCommand] catch failed to execute unraid-api ${payload}`, error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
|
||||
// Actions
|
||||
const recover = () => {
|
||||
console.debug('[accountStore.recover]');
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -42,7 +41,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
);
|
||||
};
|
||||
const replace = () => {
|
||||
console.debug('[accountStore.replace]');
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -55,7 +53,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
);
|
||||
};
|
||||
const signIn = () => {
|
||||
console.debug('[accountStore.signIn]');
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -68,7 +65,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
);
|
||||
};
|
||||
const signOut = () => {
|
||||
console.debug('[accountStore.signOut]');
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -81,7 +77,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
);
|
||||
};
|
||||
const trialExtend = () => {
|
||||
console.debug('[accountStore.trialExtend]');
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -94,7 +89,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
);
|
||||
};
|
||||
const trialStart = () => {
|
||||
console.debug('[accountStore.trialStart]');
|
||||
callbackStore.send(
|
||||
ACCOUNT_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -111,7 +105,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
* @note unraid-api requires apikey & token realted keys to be lowercase
|
||||
*/
|
||||
const updatePluginConfig = async (action: ExternalSignIn | ExternalSignOut) => {
|
||||
console.debug('[accountStore.updatePluginConfig]', action);
|
||||
// save any existing username before updating
|
||||
if (serverStore.username) { username.value = serverStore.username; }
|
||||
|
||||
@@ -119,7 +112,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
accountActionStatus.value = 'updating';
|
||||
|
||||
if (!serverStore.registered && !accountAction.value.user) {
|
||||
console.debug('[accountStore.updatePluginConfig] Not registered skipping sign out');
|
||||
accountActionHide.value = true;
|
||||
accountActionStatus.value = 'success';
|
||||
return;
|
||||
@@ -154,11 +146,9 @@ export const useAccountStore = defineStore('account', () => {
|
||||
})
|
||||
.post()
|
||||
.res((res) => {
|
||||
console.debug('[accountStore.updatePluginConfig] WebguiUpdate res', res);
|
||||
accountActionStatus.value = 'success';
|
||||
})
|
||||
.catch((err) => {
|
||||
console.debug('[accountStore.updatePluginConfig] WebguiUpdate err', err);
|
||||
accountActionStatus.value = 'failed';
|
||||
errorsStore.setError({
|
||||
heading: 'Failed to update Connect account configuration',
|
||||
@@ -170,7 +160,6 @@ export const useAccountStore = defineStore('account', () => {
|
||||
});
|
||||
return response;
|
||||
} catch (err) {
|
||||
console.debug('[accountStore.updatePluginConfig] WebguiUpdate catch err', err);
|
||||
accountActionStatus.value = 'failed';
|
||||
errorsStore.setError({
|
||||
heading: 'Failed to update Connect account configuration',
|
||||
|
||||
@@ -20,8 +20,6 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
|
||||
const saveCallbackData = (
|
||||
decryptedData?: QueryPayloads,
|
||||
) => {
|
||||
console.debug('[saveCallbackData]', { decryptedData });
|
||||
|
||||
if (decryptedData) {
|
||||
callbackData.value = decryptedData;
|
||||
}
|
||||
@@ -34,8 +32,6 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
|
||||
};
|
||||
|
||||
const redirectToCallbackType = () => {
|
||||
console.debug('[redirectToCallbackType]');
|
||||
|
||||
if (!callbackData.value || !callbackData.value.type || callbackData.value.type !== 'forUpc' || !callbackData.value.actions?.length) {
|
||||
callbackError.value = 'Callback redirect type not present or incorrect';
|
||||
callbackStatus.value = 'ready'; // default status
|
||||
@@ -46,7 +42,6 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
|
||||
|
||||
// Parse the data and perform actions
|
||||
callbackData.value.actions.forEach(async (action, index, array) => {
|
||||
console.debug('[action]', action);
|
||||
if (action?.keyUrl) {
|
||||
await installKeyStore.install(action as ExternalKeyActions);
|
||||
}
|
||||
@@ -73,7 +68,6 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
|
||||
const setCallbackStatus = (status: CallbackStatus) => { callbackStatus.value = status; };
|
||||
|
||||
watch(callbackStatus, (newVal, oldVal) => {
|
||||
console.debug('[callbackStatus]', newVal);
|
||||
if (newVal === 'loading') {
|
||||
addPreventClose();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ export const useDropdownStore = defineStore('dropdown', () => {
|
||||
*/
|
||||
const serverStateEnokeyfile = computed(() => serverStore.state === 'ENOKEYFILE');
|
||||
watch(serverStateEnokeyfile, (newVal, oldVal) => {
|
||||
console.debug('[watch.serverStateEnokeyfile]', newVal, oldVal);
|
||||
const autoOpenSessionStorage = `unraid_${serverStore.guid.slice(-12) ?? 'NO_GUID'}_ENOKEYFILE`;
|
||||
if (newVal && !sessionStorage.getItem(autoOpenSessionStorage)) {
|
||||
sessionStorage.setItem(autoOpenSessionStorage, 'true');
|
||||
|
||||
@@ -42,7 +42,6 @@ export const useErrorsStore = defineStore('errors', () => {
|
||||
};
|
||||
|
||||
const setError = (error: Error) => {
|
||||
console.debug('[setError]', error);
|
||||
errors.value.push(error);
|
||||
};
|
||||
|
||||
@@ -52,27 +51,22 @@ export const useErrorsStore = defineStore('errors', () => {
|
||||
}
|
||||
|
||||
const openTroubleshoot = async (payload: TroubleshootPayload) => {
|
||||
console.debug('[openTroubleshoot]', payload);
|
||||
try {
|
||||
// @ts-ignore – `FeedbackButton` will be included in 6.10.4+ DefaultPageLayout
|
||||
await FeedbackButton();
|
||||
// once the modal is visible we need to select the radio to correctly show the bug report form
|
||||
let $modal = document.querySelector('.sweet-alert.visible');
|
||||
while (!$modal) {
|
||||
console.debug('[openTroubleshoot] getting $modal…');
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
$modal = document.querySelector('.sweet-alert.visible');
|
||||
}
|
||||
console.debug('[openTroubleshoot] $modal', $modal);
|
||||
// autofill errors into the bug report form
|
||||
if (errors.value.length) {
|
||||
let $textarea: HTMLInputElement | null = $modal.querySelector('#troubleshootDetails');
|
||||
while (!$textarea) {
|
||||
console.debug('[openTroubleshoot] getting $textarea…');
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
$textarea = $modal.querySelector('#troubleshootDetails');
|
||||
}
|
||||
console.debug('[openTroubleshoot] $textarea', $textarea);
|
||||
const errorMessages = errors.value.map((error, index) => {
|
||||
const index1 = index + 1;
|
||||
let message = `• Error ${index1}: ${error.heading}\n`;
|
||||
@@ -91,11 +85,9 @@ export const useErrorsStore = defineStore('errors', () => {
|
||||
// autofill emails
|
||||
let $emailInput: HTMLInputElement | null = $modal.querySelector('#troubleshootEmail');
|
||||
while (!$emailInput) {
|
||||
console.debug('[openTroubleshoot] getting $emailInput…');
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
$emailInput = $modal.querySelector('#troubleshootEmail');
|
||||
}
|
||||
console.debug('[openTroubleshoot] $emailInput', $emailInput);
|
||||
if (payload.email) {
|
||||
$emailInput.value = payload.email;
|
||||
} else {
|
||||
|
||||
@@ -29,7 +29,6 @@ export const useInstallKeyStore = defineStore('installKey', () => {
|
||||
});
|
||||
|
||||
const install = async (action: ExternalKeyActions) => {
|
||||
console.debug('[install]');
|
||||
keyInstallStatus.value = 'installing';
|
||||
keyAction.value = action;
|
||||
|
||||
@@ -68,10 +67,6 @@ export const useInstallKeyStore = defineStore('installKey', () => {
|
||||
}
|
||||
};
|
||||
|
||||
watch(keyInstallStatus, (newV, oldV) => {
|
||||
console.debug('[keyInstallStatus]', newV, oldV);
|
||||
});
|
||||
|
||||
return {
|
||||
// State
|
||||
keyInstallStatus,
|
||||
|
||||
@@ -15,7 +15,6 @@ export const usePurchaseStore = defineStore('purchase', () => {
|
||||
const serverStore = useServerStore();
|
||||
|
||||
const redeem = () => {
|
||||
console.debug('[serverStore.redeem]');
|
||||
callbackStore.send(
|
||||
PURCHASE_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -28,7 +27,6 @@ export const usePurchaseStore = defineStore('purchase', () => {
|
||||
);
|
||||
};
|
||||
const purchase = () => {
|
||||
console.debug('[serverStore.purchase]');
|
||||
callbackStore.send(
|
||||
PURCHASE_CALLBACK.toString(),
|
||||
[{
|
||||
@@ -41,7 +39,6 @@ export const usePurchaseStore = defineStore('purchase', () => {
|
||||
);
|
||||
};
|
||||
const upgrade = () => {
|
||||
console.debug('[serverStore.upgrade]');
|
||||
callbackStore.send(
|
||||
PURCHASE_CALLBACK.toString(),
|
||||
[{
|
||||
|
||||
@@ -544,7 +544,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
|
||||
// Keeping separate from validApiKeyLength because we may want to add more checks. Cloud also help with debugging user error submissions.
|
||||
if (apiKey.value.length !== 64) {
|
||||
console.debug('[invalidApiKey] invalid length');
|
||||
return {
|
||||
heading: 'Invalid API Key',
|
||||
level: 'error',
|
||||
@@ -554,7 +553,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
};
|
||||
}
|
||||
if (!apiKey.value.startsWith('unupc_')) {
|
||||
console.debug('[invalidApiKey] invalid for upc');
|
||||
return {
|
||||
heading: 'Invalid API Key Format',
|
||||
level: 'error',
|
||||
@@ -566,7 +564,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
return undefined;
|
||||
});
|
||||
watch(invalidApiKey, (newVal, oldVal) => {
|
||||
console.debug('[watch:invalidApiKey]', newVal, oldVal);
|
||||
if (oldVal && oldVal.ref) { errorsStore.removeErrorByRef(oldVal.ref); }
|
||||
if (newVal) { errorsStore.setError(newVal); }
|
||||
});
|
||||
@@ -584,7 +581,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
return undefined;
|
||||
});
|
||||
watch(tooManyDevices, (newVal, oldVal) => {
|
||||
console.debug('[watch:tooManyDevices]', newVal, oldVal);
|
||||
if (oldVal && oldVal.ref) { errorsStore.removeErrorByRef(oldVal.ref); }
|
||||
if (newVal) { errorsStore.setError(newVal); }
|
||||
});
|
||||
@@ -610,7 +606,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
return undefined;
|
||||
});
|
||||
watch(pluginInstallFailed, (newVal, oldVal) => {
|
||||
console.debug('[watch:pluginInstallFailed]', newVal, oldVal);
|
||||
if (oldVal && oldVal.ref) { errorsStore.removeErrorByRef(oldVal.ref); }
|
||||
if (newVal) { errorsStore.setError(newVal); }
|
||||
});
|
||||
@@ -643,7 +638,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
}
|
||||
: undefined));
|
||||
watch(deprecatedUnraidSSL, (newVal, oldVal) => {
|
||||
console.debug('[watch:deprecatedUnraidSSL]', newVal, oldVal);
|
||||
if (oldVal && oldVal.ref) { errorsStore.removeErrorByRef(oldVal.ref); }
|
||||
if (newVal) { errorsStore.setError(newVal); }
|
||||
});
|
||||
@@ -672,7 +666,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
};
|
||||
});
|
||||
watch(cloudError, (newVal, oldVal) => {
|
||||
console.debug('[watch:cloudError]', newVal, oldVal);
|
||||
if (oldVal && oldVal.ref) { errorsStore.removeErrorByRef(oldVal.ref); }
|
||||
if (newVal) { errorsStore.setError(newVal); }
|
||||
});
|
||||
@@ -692,20 +685,16 @@ export const useServerStore = defineStore('server', () => {
|
||||
*/
|
||||
const registeredWithValidApiKey = computed(() => registered.value && !invalidApiKey.value);
|
||||
watch(registeredWithValidApiKey, (newVal, oldVal) => {
|
||||
console.debug('[watch:registeredWithValidApiKey]', newVal, oldVal);
|
||||
if (oldVal) {
|
||||
console.debug('[watch:registeredWithValidApiKey] no apiKey, stop unraid-api client');
|
||||
return unraidApiStore.closeUnraidApiClient();
|
||||
}
|
||||
if (newVal) {
|
||||
// if this is just after sign in, let's delay the start by a few seconds to give unraid-api time to update
|
||||
if (accountStore.accountActionType === 'signIn') {
|
||||
console.debug('[watch:registeredWithValidApiKey] delay start unraid-api client');
|
||||
return setTimeout(() => {
|
||||
unraidApiStore.createApolloClient();
|
||||
}, 2000);
|
||||
} else {
|
||||
console.debug('[watch:registeredWithValidApiKey] new apiKey, start unraid-api client');
|
||||
return unraidApiStore.createApolloClient();
|
||||
}
|
||||
}
|
||||
@@ -714,7 +703,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
* Actions
|
||||
*/
|
||||
const setServer = (data: Server) => {
|
||||
console.debug('[setServer] data', data);
|
||||
if (typeof data?.apiKey !== 'undefined') { apiKey.value = data.apiKey; }
|
||||
if (typeof data?.apiVersion !== 'undefined') { apiVersion.value = data.apiVersion; }
|
||||
if (typeof data?.avatar !== 'undefined') { avatar.value = data.avatar; }
|
||||
@@ -745,7 +733,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
if (typeof data?.uptime !== 'undefined') { uptime.value = data.uptime; }
|
||||
if (typeof data?.username !== 'undefined') { username.value = data.username; }
|
||||
if (typeof data?.wanFQDN !== 'undefined') { wanFQDN.value = data.wanFQDN; }
|
||||
console.debug('[setServer] server', server.value);
|
||||
};
|
||||
|
||||
const mutateServerStateFromApi = (data: serverStateQuery): Server => {
|
||||
@@ -769,7 +756,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
expireTime: (data.registration && data.registration.expiration) ? data.registration.expiration : 0,
|
||||
...(data.cloud && { cloud: data.cloud }),
|
||||
};
|
||||
console.debug('[mutateServerStateFromApi] mutatedData', mutatedData);
|
||||
return mutatedData;
|
||||
};
|
||||
|
||||
@@ -781,7 +767,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
const serverState = computed(() => resultServerState.value ?? null);
|
||||
apiServerStateRefresh.value = refetchServerState;
|
||||
watch(serverState, (value) => {
|
||||
console.debug('[watch:serverState]', value);
|
||||
if (value) {
|
||||
const mutatedServerStateResult = mutateServerStateFromApi(value);
|
||||
setServer(mutatedServerStateResult);
|
||||
@@ -791,12 +776,10 @@ export const useServerStore = defineStore('server', () => {
|
||||
};
|
||||
|
||||
const phpServerStateRefresh = async () => {
|
||||
console.debug('[phpServerStateRefresh] start');
|
||||
try {
|
||||
const stateResponse: Server = await WebguiState
|
||||
.get()
|
||||
.json();
|
||||
console.debug('[phpServerStateRefresh] stateResponse', stateResponse);
|
||||
setServer(stateResponse);
|
||||
return stateResponse;
|
||||
} catch (error) {
|
||||
@@ -811,7 +794,6 @@ export const useServerStore = defineStore('server', () => {
|
||||
const refreshServerState = async () => {
|
||||
// If we've reached the refresh limit, stop refreshing
|
||||
if (refreshCount >= refreshLimit) {
|
||||
console.debug('[refreshServerState] refresh limit reached, stop refreshing');
|
||||
refreshServerStateStatus.value = 'timeout';
|
||||
return false;
|
||||
}
|
||||
@@ -822,43 +804,27 @@ export const useServerStore = defineStore('server', () => {
|
||||
const oldRegistered = registered.value;
|
||||
const oldState = state.value;
|
||||
const fromApi = !!apiServerStateRefresh.value;
|
||||
console.debug('[refreshServerState] start', {
|
||||
fromApi,
|
||||
refreshCount,
|
||||
});
|
||||
// Fetch the server state from the API or PHP
|
||||
const response = fromApi
|
||||
? await apiServerStateRefresh.value()
|
||||
: await phpServerStateRefresh();
|
||||
if (!response) {
|
||||
console.debug('[refreshServerState] no response, fetch again in 250ms…');
|
||||
return setTimeout(() => {
|
||||
refreshServerState();
|
||||
}, refreshTimeout);
|
||||
}
|
||||
console.debug('[refreshServerState] response', response);
|
||||
// Extract the new values from the response
|
||||
const newRegistered = fromApi && response?.data ? !!response.data.owner.username : response.registered;
|
||||
const newState = fromApi && response?.data ? response.data.vars.regState : response.state;
|
||||
// Compare the new values to the old values
|
||||
const registrationStatusChanged = oldRegistered !== newRegistered;
|
||||
const stateChanged = oldState !== newState;
|
||||
console.debug('[refreshServerState] newState', {
|
||||
oldRegistered,
|
||||
newRegistered,
|
||||
oldState,
|
||||
newState,
|
||||
registrationStatusChanged,
|
||||
stateChanged,
|
||||
});
|
||||
// If the registration status or state changed, stop refreshing
|
||||
if (registrationStatusChanged || stateChanged) {
|
||||
console.debug('[refreshServerState] change detected, stop refreshing', { registrationStatusChanged, stateChanged });
|
||||
refreshServerStateStatus.value = 'done';
|
||||
return true;
|
||||
}
|
||||
// If we haven't reached the refresh limit, try again
|
||||
console.debug('[refreshServerState] no change, fetch again in 250ms…', { registrationStatusChanged, stateChanged });
|
||||
setTimeout(() => {
|
||||
return refreshServerState();
|
||||
}, refreshTimeout);
|
||||
|
||||
@@ -30,7 +30,6 @@ export const useThemeStore = defineStore('theme', () => {
|
||||
});
|
||||
// Actions
|
||||
const setTheme = (data: Theme) => {
|
||||
console.debug('[setTheme]');
|
||||
theme.value = data;
|
||||
};
|
||||
const setCssVars = () => {
|
||||
|
||||
@@ -26,14 +26,12 @@ export const useTrialStore = defineStore('trial', () => {
|
||||
const trialModalVisible = computed(() => trialStatus.value === 'failed' || trialStatus.value === 'trialExtend' || trialStatus.value === 'trialStart');
|
||||
|
||||
const requestTrial = async (type?: TrialExtend | TrialStart) => {
|
||||
console.debug('[requestTrial]');
|
||||
try {
|
||||
const payload = {
|
||||
guid: serverStore.guid,
|
||||
timestamp: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
const response: StartTrialResponse = await startTrial(payload).json();
|
||||
console.debug('[requestTrial]', response);
|
||||
if (!response.license) {
|
||||
trialStatus.value = 'failed';
|
||||
return console.error('[requestTrial]', 'No license returned', response);
|
||||
@@ -49,7 +47,6 @@ export const useTrialStore = defineStore('trial', () => {
|
||||
sender: window.location.href,
|
||||
type: 'forUpc',
|
||||
};
|
||||
console.debug('[requestTrial]', trialStartData);
|
||||
trialStatus.value = 'success';
|
||||
return callbackActionsStore.redirectToCallbackType(trialStartData);
|
||||
} catch (error) {
|
||||
@@ -62,8 +59,7 @@ export const useTrialStore = defineStore('trial', () => {
|
||||
trialStatus.value = status;
|
||||
};
|
||||
|
||||
watch(trialStatus, (newVal, oldVal) => {
|
||||
console.debug('[trialStatus]', newVal, oldVal);
|
||||
watch(trialStatus, (newVal) => {
|
||||
// opening
|
||||
if (newVal === 'trialExtend' || newVal === 'trialStart') {
|
||||
addPreventClose();
|
||||
|
||||
@@ -29,14 +29,12 @@ const httpEndpoint = GRAPHQL;
|
||||
const wsEndpoint = new URL(GRAPHQL.toString().replace('http', 'ws'));
|
||||
|
||||
export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
console.debug('[useUnraidApiStore]');
|
||||
const accountStore = useAccountStore();
|
||||
// const errorsStore = useErrorsStore();
|
||||
const serverStore = useServerStore();
|
||||
|
||||
const unraidApiClient = ref<ApolloClient<any>>();
|
||||
watch(unraidApiClient, (newVal, oldVal) => {
|
||||
console.debug('[watch:unraidApiStore.unraidApiClient]', { newVal, oldVal });
|
||||
if (newVal) {
|
||||
const apiResponse = serverStore.fetchServerFromApi();
|
||||
if (apiResponse) {
|
||||
@@ -48,9 +46,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
|
||||
// const unraidApiErrors = ref<any[]>([]);
|
||||
const unraidApiStatus = ref<'connecting' | 'offline' | 'online' | 'restarting'>('offline');
|
||||
watch(unraidApiStatus, (newVal, oldVal) => {
|
||||
console.debug('[watch:unraidApiStore.unraidApiStatus]', { newVal, oldVal });
|
||||
});
|
||||
|
||||
const unraidApiRestartAction = computed((): UserProfileLink | undefined => {
|
||||
const { connectPluginInstalled, stateDataError } = serverStore;
|
||||
@@ -69,9 +64,9 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
* Automatically called when an apiKey is set in the serverStore
|
||||
*/
|
||||
const createApolloClient = () => {
|
||||
console.debug('[useUnraidApiStore.createApolloClient]', serverStore.apiKey);
|
||||
// sign out imminent, skipping createApolloClient
|
||||
if (accountStore.accountActionType === 'signOut') {
|
||||
return console.debug('[useUnraidApiStore.createApolloClient] sign out imminent, skipping createApolloClient');
|
||||
return;
|
||||
}
|
||||
|
||||
unraidApiStatus.value = 'connecting';
|
||||
@@ -97,7 +92,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
*/
|
||||
const errorLink = onError(({ graphQLErrors, networkError }) => {
|
||||
if (graphQLErrors) {
|
||||
console.debug('[GraphQL error]', graphQLErrors);
|
||||
graphQLErrors.map((error) => {
|
||||
console.error('[GraphQL error]', error, error.error.message);
|
||||
if (error.error.message.includes('offline')) {
|
||||
@@ -108,7 +102,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
}
|
||||
return error.message;
|
||||
});
|
||||
console.debug('[GraphQL error]', graphQLErrors);
|
||||
}
|
||||
|
||||
if (networkError && !prioritizeCorsError) {
|
||||
@@ -125,7 +118,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
attempts: {
|
||||
max: 20,
|
||||
retryIf: (error, _operation) => {
|
||||
console.debug('[retryLink.retryIf]', { error, _operation, prioritizeCorsError });
|
||||
return !!error && !prioritizeCorsError; // don't retry when ERROR_CORS_403
|
||||
},
|
||||
},
|
||||
@@ -164,14 +156,14 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
});
|
||||
|
||||
provideApolloClient(unraidApiClient.value);
|
||||
console.debug('[useUnraidApiStore.createApolloClient] 🏁 CREATED');
|
||||
};
|
||||
/**
|
||||
* Automatically called when an apiKey is unset in the serverStore
|
||||
*/
|
||||
const closeUnraidApiClient = async () => {
|
||||
console.debug('[useUnraidApiStore.closeUnraidApiClient] STARTED');
|
||||
if (!unraidApiClient.value) { return console.debug('[useUnraidApiStore.closeUnraidApiClient] unraidApiClient not set'); }
|
||||
if (!unraidApiClient.value) {
|
||||
return;
|
||||
}
|
||||
if (unraidApiClient.value) {
|
||||
await unraidApiClient.value.clearStore();
|
||||
unraidApiClient.value.stop();
|
||||
@@ -179,7 +171,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
}
|
||||
unraidApiClient.value = undefined;
|
||||
unraidApiStatus.value = 'offline';
|
||||
console.debug('[useUnraidApiStore.closeUnraidApiClient] DONE');
|
||||
};
|
||||
|
||||
const restartUnraidApiClient = async () => {
|
||||
@@ -188,7 +179,6 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
csrf_token: serverStore.csrf,
|
||||
command: 'start',
|
||||
});
|
||||
console.debug('[restartUnraidApiClient]', response);
|
||||
return setTimeout(() => {
|
||||
if (unraidApiClient.value) {
|
||||
createApolloClient();
|
||||
|
||||
Reference in New Issue
Block a user