Resolve various issues:

- Remove import types
- Mismatch in interface / types
- remove some weird git conflicts
This commit is contained in:
Joep 2023-09-11 22:25:29 +02:00
parent bf99823977
commit 101aba86fc
No known key found for this signature in database
GPG Key ID: 6F5588F1DC2A8209
30 changed files with 202 additions and 267 deletions

View File

@ -35,11 +35,15 @@
<<<<<<< HEAD <<<<<<< HEAD
"@intlify/unplugin-vue-i18n": "^0.12.3", "@intlify/unplugin-vue-i18n": "^0.12.3",
"@types/lodash-es": "^4.17.9", "@types/lodash-es": "^4.17.9",
<<<<<<< HEAD
======= =======
"@intlify/unplugin-vue-i18n": "^1.0.1", "@intlify/unplugin-vue-i18n": "^1.0.1",
"@types/lodash-es": "^4.17.9", "@types/lodash-es": "^4.17.9",
"@types/node": "^20.6.0", "@types/node": "^20.6.0",
>>>>>>> kloon15/vue3 >>>>>>> kloon15/vue3
=======
"@types/node": "^20.6.0",
>>>>>>> vue3-bak
"@typescript-eslint/eslint-plugin": "^6.6.0", "@typescript-eslint/eslint-plugin": "^6.6.0",
"@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-vue": "^4.3.4", "@vitejs/plugin-vue": "^4.3.4",
@ -2177,17 +2181,29 @@
} }
}, },
"node_modules/@eslint/js": { "node_modules/@eslint/js": {
<<<<<<< HEAD
"version": "8.49.0", "version": "8.49.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz",
"integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==", "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": { "engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
} }
}, },
"node_modules/@humanwhocodes/config-array": { "node_modules/@humanwhocodes/config-array": {
<<<<<<< HEAD
"version": "0.11.11", "version": "0.11.11",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz",
"integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==", "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": { "dependencies": {
"@humanwhocodes/object-schema": "^1.2.1", "@humanwhocodes/object-schema": "^1.2.1",
"debug": "^4.1.1", "debug": "^4.1.1",
@ -2504,6 +2520,7 @@
"version": "7.0.12", "version": "7.0.12",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
"integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==" "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA=="
<<<<<<< HEAD
}, },
"node_modules/@types/lodash": { "node_modules/@types/lodash": {
"version": "4.14.198", "version": "4.14.198",
@ -2525,6 +2542,8 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.0.tgz",
"integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==", "integrity": "sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==",
"dev": true "dev": true
=======
>>>>>>> vue3-bak
}, },
"node_modules/@types/lodash": { "node_modules/@types/lodash": {
"version": "4.14.198", "version": "4.14.198",
@ -2541,6 +2560,12 @@
"@types/lodash": "*" "@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": { "node_modules/@types/semver": {
"version": "7.5.1", "version": "7.5.1",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz",
@ -3067,6 +3092,39 @@
"node": ">=4.0" "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": { "node_modules/@vue/reactivity": {
"version": "3.3.4", "version": "3.3.4",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.4.tgz", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.4.tgz",
@ -3969,9 +4027,15 @@
} }
}, },
"node_modules/eslint": { "node_modules/eslint": {
<<<<<<< HEAD
"version": "8.49.0", "version": "8.49.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz",
"integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==", "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": { "dependencies": {
"@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1", "@eslint-community/regexpp": "^4.6.1",
@ -4082,6 +4146,39 @@
"eslint": "^6.2.0 || ^7.0.0 || ^8.0.0" "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": { "node_modules/eslint-scope": {
"version": "7.2.2", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
@ -4213,6 +4310,20 @@
"url": "https://opencollective.com/eslint" "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": { "node_modules/esprima": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
@ -6585,6 +6696,39 @@
"eslint": ">=6.0.0" "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": { "node_modules/vue-i18n": {
"version": "9.3.0", "version": "9.3.0",
"resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.3.0.tgz", "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.3.0.tgz",

View File

@ -38,14 +38,9 @@
"vue-toastification": "^2.0.0-rc.5" "vue-toastification": "^2.0.0-rc.5"
}, },
"devDependencies": { "devDependencies": {
<<<<<<< HEAD
"@intlify/unplugin-vue-i18n": "^0.12.3",
"@types/lodash-es": "^4.17.9", "@types/lodash-es": "^4.17.9",
=======
"@intlify/unplugin-vue-i18n": "^1.0.1", "@intlify/unplugin-vue-i18n": "^1.0.1",
"@types/lodash-es": "^4.17.9",
"@types/node": "^20.6.0", "@types/node": "^20.6.0",
>>>>>>> kloon15/vue3
"@typescript-eslint/eslint-plugin": "^6.6.0", "@typescript-eslint/eslint-plugin": "^6.6.0",
"@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-vue": "^4.3.4", "@vitejs/plugin-vue": "^4.3.4",

View File

@ -2,13 +2,6 @@ import { createURL, fetchURL, removePrefix } from "./utils";
import { baseURL } from "@/utils/constants"; import { baseURL } from "@/utils/constants";
import { useAuthStore } from "@/stores/auth"; import { useAuthStore } from "@/stores/auth";
import { upload as postTus, useTus } from "./tus"; import { upload as postTus, useTus } from "./tus";
import type {
ApiContent,
ApiMethod,
ApiOpts,
ChecksumAlgs,
IFile,
} from "@/types";
export async function fetch(url: string) { export async function fetch(url: string) {
url = removePrefix(url); url = removePrefix(url);

View File

@ -1,4 +1,3 @@
import type { IShare } from "@/types";
import { fetchURL, removePrefix, createURL } from "./utils"; import { fetchURL, removePrefix, createURL } from "./utils";
import { baseURL } from "@/utils/constants"; import { baseURL } from "@/utils/constants";
@ -67,7 +66,7 @@ export function download(
window.open(url); window.open(url);
} }
export function getDownloadURL(share: IShare, inline = false) { export function getDownloadURL(share: IFile, inline = false) {
const params = { const params = {
...(inline && { inline: "true" }), ...(inline && { inline: "true" }),
...(share.token && { token: share.token }), ...(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); return createURL("api/public/dl/" + share.hash + share.path, params, false);
} }

View File

@ -1,6 +1,5 @@
import { fetchURL, removePrefix } from "./utils"; import { fetchURL, removePrefix } from "./utils";
import url from "../utils/url"; import url from "../utils/url";
import type { Item } from "@/types";
export default async function search(base: string, query: string) { export default async function search(base: string, query: string) {
base = removePrefix(base); base = removePrefix(base);

View File

@ -1,4 +1,3 @@
import type { ISettings } from "@/types";
import { fetchURL, fetchJSON } from "./utils"; import { fetchURL, fetchJSON } from "./utils";
export function get() { export function get() {

View File

@ -1,11 +1,10 @@
import type { ApiUrl, IShare } from "@/types";
import { fetchURL, fetchJSON, removePrefix, createURL } from "./utils"; import { fetchURL, fetchJSON, removePrefix, createURL } from "./utils";
export async function list() { export async function list() {
return fetchJSON("/api/shares"); return fetchJSON("/api/shares");
} }
export async function get(url: ApiUrl) { export async function get(url: string) {
url = removePrefix(url); url = removePrefix(url);
return fetchJSON(`/api/share${url}`); return fetchJSON(`/api/share${url}`);
} }
@ -17,7 +16,7 @@ export async function remove(hash: string) {
} }
export async function create( export async function create(
url: ApiUrl, url: string,
password = "", password = "",
expires = "", expires = "",
unit = "hours" 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); return createURL("share/" + share.hash, {}, false);
} }

View File

@ -3,7 +3,6 @@ import { baseURL, tusEndpoint, tusSettings } from "@/utils/constants";
import { useAuthStore } from "@/stores/auth"; import { useAuthStore } from "@/stores/auth";
import { removePrefix } from "@/api/utils"; import { removePrefix } from "@/api/utils";
import { fetchURL } from "./utils"; import { fetchURL } from "./utils";
import type { ApiContent, TusSettings } from "@/types";
const RETRY_BASE_DELAY = 1000; const RETRY_BASE_DELAY = 1000;
const RETRY_MAX_DELAY = 20000; const RETRY_MAX_DELAY = 20000;

View File

@ -1,4 +1,3 @@
import type { User } from "@/types/user";
import { fetchURL, fetchJSON } from "./utils"; import { fetchURL, fetchJSON } from "./utils";
export async function getAll() { export async function getAll() {
@ -9,7 +8,7 @@ export async function get(id: number) {
return fetchJSON(`/api/users/${id}`, {}); return fetchJSON(`/api/users/${id}`, {});
} }
export async function create(user: User) { export async function create(user: IUser) {
const res = await fetchURL(`/api/users`, { const res = await fetchURL(`/api/users`, {
method: "POST", method: "POST",
body: JSON.stringify({ 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: User, which = ["all"]) {
=======
export async function update(user: IUser, which = ["all"]) {
>>>>>>> vue3-bak
await fetchURL(`/api/users/${user.id}`, { await fetchURL(`/api/users/${user.id}`, {
method: "PUT", method: "PUT",
body: JSON.stringify({ body: JSON.stringify({

View File

@ -1,5 +1,4 @@
import { useAuthStore } from "@/stores/auth"; import { useAuthStore } from "@/stores/auth";
import type { ApiOpts, SearchParams } from "@/types";
import { renew, logout } from "@/utils/auth"; import { renew, logout } from "@/utils/auth";
import { baseURL } from "@/utils/constants"; import { baseURL } from "@/utils/constants";
import { encodePath } from "@/utils/url"; import { encodePath } from "@/utils/url";

View File

@ -74,10 +74,6 @@ import Commands from "./Commands.vue";
import { enableExec } from "@/utils/constants"; import { enableExec } from "@/utils/constants";
import { computed, onMounted, ref, watch } from "vue"; import { computed, onMounted, ref, watch } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
<<<<<<< HEAD
=======
import { IUser } from "@/types";
>>>>>>> kloon15/vue3
const { t } = useI18n(); const { t } = useI18n();
@ -86,15 +82,9 @@ const originalUserScope = ref<string | null>(null);
const props = defineProps<{ const props = defineProps<{
user: IUser; user: IUser;
<<<<<<< HEAD
createUserDir: boolean;
isNew: boolean;
isDefault: boolean;
=======
isNew: boolean; isNew: boolean;
isDefault: boolean; isDefault: boolean;
createUserDir?: boolean; createUserDir?: boolean;
>>>>>>> kloon15/vue3
}>(); }>();
onMounted(() => { onMounted(() => {

View File

@ -135,4 +135,4 @@ export const i18n = createI18n({
legacy: true, legacy: true,
}); });
export default i18n; export default i18n;

View File

@ -1,4 +1,3 @@
import type { IUser } from "@/types";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import dayjs from "dayjs"; import dayjs from "dayjs";
import i18n, { detectLocale } from "@/i18n"; import i18n, { detectLocale } from "@/i18n";
@ -19,29 +18,24 @@ export const useAuthStore = defineStore("auth", {
}, },
actions: { actions: {
// no context as first argument, use `this` instead // no context as first argument, use `this` instead
setUser(user: IUser | null) { setUser(value: IUser) {
if (user === null) { if (value === null) {
this.user = null; this.user = null;
return; return;
} }
const locale = user.locale || detectLocale(); const locale = value.locale || detectLocale();
dayjs.locale(locale); 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 // https://vue-i18n.intlify.dev/guide/essentials/scope.html#local-scope-1
//@ts-ignore //@ts-ignore
i18n.global.locale.value = locale; i18n.global.locale = locale;
this.user = user; this.user = value;
}, },
updateUser(user: Partial<IUser>) { updateUser(value: IUser) {
if (user.locale) { if (typeof value !== "object" || !value) return;
dayjs.locale(user.locale); this.setUser(cloneDeep(value));
// see above
//@ts-ignore
i18n.global.locale.value = user.locale;
}
this.user = { ...this.user, ...cloneDeep(user) } as IUser;
}, },
// easily reset state using `$reset` // easily reset state using `$reset`
clearUser() { clearUser() {

View File

@ -1,4 +1,3 @@
import type { IFile } from "@/types";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
export const useFileStore = defineStore("file", { export const useFileStore = defineStore("file", {

View File

@ -1,4 +1,3 @@
import type { LayoutValue } from "@/types";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
// import { useAuthPreferencesStore } from "./auth-preferences"; // import { useAuthPreferencesStore } from "./auth-preferences";
// import { useAuthEmailStore } from "./auth-email"; // import { useAuthEmailStore } from "./auth-email";

View File

@ -3,7 +3,6 @@ import { useFileStore } from "./file";
import { files as api } from "@/api"; import { files as api } from "@/api";
import throttle from "lodash/throttle"; import throttle from "lodash/throttle";
import buttons from "@/utils/buttons"; import buttons from "@/utils/buttons";
import type { Item, Uploads } from "@/types";
// TODO: make this into a user setting // TODO: make this into a user setting
const UPLOADS_LIMIT = 5; const UPLOADS_LIMIT = 5;

View File

@ -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"; type ApiContent =
export type ApiContent =
| Blob | Blob
| File | File
| Pick<ReadableStreamDefaultReader<any>, "read"> | Pick<ReadableStreamDefaultReader<any>, "read">
| ""; | "";
export interface ApiOpts { interface ApiOpts {
method?: ApiMethod; method?: ApiMethod;
headers?: object; headers?: object;
body?: any; body?: any;
} }
export interface TusSettings { interface TusSettings {
retryCount: number; retryCount: number;
chunkSize: number; chunkSize: number;
} }
export type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512"; type ChecksumAlgs = "md5" | "sha1" | "sha256" | "sha512";
type inline = any; type inline = any;
<<<<<<< HEAD interface Share {
interface IShare {
expire: any; expire: any;
=======
export interface IShare {
>>>>>>> kloon15/vue3
hash: string; hash: string;
path: string; path: string;
expire?: any; userID: number;
userID?: number; token: string;
token?: string;
} }
interface settings { interface settings {
any; any;
} }
export interface SearchParams { interface SearchParams {
[key: string]: string; [key: string]: string;
} }

View File

@ -1,4 +1,4 @@
export interface IFile { interface IFile {
index?: number; index?: number;
name: string; name: string;
modified: string; modified: string;
@ -14,7 +14,7 @@ export interface IFile {
url?: string; url?: string;
} }
export type FileType = type FileType =
| "video" | "video"
| "audio" | "audio"
| "image" | "image"
@ -37,17 +37,17 @@ type req = {
hash: string; hash: string;
}; };
export interface Uploads { interface Uploads {
[key: string]: Upload; [key: string]: Upload;
} }
export interface Upload { interface Upload {
id: number; id: number;
file: IFile; file: IFile;
type: string; type: string;
} }
export interface Item { interface Item {
id: number; id: number;
url?: string; url?: string;
path: string; path: string;

View File

@ -1,6 +0,0 @@
export * from "./api";
export * from "./file";
export * from "./layout";
export * from "./settings";
export * from "./toast";
export * from "./user";

View File

@ -1,6 +1,4 @@
import type { Permissions } from "./user"; interface ISettings {
export interface ISettings {
signup: boolean; signup: boolean;
createUserDir: boolean; createUserDir: boolean;
userHomeBasePath: string; userHomeBasePath: string;
@ -43,7 +41,7 @@ interface SettingsTus {
retryCount: number; retryCount: number;
} }
export interface SettingsCommand { interface SettingsCommand {
after_copy?: string[]; after_copy?: string[];
after_delete?: string[]; after_delete?: string[];
after_rename?: string[]; after_rename?: string[];
@ -56,7 +54,7 @@ export interface SettingsCommand {
before_upload?: string[]; before_upload?: string[];
} }
export interface SettingsUnit { interface SettingsUnit {
KB: number; KB: number;
MB: number; MB: number;
GB: number; GB: number;

View File

@ -1,5 +1,5 @@
export type IToastSuccess = (message: string) => void; type IToastSuccess = (message: string) => void;
export type IToastError = ( type IToastError = (
error: Error | string, error: Error | string,
displayReport?: boolean displayReport?: boolean
) => void; ) => void;

View File

@ -1,16 +1,11 @@
<<<<<<< HEAD
type UserKey = keyof IUser; type UserKey = keyof IUser;
interface IUser { interface IUser {
=======
export interface IUser {
>>>>>>> kloon15/vue3
id: number; id: number;
username: string; username: string;
password: string; password: string;
scope: string; scope: string;
locale: string; locale: string;
<<<<<<< HEAD
lockPassword: boolean; lockPassword: boolean;
viewMode: string; viewMode: string;
singleClick: boolean; singleClick: boolean;
@ -36,45 +31,4 @@ interface UserPerm {
interface UserSorting { interface UserSorting {
by: string; by: string;
asc: boolean; 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

View File

@ -3,11 +3,10 @@ import router from "@/router";
import jwt_decode from "jwt-decode"; import jwt_decode from "jwt-decode";
import { baseURL } from "./constants"; import { baseURL } from "./constants";
import { StatusError } from "@/api/utils"; import { StatusError } from "@/api/utils";
import type { User } from "@/types";
export function parseToken(token: string) { export function parseToken(token: string) {
// falsy or malformed jwt will throw InvalidTokenError // 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;`; document.cookie = `auth=${token}; Path=/; SameSite=Strict;`;

View File

@ -1,5 +1,4 @@
import { useUploadStore } from "@/stores/upload"; import { useUploadStore } from "@/stores/upload";
import type { IFile, Item, FileType } from "@/types";
import url from "@/utils/url"; import url from "@/utils/url";
export function checkConflict(files: IFile[], items: Item[]) { export function checkConflict(files: IFile[], items: Item[]) {

View File

@ -197,7 +197,6 @@ import { useLayoutStore } from "@/stores/layout";
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from "vue"; import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import type { IToastSuccess } from "@/types";
const error = ref<null | any>(null); const error = ref<null | any>(null);
const showLimit = ref<number>(100); const showLimit = ref<number>(100);
@ -335,6 +334,7 @@ const download = () => {
const linkSelected = () => { const linkSelected = () => {
return isSingleFile() && req.value return isSingleFile() && req.value
? api.getDownloadURL({ ? api.getDownloadURL({
...req.value,
hash: hash.value, hash: hash.value,
path: req.value.items[fileStore.selected[0]].path, path: req.value.items[fileStore.selected[0]].path,
}) })

View File

@ -158,7 +158,6 @@
<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"
@ -240,13 +239,6 @@ import Themes from "@/components/settings/Themes.vue";
import Errors from "@/views/Errors.vue"; import Errors from "@/views/Errors.vue";
import { computed, inject, onBeforeUnmount, onMounted, ref } from "vue"; import { computed, inject, onBeforeUnmount, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import type {
ISettings,
IToastError,
IToastSuccess,
SettingsCommand,
SettingsUnit,
} from "@/types";
const error = ref<any>(null); const error = ref<any>(null);
const originalSettings = ref<ISettings | null>(null); const originalSettings = ref<ISettings | null>(null);
@ -254,12 +246,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[] | string; [key in keyof SettingsCommand]: string;
}>({}); }>({});
const shellValue = ref<string>(""); const shellValue = ref<string>("");
const $showError = inject<IToastError>("$showError")!; const $showSuccess = inject<IToastSuccess>("$showSuccess") as IToastSuccess;
const $showSuccess = inject<IToastSuccess>("$showSuccess")!; const $showError = inject<IToastError>("$showError") as IToastError;
const { t } = useI18n(); const { t } = useI18n();
@ -312,7 +304,6 @@ const save = async () => {
commands: {}, commands: {},
}; };
<<<<<<< HEAD
// @ts-ignore // @ts-ignore
for (const name of Object.keys(settings.value.commands)) { for (const name of Object.keys(settings.value.commands)) {
// @ts-ignore // @ts-ignore
@ -326,22 +317,6 @@ const save = async () => {
} else { } else {
// @ts-ignore // @ts-ignore
newSettings.commands[name] = newValue; 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"); newSettings.shell = shellValue.value.split("\n");
@ -396,20 +371,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: {} };
const keys = Object.keys(original.commands) as Array<keyof SettingsCommand>; for (const key in original.commands) {
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
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;
<<<<<<< HEAD
// @ts-ignore // @ts-ignore
=======
>>>>>>> kloon15/vue3
shellValue.value = newSettings.shell.join("\n"); shellValue.value = newSettings.shell.join("\n");
} catch (e) { } catch (e) {
error.value = e; error.value = e;

View File

@ -83,22 +83,13 @@ import Languages from "@/components/settings/Languages.vue";
// import i18n, { rtlLanguages } from "@/i18n"; // import i18n, { rtlLanguages } from "@/i18n";
import { inject, onMounted, ref } from "vue"; import { inject, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
<<<<<<< HEAD
=======
import type { IToastError, IToastSuccess } from "@/types";
>>>>>>> kloon15/vue3
const layoutStore = useLayoutStore(); const layoutStore = useLayoutStore();
const authStore = useAuthStore(); const authStore = useAuthStore();
const { t } = useI18n(); const { t } = useI18n();
<<<<<<< HEAD const $showSuccess = inject("$showSuccess") as IToastSuccess;
const $showError = inject("$showError") as TToast; const $showError = inject("$showError") as IToastError;
const $showSuccess = inject("$showSuccess") as TToast;
=======
const $showError = inject<IToastError>("$showError")!;
const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
>>>>>>> kloon15/vue3
const password = ref<string>(""); const password = ref<string>("");
const passwordConf = ref<string>(""); const passwordConf = ref<string>("");
@ -147,7 +138,7 @@ const updatePassword = async (event: Event) => {
} }
try { 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"]); await api.update(data, ["password"]);
authStore.updateUser(data); authStore.updateUser(data);
$showSuccess(t("settings.passwordUpdated")); $showSuccess(t("settings.passwordUpdated"));
@ -162,6 +153,7 @@ const updateSettings = async (event: Event) => {
if (authStore.user === null) throw "User is not set"; if (authStore.user === null) throw "User is not set";
const data = { const data = {
...authStore.user,
id: authStore.user.id, id: authStore.user.id,
locale: locale.value, locale: locale.value,
hideDotfiles: hideDotfiles.value, hideDotfiles: hideDotfiles.value,

View File

@ -71,16 +71,9 @@ import Clipboard from "clipboard";
import Errors from "@/views/Errors.vue"; import Errors from "@/views/Errors.vue";
import { inject, onBeforeUnmount, ref, onMounted } from "vue"; import { inject, onBeforeUnmount, ref, onMounted } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
<<<<<<< HEAD
const $showError = inject("$showError") as TToast; const $showError = inject("$showError") as IToastSuccess;
const $showSuccess = inject("$showSuccess") as TToast; const $showSuccess = inject("$showSuccess") as IToastError;
=======
import type { IShare, IToastError, IToastSuccess } from "@/types";
const $showError = inject<IToastError>("$showError")!;
const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
>>>>>>> kloon15/vue3
const { t } = useI18n(); const { t } = useI18n();
const layoutStore = useLayoutStore(); const layoutStore = useLayoutStore();
@ -142,7 +135,7 @@ const humanTime = (time: number) => {
return dayjs(time * 1000).fromNow(); return dayjs(time * 1000).fromNow();
}; };
const buildLink = (share: IShare) => { const buildLink = (share: Share) => {
return api.getShareURL(share); return api.getShareURL(share);
}; };
</script> </script>

View File

@ -75,31 +75,19 @@ import { useLayoutStore } from "@/stores/layout";
import { users as api, settings } from "@/api"; import { users as api, settings } from "@/api";
import UserForm from "@/components/settings/UserForm.vue"; import UserForm from "@/components/settings/UserForm.vue";
import Errors from "@/views/Errors.vue"; import Errors from "@/views/Errors.vue";
<<<<<<< HEAD
// @ts-ignore // @ts-ignore
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
import { computed, inject, onMounted, ref, watch } from "vue"; import { computed, inject, onMounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useI18n } from "vue-i18n"; 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<any | null>(null); const error = ref<any | null>(null);
const originalUser = ref<IUser | null>(null); const originalUser = ref<IUser | null>(null);
const user = ref<IUser | null>(null); const user = ref<IUser | null>(null);
const createUserDir = ref<boolean>(false); const createUserDir = ref<boolean>(false);
<<<<<<< HEAD const $showError = inject("$showError") as IToastError;
const $showError = inject("$showError") as TToast; const $showSuccess = inject("$showSuccess") as IToastSuccess;
const $showSuccess = inject("$showSuccess") as TToast;
=======
const $showError = inject<IToastError>("$showError")!;
const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
>>>>>>> kloon15/vue3
const authStore = useAuthStore(); const authStore = useAuthStore();
const layoutStore = useLayoutStore(); const layoutStore = useLayoutStore();
@ -133,8 +121,6 @@ const fetchData = async () => {
rules: [], rules: [],
lockPassword: false, lockPassword: false,
id: 0, id: 0,
<<<<<<< HEAD
=======
}; };
} else { } else {
const id = Array.isArray(route.params.id) const id = Array.isArray(route.params.id)
@ -175,58 +161,8 @@ const save = async (event: Event) => {
const newUser: IUser = { const newUser: IUser = {
...originalUser.value, ...originalUser.value,
...user.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; const loc = (await api.create(newUser)) as string;
router.push({ path: loc }); router.push({ path: loc });
$showSuccess(t("settings.userCreated")); $showSuccess(t("settings.userCreated"));
@ -235,7 +171,6 @@ const save = async (event: Event) => {
if (user.value.id === authStore.user?.id) { if (user.value.id === authStore.user?.id) {
authStore.updateUser(user.value); authStore.updateUser(user.value);
>>>>>>> kloon15/vue3
} }
$showSuccess(t("settings.userUpdated")); $showSuccess(t("settings.userUpdated"));

View File

@ -47,10 +47,6 @@ import { users as api } from "@/api";
import Errors from "@/views/Errors.vue"; import Errors from "@/views/Errors.vue";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
<<<<<<< HEAD
=======
import type { IUser } from "@/types";
>>>>>>> kloon15/vue3
const error = ref<any>(null); const error = ref<any>(null);
const users = ref<IUser[]>([]); const users = ref<IUser[]>([]);