chore: lint manual fixes

This commit is contained in:
Zack Spear
2023-10-30 12:43:23 -07:00
committed by Zack Spear
parent caab570be6
commit 2104eebe02
22 changed files with 59 additions and 94 deletions

View File

@@ -21,5 +21,6 @@ module.exports = {
'vue/multi-word-component-names': 'off',
'vue/v-on-event-hyphenation': 'off',
'vue/no-v-html': 'off',
'no-fallthrough': 'off',
}
};

View File

@@ -1,15 +1,15 @@
import type { Server, ServerState } from '~/types/server';
function makeid (length: number) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
const charactersLength = characters.length;
let result = '';
for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); }
return result;
}
// function makeid(length: number) {
// const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
// const charactersLength = characters.length;
// let result = '';
// for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); }
// return result;
// }
// '1111-1111-5GDB-123412341234' Starter.key = TkJCrVyXMLWWGKZF6TCEvf0C86UYI9KfUDSOm7JoFP19tOMTMgLKcJ6QIOt9_9Psg_t0yF-ANmzSgZzCo94ljXoPm4BESFByR0K7nyY9KVvU8szLEUcBUT3xC2adxLrAXFNxiPeK-mZqt34n16uETKYvLKL_Sr5_JziG5L5lJFBqYZCPmfLMiguFo1vp0xL8pnBH7q8bYoBnePrAcAVb9mAGxFVPEInSPkMBfC67JLHz7XY1Y_K5bYIq3go9XPtLltJ53_U4BQiMHooXUBJCKXodpqoGxq0eV0IhNEYdauAhnTsG90qmGZig0hZalQ0soouc4JZEMiYEcZbn9mBxPg
const randomGuid = '1111-1111-5GDB-123412341234';
const staticGuid = '1111-1111-5GDB-123412341234';
// const randomGuid = `1111-1111-${makeid(4)}-123412341234`; // this guid is registered in key server
// const newGuid = `1234-1234-${makeid(4)}-123412341234`; // this is a new USB, not registered
@@ -65,12 +65,15 @@ switch (state) {
const uptime = Date.now() - 60 * 60 * 1000; // 1 hour ago
const twoDaysAgo = Date.now() - 2 * 24 * 60 * 60 * 1000; // 2 days ago
const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000; // 1 day ago
// const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000; // 1 day ago
const oneHourFromNow = Date.now() + 60 * 60 * 1000; // 1 hour from now
const oneDayFromNow = Date.now() + 24 * 60 * 60 * 1000; // 1 day from now
let expireTime = 0;
if (state === 'TRIAL') { expireTime = oneHourFromNow; } // in 1 hour
else if (state === 'EEXPIRED') { expireTime = uptime; } // 1 hour ago
if (state === 'TRIAL') {
expireTime = oneHourFromNow; // in 1 hour
} else if (state === 'EEXPIRED') {
expireTime = uptime; // 1 hour ago
}
let regExp: number | undefined;
if (state === 'STARTER' || state === 'UNLEASHED') {
@@ -98,7 +101,7 @@ export const serverState: Server = {
flashBackupActivated: !!connectPluginInstalled,
flashProduct: 'SanDisk_3.2Gen1',
flashVendor: 'USB',
guid: randomGuid,
guid: staticGuid,
// "guid": "0781-5583-8355-81071A2B0211",
inIframe: false,
// keyfile: 'DUMMY_KEYFILE',

View File

@@ -12,6 +12,7 @@ const props = withDefaults(defineProps<{
maxWidth?: boolean;
t: any;
}>(), {
actions: undefined,
filterBy: undefined,
filterOut: undefined,
maxWidth: false,

View File

@@ -21,7 +21,6 @@ import {
ShieldCheckIcon,
ShieldExclamationIcon,
} from '@heroicons/vue/24/solid';
import dayjs from 'dayjs';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
@@ -44,7 +43,6 @@ const {
flashVendor,
flashProduct,
keyActions,
keyfile,
regGuid,
regTm,
regTo,

View File

@@ -6,7 +6,6 @@ import useDateTimeHelper from '~/composables/dateTime';
import { DOCS_REGISTRATION_LICENSING } from '~/helpers/urls';
import { useReplaceRenewStore } from '~/store/replaceRenew';
import { useServerStore } from '~/store/server';
import { useUpdateOsStore, useUpdateOsActionsStore } from '~/store/updateOsActions';
export interface Props {
t: any;
@@ -16,8 +15,6 @@ const props = defineProps<Props>();
const replaceRenewStore = useReplaceRenewStore();
const serverStore = useServerStore();
const updateOsStore = useUpdateOsStore();
const updateOsActionsStore = useUpdateOsActionsStore();
const { renewStatus } = storeToRefs(replaceRenewStore);
const {
@@ -25,10 +22,7 @@ const {
regExp,
regUpdatesExpired,
renewAction,
regTy,
} = storeToRefs(serverStore);
const { availableWithRenewal } = storeToRefs(updateOsStore);
const { ineligibleText } = storeToRefs(updateOsActionsStore);
const reload = () => {
window.location.reload();
@@ -62,9 +56,6 @@ const output = computed(() => {
<template v-if="renewStatus === 'installed'">
{{ t('Your license key was automatically renewed and installed. Reload the page to see updated details.') }}
</template>
<!-- <template v-else-if="regUpdatesExpired && ineligibleText">
{{ t(ineligibleText, [regTy, formattedRegExp]) }}
</template> -->
</p>
<div class="flex flex-wrap items-start justify-between gap-8px">
<BrandButton

View File

@@ -4,7 +4,7 @@
*/
import { Switch, SwitchGroup, SwitchLabel } from '@headlessui/vue';
const props = withDefaults(defineProps<{
withDefaults(defineProps<{
description?: string; // @todo setup
label: string;
}>(), {

View File

@@ -15,21 +15,12 @@ else
echo "Third party plugins found - PLEASE CHECK YOUR UNRAID NOTIFICATIONS AND WAIT FOR THE MESSAGE THAT IT IS SAFE TO REBOOT!"
fi
*/
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import { useUpdateOsStore, useUpdateOsActionsStore } from '~/store/updateOsActions';
import 'tailwindcss/tailwind.css';
import '~/assets/main.css';
const { t } = useI18n();
const updateOsStore = useUpdateOsStore();
const updateOsActionsStore = useUpdateOsActionsStore();
const { available, availableWithRenewal } = storeToRefs(updateOsStore);
const { rebootType } = storeToRefs(updateOsActionsStore);
</script>
<template>
@@ -39,15 +30,6 @@ const { rebootType } = storeToRefs(updateOsActionsStore);
:title="t('Update Unraid OS')"
:t="t"
/>
<!-- <UpdateOsUpdateIneligible
v-if="availableWithRenewal && rebootType === ''"
:t="t" />
<UpdateOsUpdate
v-if="available && rebootType === ''"
:t="t" />
<UpdateOsThirdPartyDrivers
v-if="rebootType === 'thirdPartyDriversDownloading'"
:t="t" /> -->
</UiPageContainer>
</template>

View File

@@ -6,7 +6,7 @@ import { onBeforeMount } from 'vue';
import { WEBGUI_TOOLS_UPDATE } from '~/helpers/urls';
import { useUpdateOsActionsStore } from '~/store/updateOsActions';
const props = defineProps<{
defineProps<{
t: any;
}>();

View File

@@ -24,7 +24,7 @@ const updateOsStore = useUpdateOsStore();
const updateOsActionsStore = useUpdateOsActionsStore();
const { guid, keyfile, osVersion, osVersionBranch } = storeToRefs(serverStore);
const { isOsVersionStable, parsedReleaseTimestamp } = storeToRefs(updateOsStore);
const { parsedReleaseTimestamp } = storeToRefs(updateOsStore);
const { status } = storeToRefs(updateOsActionsStore);
const includeNext = ref(osVersionBranch.value !== 'stable');

View File

@@ -1,14 +1,11 @@
<script lang="ts" setup>
import { TransitionRoot } from '@headlessui/vue';
import {
ArrowTopRightOnSquareIcon,
ArrowUturnDownIcon,
InformationCircleIcon,
LifebuoyIcon,
} from '@heroicons/vue/24/solid';
import dayjs from 'dayjs';
import { storeToRefs } from 'pinia';
import type { SemVer } from 'semver';
import { ref } from 'vue';
import 'tailwindcss/tailwind.css';

View File

@@ -8,12 +8,9 @@ import { Switch, SwitchGroup, SwitchLabel } from '@headlessui/vue';
import {
ArchiveBoxArrowDownIcon,
ArrowPathIcon,
ArrowSmallRightIcon,
ArrowTopRightOnSquareIcon,
BellAlertIcon,
EyeIcon,
ShieldExclamationIcon,
WrenchScrewdriverIcon,
} from '@heroicons/vue/24/solid';
import dayjs from 'dayjs';
import { storeToRefs } from 'pinia';

View File

@@ -1,10 +1,8 @@
<script lang="ts" setup>
import {
ArrowSmallRightIcon,
ArrowTopRightOnSquareIcon,
ExclamationTriangleIcon,
EyeIcon,
WrenchScrewdriverIcon,
} from '@heroicons/vue/24/solid';
import dayjs from 'dayjs';
import { storeToRefs } from 'pinia';

View File

@@ -43,7 +43,6 @@ const {
connectPluginInstalled,
} = storeToRefs(serverStore);
const { bannerGradient, theme } = storeToRefs(useThemeStore());
const { isOsVersionStable } = storeToRefs(updateOsStore);
const hideDropdown = computed(() => state.value === 'PRO' && !connectPluginInstalled.value);

View File

@@ -6,7 +6,6 @@ import {
ChevronDoubleDownIcon,
ClipboardIcon,
CogIcon,
InformationCircleIcon,
} from '@heroicons/vue/24/solid';
import { storeToRefs } from 'pinia';
import 'tailwindcss/tailwind.css';

View File

@@ -31,7 +31,6 @@ const {
stateData,
} = storeToRefs(useServerStore());
const { available: osUpdateAvailable } = storeToRefs(useUpdateOsStore());
const { rebootType } = storeToRefs(updateOsActionsStore);
const signInAction = computed(() => stateData.value.actions?.filter((act: { name: string; }) => act.name === 'signIn') ?? []);
const signOutAction = computed(() => stateData.value.actions?.filter((act: { name: string; }) => act.name === 'signOut') ?? []);

View File

@@ -1,5 +1,5 @@
import wretch from 'wretch';
import FormDataAddon from 'wretch/addons/formData';
import formData from 'wretch/addons/formData';
import formUrl from 'wretch/addons/formUrl';
import queryString from 'wretch/addons/queryString';
@@ -8,7 +8,7 @@ import { useErrorsStore } from '~/store/errors';
const errorsStore = useErrorsStore();
export const request = wretch()
.addon(FormDataAddon)
.addon(formData)
.addon(formUrl)
.addon(queryString)
.errorType('json')

View File

@@ -1,6 +1,5 @@
<script lang="ts" setup>
import AES from 'crypto-js/aes';
import Utf8 from 'crypto-js/enc-utf8';
import { serverState } from '~/_data/serverState';

View File

@@ -11,7 +11,8 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
const accountStore = useAccountStore();
const installKeyStore = useInstallKeyStore();
const serverStore = useServerStore();
const updateOsStore = useUpdateOsStore();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const updateOsStore = useUpdateOsStore(); // if we remove this line, the store things break…
const updateOsActionsStore = useUpdateOsActionsStore();
type CallbackStatus = 'closing' | 'error' | 'loading' | 'ready' | 'success';
@@ -34,7 +35,7 @@ export const useCallbackActionsStore = defineStore('callbackActions', () => {
redirectToCallbackType?.();
};
const redirectToCallbackType = async () => {
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';

View File

@@ -12,9 +12,9 @@ import {
type KeyLatestResponse,
type ValidateGuidResponse,
} from '~/composables/services/keyServer';
import { WebguiNotify } from '~/composables/services/webgui';
// import { WebguiNotify } from '~/composables/services/webgui';
import { useCallbackStore } from '~/store/callbackActions';
import { useInstallKeyStore } from '~/store/installKey';
// import { useInstallKeyStore } from '~/store/installKey';
import { useServerStore } from '~/store/server';
import type { UiBadgeProps } from '~/types/ui/badge';
import BrandLoadingWhite from '~/components/Brand/LoadingWhite.vue';
@@ -37,7 +37,7 @@ export const REPLACE_CHECK_LOCAL_STORAGE_KEY = 'unraidReplaceCheck';
export const useReplaceRenewStore = defineStore('replaceRenewCheck', () => {
const callbackStore = useCallbackStore();
const installKeyStore = useInstallKeyStore();
// const installKeyStore = useInstallKeyStore();
const serverStore = useServerStore();
const guid = computed(() => serverStore.guid);
@@ -52,10 +52,14 @@ export const useReplaceRenewStore = defineStore('replaceRenewCheck', () => {
} | null>(null);
const renewStatus = ref<'checking' | 'error' | 'installing' | 'installed' | 'ready'>('ready');
const setRenewStatus = (status: typeof renewStatus.value) => renewStatus.value = status;
const setRenewStatus = (status: typeof renewStatus.value) => {
renewStatus.value = status;
};
const replaceStatus = ref<'checking' | 'eligible' | 'error' | 'ineligible' | 'ready'>(guid.value ? 'ready' : 'error');
const setReplaceStatus = (status: typeof replaceStatus.value) => replaceStatus.value = status;
const setReplaceStatus = (status: typeof replaceStatus.value) => {
replaceStatus.value = status;
};
const replaceStatusOutput = computed((): UiBadgePropsExtended | undefined => {
// text values are translated in the component
switch (replaceStatus.value) {
@@ -131,7 +135,7 @@ export const useReplaceRenewStore = defineStore('replaceRenewCheck', () => {
setReplaceStatus(response?.replaceable ? 'eligible' : 'ineligible');
/** cache the response to prevent repeated POSTs in the session */
if (replaceStatus.value === 'eligible' || replaceStatus.value === 'ineligible' && !validationResponse.value) {
if ((replaceStatus.value === 'eligible' || replaceStatus.value === 'ineligible') && !validationResponse.value) {
sessionStorage.setItem(REPLACE_CHECK_LOCAL_STORAGE_KEY, JSON.stringify({
key: keyfileShort.value,
timestamp: Date.now(),
@@ -188,7 +192,7 @@ export const useReplaceRenewStore = defineStore('replaceRenewCheck', () => {
/**
* If we already have a validation response, set the status to eligible or ineligible
*/
onBeforeMount(async () => {
onBeforeMount(() => {
if (validationResponse.value) {
// ensure the response timestamp is still valid and not old due to someone keeping their browser open
const currentTime = new Date().getTime();

View File

@@ -99,7 +99,7 @@ export const useServerStore = defineStore('server', () => {
const regTy = ref<string>('');
const regExp = ref<number>(0);
const regUpdatesExpired = computed(() => {
if (!regExp.value || state.value !== 'STARTER' && state.value !== 'UNLEASHED') { return false; }
if (!regExp.value || (state.value !== 'STARTER' && state.value !== 'UNLEASHED')) { return false; }
const today = dayjs();
const parsedUpdateExpirationDate = dayjs(regExp.value);
@@ -618,7 +618,7 @@ export const useServerStore = defineStore('server', () => {
const tooManyDevices = computed((): Error | undefined => {
if ((deviceCount.value !== 0 && regDev.value !== 0 && deviceCount.value > regDev.value) ||
!config.value?.valid && config.value?.error === 'INVALID') {
(!config.value?.valid && config.value?.error === 'INVALID')) {
return {
heading: 'Too Many Devices',
level: 'error',

View File

@@ -1,4 +1,4 @@
import dayjs from 'dayjs';
import dayjs, { extend } from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import relativeTime from 'dayjs/plugin/relativeTime';
import { defineStore, createPinia, setActivePinia } from 'pinia';
@@ -26,7 +26,7 @@ export interface RequestReleasesPayload {
}
export interface Release {
version: string; // "6.12.4"
version: string; // "6.12.4"
name: string; // "Unraid 6.12.4"
basefile: string; // "unRAIDServer-6.12.4-x86_64.zip"
date: string; // "2023-08-31"
@@ -95,8 +95,9 @@ interface UpdateOsStorePayload {
*/
setActivePinia(createPinia());
dayjs.extend(customParseFormat);
dayjs.extend(relativeTime);
// dayjs plugins
extend(customParseFormat);
extend(relativeTime);
export const RELEASES_LOCAL_STORAGE_KEY = 'unraidReleasesResponse';
@@ -249,14 +250,13 @@ export const useUpdateOsStoreGeneric = (payload: UpdateOsStorePayload) =>
if (payload.skipCache) {
await purgeReleasesCache();
}
/**
* Compare the timestamp of the cached releases data to the current time,
* if it's older than 7 days, reset releases.
* Which will trigger a new API call to get the releases.
* Otherwise skip the API call and use the cached data.
*/
else if (!payload.skipCache && releases.value) {
} else if (!payload.skipCache && releases.value) {
/**
* Compare the timestamp of the cached releases data to the current time,
* if it's older than 7 days, reset releases.
* Which will trigger a new API call to get the releases.
* Otherwise skip the API call and use the cached data.
*/
const currentTime = new Date().getTime();
const cacheDuration = import.meta.env.DEV ? 30000 : 604800000; // 30 seconds for testing, 7 days for prod
if (currentTime - releases.value.timestamp > cacheDuration) {
@@ -340,6 +340,7 @@ export const useUpdateOsStoreGeneric = (payload: UpdateOsStorePayload) =>
available.value = release.version;
return true;
}
return false;
});
});
};

View File

@@ -7,7 +7,7 @@ import { getOsReleaseBySha256 } from '~/composables/services/keyServer';
import { ACCOUNT_CALLBACK, WEBGUI_TOOLS_UPDATE } from '~/helpers/urls';
import { useCallbackStore } from '~/store/callbackActions';
import { useErrorsStore } from '~/store/errors';
// import { useErrorsStore } from '~/store/errors';
import { useServerStore } from '~/store/server';
import {
useUpdateOsStoreGeneric,
@@ -25,7 +25,7 @@ setActivePinia(createPinia());
export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
const callbackStore = useCallbackStore();
const errorsStore = useErrorsStore();
// const errorsStore = useErrorsStore();
const serverStore = useServerStore();
const useUpdateOsStore = useUpdateOsStoreGeneric();
const updateOsStore = useUpdateOsStore();
@@ -109,7 +109,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
};
const executeUpdateOsCallback = async () => {
callbackStore.send(
await callbackStore.send(
ACCOUNT_CALLBACK.toString(),
[{
server: {
@@ -136,7 +136,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
}
};
const confirmUpdateOs = async (release: Release) => {
const confirmUpdateOs = (release: Release) => {
callbackUpdateRelease.value = release;
setStatus('confirming');
};
@@ -154,19 +154,14 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
});
};
const rebootServer = async () => {
const rebootServer = () => {
// @ts-ignore • global set in the webgui
document.rebootNow.submit();
};
const viewCurrentReleaseNotes = (modalTitle: string, webguiFilePath?: string | undefined) => {
// @ts-ignore  this is a global function provided by the webgui
if (typeof openChanges === 'function') {
// @ts-ignore
openChanges(
`showchanges ${webguiFilePath ?? '/var/tmp/unRAIDServer.txt'}`,
modalTitle,
);
const viewCurrentReleaseNotes = (modalTitle:string, webguiFilePath?:string|undefined) => {
if (typeof openChanges === 'function') { // @ts-ignore
openChanges(`showchanges ${webguiFilePath ?? '/var/tmp/unRAIDServer.txt'}`, modalTitle);
} else {
alert('Unable to open release notes');
}