Skip to content

Commit

Permalink
N21-1751 open datasheet in shd (#249)
Browse files Browse the repository at this point in the history
* endpoint proxy for datasheet

---------

Co-authored-by: Marvin Öhlerking <[email protected]>
  • Loading branch information
IgorCapCoder and MarvinOehlerkingCap authored Feb 21, 2024
1 parent e24bdbc commit e354939
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controllers/ctltools.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ const getCreateHandler = (req, res, next) => {
};

const getTableActions = (item, path) => {
const baseUrl = process.env.HOST || 'http://localhost:3030';
return [
{
link: path + item.id,
Expand All @@ -136,7 +135,7 @@ const getTableActions = (item, path) => {
title: 'bearbeiten'
},
{
link: baseUrl + '/api/v3/tools/external-tools/' + item.id + '/datasheet',
link: path + item.id + '/datasheet',
class: 'btn-data-sheet',
icon: 'file-text-o',
title: 'Datenblatt anzeigen',
Expand Down Expand Up @@ -289,13 +288,22 @@ const showTools = (req, res) => {
});
};

const getDatasheet = (req,res,next) => {
try {
api(req, { version: 'v3' }).get(`/tools/external-tools/${req.params.id}/datasheet`).pipe(res);
} catch (e) {
next(e);
}
}

router.use(authHelper.authChecker);

router.get('/search', showTools);
router.put('/:id', getUpdateHandler);
router.get('/:id', getDetailHandler);
router.delete('/:id', getDeleteHandler);
router.post('/', getCreateHandler);
router.get('/:id/datasheet', getDatasheet);

router.all('/', showTools);

Expand Down

0 comments on commit e354939

Please sign in to comment.