feat(remote download): show download node in list page

This commit is contained in:
HFO4
2022-10-30 10:45:25 +08:00
parent 7dda81368d
commit f8ed4b4a5a
4 changed files with 19 additions and 2 deletions

View File

@@ -27,6 +27,13 @@ type DownloadListService struct {
func (service *DownloadListService) Finished(c *gin.Context, user *model.User) serializer.Response {
// 查找下载记录
downloads := model.GetDownloadsByStatusAndUser(service.Page, user.ID, common.Error, common.Complete, common.Canceled, common.Unknown)
for key, download := range downloads {
node := cluster.Default.GetNodeByID(download.GetNodeID())
if node != nil {
downloads[key].NodeName = node.DBModel().Name
}
}
return serializer.BuildFinishedListResponse(downloads)
}
@@ -35,12 +42,17 @@ func (service *DownloadListService) Downloading(c *gin.Context, user *model.User
// 查找下载记录
downloads := model.GetDownloadsByStatusAndUser(service.Page, user.ID, common.Downloading, common.Seeding, common.Paused, common.Ready)
intervals := make(map[uint]int)
for _, download := range downloads {
for key, download := range downloads {
if _, ok := intervals[download.ID]; !ok {
if node := cluster.Default.GetNodeByID(download.GetNodeID()); node != nil {
intervals[download.ID] = node.DBModel().Aria2OptionsSerialized.Interval
}
}
node := cluster.Default.GetNodeByID(download.GetNodeID())
if node != nil {
downloads[key].NodeName = node.DBModel().Name
}
}
return serializer.BuildDownloadingResponse(downloads, intervals)