mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-09 09:54:41 +08:00
Add queue list
This commit is contained in:
@@ -8,9 +8,10 @@ const widget = {
|
||||
mappings: {
|
||||
series: {
|
||||
endpoint: "series",
|
||||
map: (data) => ({
|
||||
total: asJson(data).length,
|
||||
})
|
||||
map: (data) => asJson(data).map((entry) => ({
|
||||
title: entry.title,
|
||||
id: entry.id
|
||||
}))
|
||||
},
|
||||
queue: {
|
||||
endpoint: "queue",
|
||||
@@ -24,6 +25,38 @@ const widget = {
|
||||
"totalRecords"
|
||||
]
|
||||
},
|
||||
"queue/details": {
|
||||
endpoint: "queue/details",
|
||||
map: (data) => asJson(data).map((entry) => ({
|
||||
trackedDownloadState: entry.trackedDownloadState,
|
||||
trackedDownloadStatus: entry.trackedDownloadStatus,
|
||||
timeLeft: entry.timeleft,
|
||||
size: entry.size,
|
||||
sizeLeft: entry.sizeleft,
|
||||
seriesId: entry.seriesId,
|
||||
episodeTitle: entry.episode?.title,
|
||||
episodeId: entry.episodeId
|
||||
})).sort((a, b) => {
|
||||
const downloadingA = a.trackedDownloadState === "downloading"
|
||||
const downloadingB = b.trackedDownloadState === "downloading"
|
||||
if (downloadingA && !downloadingB) {
|
||||
return -1;
|
||||
}
|
||||
if (downloadingB && !downloadingA) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const percentA = a.sizeLeft / a.size;
|
||||
const percentB = b.sizeLeft / b.size;
|
||||
if (percentA < percentB) {
|
||||
return -1;
|
||||
}
|
||||
if (percentA > percentB) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user