diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-17 21:03:00 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-17 21:03:00 +0200 |
commit | a877d5acc5c52b8667c65f725bbca9a52e40ec48 (patch) | |
tree | 20b5dd56f71c7572360807f894e85e0ab729629f /server/controllers/api | |
parent | 479f229198bdfcfd3a63d02babdddaa8b2209ccb (diff) | |
download | PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.tar.gz PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.tar.zst PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.zip |
Add ability to sort videos list
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/v1/videos.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index c6dbfbaf2..73e496ace 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -15,7 +15,9 @@ const oAuth2 = middlewares.oauth2 | |||
15 | const pagination = middlewares.pagination | 15 | const pagination = middlewares.pagination |
16 | const reqValidator = middlewares.reqValidators | 16 | const reqValidator = middlewares.reqValidators |
17 | const reqValidatorPagination = reqValidator.pagination | 17 | const reqValidatorPagination = reqValidator.pagination |
18 | const reqValidatorSort = reqValidator.sort | ||
18 | const reqValidatorVideos = reqValidator.videos | 19 | const reqValidatorVideos = reqValidator.videos |
20 | const sort = middlewares.sort | ||
19 | const utils = require('../../../helpers/utils') | 21 | const utils = require('../../../helpers/utils') |
20 | const Videos = require('../../../models/videos') // model | 22 | const Videos = require('../../../models/videos') // model |
21 | const videos = require('../../../lib/videos') | 23 | const videos = require('../../../lib/videos') |
@@ -47,6 +49,8 @@ const thumbnailsDir = path.join(__dirname, '..', '..', '..', '..', config.get('s | |||
47 | 49 | ||
48 | router.get('/', | 50 | router.get('/', |
49 | reqValidatorPagination.pagination, | 51 | reqValidatorPagination.pagination, |
52 | reqValidatorSort.videosSort, | ||
53 | sort.setVideosSort, | ||
50 | pagination.setPagination, | 54 | pagination.setPagination, |
51 | listVideos | 55 | listVideos |
52 | ) | 56 | ) |
@@ -68,6 +72,8 @@ router.delete('/:id', | |||
68 | router.get('/search/:name', | 72 | router.get('/search/:name', |
69 | reqValidatorVideos.videosSearch, | 73 | reqValidatorVideos.videosSearch, |
70 | reqValidatorPagination.pagination, | 74 | reqValidatorPagination.pagination, |
75 | reqValidatorSort.videosSort, | ||
76 | sort.setVideosSort, | ||
71 | pagination.setPagination, | 77 | pagination.setPagination, |
72 | searchVideos | 78 | searchVideos |
73 | ) | 79 | ) |
@@ -173,7 +179,7 @@ function getVideos (req, res, next) { | |||
173 | } | 179 | } |
174 | 180 | ||
175 | function listVideos (req, res, next) { | 181 | function listVideos (req, res, next) { |
176 | Videos.list(req.query.start, req.query.count, function (err, videosList) { | 182 | Videos.list(req.query.start, req.query.count, req.query.sort, function (err, videosList) { |
177 | if (err) return next(err) | 183 | if (err) return next(err) |
178 | 184 | ||
179 | res.json(getFormatedVideos(videosList)) | 185 | res.json(getFormatedVideos(videosList)) |
@@ -231,7 +237,7 @@ function removeVideo (req, res, next) { | |||
231 | } | 237 | } |
232 | 238 | ||
233 | function searchVideos (req, res, next) { | 239 | function searchVideos (req, res, next) { |
234 | Videos.search(req.params.name, req.query.start, req.query.count, function (err, videosList) { | 240 | Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList) { |
235 | if (err) return next(err) | 241 | if (err) return next(err) |
236 | 242 | ||
237 | res.json(getFormatedVideos(videosList)) | 243 | res.json(getFormatedVideos(videosList)) |