diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 023a0c6f..f1a7c2e6 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -35,11 +35,15 @@ <<<<<<< HEAD "@intlify/unplugin-vue-i18n": "^0.12.3", "@types/lodash-es": "^4.17.9", +<<<<<<< HEAD ======= "@intlify/unplugin-vue-i18n": "^1.0.1", "@types/lodash-es": "^4.17.9", "@types/node": "^20.6.0", >>>>>>> kloon15/vue3 +======= + "@types/node": "^20.6.0", +>>>>>>> vue3-bak "@typescript-eslint/eslint-plugin": "^6.6.0", "@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-vue": "^4.3.4", @@ -2177,17 +2181,29 @@ } }, "node_modules/@eslint/js": { +<<<<<<< HEAD "version": "8.49.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz", "integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==", +======= + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz", + "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==", +>>>>>>> vue3-bak "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { +<<<<<<< HEAD "version": "0.11.11", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz", "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==", +======= + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", +>>>>>>> vue3-bak "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", @@ -2504,6 +2520,7 @@ "version": "7.0.12", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" +<<<<<<< HEAD }, "node_modules/@types/lodash": { "version": "4.14.198", @@ -2525,6 +2542,8 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", "dev": true +======= +>>>>>>> vue3-bak }, "node_modules/@types/lodash": { "version": "4.14.198", @@ -2541,6 +2560,12 @@ "@types/lodash": "*" } }, + "node_modules/@types/node": { + "version": "20.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", + "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.5.1", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz", @@ -3067,6 +3092,39 @@ "node": ">=4.0" } }, +<<<<<<< HEAD +======= + "node_modules/@vue/eslint-config-typescript/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@vue/eslint-config-typescript/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@vue/eslint-config-typescript/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, +>>>>>>> vue3-bak "node_modules/@vue/reactivity": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.4.tgz", @@ -3969,9 +4027,15 @@ } }, "node_modules/eslint": { +<<<<<<< HEAD "version": "8.49.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz", "integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==", +======= + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz", + "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==", +>>>>>>> vue3-bak "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -4082,6 +4146,39 @@ "eslint": "^6.2.0 || ^7.0.0 || ^8.0.0" } }, +<<<<<<< HEAD +======= + "node_modules/eslint-plugin-vue/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-plugin-vue/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-plugin-vue/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, +>>>>>>> vue3-bak "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -4213,6 +4310,20 @@ "url": "https://opencollective.com/eslint" } }, +<<<<<<< HEAD +======= + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz", + "integrity": "sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, +>>>>>>> vue3-bak "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", @@ -6585,6 +6696,39 @@ "eslint": ">=6.0.0" } }, +<<<<<<< HEAD +======= + "node_modules/vue-eslint-parser/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/vue-eslint-parser/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/vue-eslint-parser/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, +>>>>>>> vue3-bak "node_modules/vue-i18n": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.3.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 47e0dbc0..8329a330 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -38,14 +38,9 @@ "vue-toastification": "^2.0.0-rc.5" }, "devDependencies": { -<<<<<<< HEAD - "@intlify/unplugin-vue-i18n": "^0.12.3", "@types/lodash-es": "^4.17.9", -======= "@intlify/unplugin-vue-i18n": "^1.0.1", - "@types/lodash-es": "^4.17.9", "@types/node": "^20.6.0", ->>>>>>> kloon15/vue3 "@typescript-eslint/eslint-plugin": "^6.6.0", "@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-vue": "^4.3.4", diff --git a/frontend/src/api/files.ts b/frontend/src/api/files.ts index 5712ff8e..13e8b2cc 100644 --- a/frontend/src/api/files.ts +++ b/frontend/src/api/files.ts @@ -2,13 +2,6 @@ import { createURL, fetchURL, removePrefix } from "./utils"; import { baseURL } from "@/utils/constants"; import { useAuthStore } from "@/stores/auth"; import { upload as postTus, useTus } from "./tus"; -import type { - ApiContent, - ApiMethod, - ApiOpts, - ChecksumAlgs, - IFile, -} from "@/types"; export async function fetch(url: string) { url = removePrefix(url); diff --git a/frontend/src/api/pub.ts b/frontend/src/api/pub.ts index d8c99feb..5765b7f7 100644 --- a/frontend/src/api/pub.ts +++ b/frontend/src/api/pub.ts @@ -1,4 +1,3 @@ -import type { IShare } from "@/types"; import { fetchURL, removePrefix, createURL } from "./utils"; import { baseURL } from "@/utils/constants"; @@ -67,7 +66,7 @@ export function download( window.open(url); } -export function getDownloadURL(share: IShare, inline = false) { +export function getDownloadURL(share: IFile, inline = false) { const params = { ...(inline && { inline: "true" }), ...(share.token && { token: share.token }), @@ -75,3 +74,4 @@ export function getDownloadURL(share: IShare, inline = false) { return createURL("api/public/dl/" + share.hash + share.path, params, false); } + \ No newline at end of file diff --git a/frontend/src/api/search.ts b/frontend/src/api/search.ts index 4f77c0b9..acbb122b 100644 --- a/frontend/src/api/search.ts +++ b/frontend/src/api/search.ts @@ -1,6 +1,5 @@ import { fetchURL, removePrefix } from "./utils"; import url from "../utils/url"; -import type { Item } from "@/types"; export default async function search(base: string, query: string) { base = removePrefix(base); diff --git a/frontend/src/api/settings.ts b/frontend/src/api/settings.ts index dedc0013..d17c9146 100644 --- a/frontend/src/api/settings.ts +++ b/frontend/src/api/settings.ts @@ -1,4 +1,3 @@ -import type { ISettings } from "@/types"; import { fetchURL, fetchJSON } from "./utils"; export function get() { diff --git a/frontend/src/api/share.ts b/frontend/src/api/share.ts index 52987415..23ae5bda 100644 --- a/frontend/src/api/share.ts +++ b/frontend/src/api/share.ts @@ -1,11 +1,10 @@ -import type { ApiUrl, IShare } from "@/types"; import { fetchURL, fetchJSON, removePrefix, createURL } from "./utils"; export async function list() { return fetchJSON("/api/shares"); } -export async function get(url: ApiUrl) { +export async function get(url: string) { url = removePrefix(url); return fetchJSON(`/api/share${url}`); } @@ -17,7 +16,7 @@ export async function remove(hash: string) { } export async function create( - url: ApiUrl, + url: string, password = "", expires = "", unit = "hours" @@ -41,6 +40,6 @@ export async function create( }); } -export function getShareURL(share: IShare) { +export function getShareURL(share: Share) { return createURL("share/" + share.hash, {}, false); } diff --git a/frontend/src/api/tus.ts b/frontend/src/api/tus.ts index 601f48bd..bdc234d5 100644 --- a/frontend/src/api/tus.ts +++ b/frontend/src/api/tus.ts @@ -3,7 +3,6 @@ import { baseURL, tusEndpoint, tusSettings } from "@/utils/constants"; import { useAuthStore } from "@/stores/auth"; import { removePrefix } from "@/api/utils"; import { fetchURL } from "./utils"; -import type { ApiContent, TusSettings } from "@/types"; const RETRY_BASE_DELAY = 1000; const RETRY_MAX_DELAY = 20000; diff --git a/frontend/src/api/users.ts b/frontend/src/api/users.ts index 7422a4c8..bf82f76e 100644 --- a/frontend/src/api/users.ts +++ b/frontend/src/api/users.ts @@ -1,4 +1,3 @@ -import type { User } from "@/types/user"; import { fetchURL, fetchJSON } from "./utils"; export async function getAll() { @@ -9,7 +8,7 @@ export async function get(id: number) { return fetchJSON(`/api/users/${id}`, {}); } -export async function create(user: User) { +export async function create(user: IUser) { const res = await fetchURL(`/api/users`, { method: "POST", body: JSON.stringify({ @@ -24,7 +23,11 @@ export async function create(user: User) { } } +<<<<<<< HEAD export async function update(user: User, which = ["all"]) { +======= +export async function update(user: IUser, which = ["all"]) { +>>>>>>> vue3-bak await fetchURL(`/api/users/${user.id}`, { method: "PUT", body: JSON.stringify({ diff --git a/frontend/src/api/utils.ts b/frontend/src/api/utils.ts index 452c7def..b413f786 100644 --- a/frontend/src/api/utils.ts +++ b/frontend/src/api/utils.ts @@ -1,5 +1,4 @@ import { useAuthStore } from "@/stores/auth"; -import type { ApiOpts, SearchParams } from "@/types"; import { renew, logout } from "@/utils/auth"; import { baseURL } from "@/utils/constants"; import { encodePath } from "@/utils/url"; diff --git a/frontend/src/components/settings/UserForm.vue b/frontend/src/components/settings/UserForm.vue index 080bb193..48aee2aa 100644 --- a/frontend/src/components/settings/UserForm.vue +++ b/frontend/src/components/settings/UserForm.vue @@ -74,10 +74,6 @@ import Commands from "./Commands.vue"; import { enableExec } from "@/utils/constants"; import { computed, onMounted, ref, watch } from "vue"; import { useI18n } from "vue-i18n"; -<<<<<<< HEAD -======= -import { IUser } from "@/types"; ->>>>>>> kloon15/vue3 const { t } = useI18n(); @@ -86,15 +82,9 @@ const originalUserScope = ref(null); const props = defineProps<{ user: IUser; -<<<<<<< HEAD - createUserDir: boolean; - isNew: boolean; - isDefault: boolean; -======= isNew: boolean; isDefault: boolean; createUserDir?: boolean; ->>>>>>> kloon15/vue3 }>(); onMounted(() => { diff --git a/frontend/src/i18n/index.ts b/frontend/src/i18n/index.ts index 4cd72d40..8acf7d4d 100644 --- a/frontend/src/i18n/index.ts +++ b/frontend/src/i18n/index.ts @@ -135,4 +135,4 @@ export const i18n = createI18n({ legacy: true, }); -export default i18n; +export default i18n; \ No newline at end of file diff --git a/frontend/src/stores/auth.ts b/frontend/src/stores/auth.ts index 8aefe926..940c0d18 100644 --- a/frontend/src/stores/auth.ts +++ b/frontend/src/stores/auth.ts @@ -1,4 +1,3 @@ -import type { IUser } from "@/types"; import { defineStore } from "pinia"; import dayjs from "dayjs"; import i18n, { detectLocale } from "@/i18n"; @@ -19,29 +18,24 @@ export const useAuthStore = defineStore("auth", { }, actions: { // no context as first argument, use `this` instead - setUser(user: IUser | null) { - if (user === null) { + setUser(value: IUser) { + if (value === null) { this.user = null; return; } - const locale = user.locale || detectLocale(); + const locale = value.locale || detectLocale(); dayjs.locale(locale); - // according to doc u only need .value if legacy: false but they lied + // according to doc u only need .value if legacy: false + // in createI18n but they lied // https://vue-i18n.intlify.dev/guide/essentials/scope.html#local-scope-1 //@ts-ignore - i18n.global.locale.value = locale; - this.user = user; + i18n.global.locale = locale; + this.user = value; }, - updateUser(user: Partial) { - if (user.locale) { - dayjs.locale(user.locale); - // see above - //@ts-ignore - i18n.global.locale.value = user.locale; - } - - this.user = { ...this.user, ...cloneDeep(user) } as IUser; + updateUser(value: IUser) { + if (typeof value !== "object" || !value) return; + this.setUser(cloneDeep(value)); }, // easily reset state using `$reset` clearUser() { diff --git a/frontend/src/stores/file.ts b/frontend/src/stores/file.ts index 4b0409d3..a1138c38 100644 --- a/frontend/src/stores/file.ts +++ b/frontend/src/stores/file.ts @@ -1,4 +1,3 @@ -import type { IFile } from "@/types"; import { defineStore } from "pinia"; export const useFileStore = defineStore("file", { diff --git a/frontend/src/stores/layout.ts b/frontend/src/stores/layout.ts index 27d98b16..18c65408 100644 --- a/frontend/src/stores/layout.ts +++ b/frontend/src/stores/layout.ts @@ -1,4 +1,3 @@ -import type { LayoutValue } from "@/types"; import { defineStore } from "pinia"; // import { useAuthPreferencesStore } from "./auth-preferences"; // import { useAuthEmailStore } from "./auth-email"; diff --git a/frontend/src/stores/upload.ts b/frontend/src/stores/upload.ts index 2788fd43..a2364b35 100644 --- a/frontend/src/stores/upload.ts +++ b/frontend/src/stores/upload.ts @@ -3,7 +3,6 @@ import { useFileStore } from "./file"; import { files as api } from "@/api"; import throttle from "lodash/throttle"; import buttons from "@/utils/buttons"; -import type { Item, Uploads } from "@/types"; // TODO: make this into a user setting const UPLOADS_LIMIT = 5; diff --git a/frontend/src/types/api.d.ts b/frontend/src/types/api.d.ts index 92529bd0..bd320b75 100644 --- a/frontend/src/types/api.d.ts +++ b/frontend/src/types/api.d.ts @@ -1,45 +1,38 @@ -export type ApiUrl = string; // Can also be set as a path eg: "path1" | "path2" +type ApiMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; -export type ApiMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; - -export type ApiContent = +type ApiContent = | Blob | File | Pick, "read"> | ""; -export interface ApiOpts { +interface ApiOpts { method?: ApiMethod; headers?: object; body?: any; } -export interface TusSettings { +interface TusSettings { retryCount: number; chunkSize: number; } -export type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512"; +type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512"; type inline = any; -<<<<<<< HEAD -interface IShare { +interface Share { expire: any; -======= -export interface IShare { ->>>>>>> kloon15/vue3 hash: string; path: string; - expire?: any; - userID?: number; - token?: string; + userID: number; + token: string; } interface settings { any; } -export interface SearchParams { +interface SearchParams { [key: string]: string; } diff --git a/frontend/src/types/file.d.ts b/frontend/src/types/file.d.ts index a7795cf0..f6ccc639 100644 --- a/frontend/src/types/file.d.ts +++ b/frontend/src/types/file.d.ts @@ -1,4 +1,4 @@ -export interface IFile { +interface IFile { index?: number; name: string; modified: string; @@ -14,7 +14,7 @@ export interface IFile { url?: string; } -export type FileType = +type FileType = | "video" | "audio" | "image" @@ -37,17 +37,17 @@ type req = { hash: string; }; -export interface Uploads { +interface Uploads { [key: string]: Upload; } -export interface Upload { +interface Upload { id: number; file: IFile; type: string; } -export interface Item { +interface Item { id: number; url?: string; path: string; diff --git a/frontend/src/types/index.d.ts b/frontend/src/types/index.d.ts deleted file mode 100644 index 4b35119b..00000000 --- a/frontend/src/types/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./api"; -export * from "./file"; -export * from "./layout"; -export * from "./settings"; -export * from "./toast"; -export * from "./user"; diff --git a/frontend/src/types/settings.d.ts b/frontend/src/types/settings.d.ts index 02ebbb28..8cc09d2f 100644 --- a/frontend/src/types/settings.d.ts +++ b/frontend/src/types/settings.d.ts @@ -1,6 +1,4 @@ -import type { Permissions } from "./user"; - -export interface ISettings { + interface ISettings { signup: boolean; createUserDir: boolean; userHomeBasePath: string; @@ -43,7 +41,7 @@ interface SettingsTus { retryCount: number; } -export interface SettingsCommand { +interface SettingsCommand { after_copy?: string[]; after_delete?: string[]; after_rename?: string[]; @@ -56,7 +54,7 @@ export interface SettingsCommand { before_upload?: string[]; } -export interface SettingsUnit { +interface SettingsUnit { KB: number; MB: number; GB: number; diff --git a/frontend/src/types/toast.d.ts b/frontend/src/types/toast.d.ts index 4428fff8..07917620 100644 --- a/frontend/src/types/toast.d.ts +++ b/frontend/src/types/toast.d.ts @@ -1,5 +1,5 @@ -export type IToastSuccess = (message: string) => void; -export type IToastError = ( +type IToastSuccess = (message: string) => void; +type IToastError = ( error: Error | string, displayReport?: boolean ) => void; diff --git a/frontend/src/types/user.d.ts b/frontend/src/types/user.d.ts index 3f6d5426..a79df7c7 100644 --- a/frontend/src/types/user.d.ts +++ b/frontend/src/types/user.d.ts @@ -1,16 +1,11 @@ -<<<<<<< HEAD type UserKey = keyof IUser; interface IUser { -======= -export interface IUser { ->>>>>>> kloon15/vue3 id: number; username: string; password: string; scope: string; locale: string; -<<<<<<< HEAD lockPassword: boolean; viewMode: string; singleClick: boolean; @@ -36,45 +31,4 @@ interface UserPerm { interface UserSorting { by: string; asc: boolean; -} -======= - perm: Permissions; - commands: string[]; - rules: IRule[]; - lockPassword: boolean; - hideDotfiles: boolean; - singleClick: boolean; - dateFormat: boolean; -} - -export interface Permissions { - admin: boolean; - copy: boolean; - create: boolean; - delete: boolean; - download: boolean; - execute: boolean; - modify: boolean; - move: boolean; - rename: boolean; - share: boolean; - shell: boolean; - upload: boolean; -} - -export interface UserSorting { - by: string; - asc: boolean; -} - -export interface IRule { - allow: boolean; - path: string; - regex: boolean; - regexp: IRegexp; -} - -interface IRegexp { - raw: string; -} ->>>>>>> kloon15/vue3 +} \ No newline at end of file diff --git a/frontend/src/utils/auth.ts b/frontend/src/utils/auth.ts index 6b4c00e2..520f4f63 100644 --- a/frontend/src/utils/auth.ts +++ b/frontend/src/utils/auth.ts @@ -3,11 +3,10 @@ import router from "@/router"; import jwt_decode from "jwt-decode"; import { baseURL } from "./constants"; import { StatusError } from "@/api/utils"; -import type { User } from "@/types"; export function parseToken(token: string) { // falsy or malformed jwt will throw InvalidTokenError - const data = jwt_decode<{ [key: string]: any; user: User }>(token); + const data = jwt_decode<{ [key: string]: any; user: IUser }>(token); document.cookie = `auth=${token}; Path=/; SameSite=Strict;`; diff --git a/frontend/src/utils/upload.ts b/frontend/src/utils/upload.ts index 4fa317b4..58fcbcb4 100644 --- a/frontend/src/utils/upload.ts +++ b/frontend/src/utils/upload.ts @@ -1,5 +1,4 @@ import { useUploadStore } from "@/stores/upload"; -import type { IFile, Item, FileType } from "@/types"; import url from "@/utils/url"; export function checkConflict(files: IFile[], items: Item[]) { diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index db85722c..2258167b 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -197,7 +197,6 @@ import { useLayoutStore } from "@/stores/layout"; import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from "vue"; import { useRoute } from "vue-router"; import { useI18n } from "vue-i18n"; -import type { IToastSuccess } from "@/types"; const error = ref(null); const showLimit = ref(100); @@ -335,6 +334,7 @@ const download = () => { const linkSelected = () => { return isSingleFile() && req.value ? api.getDownloadURL({ + ...req.value, hash: hash.value, path: req.value.items[fileStore.selected[0]].path, }) diff --git a/frontend/src/views/settings/Global.vue b/frontend/src/views/settings/Global.vue index 2a715bec..931e3ede 100644 --- a/frontend/src/views/settings/Global.vue +++ b/frontend/src/views/settings/Global.vue @@ -158,7 +158,6 @@

{{ t("settings.defaultUserDescription") }}

- (null); const originalSettings = ref(null); @@ -254,12 +246,12 @@ const settings = ref(null); const debounceTimeout = ref(null); const commandObject = ref<{ - [key in keyof SettingsCommand]: string[] | string; + [key in keyof SettingsCommand]: string; }>({}); const shellValue = ref(""); -const $showError = inject("$showError")!; -const $showSuccess = inject("$showSuccess")!; +const $showSuccess = inject("$showSuccess") as IToastSuccess; +const $showError = inject("$showError") as IToastError; const { t } = useI18n(); @@ -312,7 +304,6 @@ const save = async () => { commands: {}, }; -<<<<<<< HEAD // @ts-ignore for (const name of Object.keys(settings.value.commands)) { // @ts-ignore @@ -326,22 +317,6 @@ const save = async () => { } else { // @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 !== ""); ->>>>>>> kloon15/vue3 } } newSettings.shell = shellValue.value.split("\n"); @@ -396,20 +371,16 @@ onMounted(async () => { const original: ISettings = await api.get(); let newSettings: ISettings = { ...original, commands: {} }; - const keys = Object.keys(original.commands) as Array; - for (const key in keys) { - //@ts-ignore + for (const key in original.commands) { + // @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; -<<<<<<< HEAD // @ts-ignore -======= ->>>>>>> kloon15/vue3 shellValue.value = newSettings.shell.join("\n"); } catch (e) { error.value = e; diff --git a/frontend/src/views/settings/Profile.vue b/frontend/src/views/settings/Profile.vue index a51dd821..d899ff10 100644 --- a/frontend/src/views/settings/Profile.vue +++ b/frontend/src/views/settings/Profile.vue @@ -83,22 +83,13 @@ import Languages from "@/components/settings/Languages.vue"; // import i18n, { rtlLanguages } from "@/i18n"; import { inject, onMounted, ref } from "vue"; import { useI18n } from "vue-i18n"; -<<<<<<< HEAD -======= -import type { IToastError, IToastSuccess } from "@/types"; ->>>>>>> kloon15/vue3 const layoutStore = useLayoutStore(); const authStore = useAuthStore(); const { t } = useI18n(); -<<<<<<< HEAD -const $showError = inject("$showError") as TToast; -const $showSuccess = inject("$showSuccess") as TToast; -======= -const $showError = inject("$showError")!; -const $showSuccess = inject("$showSuccess")!; ->>>>>>> kloon15/vue3 +const $showSuccess = inject("$showSuccess") as IToastSuccess; +const $showError = inject("$showError") as IToastError; const password = ref(""); const passwordConf = ref(""); @@ -147,7 +138,7 @@ const updatePassword = async (event: Event) => { } try { - const data = { id: authStore.user.id, password: password.value }; + const data = {...authStore.user, id: authStore.user.id, password: password.value }; await api.update(data, ["password"]); authStore.updateUser(data); $showSuccess(t("settings.passwordUpdated")); @@ -162,6 +153,7 @@ const updateSettings = async (event: Event) => { if (authStore.user === null) throw "User is not set"; const data = { + ...authStore.user, id: authStore.user.id, locale: locale.value, hideDotfiles: hideDotfiles.value, diff --git a/frontend/src/views/settings/Shares.vue b/frontend/src/views/settings/Shares.vue index 5545d7e9..36831fd1 100644 --- a/frontend/src/views/settings/Shares.vue +++ b/frontend/src/views/settings/Shares.vue @@ -71,16 +71,9 @@ import Clipboard from "clipboard"; import Errors from "@/views/Errors.vue"; import { inject, onBeforeUnmount, ref, onMounted } from "vue"; import { useI18n } from "vue-i18n"; -<<<<<<< HEAD -const $showError = inject("$showError") as TToast; -const $showSuccess = inject("$showSuccess") as TToast; -======= -import type { IShare, IToastError, IToastSuccess } from "@/types"; - -const $showError = inject("$showError")!; -const $showSuccess = inject("$showSuccess")!; ->>>>>>> kloon15/vue3 +const $showError = inject("$showError") as IToastSuccess; +const $showSuccess = inject("$showSuccess") as IToastError; const { t } = useI18n(); const layoutStore = useLayoutStore(); @@ -142,7 +135,7 @@ const humanTime = (time: number) => { return dayjs(time * 1000).fromNow(); }; -const buildLink = (share: IShare) => { +const buildLink = (share: Share) => { return api.getShareURL(share); }; diff --git a/frontend/src/views/settings/User.vue b/frontend/src/views/settings/User.vue index c4b3a633..3dd6dfff 100644 --- a/frontend/src/views/settings/User.vue +++ b/frontend/src/views/settings/User.vue @@ -75,31 +75,19 @@ import { useLayoutStore } from "@/stores/layout"; import { users as api, settings } from "@/api"; import UserForm from "@/components/settings/UserForm.vue"; import Errors from "@/views/Errors.vue"; -<<<<<<< HEAD // @ts-ignore import { cloneDeep } from "lodash-es"; import { computed, inject, onMounted, ref, watch } from "vue"; import { useRoute, useRouter } from "vue-router"; import { useI18n } from "vue-i18n"; -======= -import { computed, inject, onMounted, ref, watch } from "vue"; -import { useRoute, useRouter } from "vue-router"; -import { useI18n } from "vue-i18n"; -import type { IToastError, IToastSuccess, IUser } from "@/types"; ->>>>>>> kloon15/vue3 const error = ref(null); const originalUser = ref(null); const user = ref(null); const createUserDir = ref(false); -<<<<<<< HEAD -const $showError = inject("$showError") as TToast; -const $showSuccess = inject("$showSuccess") as TToast; -======= -const $showError = inject("$showError")!; -const $showSuccess = inject("$showSuccess")!; ->>>>>>> kloon15/vue3 +const $showError = inject("$showError") as IToastError; +const $showSuccess = inject("$showSuccess") as IToastSuccess; const authStore = useAuthStore(); const layoutStore = useLayoutStore(); @@ -133,8 +121,6 @@ const fetchData = async () => { rules: [], lockPassword: false, id: 0, -<<<<<<< HEAD -======= }; } else { const id = Array.isArray(route.params.id) @@ -175,58 +161,8 @@ const save = async (event: Event) => { const newUser: IUser = { ...originalUser.value, ...user.value, ->>>>>>> kloon15/vue3 }; - } else { - const id = Array.isArray(route.params.id) - ? route.params.id.join("") - : route.params.id; - user.value = { ...(await api.get(parseInt(id))) }; - } - } catch (e) { - error.value = e; - } finally { - layoutStore.loading = false; - } -}; -<<<<<<< HEAD -const deletePrompt = () => layoutStore.showHover("deleteUser"); - -const deleteUser = async (e: Event) => { - e.preventDefault(); - if (user.value === null) { - return false; - } - try { - await api.remove(user.value.id); - router.push({ path: "/settings/users" }); - $showSuccess(t("settings.userDeleted")); - } catch (e: any) { - e.message === "403" ? $showError(t("errors.forbidden")) : $showError(e); - } -}; -const save = async (event: Event) => { - event.preventDefault(); - if (originalUser.value === null || user.value === null) { - return false; - } - let newUser: IUser = { - ...originalUser.value, - ...user.value, - }; - - try { - if (isNew.value) { - const loc = (await api.create(newUser)) as string; - router.push({ path: loc }); - $showSuccess(t("settings.userCreated")); - } else { - await api.update(user); - - if (user.value.id === authStore.user?.id) { - authStore.setUser({ ...cloneDeep(user) }); -======= const loc = (await api.create(newUser)) as string; router.push({ path: loc }); $showSuccess(t("settings.userCreated")); @@ -235,7 +171,6 @@ const save = async (event: Event) => { if (user.value.id === authStore.user?.id) { authStore.updateUser(user.value); ->>>>>>> kloon15/vue3 } $showSuccess(t("settings.userUpdated")); diff --git a/frontend/src/views/settings/Users.vue b/frontend/src/views/settings/Users.vue index 66a4ac43..5c609b9a 100644 --- a/frontend/src/views/settings/Users.vue +++ b/frontend/src/views/settings/Users.vue @@ -47,10 +47,6 @@ import { users as api } from "@/api"; import Errors from "@/views/Errors.vue"; import { onMounted, ref } from "vue"; import { useI18n } from "vue-i18n"; -<<<<<<< HEAD -======= -import type { IUser } from "@/types"; ->>>>>>> kloon15/vue3 const error = ref(null); const users = ref([]);