diff --git a/frontend/src/api/fetch.tsx b/frontend/src/api/fetch.tsx new file mode 100644 index 00000000..b852a908 --- /dev/null +++ b/frontend/src/api/fetch.tsx @@ -0,0 +1,21 @@ +import { fetchURL, removePrefix } from "@/api/utils.ts"; + +export async function fetchUrlFile( + savePath: string, + saveName: string, + fetchUrl: string, + opts: ApiOpts +) { + const res = await fetchURL(`/api/download/`, { + method: "POST", + body: JSON.stringify({ + url: fetchUrl, + pathname: removePrefix(savePath), + filename: saveName, + }), + ...opts, + }); + const taskID = await res.text(); + console.log("on create download task: ", taskID); + return taskID; +} diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index abc189dc..eda7216c 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -3,7 +3,8 @@ import * as share from "./share"; import * as users from "./users"; import * as settings from "./settings"; import * as pub from "./pub"; +import * as fetcher from "./fetch.tsx"; import search from "./search"; import commands from "./commands"; -export { files, share, users, settings, pub, commands, search }; +export { files, share, users, settings, pub, fetcher, commands, search }; diff --git a/frontend/src/components/prompts/Fetch.vue b/frontend/src/components/prompts/Fetch.vue new file mode 100644 index 00000000..624f8af4 --- /dev/null +++ b/frontend/src/components/prompts/Fetch.vue @@ -0,0 +1,120 @@ + + + + {{ t("prompts.fetch") }} + + + + {{ t("prompts.fetchUrl") }} + + + + + {{ t("prompts.fetchSaveName") }} + + + + + + {{ t("buttons.cancel") }} + + + {{ t("buttons.create") }} + + + + + + + + diff --git a/frontend/src/components/prompts/Prompts.vue b/frontend/src/components/prompts/Prompts.vue index 71e4e753..6d37aa54 100644 --- a/frontend/src/components/prompts/Prompts.vue +++ b/frontend/src/components/prompts/Prompts.vue @@ -25,6 +25,7 @@ import Share from "./Share.vue"; import ShareDelete from "./ShareDelete.vue"; import Upload from "./Upload.vue"; import DiscardEditorChanges from "./DiscardEditorChanges.vue"; +import Fetch from "@/components/prompts/Fetch.vue"; const layoutStore = useLayoutStore(); @@ -47,6 +48,7 @@ const components = new Map([ ["share-delete", ShareDelete], ["deleteUser", DeleteUser], ["discardEditorChanges", DiscardEditorChanges], + ["fetch", Fetch], ]); watch(currentPromptName, (newValue) => { diff --git a/frontend/src/views/files/FileListing.vue b/frontend/src/views/files/FileListing.vue index 8fa48f72..7e5db252 100644 --- a/frontend/src/views/files/FileListing.vue +++ b/frontend/src/views/files/FileListing.vue @@ -58,6 +58,12 @@ :label="t('buttons.switchView')" @action="switchView" /> + (null); const nameSorted = computed(() => - fileStore.req ? fileStore.req.sorting.by === "name" : false + fileStore.req ? fileStore.req.sorting.by === "name" : false, ); const sizeSorted = computed(() => - fileStore.req ? fileStore.req.sorting.by === "size" : false + fileStore.req ? fileStore.req.sorting.by === "size" : false, ); const modifiedSorted = computed(() => - fileStore.req ? fileStore.req.sorting.by === "modified" : false + fileStore.req ? fileStore.req.sorting.by === "modified" : false, ); const ascOrdered = computed(() => - fileStore.req ? fileStore.req.sorting.asc : false + fileStore.req ? fileStore.req.sorting.asc : false, ); const dirs = computed(() => items.value.dirs.slice(0, showLimit.value)); @@ -412,6 +410,7 @@ const headerButtons = computed(() => { share: fileStore.selectedCount === 1 && authStore.user?.perm.share, move: fileStore.selectedCount > 0 && authStore.user?.perm.rename, copy: fileStore.selectedCount > 0 && authStore.user?.perm.create, + fetch: authStore.user?.perm.create, }; }); @@ -644,7 +643,7 @@ const colunmsResize = () => { if (items_ === null) return; let columns = Math.floor( - (document.querySelector("main")?.offsetWidth ?? 0) / columnWidth.value + (document.querySelector("main")?.offsetWidth ?? 0) / columnWidth.value, ); if (columns === 0) columns = 1; items_.style.width = `calc(${100 / columns}% - 1em)`; @@ -854,6 +853,16 @@ const windowsResize = throttle(() => { fillWindow(); }, 100); +const fetch = () => { + layoutStore.showHover({ + prompt: "fetch", + confirm: (format: any) => { + layoutStore.closeHovers(); + + }, + }); +}; + const download = () => { if (fileStore.req === null) return; @@ -942,7 +951,7 @@ const fillWindow = (fit = false) => { // Quantity of items needed to fill 2x of the window height const showQuantity = Math.ceil( - (windowHeight + windowHeight * 2) / itemWeight.value + (windowHeight + windowHeight * 2) / itemWeight.value, ); // Less items to display than current
{{ t("prompts.fetchUrl") }}
{{ t("prompts.fetchSaveName") }}