agmission/Development/server/routes/upload_job.js

48 lines
1.8 KiB
JavaScript

module.exports = function (app) {
const router = require('express').Router(),
uploadJobCtl = require('../controllers/upload_job')(app),
{ checkRqPkgSubscription } = require('../middlewares/app_validator');
/**
* @api {post} /imports/uploadJob Upload Job items, data or both
* @apiVersion 1.2.1
* @apiName PostImportsUploadJob
* @apiGroup Imports
* @apiDescription Upload the file then update given Job with items, data files. Supported files: zip (AgNav or ESRI shape), kml/kml. Upload uses HTTP MultiPart form data encoding type.
* @apiParam {Integer} jobId Job Id
* @apiParam {Integer} updateOp Job update type. For aircraft users, value of 1 is normally always be used.
*
* 1: Only import data files
*
* 2: Append found items to job items
*
* 3: Override job items with the found items
*
* @apiParam name Field name for the file in Multipart. Value must always be "jobs[]"
* @apiSuccessExample {json} Success
* HTTP/1.1 200 OK
* @apiuse JobNotFoundError
* @apiuse WrongJobFileError
* @apiuse JobNotAssignedError
*/
router.post('/uploadJob', uploadJobCtl.uploadJob_post);
/**
* Handle uploading Job areas/data files from a multi-part request
*/
router.post('/uploadData', uploadJobCtl.uploadData_post);
router.post('/cancelImport', uploadJobCtl.cancelImport_post);
/**
* Handle uploading areas files (from a multi-part request) to add Areas from files to the Client's library
* @param ops options in structure:
* {
* clientId: [applicattor Id], // Optional when readOnly = true
* readOnly: [boolean], // Read the areas then return only, not store into db or other processing.
* }
**/
router.post('/uploadAreas', checkRqPkgSubscription, uploadJobCtl.uploadAreas_post);
app.use('/api/imports/', router);
}