The contextpath parameter in converge.go is temporary and should be removed later. What is needed is autodetectio of the context path for the usage page and passing on the context for rendering.
94 lines
2.1 KiB
Plaintext
94 lines
2.1 KiB
Plaintext
package templates
|
|
|
|
import (
|
|
"converge/pkg/models"
|
|
"strconv"
|
|
"time"
|
|
_ "time/tzdata"
|
|
)
|
|
|
|
|
|
templ Sessions(state *models.State, loc *time.Location) {
|
|
<div hx-ext="ws" ws-connect="../ws/sessions">
|
|
<h1>sessions</h1>
|
|
|
|
<div id="status">
|
|
if state != nil {
|
|
@State(state, loc)
|
|
} else {
|
|
Loading...
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
}
|
|
|
|
templ State(state *models.State, location *time.Location) {
|
|
<div id="status">
|
|
|
|
<h3>agents</h3>
|
|
|
|
if len(state.Agents) == 0 {
|
|
<p>-</p>
|
|
} else {
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>start time</th>
|
|
<th>expiry time</th>
|
|
<th>username</th>
|
|
<th>host</th>
|
|
<th>OS</th>
|
|
<th>shell</th>
|
|
</tr>
|
|
</thead>
|
|
for _, agent := range state.Agents {
|
|
<tr>
|
|
<td>{agent.GeneratedId}</td>
|
|
<td>{agent.StartTime.In(location).Format(time.DateTime)}</td>
|
|
<td>{agent.ExpiryTime.In(location).Format(time.DateTime)}</td>
|
|
<td>{agent.AgentInfo.Username}</td>
|
|
<td>{agent.AgentInfo.Hostname}</td>
|
|
<td>{agent.AgentInfo.OS}</td>
|
|
<td>{agent.AgentInfo.Shell}</td>
|
|
</tr>
|
|
}
|
|
</table>
|
|
|
|
}
|
|
|
|
|
|
<h3>clients</h3>
|
|
|
|
if len(state.Clients) == 0 {
|
|
<p>-</p>
|
|
} else {
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>agent#</th>
|
|
<th>id</th>
|
|
<th>start time</th>
|
|
<th>session type</th>
|
|
</tr>
|
|
</thead>
|
|
for _, client := range state.Clients {
|
|
<tr>
|
|
<td>{client.AgentId}</td>
|
|
<td>{strconv.Itoa(client.ClientId)}</td>
|
|
<td>{client.StartTime.In(location).Format(time.DateTime)}</td>
|
|
<td>{client.SessionType}</td>
|
|
</tr>
|
|
}
|
|
</table>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
|
|
templ SessionsTab(state *models.State, loc *time.Location) {
|
|
@BasePage(4) {
|
|
@Sessions(state, loc)
|
|
}
|
|
} |