mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-10-17 13:19:18 +02:00
Previously, failed downloads showed only an alert icon and a dismiss (X) button — the user had no way to retry or reach the resource page without manually re-adding the download and finding the source URL elsewhere. This commit adds: - POST /api/downloads/jobs/:jobId/retry endpoint (controller + service) - retryDownloadJob() API method on the frontend - Failed-state UI in ActiveDownloads.tsx now shows: - Retry button (re-dispatches the original download job) - 'Download page' external link (when the download URL is an HTTP(S) URL) - Loading state on the retry button while the request is in-flight - Screenshots documenting before/after UI Co-authored-by: eizus <hello@cdr.xyz>
32 lines
971 B
TypeScript
32 lines
971 B
TypeScript
import type { HttpContext } from '@adonisjs/core/http'
|
|
import { DownloadService } from '#services/download_service'
|
|
import { downloadJobsByFiletypeSchema } from '#validators/download'
|
|
import { inject } from '@adonisjs/core'
|
|
|
|
@inject()
|
|
export default class DownloadsController {
|
|
constructor(private downloadService: DownloadService) {}
|
|
|
|
async index() {
|
|
return this.downloadService.listDownloadJobs()
|
|
}
|
|
|
|
async filetype({ request }: HttpContext) {
|
|
const payload = await request.validateUsing(downloadJobsByFiletypeSchema)
|
|
return this.downloadService.listDownloadJobs(payload.params.filetype)
|
|
}
|
|
|
|
async removeJob({ params }: HttpContext) {
|
|
await this.downloadService.removeFailedJob(params.jobId)
|
|
return { success: true }
|
|
}
|
|
|
|
async cancelJob({ params }: HttpContext) {
|
|
return this.downloadService.cancelJob(params.jobId)
|
|
}
|
|
|
|
async retryJob({ params }: HttpContext) {
|
|
return this.downloadService.retryFailedJob(params.jobId)
|
|
}
|
|
}
|