mirror of
https://github.com/unraid/api.git
synced 2026-01-06 08:39:54 -06:00
fix: lint issues
This commit is contained in:
@@ -54,7 +54,7 @@ const {
|
||||
* regExp may not have a value until we get a response from the refreshServerState action
|
||||
* So we need to watch for this value to be able to format it based on the user's date time preferences.
|
||||
*/
|
||||
const formattedRegExp = ref<any>();
|
||||
const formattedRegExp = ref<string>();
|
||||
const setFormattedRegExp = () => { // ran in watch on regExp and onBeforeMount
|
||||
if (!regExp.value) { return; }
|
||||
|
||||
@@ -200,10 +200,10 @@ const close = () => {
|
||||
};
|
||||
|
||||
const renderMainSlot = computed(() => {
|
||||
return checkForUpdatesLoading.value || available.value || availableWithRenewal.value || extraLinks.value?.length > 0 || updateOsIgnoredReleases.value.length > 0;
|
||||
return !!(checkForUpdatesLoading.value || available.value || availableWithRenewal.value || extraLinks.value?.length > 0 || updateOsIgnoredReleases.value.length > 0);
|
||||
});
|
||||
|
||||
const userFormattedReleaseDate = ref<any>();
|
||||
const userFormattedReleaseDate = ref<string>();
|
||||
/**
|
||||
* availableReleaseDate may not have a value until we get a release in the update os check response.
|
||||
* So we need to watch for this value to be able to format it based on the user's date time preferences.
|
||||
|
||||
@@ -90,6 +90,7 @@ const heading = computed(() => {
|
||||
case 'success':
|
||||
return props.t('Success!');
|
||||
}
|
||||
return '';
|
||||
});
|
||||
const subheading = computed(() => {
|
||||
if (updateOsStatus.value === 'confirming') {
|
||||
@@ -141,10 +142,6 @@ const keyInstallStatusCopy = computed((): { text: string; } => {
|
||||
let txt2 = props.t('Installed');
|
||||
let txt3 = props.t('Install');
|
||||
switch (keyInstallStatus.value) {
|
||||
case 'ready':
|
||||
return {
|
||||
text: props.t('Ready to Install Key'),
|
||||
};
|
||||
case 'installing':
|
||||
if (keyActionType.value === 'trialExtend') { txt1 = props.t('Installing Extended Trial'); }
|
||||
if (keyActionType.value === 'recover') { txt1 = props.t('Installing Recovered'); }
|
||||
@@ -167,15 +164,16 @@ const keyInstallStatusCopy = computed((): { text: string; } => {
|
||||
return {
|
||||
text: props.t('Failed to {0} {1} Key', [txt3, keyType.value]),
|
||||
};
|
||||
case 'ready':
|
||||
default:
|
||||
return {
|
||||
text: props.t('Ready to Install Key'),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const accountActionStatusCopy = computed((): { text: string; } => {
|
||||
switch (accountActionStatus.value) {
|
||||
case 'ready':
|
||||
return {
|
||||
text: props.t('Ready to update Connect account configuration'),
|
||||
};
|
||||
case 'waiting':
|
||||
return {
|
||||
text: accountAction.value?.type === 'signIn'
|
||||
@@ -200,6 +198,11 @@ const accountActionStatusCopy = computed((): { text: string; } => {
|
||||
? props.t('Sign In Failed')
|
||||
: props.t('Sign Out Failed'),
|
||||
};
|
||||
case 'ready':
|
||||
default:
|
||||
return {
|
||||
text: props.t('Ready to update Connect account configuration'),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { storeToRefs } from 'pinia';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
|
||||
import { useErrorsStore } from '~/store/errors';
|
||||
import type { ServerStateDataAction } from '~/types/server';
|
||||
import type { UserProfileLink } from '~/types/userProfile';
|
||||
|
||||
defineProps<{ t: ComposerTranslation; }>();
|
||||
@@ -22,7 +21,7 @@ const { errors } = storeToRefs(errorsStore);
|
||||
<div class="text-14px px-12px flex flex-col gap-y-8px" :class="{ 'pb-8px': !error.actions }" v-html="t(error.message)" />
|
||||
<nav v-if="error.actions">
|
||||
<li v-for="(link, idx) in error.actions" :key="`link_${idx}`">
|
||||
<UpcDropdownItem :item="link as ServerStateDataAction | UserProfileLink" :rounded="false" :t="t" />
|
||||
<UpcDropdownItem :item="link as UserProfileLink" :rounded="false" :t="t" />
|
||||
</li>
|
||||
</nav>
|
||||
</li>
|
||||
|
||||
@@ -25,9 +25,10 @@ const { available: osUpdateAvailable } = storeToRefs(useUpdateOsStore());
|
||||
|
||||
const showErrorIcon = computed(() => errors.value.length || stateData.value.error);
|
||||
|
||||
const text = computed((): string | undefined => {
|
||||
const text = computed((): string => {
|
||||
if ((stateData.value.error) && state.value !== 'EEXPIRED') { return props.t('Fix Error'); }
|
||||
if (!registered.value && connectPluginInstalled.value) { return props.t('Sign In'); }
|
||||
return '';
|
||||
});
|
||||
|
||||
const title = computed((): string => {
|
||||
|
||||
@@ -43,6 +43,7 @@ const trialStatusCopy = computed((): TrialStatusCopy | null => {
|
||||
subheading: props.t('Please wait while the page reloads to install your trial key'),
|
||||
};
|
||||
case 'ready':
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,12 +18,13 @@ const { t } = useI18n();
|
||||
const { isRemoteAccess } = storeToRefs(useServerStore());
|
||||
|
||||
const wanIp = ref<string | null>();
|
||||
const fetchError = ref<any>();
|
||||
const fetchError = ref<string>('');
|
||||
const loading = ref(false);
|
||||
|
||||
const computedError = computed(() => {
|
||||
const computedError = computed((): string => {
|
||||
if (!props.phpWanIp) { return t('DNS issue, unable to resolve wanip4.unraid.net'); }
|
||||
if (fetchError.value) { return fetchError.value; }
|
||||
return '';
|
||||
});
|
||||
|
||||
onBeforeMount(() => {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import dayjs, { extend } from 'dayjs';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
|
||||
import type { DateFormatOption, ServerDateTimeFormat, TimeFormatOption } from '~/types/server';
|
||||
|
||||
/** @see https://day.js.org/docs/en/display/format#localized-formats */
|
||||
@@ -57,7 +59,7 @@ const timeFormatOptions: TimeFormatOption[] = [
|
||||
*/
|
||||
const useDateTimeHelper = (
|
||||
format: ServerDateTimeFormat | undefined,
|
||||
t: any,
|
||||
t: ComposerTranslation,
|
||||
hideMinutesSeconds?: boolean,
|
||||
providedDateTime?: number | undefined,
|
||||
diffCountUp?: boolean,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
import type { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
|
||||
import type { FragmentDefinitionNode } from 'graphql';
|
||||
import type { Incremental } from './graphql';
|
||||
|
||||
@@ -8,12 +8,12 @@ const useInstallPlugin = () => {
|
||||
const install = (payload: InstallPluginPayload) => {
|
||||
console.debug('[installPlugin]', payload);
|
||||
try {
|
||||
// @ts-expect-error – `openPlugin` will be included in 6.10.4+ DefaultPageLayout
|
||||
// @ts-expect-error global function defined in the webgui's DefaultPageLayout.php
|
||||
if (typeof openPlugin === 'function') {
|
||||
const plgUrl = new URL(payload.pluginUrl);
|
||||
const installString = `${plgUrl.pathname.replace('.plg', '').substring(1)}:install`; // mimic what is done on the install plg page JS but without the regex that's hard to read
|
||||
console.debug('[installPlugin]', { installString, plgUrl });
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error global function defined in the webgui's DefaultPageLayout.php
|
||||
openPlugin(
|
||||
`plugin ${payload.update ? 'update' : 'install'} ${payload.pluginUrl}${payload.update ? '' : ' forced'}`, // command – `forced` is used to bypass the strcmp check in the plugin manager script being wrong for OS versions
|
||||
payload.modalTitle, // title
|
||||
@@ -23,8 +23,8 @@ const useInstallPlugin = () => {
|
||||
1, // hide close button
|
||||
);
|
||||
} else {
|
||||
// `openBox()` is defined in the webgui's DefaultPageLayout.php and used when openPlugin is not available
|
||||
// @ts-expect-error
|
||||
//
|
||||
// @ts-expect-error openBox() is defined in the webgui's DefaultPageLayout.php and used when openPlugin is not available
|
||||
openBox(
|
||||
`/plugins/dynamix.plugin.manager/scripts/plugin&arg1=install&arg2=${payload.pluginUrl}`,
|
||||
payload.modalTitle,
|
||||
|
||||
@@ -92,6 +92,10 @@ interface WebguiUnraidCheckPayload {
|
||||
version?: string;
|
||||
}
|
||||
|
||||
interface WebguiUnraidCheckIgnoreResponse {
|
||||
updateOsIgnoredReleases: string[];
|
||||
}
|
||||
|
||||
export const WebguiCheckForUpdate = async (): Promise<ServerUpdateOsResponse | unknown> => {
|
||||
console.debug('[WebguiCheckForUpdate]');
|
||||
try {
|
||||
@@ -121,7 +125,7 @@ export const WebguiCheckForUpdate = async (): Promise<ServerUpdateOsResponse | u
|
||||
}
|
||||
};
|
||||
|
||||
export const WebguiUpdateIgnore = async (payload: WebguiUnraidCheckPayload): Promise<any | void> => {
|
||||
export const WebguiUpdateIgnore = async (payload: WebguiUnraidCheckPayload): Promise<WebguiUnraidCheckIgnoreResponse> => {
|
||||
console.debug('[WebguiUpdateIgnore] payload', payload);
|
||||
try {
|
||||
const response = await request
|
||||
|
||||
@@ -6,7 +6,7 @@ import { serverState } from '~/_data/serverState';
|
||||
|
||||
const nuxtApp = useNuxtApp();
|
||||
onBeforeMount(() => {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error - customElements doesn't provide types
|
||||
nuxtApp.$customElements.registerEntry('UnraidComponents');
|
||||
});
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import { usePurchaseStore } from '~/store/purchase';
|
||||
import { useThemeStore, type Theme } from '~/store/theme';
|
||||
import { useUnraidApiStore } from '~/store/unraidApi';
|
||||
|
||||
import type { ApolloQueryResult } from '@apollo/client/core/types';
|
||||
import type { Config, PartialCloudFragment, serverStateQuery } from '~/composables/gql/graphql';
|
||||
import type {
|
||||
Server,
|
||||
@@ -162,7 +163,7 @@ export const useServerStore = defineStore('server', () => {
|
||||
const wanFQDN = ref<string>('');
|
||||
const combinedKnownOrigins = ref<string[]>([]);
|
||||
|
||||
const apiServerStateRefresh = ref<any>(null);
|
||||
const apiServerStateRefresh = ref<(variables?: Record<string, never> | undefined) => Promise<ApolloQueryResult<serverStateQuery>> | undefined>();
|
||||
/**
|
||||
* Getters
|
||||
*/
|
||||
@@ -1015,10 +1016,10 @@ export const useServerStore = defineStore('server', () => {
|
||||
const oldState = state.value;
|
||||
const oldRegExp = regExp.value;
|
||||
|
||||
const fromApi = !!apiServerStateRefresh.value;
|
||||
const fromApi = !!(apiServerStateRefresh && apiServerStateRefresh.value);
|
||||
// Fetch the server state from the API or PHP
|
||||
const response = fromApi
|
||||
? await apiServerStateRefresh.value()
|
||||
? await (apiServerStateRefresh && apiServerStateRefresh.value ? apiServerStateRefresh.value() : undefined)
|
||||
: await phpServerStateRefresh();
|
||||
if (!response) {
|
||||
return setTimeout(() => {
|
||||
@@ -1027,13 +1028,13 @@ export const useServerStore = defineStore('server', () => {
|
||||
}
|
||||
|
||||
// Extract the new values from the response
|
||||
const newRegistered = fromApi && response?.data ? response.data.owner.username !== 'root' : response.registered;
|
||||
const newState = fromApi && response?.data ? response.data.vars.regState : response.state;
|
||||
const newRegExp = fromApi && response?.data ? Number(response.data.registration.updateExpiration ?? 0) : response.regExp;
|
||||
const newRegistered = fromApi && 'data' in response ? (response.data.owner && response.data.owner.username !== 'root') : (response as Server).registered;
|
||||
const newState = fromApi && 'data' in response ? response.data.vars?.regState : (response as Server).state;
|
||||
const newRegExp = fromApi && 'data' in response ? Number(response.data.registration?.updateExpiration ?? 0) : (response as Server).regExp;
|
||||
// Compare the new values to the old values
|
||||
const registrationStatusChanged = oldRegistered !== newRegistered;
|
||||
const stateChanged = oldState !== newState;
|
||||
const regExpChanged = newRegExp > oldRegExp;
|
||||
const regExpChanged = newRegExp ?? 0 > oldRegExp;
|
||||
|
||||
// If the registration status or state changed, stop refreshing
|
||||
if (registrationStatusChanged || stateChanged || regExpChanged) {
|
||||
|
||||
@@ -82,9 +82,10 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
}),
|
||||
);
|
||||
|
||||
// @typescript-eslint/no-explicit-any-disable-next-line
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const errorLink = onError(({ graphQLErrors, networkError }: any) => {
|
||||
if (graphQLErrors) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
graphQLErrors.map((error: any) => {
|
||||
console.error('[GraphQL error]', error);
|
||||
const errorMsg = error.error && error.error.message ? error.error.message : error.message;
|
||||
@@ -144,6 +145,7 @@ export const useUnraidApiStore = defineStore('unraidApi', () => {
|
||||
operation?: string;
|
||||
};
|
||||
const splitLinks = split(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
({ query }: any) => {
|
||||
const definition: Definintion = getMainDefinition(query);
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { ArrowTopRightOnSquareIcon } from '@heroicons/vue/24/solid';
|
||||
|
||||
export interface UserProfileLink {
|
||||
// void | Promise<void>
|
||||
click?: any; // @todo be more specific
|
||||
click?: () => void | Promise<void>;
|
||||
clickParams?: string[] | number[];
|
||||
disabled?: boolean;
|
||||
emphasize?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user