106 lines
2.7 KiB
Plaintext
106 lines
2.7 KiB
Plaintext
package ui
|
|
|
|
import (
|
|
"git.wamblee.org/converge/pkg/models"
|
|
"time"
|
|
_ "time/tzdata"
|
|
)
|
|
|
|
|
|
templ Sessions(agents []*models.Agent, clients []*models.Client, loc *time.Location) {
|
|
<div>
|
|
<div ws-send
|
|
hx-trigger="load"
|
|
hx-vals='{"message": "Hello, server! Page loaded."}'>
|
|
</div>
|
|
<h1>sessions</h1>
|
|
|
|
<div id="status">
|
|
if len(agents) > 0 {
|
|
@State(agents, clients, loc)
|
|
} else {
|
|
Loading...
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
}
|
|
|
|
templ State(agents []*models.Agent, clients []*models.Client, location *time.Location) {
|
|
<div id="status">
|
|
|
|
<h3>agents</h3>
|
|
|
|
if len(agents) == 0 {
|
|
<p>-</p>
|
|
} else {
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>rendez-vous id</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 agents {
|
|
<tr>
|
|
<td>{string(agent.PublicId)}</td>
|
|
<td>{agent.StartTime.In(location).Format(time.DateTime)}</td>
|
|
<td>{agent.GetExpiryTime().In(location).Format(time.DateTime)}</td>
|
|
<td>{agent.EnvironmentInfo.Username}</td>
|
|
<td>{agent.EnvironmentInfo.Hostname}</td>
|
|
<td>{agent.EnvironmentInfo.OS}</td>
|
|
<td>{agent.EnvironmentInfo.Shell}</td>
|
|
</tr>
|
|
}
|
|
</table>
|
|
|
|
}
|
|
|
|
|
|
<h3>clients</h3>
|
|
|
|
if len(clients) == 0 {
|
|
<p>-</p>
|
|
} else {
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>id</th>
|
|
<th>start time</th>
|
|
<th>session type</th>
|
|
<th>rendez-vous id</th>
|
|
<th>username</th>
|
|
<th>host</th>
|
|
<th>os</th>
|
|
<th>shell</th>
|
|
</tr>
|
|
</thead>
|
|
for _, client := range clients {
|
|
<tr>
|
|
<td>{string(client.ClientId)}</td>
|
|
<td>{client.StartTime.In(location).Format(time.DateTime)}</td>
|
|
<td>{string(client.SessionType)}</td>
|
|
<td>{string(client.PublicId)}</td>
|
|
<td>{client.EnvironmentInfo.Username}</td>
|
|
<td>{client.EnvironmentInfo.Hostname}</td>
|
|
<td>{client.EnvironmentInfo.OS}</td>
|
|
<td>{client.EnvironmentInfo.Shell}</td>
|
|
</tr>
|
|
}
|
|
</table>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
|
|
templ SessionsTab(agents []*models.Agent, clients []*models.Client, loc *time.Location) {
|
|
@BasePage(4) {
|
|
@Sessions(agents, clients, loc)
|
|
}
|
|
}
|