Skip to content

Commit

Permalink
feat: adapt the new task api (#120)
Browse files Browse the repository at this point in the history
* wip: adapt new api

* Squashed commit of the following:

commit 82869dd
Author: Andy Hsu <i@nn.ci>
Date:   Thu Oct 26 19:25:16 2023 +0800

    chore: change ts query key

commit 1243b9f
Author: Isla <bot@nn.ci>
Date:   Thu Oct 26 11:24:14 2023 +0000

    style: format code with prettier

commit 4f7d9c8
Author: IlaBot <bot@nn.ci>
Date:   Thu Oct 26 11:23:31 2023 +0000

    chore: auto update i18n file

commit d7febf8
Author: Andy Hsu <i@nn.ci>
Date:   Sun Oct 22 20:39:01 2023 +0800

    fix: missing font of katex (close AlistGo/alist#5417)

commit ab6701c
Author: Andy Hsu <i@nn.ci>
Date:   Sun Oct 22 19:05:48 2023 +0800

    feat: add shortcut for text save (close AlistGo/alist#5396)

commit 04d98e9
Author: Isla <bot@nn.ci>
Date:   Thu Oct 12 13:00:33 2023 +0000

    style: format code with prettier

commit cb4ee21
Author: IlaBot <bot@nn.ci>
Date:   Thu Oct 12 12:59:48 2023 +0000

    chore: auto update i18n file

* chore: main updates (#119)

* chore: auto update i18n file

* style: format code with prettier

* feat: add shortcut for text save (close AlistGo/alist#5396)

* fix: missing font of katex (close AlistGo/alist#5417)

* chore: auto update i18n file

* style: format code with prettier

* chore: change ts query key

* chore: auto update i18n file

* style: format code with prettier

* fix: package download setting does not take effect (close AlistGo/alist#5478)

* feat: audio player use list order by default (#115)

---------

Co-authored-by: IlaBot <bot@nn.ci>
Co-authored-by: 22 <60903333+nini22P@users.noreply.github.com>

---------

Co-authored-by: IlaBot <bot@nn.ci>
Co-authored-by: 22 <60903333+nini22P@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 6, 2023
1 parent a392bea commit 6cb6af8
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 31 deletions.
5 changes: 2 additions & 3 deletions src/lang/en/manage.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
"profile": "Profile",
"about": "About",
"tasks": "Tasks",
"aria2": "Aria2",
"upload": "Upload",
"copy": "Copy",
"backup-restore": "Backup & Restore",
"home": "Home",
"indexes": "Indexes",
"sso": "Single Sign-on",
"qbit": "qBittorrent",
"docs": "Documentation"
"docs": "Documentation",
"offline_download": "Offline Download"
},
"title": "AList Manage",
"not_admin": "You are not admin user, please login with admin account.",
Expand Down
6 changes: 2 additions & 4 deletions src/lang/en/tasks.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"aria2_down": "Download file to local machine",
"aria2_transfer": "Transfer downloaded file to corresponding storage",
"qbit_down": "Download file to local machine",
"qbit_transfer": "Transfer downloaded file to corresponding storage",
"offline_download": "Download file to local machine",
"offline_download_transfer": "Transfer downloaded file to corresponding storage",
"upload": "Upload file to corresponding storage",
"copy": "Copy file from a storage to another storage",
"done": "Completed",
Expand Down
40 changes: 29 additions & 11 deletions src/pages/home/toolbar/OfflineDownload.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
import { Box, createDisclosure } from "@hope-ui/solid"
import { ModalInput, SelectWrapper } from "~/components"
import { useFetch, useRouter, useT } from "~/hooks"
import { offlineDownload, bus, handleRespWithNotifySuccess } from "~/utils"
import { createSignal, onCleanup } from "solid-js"
import {
offlineDownload,
bus,
handleRespWithNotifySuccess,
r,
handleResp,
} from "~/utils"
import { createSignal, onCleanup, onMount } from "solid-js"
import { PResp } from "~/types"

export const OfflineDownload = () => {
const t = useT()
const [type, setType] = createSignal("aria2")
const [tools, setTools] = createSignal([] as string[])
const [toolsLoading, reqTool] = useFetch((): PResp<string[]> => {
return r.get("/public/offline_download_tools")
})
const [tool, setTool] = createSignal("")
onMount(async () => {
const resp = await reqTool()
handleResp(resp, (data) => {
setTools(data)
setTool(data[0])
})
})

const { isOpen, onOpen, onClose } = createDisclosure()
const [loading, ok] = useFetch(offlineDownload)
const { pathname } = useRouter()
Expand All @@ -25,22 +44,21 @@ export const OfflineDownload = () => {
type="text"
opened={isOpen()}
onClose={onClose}
loading={loading()}
loading={toolsLoading() || loading()}
tips={t("home.toolbar.offline_download-tips")}
topSlot={
<Box mb="$2">
<SelectWrapper
value={type()}
onChange={(v) => setType(v)}
options={[
{ value: "aria2", label: "Aria2" },
{ value: "qbit", label: "qBittorrent" },
]}
value={tool()}
onChange={(v) => setTool(v)}
options={tools().map((tool) => {
return { value: tool, label: tool }
})}
/>
</Box>
}
onSubmit={async (urls) => {
const resp = await ok(pathname(), urls.split("\n"), type())
const resp = await ok(pathname(), urls.split("\n"), tool())
handleRespWithNotifySuccess(resp, () => {
onClose()
})
Expand Down
27 changes: 16 additions & 11 deletions src/pages/manage/sidemenu_items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import {
BsMedium,
BsFingerprint,
BsFront,
BsCloudArrowDownFill,
BsCloudUploadFill,
BsSearch,
} from "solid-icons/bs"
import { FiLogIn } from "solid-icons/fi"
import { SiMetabase } from "solid-icons/si"
import { CgDatabase } from "solid-icons/cg"
import { OcWorkflow2 } from "solid-icons/oc"
import { IoCopy, IoHome } from "solid-icons/io"
import { IoCopy, IoHome, IoMagnetOutline } from "solid-icons/io"
import { Component, lazy } from "solid-js"
import { Group, UserRole } from "~/types"
import { FaBrandsQuinscape, FaSolidBook, FaSolidDatabase } from "solid-icons/fa"
Expand Down Expand Up @@ -86,17 +85,23 @@ export const side_menu_items: SideMenuItem[] = [
to: "/@manage/tasks",
children: [
{
title: "manage.sidemenu.aria2",
icon: BsCloudArrowDownFill,
title: "manage.sidemenu.offline_download",
icon: IoMagnetOutline,
to: "/@manage/tasks/aria2",
component: lazy(() => import("./tasks/Aria2")),
},
{
title: "manage.sidemenu.qbit",
icon: FaBrandsQuinscape,
to: "/@manage/tasks/qbit",
component: lazy(() => import("./tasks/Qbit")),
component: lazy(() => import("./tasks/offline_download")),
},
// {
// title: "manage.sidemenu.aria2",
// icon: BsCloudArrowDownFill,
// to: "/@manage/tasks/aria2",
// component: lazy(() => import("./tasks/Aria2")),
// },
// {
// title: "manage.sidemenu.qbit",
// icon: FaBrandsQuinscape,
// to: "/@manage/tasks/qbit",
// component: lazy(() => import("./tasks/Qbit")),
// },
{
title: "manage.sidemenu.upload",
icon: BsCloudUploadFill,
Expand Down
15 changes: 15 additions & 0 deletions src/pages/manage/tasks/offline_download.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { VStack } from "@hope-ui/solid"
import { useManageTitle } from "~/hooks"
import { TypeTasks } from "./Tasks"

const OfflineDownload = () => {
useManageTitle("manage.sidemenu.offline_download")
return (
<VStack w="$full" alignItems="start" spacing="$4">
<TypeTasks type="offline_download" canRetry />
<TypeTasks type="offline_download_transfer" />
</VStack>
)
}

export default OfflineDownload
4 changes: 2 additions & 2 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export const fsNewFile = (path: string, password: string): PEmptyResp => {
export const offlineDownload = (
path: string,
urls: string[],
type: string,
tool: string,
): PEmptyResp => {
return r.post(`/fs/add_${type}`, { path, urls })
return r.post(`/fs/add_offline_download`, { path, urls, tool })
}

export const fetchText = async (
Expand Down

0 comments on commit 6cb6af8

Please sign in to comment.