feat: add logs
This commit is contained in:
parent
c40bdcbbed
commit
305bf8b571
11 changed files with 690 additions and 468 deletions
|
|
@ -17,12 +17,12 @@
|
|||
</div>
|
||||
<div id="main-editor" class="flex flex-grow">
|
||||
<div id="left-pane" class="w-1/2 flex-grow h-full flex flex-col">
|
||||
<h1>LIBRARY</h1>
|
||||
<h1 class="text-lg">LIBRARY</h1>
|
||||
<div id="library-editor" class="w-full flex-grow"><%= it.db.library %></div>
|
||||
<button id="save-library" type="submit">Save</button>
|
||||
</div>
|
||||
<div id="preview-area" class="w-1/2 h-full flex flex-col">
|
||||
<h1>REPL</h1>
|
||||
<h1 class="text-lg">REPL</h1>
|
||||
<div id="repl-editor" class="w-full h-1/2">// evaluate code in here
|
||||
</div>
|
||||
<button id="send-repl">RUN</button>
|
||||
|
|
@ -76,4 +76,4 @@
|
|||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<%~ include('/workshop/sidebar', it) %>
|
||||
</div>
|
||||
<div id="main-editor" class="flex flex-grow flex-col">
|
||||
<h1>Files</h1>
|
||||
<h1 class="text-lg">Files</h1>
|
||||
<div>
|
||||
<form hx-encoding='multipart/form-data' hx-post='/workshop/<%= it.structure.id %>/files' hx-target="#files-list" hx-swap="afterbegin" _='on htmx:xhr:progress(loaded, total) set #progress.value to (loaded/total)*100'>
|
||||
<input type='file' name='file'>
|
||||
|
|
@ -39,4 +39,4 @@
|
|||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
6
views/workshop/logs.eta
Normal file
6
views/workshop/logs.eta
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<div hx-swap="outerHTML" hx-get="/workshop/<%= it.structId %>/route/<%= it.routeId %>/logs?since=<%= it.since || 0 %>" hx-trigger="every 2s" class="hidden"></div>
|
||||
<% it.logs.forEach((log) => { %>
|
||||
<div class="<% if (log.error) { %>bg-red-800 text-white <% } %>">
|
||||
<%= log.content %>
|
||||
</div>
|
||||
<% }) %>
|
||||
|
|
@ -18,7 +18,13 @@
|
|||
<div id="main-editor" class="flex flex-grow">
|
||||
<div id="left-pane" class="w-1/2 flex-grow h-full flex flex-col">
|
||||
<div id="editor" class="w-full flex-grow"><%= it.route.handler %></div>
|
||||
<div class="flex">
|
||||
<button id="save-btn" type="submit">Save</button>
|
||||
<button id="save-btn" type="submit" _="on click toggle .hidden on #logs">Logs</button>
|
||||
</div>
|
||||
<pre id="logs" class="max-h-[50vh] overflow-scroll hidden">
|
||||
<ul hx-get="/workshop/<%= it.structure.id %>/route/<%= it.route.id %>/logs" hx-trigger="load" class="flex flex-col-reverse"></ul>
|
||||
</pre>
|
||||
</div>
|
||||
<div id="preview-area" class="w-1/2 h-full flex flex-col">
|
||||
<form _="on submit halt the event then set #preview's contentWindow.location.href to #url's value">
|
||||
|
|
@ -38,24 +44,23 @@
|
|||
editor.setTheme("ace/theme/monokai");
|
||||
editor.session.setMode("ace/mode/javascript");
|
||||
|
||||
document.getElementById('save-btn').onclick = function() {
|
||||
fetch('/workshop/<%= it.structure.id %>/route/<%= it.route.id %>', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
handler: editor.getValue()
|
||||
}).toString()
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
document.getElementById('preview').contentWindow.location.reload()
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
document.getElementById('save-btn').onclick = function() {
|
||||
fetch('/workshop/<%= it.structure.id %>/route/<%= it.route.id %>', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
handler: editor.getValue()
|
||||
}).toString()
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
document.getElementById('preview').contentWindow.location.reload()
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue