Use Kloon15 changes which apperantly disappeard
This commit is contained in:
parent
24dd6b4fa1
commit
a70bf08889
6
frontend/src/types/api.d.ts
vendored
6
frontend/src/types/api.d.ts
vendored
@ -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 {
|
||||||
|
|||||||
37
frontend/src/types/user.d.ts
vendored
37
frontend/src/types/user.d.ts
vendored
@ -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;
|
||||||
}
|
}
|
||||||
@ -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,16 +373,16 @@ 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>;
|
||||||
// @ts-ignore
|
for (const key in keys) {
|
||||||
|
//@ts-ignore
|
||||||
newSettings.commands[key] = original.commands[key];
|
newSettings.commands[key] = original.commands[key];
|
||||||
// @ts-ignore
|
//@ts-ignore
|
||||||
commandObject.value[key] = original.commands[key].join("\n");
|
commandObject.value[key] = original.commands[key].join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -395,4 +397,4 @@ onBeforeUnmount(() => {
|
|||||||
clearTimeout(debounceTimeout.value);
|
clearTimeout(debounceTimeout.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user