update flap and add latest output button

This commit is contained in:
2019-08-14 10:03:19 -05:00
parent 5afe24ed52
commit 287cd0107d
6 changed files with 149 additions and 44 deletions

View File

@@ -196,6 +196,29 @@ class v1 {
return _flitter.view(res, 'dash_v1:out', {project, user: req.session.auth.user, out, prettyd:pretty, show_back: true, title: out.brief, title_small: true });
}
async out_latest(req, res, next){
const project = await Project.findById(req.params.project)
if ( !project || (!await devbug.permission.project.view(project, req.session.auth.user)) ){
return _flitter.error(res, 401, {reason: 'You do not have permission to view this project.'})
}
const out = await Out.findOne({}, {}, { sort: { 'created': -1 } })
if ( !out ){
return _flitter.error(res, 404, {reason: 'This project has no outputs yet.'})
}
let pretty
try {
pretty = JSON.stringify(JSON.parse(out.data), null, 4)
console.log('Pretty out: ', pretty)
}
catch (e){
return _flitter.error(res, 500, {reason: 'Unable to parse output data. Data contains invalid JSON.'})
}
return _flitter.view(res, 'dash_v1:out', {project, user: req.session.auth.user, out, prettyd:pretty, show_back: true, title: 'Latest output: '+out.brief, title_small: true });
}
async out_delete(req, res, next){
const out = await Out.findById(req.params.id)