You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
824 B

6 years ago
import { Target } from '../target'
import * as express from 'express'
async function addTask(req, res) {
let body = req.body;
let from = parseInt(body.from);
let to = parseInt(body.to);
6 years ago
let panelUrl = body.panelUrl;
let targets = [body.target];
let datasource = body.datasourceRequest;
let datasourceName = body.datasourceName;
6 years ago
let user = body.user;
6 years ago
if(isNaN(from) || isNaN(to)) {
res.status(500).send('Range error: please fill both "from" and "to" fields');
} else if(from >= to) {
res.status(500).send('Range error: "from" should be less than "to"');
} else {
res.status(200).send('Task added');
let target = new Target(panelUrl, user, datasource, targets, from, to, datasourceName);
6 years ago
target.export();
}
}
export const router = express.Router();
router.post('/', addTask);