UI improvements
This commit is contained in:
parent
15087ca30f
commit
1bd6ad1830
@ -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')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,9 @@ const v1 = {
|
||||
|
||||
'/project/new': [ _flitter.controller('dash:v1').new_project_show ],
|
||||
'/project/view/:id': [ _flitter.controller('dash:v1').project_view ],
|
||||
'/project/delete/:id': [ _flitter.controller('dash:v1').project_delete_show ],
|
||||
'/project/edit/:id': [ _flitter.controller('dash:v1').project_edit_show ],
|
||||
|
||||
'/out/view/:id': [ _flitter.controller('dash:v1').out_view ],
|
||||
},
|
||||
|
||||
@ -53,6 +56,8 @@ const v1 = {
|
||||
*/
|
||||
post: {
|
||||
'/project/new': [ _flitter.controller('dash:v1').new_project_do ],
|
||||
'/project/delete/:id': [ _flitter.controller('dash:v1').project_delete_do ],
|
||||
'/project/edit/:id': [ _flitter.controller('dash:v1').project_edit_do ],
|
||||
},
|
||||
}
|
||||
|
||||
|
5
app/views/dash_v1/confirm.pug
Normal file
5
app/views/dash_v1/confirm.pug
Normal file
@ -0,0 +1,5 @@
|
||||
extends ./template
|
||||
block content
|
||||
p #{text}
|
||||
form(method='post' action=destination)
|
||||
button(type='submit') Yes, I'm sure.
|
@ -1,12 +1,5 @@
|
||||
html
|
||||
head
|
||||
title DevBug Dashboard
|
||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
||||
body
|
||||
h1 DevBug Dashboard
|
||||
ul.navul
|
||||
li.navli
|
||||
a.nava(href='/auth/logout') Logout
|
||||
extends ./template
|
||||
block content
|
||||
h3 My Projects
|
||||
ul(style='list-style-type: none;')
|
||||
li
|
||||
|
@ -1,16 +1,5 @@
|
||||
html
|
||||
head
|
||||
title #{out.brief}
|
||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
||||
body
|
||||
h2 #{out.brief}
|
||||
ul.navul
|
||||
li.navli
|
||||
a.nava(href='/dash/v1') Dashboard
|
||||
li.navli
|
||||
a.nava(href='javascript:window.history.back()') Back
|
||||
li.navli
|
||||
a.nava(href='/auth/logout') Logout
|
||||
extends ./template
|
||||
block content
|
||||
pre
|
||||
code
|
||||
div #{prettyd}
|
@ -1,15 +1,11 @@
|
||||
html
|
||||
head
|
||||
title #{(update ? 'Update Project' : 'Create New Project')} | DevBug
|
||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
||||
body
|
||||
h2 #{(update ? 'Update Project' : 'Create New Project')}
|
||||
extends ./template
|
||||
block content
|
||||
if errors
|
||||
each error in errors
|
||||
p(style='color: red; font-weight: bold;') #{error}
|
||||
form(method='post', enctype='multipart/form-data')
|
||||
label(for='project_name') Project Name:
|
||||
input#project_name(type='text', name='name' required autofocus)
|
||||
input#project_name(type='text', name='name' value=(project_name ? project_name : '') required autofocus)
|
||||
br
|
||||
br
|
||||
button(type='submit') Create Project
|
||||
button(type='submit') #{project_name ? 'Update Project' : 'Create Project'}
|
18
app/views/dash_v1/template.pug
Normal file
18
app/views/dash_v1/template.pug
Normal file
@ -0,0 +1,18 @@
|
||||
html
|
||||
head
|
||||
title #{(title ? title+' | DevBug' : 'DevBug Dashboard')}
|
||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
||||
body
|
||||
if title_small
|
||||
h3 #{(title ? title+' | DevBug' : 'DevBug Dashboard')}
|
||||
else
|
||||
h1 #{(title ? title+' | DevBug' : 'DevBug Dashboard')}
|
||||
ul.navul
|
||||
li.navli
|
||||
a.nava(href='/dash/v1') Home
|
||||
li.navli
|
||||
a.nava(href='/auth/logout') Logout
|
||||
if show_back
|
||||
li.navli
|
||||
a.nava(href='javascript:window.history.back()') Back
|
||||
block content
|
@ -1,15 +1,6 @@
|
||||
html
|
||||
head
|
||||
title View: #{project.name} | Devbug
|
||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
||||
body
|
||||
h2 View: #{project.name}
|
||||
h4 API Key: #{ project.uuid }
|
||||
ul.navul
|
||||
li.navli
|
||||
a.nava(href='/dash/v1') Dashboard
|
||||
li.navli
|
||||
a.nava(href='/auth/logout') Logout
|
||||
extends ./template
|
||||
block content
|
||||
h3 Project API Key: #{project.uuid}
|
||||
table
|
||||
thead
|
||||
tr
|
||||
@ -25,3 +16,5 @@ html
|
||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||
li
|
||||
a.action(href='/dash/v1/out/view/'+out.id) View
|
||||
li
|
||||
a.action(href='/dash/v1/out/delete/'+out.id) Delete
|
Loading…
Reference in New Issue
Block a user