Skip to content

Commit

Permalink
add dataSheetHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
MBergCap committed Jan 26, 2024
1 parent d319421 commit 1ec6ead
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions controllers/ctltools.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ const getCreateHandler = (req, res, next) => {
});
};

const getDataSheetHandler = (req, res) => {

api(req, {version: 'v3'}).get(`/tools/external-tools/${req.params.id}/datasheet`)
.then(apiRes => {
res.setHeader('Content-Type', 'application/pdf');
res.send(apiRes);
})
}

const getTableActions = (item, path) => {
return [
{
Expand All @@ -135,10 +144,11 @@ const getTableActions = (item, path) => {
title: 'bearbeiten'
},
{
link: '/tools/external-tools/' + item.id + '/datasheet',
link: item.id + '/datasheet',
class: 'btn-data-sheet',
icon: 'file-text-o',
title: 'Datenblatt'
title: 'Datenblatt',
blank: '_blank'
},
{
link: path + item.id,
Expand Down Expand Up @@ -292,6 +302,7 @@ router.use(authHelper.authChecker);
router.get('/search', showTools);
router.put('/:id', getUpdateHandler);
router.get('/:id', getDetailHandler);
router.get('/:id/datasheet', getDataSheetHandler);
router.delete('/:id', getDeleteHandler);
router.post('/', getCreateHandler);

Expand Down
2 changes: 1 addition & 1 deletion views/lib/components/table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</button>
</form>
{{else}}
<a class="btn btn-secondary btn-sm {{this.class}}" href="{{this.link}}" title="{{this.title}}">
<a class="btn btn-secondary btn-sm {{this.class}}" href="{{this.link}}" title="{{this.title}}" target="{{blank}}">
<i class="fa fa-{{this.icon}}"></i> {{this.label}}
</a>
{{/if}}
Expand Down

0 comments on commit 1ec6ead

Please sign in to comment.