Merge branch 'develop' into perf-v11
This commit is contained in:
@@ -182,18 +182,24 @@ router.get('/stop/:browserId', requireSignIn, async (req: AuthenticatedRequest,
|
||||
/**
|
||||
* GET endpoint for getting the id of the active remote browser.
|
||||
*/
|
||||
router.get('/active', requireSignIn, (req, res) => {
|
||||
const id = getActiveBrowserId();
|
||||
router.get('/active', requireSignIn, (req: AuthenticatedRequest, res) => {
|
||||
if (!req.user) {
|
||||
return res.status(401).send('User not authenticated');
|
||||
}
|
||||
const id = getActiveBrowserId(req.user?.id);
|
||||
return res.send(id);
|
||||
});
|
||||
|
||||
/**
|
||||
* GET endpoint for getting the current url of the active remote browser.
|
||||
*/
|
||||
router.get('/active/url', requireSignIn, (req, res) => {
|
||||
const id = getActiveBrowserId();
|
||||
router.get('/active/url', requireSignIn, (req: AuthenticatedRequest, res) => {
|
||||
if (!req.user) {
|
||||
return res.status(401).send('User not authenticated');
|
||||
}
|
||||
const id = getActiveBrowserId(req.user?.id);
|
||||
if (id) {
|
||||
const url = getRemoteBrowserCurrentUrl(id);
|
||||
const url = getRemoteBrowserCurrentUrl(id, req.user?.id);
|
||||
return res.send(url);
|
||||
}
|
||||
return res.send(null);
|
||||
@@ -202,10 +208,13 @@ router.get('/active/url', requireSignIn, (req, res) => {
|
||||
/**
|
||||
* GET endpoint for getting the current tabs of the active remote browser.
|
||||
*/
|
||||
router.get('/active/tabs', requireSignIn, (req, res) => {
|
||||
const id = getActiveBrowserId();
|
||||
router.get('/active/tabs', requireSignIn, (req: AuthenticatedRequest, res) => {
|
||||
if (!req.user) {
|
||||
return res.status(401).send('User not authenticated');
|
||||
}
|
||||
const id = getActiveBrowserId(req.user?.id);
|
||||
if (id) {
|
||||
const hosts = getRemoteBrowserCurrentTabs(id);
|
||||
const hosts = getRemoteBrowserCurrentTabs(id, req.user?.id);
|
||||
return res.send(hosts);
|
||||
}
|
||||
return res.send([]);
|
||||
@@ -219,7 +228,7 @@ router.get('/interpret', requireSignIn, async (req: AuthenticatedRequest, res) =
|
||||
if (!req.user) {
|
||||
return res.status(401).send('User not authenticated');
|
||||
}
|
||||
await interpretWholeWorkflow();
|
||||
await interpretWholeWorkflow(req.user?.id);
|
||||
return res.send('interpretation done');
|
||||
} catch (e) {
|
||||
return res.send('interpretation failed');
|
||||
@@ -233,7 +242,7 @@ router.get('/interpret/stop', requireSignIn, async (req: AuthenticatedRequest, r
|
||||
if (!req.user) {
|
||||
return res.status(401).send('User not authenticated');
|
||||
}
|
||||
await stopRunningInterpretation();
|
||||
await stopRunningInterpretation(req.user?.id);
|
||||
return res.send('interpretation stopped');
|
||||
});
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@ router.post('/runs/run/:id', requireSignIn, async (req: AuthenticatedRequest, re
|
||||
workflow, currentPage, (newPage: Page) => currentPage = newPage, plainRun.interpreterSettings);
|
||||
const binaryOutputService = new BinaryOutputService('maxun-run-screenshots');
|
||||
const uploadedBinaryOutput = await binaryOutputService.uploadAndStoreBinaryOutput(run, interpretationInfo.binaryOutput);
|
||||
await destroyRemoteBrowser(plainRun.browserId);
|
||||
await destroyRemoteBrowser(plainRun.browserId, req.user?.id);
|
||||
await run.update({
|
||||
...run,
|
||||
status: 'success',
|
||||
@@ -900,9 +900,13 @@ router.delete('/schedule/:id', requireSignIn, async (req: AuthenticatedRequest,
|
||||
/**
|
||||
* POST endpoint for aborting a current interpretation of the run.
|
||||
*/
|
||||
router.post('/runs/abort/:id', requireSignIn, async (req, res) => {
|
||||
router.post('/runs/abort/:id', requireSignIn, async (req: AuthenticatedRequest, res) => {
|
||||
try {
|
||||
const run = await Run.findOne({ where: { runId: req.params.id } });
|
||||
if (!req.user) { return res.status(401).send({ error: 'Unauthorized' }); }
|
||||
const run = await Run.findOne({ where: {
|
||||
runId: req.params.id,
|
||||
runByUserId: req.user.id,
|
||||
} });
|
||||
if (!run) {
|
||||
return res.status(404).send(false);
|
||||
}
|
||||
@@ -937,4 +941,4 @@ router.post('/runs/abort/:id', requireSignIn, async (req, res) => {
|
||||
logger.log('info', `Error while running a robot with name: ${req.params.fileName}_${req.params.runId}.json`);
|
||||
return res.send(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import logger from "../logger";
|
||||
import { browserPool } from "../server";
|
||||
import { requireSignIn } from '../middlewares/auth';
|
||||
import Robot from '../models/Robot';
|
||||
import { AuthenticatedRequest } from './record';
|
||||
|
||||
export const router = Router();
|
||||
|
||||
@@ -46,8 +47,9 @@ router.get('/params/:browserId', requireSignIn, (req, res) => {
|
||||
/**
|
||||
* DELETE endpoint for deleting a pair from the generated workflow.
|
||||
*/
|
||||
router.delete('/pair/:index', requireSignIn, (req, res) => {
|
||||
const id = browserPool.getActiveBrowserId();
|
||||
router.delete('/pair/:index', requireSignIn, (req: AuthenticatedRequest, res) => {
|
||||
if (!req.user) { return res.status(401).send('User not authenticated'); }
|
||||
const id = browserPool.getActiveBrowserId(req.user?.id);
|
||||
if (id) {
|
||||
const browser = browserPool.getRemoteBrowser(id);
|
||||
if (browser) {
|
||||
@@ -62,8 +64,9 @@ router.delete('/pair/:index', requireSignIn, (req, res) => {
|
||||
/**
|
||||
* POST endpoint for adding a pair to the generated workflow.
|
||||
*/
|
||||
router.post('/pair/:index', requireSignIn, (req, res) => {
|
||||
const id = browserPool.getActiveBrowserId();
|
||||
router.post('/pair/:index', requireSignIn, (req: AuthenticatedRequest, res) => {
|
||||
if (!req.user) { return res.status(401).send('User not authenticated'); }
|
||||
const id = browserPool.getActiveBrowserId(req.user?.id);
|
||||
if (id) {
|
||||
const browser = browserPool.getRemoteBrowser(id);
|
||||
logger.log('debug', `Adding pair to workflow`);
|
||||
@@ -82,8 +85,9 @@ router.post('/pair/:index', requireSignIn, (req, res) => {
|
||||
/**
|
||||
* PUT endpoint for updating a pair in the generated workflow.
|
||||
*/
|
||||
router.put('/pair/:index', requireSignIn, (req, res) => {
|
||||
const id = browserPool.getActiveBrowserId();
|
||||
router.put('/pair/:index', requireSignIn, (req: AuthenticatedRequest, res) => {
|
||||
if (!req.user) { return res.status(401).send('User not authenticated'); }
|
||||
const id = browserPool.getActiveBrowserId(req.user?.id);
|
||||
if (id) {
|
||||
const browser = browserPool.getRemoteBrowser(id);
|
||||
logger.log('debug', `Updating pair in workflow`);
|
||||
|
||||
Reference in New Issue
Block a user