diff --git a/frontend/src/types/api.d.ts b/frontend/src/types/api.d.ts
index bd320b75..a027e712 100644
--- a/frontend/src/types/api.d.ts
+++ b/frontend/src/types/api.d.ts
@@ -22,11 +22,11 @@ type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512";
type inline = any;
interface Share {
- expire: any;
hash: string;
path: string;
- userID: number;
- token: string;
+ expire?: any;
+ userID?: number;
+ token?: string;
}
interface settings {
diff --git a/frontend/src/types/user.d.ts b/frontend/src/types/user.d.ts
index a79df7c7..86c5d117 100644
--- a/frontend/src/types/user.d.ts
+++ b/frontend/src/types/user.d.ts
@@ -1,34 +1,45 @@
-type UserKey = keyof IUser;
-
interface IUser {
id: number;
username: string;
password: string;
scope: string;
locale: string;
+ perm: Permissions;
+ commands: string[];
+ rules: IRule[];
lockPassword: boolean;
- viewMode: string;
- singleClick: boolean;
- perm: UserPerm;
- commands: any[];
- sorting: UserSorting;
- rules: any[];
hideDotfiles: boolean;
+ singleClick: boolean;
dateFormat: boolean;
}
-interface UserPerm {
+interface Permissions {
admin: boolean;
- execute: boolean;
+ copy: boolean;
create: boolean;
- rename: boolean;
- modify: boolean;
delete: boolean;
- share: boolean;
download: boolean;
+ execute: boolean;
+ modify: boolean;
+ move: boolean;
+ rename: boolean;
+ share: boolean;
+ shell: boolean;
+ upload: boolean;
}
interface UserSorting {
by: string;
asc: boolean;
+}
+
+interface IRule {
+ allow: boolean;
+ path: string;
+ regex: boolean;
+ regexp: IRegexp;
+}
+
+interface IRegexp {
+ raw: string;
}
\ No newline at end of file
diff --git a/frontend/src/views/settings/Global.vue b/frontend/src/views/settings/Global.vue
index 931e3ede..a8dbf99b 100644
--- a/frontend/src/views/settings/Global.vue
+++ b/frontend/src/views/settings/Global.vue
@@ -158,6 +158,7 @@
{{ t("settings.defaultUserDescription") }}
+
(null);
const debounceTimeout = ref(null);
const commandObject = ref<{
- [key in keyof SettingsCommand]: string;
+ [key in keyof SettingsCommand]: string[] | string;
}>({});
const shellValue = ref("");
-const $showSuccess = inject("$showSuccess") as IToastSuccess;
-const $showError = inject("$showError") as IToastError;
+const $showError = inject("$showError")!;
+const $showSuccess = inject("$showSuccess")!;
const { t } = useI18n();
@@ -304,19 +305,20 @@ const save = async () => {
commands: {},
};
- // @ts-ignore
- for (const name of Object.keys(settings.value.commands)) {
- // @ts-ignore
- const newValue = commandObject.value[name];
- // @ts-ignore
- if (name in commandObject.value && !Array.isArray(newValue)) {
- // @ts-ignore
- newSettings.commands[name] = newValue
+ const keys = Object.keys(settings.value.commands) as Array<
+ keyof SettingsCommand
+ >;
+ for (const key of keys) {
+ // not sure if we can safely assert non-null
+ const newValue = commandObject.value[key];
+ if (!newValue) continue;
+
+ if (Array.isArray(newValue)) {
+ newSettings.commands[key] = newValue;
+ } else if (key in commandObject.value) {
+ newSettings.commands[key] = newValue
.split("\n")
.filter((cmd: string) => cmd !== "");
- } else {
- // @ts-ignore
- newSettings.commands[name] = newValue;
}
}
newSettings.shell = shellValue.value.split("\n");
@@ -371,16 +373,16 @@ onMounted(async () => {
const original: ISettings = await api.get();
let newSettings: ISettings = { ...original, commands: {} };
- for (const key in original.commands) {
- // @ts-ignore
+ const keys = Object.keys(original.commands) as Array;
+ for (const key in keys) {
+ //@ts-ignore
newSettings.commands[key] = original.commands[key];
- // @ts-ignore
+ //@ts-ignore
commandObject.value[key] = original.commands[key].join("\n");
}
originalSettings.value = original;
settings.value = newSettings;
- // @ts-ignore
shellValue.value = newSettings.shell.join("\n");
} catch (e) {
error.value = e;
@@ -395,4 +397,4 @@ onBeforeUnmount(() => {
clearTimeout(debounceTimeout.value);
}
});
-
+
\ No newline at end of file