summaryrefslogtreecommitdiffstats
path: root/server/api/ipxe.js
diff options
context:
space:
mode:
authorJannik Schönartz2019-03-10 03:24:33 +0100
committerJannik Schönartz2019-03-10 03:24:33 +0100
commit34ed0c5c0f85f620c1306db109b7f9fd69a4248f (patch)
tree932f0f3451d9ca54e87e76ff0faf0ec1ec35a1c9 /server/api/ipxe.js
parent[webapp/ipxe] Fix console autoscroll on linux (diff)
downloadbas-34ed0c5c0f85f620c1306db109b7f9fd69a4248f.tar.gz
bas-34ed0c5c0f85f620c1306db109b7f9fd69a4248f.tar.xz
bas-34ed0c5c0f85f620c1306db109b7f9fd69a4248f.zip
[ipxe] Add parameter to api how many lines the response should send and adjust frontend
Diffstat (limited to 'server/api/ipxe.js')
-rw-r--r--server/api/ipxe.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/api/ipxe.js b/server/api/ipxe.js
index 6367246..79b3b7f 100644
--- a/server/api/ipxe.js
+++ b/server/api/ipxe.js
@@ -28,12 +28,18 @@ router.get('/:version/console', (req, res) => {
})
router.get('/:version/log', async (req, res) => {
+ const max = req.query.max ? req.query.max : -1
res.setHeader('content-type', 'text/plain')
const filepath = path.join(__appdir, 'ipxe', 'log_' + req.params.version + '.txt')
- res.sendFile(filepath, err => {
- if (err) {
- res.end()
+
+ fs.readFile(filepath, 'utf-8', function (err, content) {
+ if (err) res.end()
+ if (max !== -1 && content) {
+ let c = content.split('\n')
+ c = c.splice(-max)
+ res.send(c.join('\n'))
}
+ else res.send(content)
})
})