update flap and add latest output button
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user