Skip to content

Commit 244f77a

Browse files
authored
Improved imported card info (#93)
* Removed old audio file (not used anymore) * Added a button to jump to the album in the library. Also added some minimal information on source and location of imported items. The back button is now at the top left, as in the library view. * Removed foo in header.
1 parent 04610d3 commit 244f77a

File tree

3 files changed

+110
-169
lines changed

3 files changed

+110
-169
lines changed

frontend/src/components/inbox/cards/importedCard.tsx

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ImportIcon } from "lucide-react";
1+
import { ImportIcon, LibraryIcon, UndoIcon } from "lucide-react";
22
import {
33
Alert,
44
AlertProps,
@@ -8,13 +8,15 @@ import {
88
Card,
99
Divider,
1010
Skeleton,
11+
Typography,
12+
useTheme,
1113
} from "@mui/material";
1214
import { useMutation, useQuery } from "@tanstack/react-query";
15+
import { Link } from "@tanstack/react-router";
1316

1417
import { APIError } from "@/api/common";
1518
import { albumImportedOptions } from "@/api/library";
1619
import { enqueueMutationOptions, sessionQueryOptions } from "@/api/session";
17-
import { BackButton } from "@/components/common/inputs/back";
1820
import { humanizeBytes } from "@/components/common/units/bytes";
1921
import { relativeTime } from "@/components/common/units/time";
2022
import { useStatusSocket } from "@/components/common/websocket/status";
@@ -36,6 +38,7 @@ export function ImportedCard({
3638
folderHash: string;
3739
folderPath: string;
3840
}) {
41+
const theme = useTheme();
3942
const { data: session } = useQuery(
4043
sessionQueryOptions({
4144
folderPath,
@@ -64,20 +67,26 @@ export function ImportedCard({
6467
title="Imported into beets library"
6568
// FIXME: Timezones seem broken, at least for me it is 2 hours off
6669
subtitle={"Imported " + relativeTime(session.updated_at)}
67-
/>
70+
>
71+
<Box sx={{ ml: "auto", alignSelf: "flex-start" }}>
72+
{session.tasks.length > 1 && (
73+
<Typography variant="caption" component="div" textAlign="right">
74+
{session.tasks.length} tasks completed
75+
</Typography>
76+
)}
77+
</Box>
78+
</CardHeader>
6879
<Divider />
6980
<Box sx={{ display: "flex", flexDirection: "column", gap: 1 }}>
7081
{session.tasks.map((task) => (
7182
<ImportedTaskInfo key={task.id} task={task} />
7283
))}
7384
</Box>
7485
<Box display="flex" gap={2}>
75-
<BackButton variant="outlined" color="secondary" size="medium" />
7686
<Button
7787
variant="outlined"
7888
color="secondary"
7989
loading={isPending}
80-
sx={{ ml: "auto" }}
8190
onClick={() => {
8291
mutate({
8392
socket,
@@ -89,6 +98,7 @@ export function ImportedCard({
8998
delete_files: true,
9099
});
91100
}}
101+
startIcon={<UndoIcon size={theme.iconSize.md} />}
92102
>
93103
Undo Import
94104
</Button>
@@ -100,11 +110,12 @@ export function ImportedCard({
100110
// Shows some information on the imported album
101111
// using the beets library
102112
function ImportedTaskInfo({ task }: { task: SerializedTaskState }) {
113+
const theme = useTheme();
103114
const {
104115
data: album,
105116
error,
106117
isPending,
107-
} = useQuery(albumImportedOptions(task.id, true, true));
118+
} = useQuery(albumImportedOptions(task.id, true, false));
108119

109120
const chosenCandidate = task.candidates.find(
110121
(c) => c.id === task.chosen_candidate_id
@@ -120,9 +131,9 @@ function ImportedTaskInfo({ task }: { task: SerializedTaskState }) {
120131
throw error;
121132
}
122133

123-
return (
124-
<Box>
125-
{isPending && (
134+
if (isPending) {
135+
return (
136+
<Box>
126137
<Skeleton
127138
variant="rectangular"
128139
width="100%"
@@ -131,9 +142,74 @@ function ImportedTaskInfo({ task }: { task: SerializedTaskState }) {
131142
borderRadius: 1,
132143
}}
133144
/>
134-
)}
135-
{task.duplicate_action}
136-
{album && <AlbumInfo album={album} />}
145+
</Box>
146+
);
147+
}
148+
149+
return (
150+
<Box
151+
sx={{
152+
display: "flex",
153+
gap: 1,
154+
width: "100%",
155+
}}
156+
>
157+
<Box
158+
sx={{
159+
display: "flex",
160+
flexDirection: "row",
161+
flexGrow: 1,
162+
flexWrap: "wrap",
163+
columnGap: 1,
164+
label: {
165+
color: "text.secondary",
166+
},
167+
}}
168+
>
169+
<Typography variant="h6" component="div" sx={{ width: "100%" }}>
170+
{album.albumartist} - {album.name}
171+
</Typography>
172+
<Box>
173+
<Typography variant="body2" component="label">
174+
Source:
175+
</Typography>
176+
<Typography variant="body1" component="div" ml={1}>
177+
{task.toppath || task.paths.join(", ")}
178+
</Typography>
179+
</Box>
180+
<Box>
181+
<Typography variant="body2" component="label">
182+
Destination:
183+
</Typography>
184+
<Typography variant="body1" component="div" ml={1}>
185+
{album.items.at(0)?.path.split("/").slice(0, -1).join("/")}
186+
</Typography>
187+
</Box>
188+
<Box>
189+
<Typography variant="body2" component="label">
190+
Operation:
191+
</Typography>
192+
<Typography variant="body1" component="div" ml={1}>
193+
{/* TODO: Hardcoded for now, should be dynamic */}
194+
COPY
195+
</Typography>
196+
</Box>
197+
</Box>
198+
<Box sx={{ flexGrow: "0 1", ml: "auto", mt: "auto" }}>
199+
<Link
200+
to="/library/album/$albumId"
201+
params={{ albumId: album.id }}
202+
style={{ textDecoration: "none", height: "100%" }}
203+
>
204+
<Button
205+
variant="contained"
206+
color="secondary"
207+
startIcon={<LibraryIcon size={theme.iconSize.md} />}
208+
>
209+
View Album
210+
</Button>
211+
</Link>
212+
</Box>
137213
</Box>
138214
);
139215
}

frontend/src/components/library/audio.tsx

Lines changed: 0 additions & 152 deletions
This file was deleted.

frontend/src/routes/inbox/folder_.$path.$hash.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createFileRoute } from "@tanstack/react-router";
44

55
import { inboxFolderQueryOptions } from "@/api/inbox";
66
import { sessionQueryOptions } from "@/api/session";
7+
import { BackIconButton } from "@/components/common/inputs/back";
78
import { LoadingWithFeedback } from "@/components/common/loading";
89
import { PageWrapper } from "@/components/common/page";
910
import { FolderCard } from "@/components/inbox/cards/folderCard";
@@ -81,14 +82,30 @@ function RouteComponent() {
8182

8283
return (
8384
<PageWrapper
84-
sx={{
85+
sx={(theme) => ({
8586
display: "flex",
8687
flexDirection: "column",
87-
gap: 2,
88-
paddingBlock: 2,
89-
paddingInline: 1,
90-
}}
88+
minHeight: "100%",
89+
height: "100%",
90+
position: "relative",
91+
gap: 1,
92+
[theme.breakpoints.up("laptop")]: {
93+
padding: 2,
94+
},
95+
})}
9196
>
97+
<BackIconButton
98+
sx={{
99+
// TODO: styling for mobile
100+
position: "absolute",
101+
top: 0,
102+
left: 0,
103+
zIndex: 2,
104+
margin: 0.5,
105+
}}
106+
size="small"
107+
color="primary"
108+
/>
92109
<FolderCard folder={folder} />
93110
<TagCard folderHash={hash} folderPath={path} />
94111
<ImportedCard folderHash={hash} folderPath={path} />

0 commit comments

Comments
 (0)