93 lines
2.7 KiB
JavaScript
93 lines
2.7 KiB
JavaScript
module.exports = function (app) {
|
|
const router = require('express').Router(),
|
|
exportCtl = require('../controllers/export')(app);
|
|
|
|
/**
|
|
* @api {post} /exports/anyJob Any new assigned Job
|
|
* @apiVersion 1.2.1
|
|
* @apiName PostExportsAnyJob
|
|
* @apiGroup Exports
|
|
* @apiDescription Check for number of new assigned Jobs. Periodically calling this method to get the number of new assigned Jobs for the user.
|
|
* Recommended polling interval >= 1 seconds.
|
|
* @apiSuccess {Integer} total Total number of new Jobs
|
|
* @apiSuccessExample {json} Success
|
|
* HTTP/1.1 200 OK
|
|
* {
|
|
* "total": 1,
|
|
* }
|
|
*/
|
|
router.post('/anyJob', exportCtl.anyJob_post);
|
|
|
|
/**
|
|
* @api {post} /exports/newJobs Get new Jobs List
|
|
* @apiVersion 1.2.1
|
|
* @apiName PostExportsnewJobs
|
|
* @apiGroup Exports
|
|
* @apiSuccess {Object[]} items new assigned Jobs list
|
|
* @apiSuccess {Object} items.job the Job
|
|
* @apiSuccess {Integer} items.job._id Job's Id.
|
|
* @apiSuccess {String} items.job.name Job's name.
|
|
* @apiSuccess {Date} items.job.startDate Job's start date.
|
|
* @apiSuccess {Date} items.job.endDate Job's end date.
|
|
* @apiSuccess {Date} items.date job's assigned date
|
|
* @apiSuccessExample {json} Success
|
|
* HTTP/1.1 200 OK
|
|
* [
|
|
* {
|
|
* "job": {
|
|
* "_id": 137,
|
|
* "name": "Test_002",
|
|
* "endDate": "2018-03-06T19:58:18.858Z",
|
|
* "startDate": "2018-03-06T05:00:00.000Z"
|
|
* },
|
|
* "date": "2018-04-11T17:23:50.000Z"
|
|
* },
|
|
* {
|
|
* "job": {
|
|
* "_id": 174,
|
|
* "startDate": "2018-03-06T05:00:00.000Z",
|
|
* "endDate": null,
|
|
* "name": "Test_002-dup1"
|
|
* },
|
|
* "date": "2018-04-11T17:35:00.000Z"
|
|
* }
|
|
* ]
|
|
*/
|
|
router.post('/newJobs', exportCtl.newJobs_post)
|
|
|
|
/**
|
|
* @api {post} /exports/downloadJob Download a Job
|
|
* @apiVersion 1.2.1
|
|
* @apiName PostExportsdownloadJob
|
|
* @apiGroup Exports
|
|
* @apiDescription Download a Job as a zip file
|
|
* @apiParam {Integer} jobId Job Id
|
|
* @apiParam {Integer} type Download type.
|
|
*
|
|
* 1: AgNav
|
|
*
|
|
* 2: AgNav project. Combine all Job's items into 1 project file
|
|
*
|
|
* 3: ESRI Shape
|
|
* @apiParamExample {json} Request-Example:
|
|
* {
|
|
* "jobId": 1, "type": 1
|
|
* }
|
|
* @apiSuccessExample Success
|
|
* HTTP/1.1 200 OK
|
|
* (..binary file content..)
|
|
* @apiuse JobNotFoundError
|
|
* @apiuse JobNotAssignedError
|
|
* @apiuse JobNoSprayAreaError
|
|
*/
|
|
router.post('/downloadJob', exportCtl.downloadJob_post)
|
|
|
|
router.post('/downloadMap', exportCtl.downloadMap_post);
|
|
|
|
router.get("/downloadAppfile", exportCtl.downloadAppfile_get);
|
|
|
|
router.post('/downloadObs', exportCtl.downloadObs_post);
|
|
|
|
app.use('/api/exports', router);
|
|
};
|