basic snippets
This commit is contained in:
36
app/views/dash_v1/snippet.pug
Normal file
36
app/views/dash_v1/snippet.pug
Normal file
@@ -0,0 +1,36 @@
|
||||
extends ./template
|
||||
block content
|
||||
if errors
|
||||
each error in errors
|
||||
p(style='color: red; font-weight: bold;') #{error}
|
||||
if (!readonly)
|
||||
form#snippet_form(method='post' enctype='multipart/form-data')
|
||||
label(for='snippet_name') Snippet Title:
|
||||
input#snippet_name(type='text' name='title' autofocus required)
|
||||
input#snippet_value(type='hidden' name='data' required)
|
||||
pre#editor #{ snippet ? snippet.data : '' }
|
||||
if (!readonly)
|
||||
button(onclick='submitSnippet()') #{ snippet ? 'Update Snippet' : 'Create Snippet' }
|
||||
|
||||
block scripts
|
||||
script(src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js")
|
||||
script.
|
||||
const editor = ace.edit('editor');
|
||||
editor.setTheme('ace/theme/cobalt');
|
||||
//- editor.session.setMode('ace/mode/javascript');
|
||||
|
||||
function trim(s){
|
||||
return ( s || '' ).replace( /^\s+|\s+$/g, '' );
|
||||
}
|
||||
|
||||
function submitSnippet(){
|
||||
const form = document.getElementById('snippet_form');
|
||||
const value = document.getElementById('snippet_value');
|
||||
const name = document.getElementById('snippet_name');
|
||||
value.value = editor.getValue();
|
||||
|
||||
if ( trim(value.value) && trim(name.value) ) form.submit();
|
||||
}
|
||||
if readonly
|
||||
script.
|
||||
editor.setOption('readOnly', true)
|
||||
@@ -3,6 +3,7 @@ html
|
||||
title #{(title ? title+' | DevBug' : 'DevBug Dashboard')}
|
||||
link(rel='stylesheet' href='/assets/dash_v1.css')
|
||||
script(src='/assets/dash_v1.js')
|
||||
block head
|
||||
body
|
||||
.page-header
|
||||
.devbug-header DevBug | v#{devbug.version} #{(user ? " | User: "+user.username : "")} #{(project ? " | Project: "+project.name+" | API: "+project.uuid : "")} #{((_flitter.config('server.environment') === 'development') ? " | Development" : "" )}
|
||||
@@ -21,4 +22,7 @@ html
|
||||
li.navli
|
||||
a.nava(href='javascript:window.history.back()') Back
|
||||
.spacer
|
||||
block content
|
||||
.content
|
||||
block content
|
||||
block scripts
|
||||
//- .spacer
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
extends ./template
|
||||
block content
|
||||
h3 Project API Key: #{project.uuid}
|
||||
|
||||
h2 Code Snippets
|
||||
a.btn(href='/dash/v1/project/snippet/'+project.id+'/new') +
|
||||
table
|
||||
thead
|
||||
tr
|
||||
th(scope='col' style='min-width: 250px') Title
|
||||
th(scope='col') Actions
|
||||
|
||||
h2 Development Outputs
|
||||
table
|
||||
thead
|
||||
tr
|
||||
|
||||
Reference in New Issue
Block a user