Toggle container.

This commit is contained in:
retoor 2025-06-10 13:00:59 +02:00
parent fbd72f727a
commit f8f1235e60
2 changed files with 32 additions and 10 deletions
src/snek

View File

@ -59,7 +59,31 @@
<script type="module">
import { app } from "/app.js";
import { Container } from "/container.js";
let prevKey = null;
{% if channel %}
app.channelUid = '{{ channel.uid.value }}'
let container = null
const getContainer = function(){
if(container)
return container
container = new Container(app.channelUid,false)
return container
}
window.getContainer = getContainer
toggleContainer(){
if(!container){
return getContainer()
}
container.terminal.element.hidden = !container.terminal.element.hidden
return container
}
{% endif %}
let prevKey = null;
document.addEventListener("keydown", () => {
if(prevKey == "Escape"){
document.querySelector("chat-input").querySelector("textarea").value = "";
@ -69,7 +93,12 @@
}
prevKey = event.key
prevKey = event.key
if(event.key == "." && event.ctrlKey){
event.preventDefault();
toggleContainer()
}
if(event.key == "," && event.ctrlKey){
event.preventDefault();
let textAreas = document.querySelectorAll("textarea")
@ -80,13 +109,6 @@
}
})
{% if channel %}
app.channelUid = '{{ channel.uid.value }}'
window.getContainer = function(){
return new Container(app.channelUid,false)
}
{% endif %}
let installPrompt = null
window.addEventListener("beforeinstallprompt", (e) => {
//e.preventDefault();

View File

@ -35,7 +35,7 @@ class ContainerView(BaseView):
if not container['status'] == 'running':
resp = await self.services.container.start(channel_uid)
await ws.send_str(str(resp))
await ws.send_bytes(b'Container is starting\n\n')
container_name = await self.services.container.get_container_name(channel_uid)