Use Kloon15 changes which apperantly disappeard

This commit is contained in:
Joep 2023-09-11 22:50:37 +02:00
parent 24dd6b4fa1
commit a70bf08889
No known key found for this signature in database
GPG Key ID: 6F5588F1DC2A8209
3 changed files with 48 additions and 35 deletions

View File

@ -22,11 +22,11 @@ type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512";
type inline = any; type inline = any;
interface Share { interface Share {
expire: any;
hash: string; hash: string;
path: string; path: string;
userID: number; expire?: any;
token: string; userID?: number;
token?: string;
} }
interface settings { interface settings {

View File

@ -1,34 +1,45 @@
type UserKey = keyof IUser;
interface IUser { interface IUser {
id: number; id: number;
username: string; username: string;
password: string; password: string;
scope: string; scope: string;
locale: string; locale: string;
perm: Permissions;
commands: string[];
rules: IRule[];
lockPassword: boolean; lockPassword: boolean;
viewMode: string;
singleClick: boolean;
perm: UserPerm;
commands: any[];
sorting: UserSorting;
rules: any[];
hideDotfiles: boolean; hideDotfiles: boolean;
singleClick: boolean;
dateFormat: boolean; dateFormat: boolean;
} }
interface UserPerm { interface Permissions {
admin: boolean; admin: boolean;
execute: boolean; copy: boolean;
create: boolean; create: boolean;
rename: boolean;
modify: boolean;
delete: boolean; delete: boolean;
share: boolean;
download: boolean; download: boolean;
execute: boolean;
modify: boolean;
move: boolean;
rename: boolean;
share: boolean;
shell: boolean;
upload: boolean;
} }
interface UserSorting { interface UserSorting {
by: string; by: string;
asc: boolean; asc: boolean;
} }
interface IRule {
allow: boolean;
path: string;
regex: boolean;
regexp: IRegexp;
}
interface IRegexp {
raw: string;
}

View File

@ -158,6 +158,7 @@
<div class="card-content"> <div class="card-content">
<p class="small">{{ t("settings.defaultUserDescription") }}</p> <p class="small">{{ t("settings.defaultUserDescription") }}</p>
<!-- TODO: idk how to fix this ts error -->
<user-form <user-form
:isNew="false" :isNew="false"
:isDefault="true" :isDefault="true"
@ -246,12 +247,12 @@ const settings = ref<ISettings | null>(null);
const debounceTimeout = ref<number | null>(null); const debounceTimeout = ref<number | null>(null);
const commandObject = ref<{ const commandObject = ref<{
[key in keyof SettingsCommand]: string; [key in keyof SettingsCommand]: string[] | string;
}>({}); }>({});
const shellValue = ref<string>(""); const shellValue = ref<string>("");
const $showSuccess = inject<IToastSuccess>("$showSuccess") as IToastSuccess; const $showError = inject<IToastError>("$showError")!;
const $showError = inject<IToastError>("$showError") as IToastError; const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
const { t } = useI18n(); const { t } = useI18n();
@ -304,19 +305,20 @@ const save = async () => {
commands: {}, commands: {},
}; };
// @ts-ignore const keys = Object.keys(settings.value.commands) as Array<
for (const name of Object.keys(settings.value.commands)) { keyof SettingsCommand
// @ts-ignore >;
const newValue = commandObject.value[name]; for (const key of keys) {
// @ts-ignore // not sure if we can safely assert non-null
if (name in commandObject.value && !Array.isArray(newValue)) { const newValue = commandObject.value[key];
// @ts-ignore if (!newValue) continue;
newSettings.commands[name] = newValue
if (Array.isArray(newValue)) {
newSettings.commands[key] = newValue;
} else if (key in commandObject.value) {
newSettings.commands[key] = newValue
.split("\n") .split("\n")
.filter((cmd: string) => cmd !== ""); .filter((cmd: string) => cmd !== "");
} else {
// @ts-ignore
newSettings.commands[name] = newValue;
} }
} }
newSettings.shell = shellValue.value.split("\n"); newSettings.shell = shellValue.value.split("\n");
@ -371,7 +373,8 @@ onMounted(async () => {
const original: ISettings = await api.get(); const original: ISettings = await api.get();
let newSettings: ISettings = { ...original, commands: {} }; let newSettings: ISettings = { ...original, commands: {} };
for (const key in original.commands) { const keys = Object.keys(original.commands) as Array<keyof SettingsCommand>;
for (const key in keys) {
//@ts-ignore //@ts-ignore
newSettings.commands[key] = original.commands[key]; newSettings.commands[key] = original.commands[key];
//@ts-ignore //@ts-ignore
@ -380,7 +383,6 @@ onMounted(async () => {
originalSettings.value = original; originalSettings.value = original;
settings.value = newSettings; settings.value = newSettings;
// @ts-ignore
shellValue.value = newSettings.shell.join("\n"); shellValue.value = newSettings.shell.join("\n");
} catch (e) { } catch (e) {
error.value = e; error.value = e;