UI improvements
This commit is contained in:
parent
15087ca30f
commit
1bd6ad1830
@ -24,12 +24,37 @@ class v1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_project_show(req, res, next){
|
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){
|
async new_project_do(req, res, next){
|
||||||
if ( !req.body.name ){
|
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({
|
const project = new Project({
|
||||||
@ -49,13 +74,14 @@ class v1 {
|
|||||||
|
|
||||||
async project_view(req, res, next){
|
async project_view(req, res, next){
|
||||||
const project = await Project.findById(req.params.id)
|
const project = await Project.findById(req.params.id)
|
||||||
const outs = await Out.find({ project_id: project.id }).sort('-created')
|
|
||||||
|
|
||||||
if ( !project ){
|
if ( !project ){
|
||||||
_flitter.error(res, 404, 'Project not found.')
|
_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){
|
async out_view(req, res, next){
|
||||||
@ -66,7 +92,26 @@ class v1 {
|
|||||||
const pretty = JSON.stringify(JSON.parse(out.data), null, 4)
|
const pretty = JSON.stringify(JSON.parse(out.data), null, 4)
|
||||||
|
|
||||||
// TODO permission access check
|
// 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/new': [ _flitter.controller('dash:v1').new_project_show ],
|
||||||
'/project/view/:id': [ _flitter.controller('dash:v1').project_view ],
|
'/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 ],
|
'/out/view/:id': [ _flitter.controller('dash:v1').out_view ],
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -53,6 +56,8 @@ const v1 = {
|
|||||||
*/
|
*/
|
||||||
post: {
|
post: {
|
||||||
'/project/new': [ _flitter.controller('dash:v1').new_project_do ],
|
'/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,30 +1,23 @@
|
|||||||
html
|
extends ./template
|
||||||
head
|
block content
|
||||||
title DevBug Dashboard
|
h3 My Projects
|
||||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
ul(style='list-style-type: none;')
|
||||||
body
|
li
|
||||||
h1 DevBug Dashboard
|
a(href='/dash/v1/project/new') Create New Project
|
||||||
ul.navul
|
table
|
||||||
li.navli
|
thead
|
||||||
a.nava(href='/auth/logout') Logout
|
tr
|
||||||
h3 My Projects
|
th(scope='col' style='min-width: 250px') Name
|
||||||
ul(style='list-style-type: none;')
|
th(scope='col') Actions
|
||||||
li
|
tbody
|
||||||
a(href='/dash/v1/project/new') Create New Project
|
each project in projects
|
||||||
table
|
|
||||||
thead
|
|
||||||
tr
|
tr
|
||||||
th(scope='col' style='min-width: 250px') Name
|
td #{project.name}
|
||||||
th(scope='col') Actions
|
td
|
||||||
tbody
|
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||||
each project in projects
|
li
|
||||||
tr
|
a.action(href='/dash/v1/project/view/'+project.id) View
|
||||||
td #{project.name}
|
li
|
||||||
td
|
a.action(href='/dash/v1/project/delete/'+project.id) Delete
|
||||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
li
|
||||||
li
|
a.action(href='/dash/v1/project/edit/'+project.id) Edit
|
||||||
a.action(href='/dash/v1/project/view/'+project.id) View
|
|
||||||
li
|
|
||||||
a.action(href='/dash/v1/project/delete/'+project.id) Delete
|
|
||||||
li
|
|
||||||
a.action(href='/dash/v1/project/edit/'+project.id) Edit
|
|
||||||
|
@ -1,16 +1,5 @@
|
|||||||
html
|
extends ./template
|
||||||
head
|
block content
|
||||||
title #{out.brief}
|
pre
|
||||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
code
|
||||||
body
|
div #{prettyd}
|
||||||
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
|
|
||||||
pre
|
|
||||||
code
|
|
||||||
div #{prettyd}
|
|
@ -1,15 +1,11 @@
|
|||||||
html
|
extends ./template
|
||||||
head
|
block content
|
||||||
title #{(update ? 'Update Project' : 'Create New Project')} | DevBug
|
if errors
|
||||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
each error in errors
|
||||||
body
|
p(style='color: red; font-weight: bold;') #{error}
|
||||||
h2 #{(update ? 'Update Project' : 'Create New Project')}
|
form(method='post', enctype='multipart/form-data')
|
||||||
if errors
|
label(for='project_name') Project Name:
|
||||||
each error in errors
|
input#project_name(type='text', name='name' value=(project_name ? project_name : '') required autofocus)
|
||||||
p(style='color: red; font-weight: bold;') #{error}
|
br
|
||||||
form(method='post', enctype='multipart/form-data')
|
br
|
||||||
label(for='project_name') Project Name:
|
button(type='submit') #{project_name ? 'Update Project' : 'Create Project'}
|
||||||
input#project_name(type='text', name='name' required autofocus)
|
|
||||||
br
|
|
||||||
br
|
|
||||||
button(type='submit') 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,27 +1,20 @@
|
|||||||
html
|
extends ./template
|
||||||
head
|
block content
|
||||||
title View: #{project.name} | Devbug
|
h3 Project API Key: #{project.uuid}
|
||||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
table
|
||||||
body
|
thead
|
||||||
h2 View: #{project.name}
|
tr
|
||||||
h4 API Key: #{ project.uuid }
|
th(scope='col' style='min-width: 250px') Brief
|
||||||
ul.navul
|
th(scope='col' style='min-width: 250px') Created On
|
||||||
li.navli
|
th(scope='col') Actions
|
||||||
a.nava(href='/dash/v1') Dashboard
|
tbody
|
||||||
li.navli
|
each out in outs
|
||||||
a.nava(href='/auth/logout') Logout
|
|
||||||
table
|
|
||||||
thead
|
|
||||||
tr
|
tr
|
||||||
th(scope='col' style='min-width: 250px') Brief
|
td #{out.brief}
|
||||||
th(scope='col' style='min-width: 250px') Created On
|
td #{ out.created.toLocaleString({timeZone: 'America/Chicago'}) }
|
||||||
th(scope='col') Actions
|
td
|
||||||
tbody
|
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
||||||
each out in outs
|
li
|
||||||
tr
|
a.action(href='/dash/v1/out/view/'+out.id) View
|
||||||
td #{out.brief}
|
li
|
||||||
td #{ out.created.toLocaleString({timeZone: 'America/Chicago'}) }
|
a.action(href='/dash/v1/out/delete/'+out.id) Delete
|
||||||
td
|
|
||||||
ul(style='list-style-type: none; margin: 0; padding: 0;')
|
|
||||||
li
|
|
||||||
a.action(href='/dash/v1/out/view/'+out.id) View
|
|
Loading…
Reference in New Issue
Block a user