aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-13 19:27:25 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-12-13 19:27:25 +0100
commit040d6896a3cd5622e78cccdedd8cce2afcf49a31 (patch)
tree1c4a1503e1886ce411e008fd0b367ef0d12088e9 /server/controllers/api
parent7aebd32f8396827012aab5ea196158606c0611e3 (diff)
downloadPeerTube-040d6896a3cd5622e78cccdedd8cce2afcf49a31.tar.gz
PeerTube-040d6896a3cd5622e78cccdedd8cce2afcf49a31.tar.zst
PeerTube-040d6896a3cd5622e78cccdedd8cce2afcf49a31.zip
add display of logs matching any state
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/jobs.ts23
1 files changed, 20 insertions, 3 deletions
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts
index ed6c94533..1131a44d6 100644
--- a/server/controllers/api/jobs.ts
+++ b/server/controllers/api/jobs.ts
@@ -12,11 +12,23 @@ import {
12 setDefaultSort 12 setDefaultSort
13} from '../../middlewares' 13} from '../../middlewares'
14import { paginationValidator } from '../../middlewares/validators' 14import { paginationValidator } from '../../middlewares/validators'
15import { listJobsValidator } from '../../middlewares/validators/jobs' 15import { listJobsStateValidator, listJobsValidator } from '../../middlewares/validators/jobs'
16import { isArray } from '../../helpers/custom-validators/misc' 16import { isArray } from '../../helpers/custom-validators/misc'
17import { jobStates } from '@server/helpers/custom-validators/jobs'
17 18
18const jobsRouter = express.Router() 19const jobsRouter = express.Router()
19 20
21jobsRouter.get('/',
22 authenticate,
23 ensureUserHasRight(UserRight.MANAGE_JOBS),
24 paginationValidator,
25 jobsSortValidator,
26 setDefaultSort,
27 setDefaultPagination,
28 listJobsValidator,
29 asyncMiddleware(listJobs)
30)
31
20jobsRouter.get('/:state', 32jobsRouter.get('/:state',
21 authenticate, 33 authenticate,
22 ensureUserHasRight(UserRight.MANAGE_JOBS), 34 ensureUserHasRight(UserRight.MANAGE_JOBS),
@@ -25,6 +37,7 @@ jobsRouter.get('/:state',
25 setDefaultSort, 37 setDefaultSort,
26 setDefaultPagination, 38 setDefaultPagination,
27 listJobsValidator, 39 listJobsValidator,
40 listJobsStateValidator,
28 asyncMiddleware(listJobs) 41 asyncMiddleware(listJobs)
29) 42)
30 43
@@ -37,7 +50,7 @@ export {
37// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
38 51
39async function listJobs (req: express.Request, res: express.Response) { 52async function listJobs (req: express.Request, res: express.Response) {
40 const state = req.params.state as JobState 53 const state = req.params.state as JobState || jobStates
41 const asc = req.query.sort === 'createdAt' 54 const asc = req.query.sort === 'createdAt'
42 const jobType = req.query.jobType 55 const jobType = req.query.jobType
43 56
@@ -52,7 +65,11 @@ async function listJobs (req: express.Request, res: express.Response) {
52 65
53 const result: ResultList<Job> = { 66 const result: ResultList<Job> = {
54 total, 67 total,
55 data: jobs.map(j => formatJob(j, state)) 68 data: Array.isArray(state)
69 ? await Promise.all(
70 jobs.map(async j => formatJob(j, await j.getState() as JobState))
71 )
72 : jobs.map(j => formatJob(j, state))
56 } 73 }
57 return res.json(result) 74 return res.json(result)
58} 75}