mirror of
https://github.com/unraid/api.git
synced 2026-01-01 22:20:05 -06:00
fix: regDevs usage to allow more flexibility for STARTER (#860)
* fix: regDevs usage to allow more flexibility for STARTER * fix: lint and type-check
This commit is contained in:
@@ -270,7 +270,7 @@ class ServerState
|
||||
"osVersionBranch" => $this->osVersionBranch,
|
||||
"protocol" => _var($_SERVER, 'REQUEST_SCHEME'),
|
||||
"rebootType" => $this->rebootDetails->getRebootType(),
|
||||
"regDev" => @(int)$this->var['regDev'] ?? 0,
|
||||
"regDevs" => @(int)$this->var['regDevs'] ?? 0,
|
||||
"regGen" => @(int)$this->var['regGen'],
|
||||
"regGuid" => @$this->var['regGUID'] ?? '',
|
||||
"regTo" => @htmlspecialchars($this->var['regTo'], ENT_HTML5, 'UTF-8') ?? '',
|
||||
|
||||
@@ -58,8 +58,8 @@ let regExp: number | undefined;
|
||||
// EBLACKLISTED1
|
||||
// EBLACKLISTED2
|
||||
// ENOCONN
|
||||
const state: ServerState = 'STARTER';
|
||||
let regDev = 0;
|
||||
const state: ServerState = 'TRIAL';
|
||||
let regDevs = 0;
|
||||
let regTy = '';
|
||||
switch (state) {
|
||||
// @ts-ignore
|
||||
@@ -73,15 +73,15 @@ switch (state) {
|
||||
regTy = 'Trial';
|
||||
// @ts-ignore
|
||||
case 'BASIC':
|
||||
regDev = 6;
|
||||
regDevs = 6;
|
||||
// @ts-ignore
|
||||
case 'PLUS':
|
||||
regDev = 12;
|
||||
regDevs = 12;
|
||||
// @ts-ignore
|
||||
case 'PRO':
|
||||
// @ts-ignore
|
||||
case 'STARTER':
|
||||
regDev = 4;
|
||||
regDevs = 6;
|
||||
// regExp = oneHourFromNow;
|
||||
// regExp = oneDayFromNow;
|
||||
regExp = ninetyDaysAgo;
|
||||
@@ -96,7 +96,7 @@ switch (state) {
|
||||
// regExp = 1696363920000; // nori.local's expiration
|
||||
// @ts-ignore
|
||||
case 'LIFETIME':
|
||||
if (regDev === 0) { regDev = 99999; }
|
||||
if (regDevs === 0) { regDevs = -1; }
|
||||
if (regTy === '') { regTy = state.charAt(0).toUpperCase() + state.substring(1).toLowerCase(); } // title case
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ const {
|
||||
flashProduct,
|
||||
keyActions,
|
||||
keyfile,
|
||||
computedRegDevs,
|
||||
regGuid,
|
||||
regTm,
|
||||
regTo,
|
||||
@@ -56,6 +57,7 @@ const {
|
||||
state,
|
||||
stateData,
|
||||
stateDataError,
|
||||
tooManyDevices,
|
||||
} = storeToRefs(serverStore);
|
||||
|
||||
const formattedRegTm = ref<any>();
|
||||
@@ -76,24 +78,6 @@ onBeforeMount(() => {
|
||||
setFormattedRegTm();
|
||||
});
|
||||
|
||||
const devicesAvailable = computed((): number => {
|
||||
switch (regTy.value) {
|
||||
case 'Starter':
|
||||
return 4;
|
||||
case 'Basic':
|
||||
return 6;
|
||||
case 'Plus':
|
||||
return 12;
|
||||
case 'Unleashed':
|
||||
case 'Lifetime':
|
||||
case 'Pro':
|
||||
case 'Trial':
|
||||
return 9999;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
const showTrialExpiration = computed((): boolean => state.value === 'TRIAL' || state.value === 'EEXPIRED');
|
||||
const showUpdateEligibility = computed((): boolean => !!(regExp.value));
|
||||
const keyInstalled = computed((): boolean => !!(!stateDataError.value && state.value !== 'ENOKEYFILE'));
|
||||
@@ -169,11 +153,11 @@ const items = computed((): RegistrationItemProps[] => {
|
||||
: []),
|
||||
...(keyInstalled.value
|
||||
? [{
|
||||
error: deviceCount.value > devicesAvailable.value,
|
||||
error: !!tooManyDevices.value,
|
||||
label: t('Attached Storage Devices'),
|
||||
text: deviceCount.value > devicesAvailable.value
|
||||
? t('{0} out of {1} allowed devices – upgrade your key to support more devices', [deviceCount.value, devicesAvailable.value > 12 ? t('unlimited') : devicesAvailable.value])
|
||||
: t('{0} out of {1} devices', [deviceCount.value, devicesAvailable.value > 12 ? t('unlimited') : devicesAvailable.value]),
|
||||
text: tooManyDevices.value
|
||||
? t('{0} out of {1} allowed devices – upgrade your key to support more devices', [deviceCount.value, computedRegDevs.value])
|
||||
: t('{0} out of {1} devices', [deviceCount.value, computedRegDevs.value === -1 ? t('unlimited') : computedRegDevs.value]),
|
||||
}]
|
||||
: []),
|
||||
...(showTransferStatus.value
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { defineStore, createPinia, setActivePinia } from 'pinia';
|
||||
import { delay } from 'wretch/middlewares';
|
||||
import { WebguiInstallKey } from '~/composables/services/webgui';
|
||||
import { useErrorsStore } from '~/store/errors';
|
||||
import { useServerStore } from '~/store/server';
|
||||
import type { ExternalKeyActions } from '~/store/callback';
|
||||
/**
|
||||
* @see https://stackoverflow.com/questions/73476371/using-pinia-with-vue-js-web-components
|
||||
@@ -12,7 +10,6 @@ setActivePinia(createPinia());
|
||||
|
||||
export const useInstallKeyStore = defineStore('installKey', () => {
|
||||
const errorsStore = useErrorsStore();
|
||||
const serverStore = useServerStore();
|
||||
|
||||
const keyInstallStatus = ref<'failed' | 'installing' | 'ready' | 'success'>('ready');
|
||||
|
||||
|
||||
@@ -95,7 +95,27 @@ export const useServerStore = defineStore('server', () => {
|
||||
const rebootType = ref<'thirdPartyDriversDownloading' | 'downgrade' | 'update' | ''>('');
|
||||
const rebootVersion = ref<string | undefined>();
|
||||
const registered = ref<boolean>();
|
||||
const regDev = ref<number>(0);
|
||||
const regDevs = ref<number>(0); // use computedRegDevs to ensure it includes Basic, Plus, and Pro
|
||||
const computedRegDevs = computed(() => {
|
||||
if (regDevs.value > 0) {
|
||||
return regDevs.value;
|
||||
}
|
||||
|
||||
switch (regTy.value) {
|
||||
case 'Starter':
|
||||
case 'Basic':
|
||||
return 6;
|
||||
case 'Plus':
|
||||
return 12;
|
||||
case 'Unleashed':
|
||||
case 'Lifetime':
|
||||
case 'Pro':
|
||||
case 'Trial':
|
||||
return -1; // unlimited
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
const regGen = ref<number>(0);
|
||||
const regGuid = ref<string>('');
|
||||
const regTm = ref<number>(0);
|
||||
@@ -164,7 +184,7 @@ export const useServerStore = defineStore('server', () => {
|
||||
osVersion: osVersion.value,
|
||||
osVersionBranch: osVersionBranch.value,
|
||||
registered: registered.value,
|
||||
regDev: regDev.value,
|
||||
regDevs: computedRegDevs.value,
|
||||
regGen: regGen.value,
|
||||
regGuid: regGuid.value,
|
||||
regExp: regExp.value,
|
||||
@@ -663,7 +683,7 @@ export const useServerStore = defineStore('server', () => {
|
||||
const trialExtensionEligible = computed(() => !regGen.value || regGen.value < 2);
|
||||
|
||||
const tooManyDevices = computed((): Error | undefined => {
|
||||
if ((deviceCount.value !== 0 && regDev.value !== 0 && deviceCount.value > regDev.value) ||
|
||||
if ((deviceCount.value !== 0 && computedRegDevs.value > 0 && deviceCount.value > computedRegDevs.value) ||
|
||||
(!config.value?.valid && config.value?.error === 'INVALID')) {
|
||||
return {
|
||||
heading: 'Too Many Devices',
|
||||
@@ -1022,7 +1042,7 @@ export const useServerStore = defineStore('server', () => {
|
||||
rebootType,
|
||||
rebootVersion,
|
||||
registered,
|
||||
regDev,
|
||||
computedRegDevs,
|
||||
regGen,
|
||||
regGuid,
|
||||
regTm,
|
||||
|
||||
@@ -91,7 +91,7 @@ export interface Server {
|
||||
rebootType?: ServerRebootType;
|
||||
rebootVersion?: string;
|
||||
registered?: boolean;
|
||||
regDev?: number;
|
||||
regDevs?: number;
|
||||
regGen?: number;
|
||||
regGuid?: string;
|
||||
regTm?: number;
|
||||
|
||||
Reference in New Issue
Block a user