UI improvements
This commit is contained in:
@@ -24,12 +24,37 @@ class v1 {
|
||||
}
|
||||
|
||||
new_project_show(req, res, next){
|
||||
return _flitter.view(res, 'dash_v1:project', {})
|
||||
return _flitter.view(res, 'dash_v1:project', { show_back: true, title: 'Create New Project' })
|
||||
}
|
||||
|
||||
async project_edit_show(req, res, next){
|
||||
const project = await Project.findById(req.params.id)
|
||||
if ( !project ){
|
||||
return _flitter.error(res, 404, 'Project not found with the specified ID.')
|
||||
}
|
||||
|
||||
return _flitter.view(res, 'dash_v1:project', { show_back: true, title: 'Update Project', project_name: project.name})
|
||||
}
|
||||
|
||||
async project_edit_do(req, res, next){
|
||||
const project = await Project.findById(req.params.id)
|
||||
if ( !project ){
|
||||
return _flitter.error(res, 404, 'Project not found with the specified ID.')
|
||||
}
|
||||
|
||||
if ( !req.body || !req.body.name ){
|
||||
return _flitter.view(res, 'dash_v1:project', {show_back: true, title: 'Update Project', project_name: project.name, errors: ['Project name is required.']})
|
||||
}
|
||||
|
||||
project.name = req.body.name
|
||||
await project.save()
|
||||
|
||||
return res.redirect('/dash/v1')
|
||||
}
|
||||
|
||||
async new_project_do(req, res, next){
|
||||
if ( !req.body.name ){
|
||||
return view(res, 'dash_v1:project', {errors: ['Project name is required.']})
|
||||
return _flitter.view(res, 'dash_v1:project', {show_back: true, title: 'Create Project', errors: ['Project name is required.']})
|
||||
}
|
||||
|
||||
const project = new Project({
|
||||
@@ -49,13 +74,14 @@ class v1 {
|
||||
|
||||
async project_view(req, res, next){
|
||||
const project = await Project.findById(req.params.id)
|
||||
const outs = await Out.find({ project_id: project.id }).sort('-created')
|
||||
|
||||
if ( !project ){
|
||||
_flitter.error(res, 404, 'Project not found.')
|
||||
}
|
||||
|
||||
return _flitter.view(res, 'dash_v1:view', { project, outs })
|
||||
const outs = await Out.find({ project_id: project.id }).sort('-created')
|
||||
|
||||
return _flitter.view(res, 'dash_v1:view', { project, outs, show_back: true, title: 'View: '+project.name })
|
||||
}
|
||||
|
||||
async out_view(req, res, next){
|
||||
@@ -66,7 +92,26 @@ class v1 {
|
||||
const pretty = JSON.stringify(JSON.parse(out.data), null, 4)
|
||||
|
||||
// TODO permission access check
|
||||
return _flitter.view(res, 'dash_v1:out', {out, prettyd:pretty});
|
||||
return _flitter.view(res, 'dash_v1:out', {out, prettyd:pretty, show_back: true, title: out.brief, title_small: true });
|
||||
}
|
||||
|
||||
project_delete_show(req, res, next){
|
||||
return _flitter.view(res, 'dash_v1:confirm', {show_back: true, title: 'Are you sure?', text: 'Deleting this project will remove all stored breakpoint data. This action cannot be undone.', destination: '/dash/v1/project/delete/'+req.params.id})
|
||||
}
|
||||
|
||||
async project_delete_do(req, res, next){
|
||||
const project = await Project.findById(req.params.id)
|
||||
if ( project ){
|
||||
const outs = await Out.find({project_id: project.id})
|
||||
|
||||
for ( const key in outs ){
|
||||
await outs[key].delete()
|
||||
}
|
||||
|
||||
await project.delete()
|
||||
}
|
||||
|
||||
return res.redirect('/dash/v1')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user