UI improvements

master
Garrett Mills 4 years ago
parent 15087ca30f
commit 1bd6ad1830
  1. 55
      app/controllers/dash/v1.controller.js
  2. 5
      app/routing/routers/dash/v1.routes.js
  3. 5
      app/views/dash_v1/confirm.pug
  4. 51
      app/views/dash_v1/main.pug
  5. 21
      app/views/dash_v1/out.pug
  6. 26
      app/views/dash_v1/project.pug
  7. 18
      app/views/dash_v1/template.pug
  8. 45
      app/views/dash_v1/view.pug

@ -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 ],
},
}

@ -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
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
h3 My Projects
ul(style='list-style-type: none;')
li
a(href='/dash/v1/project/new') Create New Project
table
thead
extends ./template
block content
h3 My Projects
ul(style='list-style-type: none;')
li
a(href='/dash/v1/project/new') Create New Project
table
thead
tr
th(scope='col' style='min-width: 250px') Name
th(scope='col') Actions
tbody
each project in projects
tr
th(scope='col' style='min-width: 250px') Name
th(scope='col') Actions
tbody
each project in projects
tr
td #{project.name}
td
ul(style='list-style-type: none; margin: 0; padding: 0;')
li
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
td #{project.name}
td
ul(style='list-style-type: none; margin: 0; padding: 0;')
li
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
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
pre
code
div #{prettyd}
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')}
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)
br
br
button(type='submit') Create 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' value=(project_name ? project_name : '') required autofocus)
br
br
button(type='submit') #{project_name ? 'Update Project' : 'Create Project'}

@ -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
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
table
thead
extends ./template
block content
h3 Project API Key: #{project.uuid}
table
thead
tr
th(scope='col' style='min-width: 250px') Brief
th(scope='col' style='min-width: 250px') Created On
th(scope='col') Actions
tbody
each out in outs
tr
th(scope='col' style='min-width: 250px') Brief
th(scope='col' style='min-width: 250px') Created On
th(scope='col') Actions
tbody
each out in outs
tr
td #{out.brief}
td #{ out.created.toLocaleString({timeZone: 'America/Chicago'}) }
td
ul(style='list-style-type: none; margin: 0; padding: 0;')
li
a.action(href='/dash/v1/out/view/'+out.id) View
td #{out.brief}
td #{ out.created.toLocaleString({timeZone: 'America/Chicago'}) }
td
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…
Cancel
Save