minor changes
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
.output {
|
||||
height: 80vh;
|
||||
height: 75vh;
|
||||
}
|
||||
.left-sidebar {
|
||||
padding: 15px;
|
||||
padding: 10px;
|
||||
width: 15vw;
|
||||
height: 100%;
|
||||
resize: both;
|
||||
}
|
||||
.pdf-frame {
|
||||
width: 100%;
|
||||
width: 85vw;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
.command-out {
|
||||
height: 20vh;
|
||||
padding: 20px;
|
||||
height: 25vh;
|
||||
padding: 5px;
|
||||
background-color: #eaeaea;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@@ -10,29 +10,30 @@
|
||||
<script src="/jscss/htmx-ext-sse.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div class="container-fluid h-100 d-flex flex-column" hx-ext="sse" sse-connect="/sse">
|
||||
<div class="row output flex-grow-1">
|
||||
|
||||
<div class="col-3 left-sidebar d-flex flex-column justify-content-between">
|
||||
<div>
|
||||
<h4>ServTeX Status</h4> <br>
|
||||
<h4>ServTeX</h4> <br>
|
||||
<div sse-swap="status">
|
||||
Compilation has not run yet.
|
||||
Compilation information unavailable.
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button class="btn btn-primary mt-2" hx-post="/compile" hx-trigger="click" hx-swap="none">Recompile</button>
|
||||
</div>
|
||||
|
||||
<div class="col-9 p-0" sse-swap="pdf">
|
||||
<iframe class="pdf-frame" src="/pdf?ts=0"></iframe>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="command-out" sse-swap="output">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="command-out" sse-swap="output"></div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
|
||||
@@ -34,8 +34,8 @@ func ssePing(writer *http.ResponseWriter) {
|
||||
// Reads globals.LatexExec
|
||||
func sseStatusSend(writer *http.ResponseWriter) {
|
||||
fmt.Fprintf((*writer), "event: status\n")
|
||||
fmt.Fprintf((*writer), "data: Execution Time: %s<br>\n", globals.LatexExec.Timestamp)
|
||||
fmt.Fprintf((*writer), "data: Execution State: %s<br>\n\n", globals.LatexExec.ExecutionState)
|
||||
fmt.Fprintf((*writer), "data: Execution Time:<br>%s<br><br>\n", globals.LatexExec.Timestamp)
|
||||
fmt.Fprintf((*writer), "data: Execution State:<br>%s<br>\n\n", globals.LatexExec.ExecutionState)
|
||||
|
||||
(*writer).(http.Flusher).Flush()
|
||||
backend.LogLine("Status Event has been sent", 1)
|
||||
@@ -85,24 +85,24 @@ func SSEventHandler(writer http.ResponseWriter, request *http.Request) {
|
||||
ssePing(&writer)
|
||||
|
||||
|
||||
lastExecution := ""
|
||||
lastExecution := &globals.LatexExecution{}
|
||||
for range time.Tick(time.Second) {
|
||||
select {
|
||||
case <-request.Context().Done():
|
||||
return
|
||||
default:
|
||||
if lastExecution == globals.LatexExec.TimestampRFC {
|
||||
ssePing(&writer)
|
||||
} else {
|
||||
sseStatusSend(&writer)
|
||||
sseOutputSend(&writer)
|
||||
// let client keep current pdf, if compile failed
|
||||
if globals.LatexExec.ExecutionState != "Failed" {
|
||||
ssePDFSend(&writer)
|
||||
}
|
||||
lastExecution = globals.LatexExec.TimestampRFC
|
||||
case <-request.Context().Done():
|
||||
return
|
||||
default:
|
||||
if lastExecution.Equal(&globals.LatexExec) {
|
||||
ssePing(&writer)
|
||||
} else {
|
||||
sseStatusSend(&writer)
|
||||
sseOutputSend(&writer)
|
||||
// let client keep current pdf, if compile failed
|
||||
if globals.LatexExec.ExecutionState != globals.LatexExecutionStateFailure {
|
||||
ssePDFSend(&writer)
|
||||
}
|
||||
lastExecution = globals.LatexExec.Copy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user