package templates import ( "converge/pkg/models" "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>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 state.Agents { <tr> <td>{agent.PublicId}</td> <td>{agent.StartTime.In(location).Format(time.DateTime)}</td> <td>{agent.ExpiryTime.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(state.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 state.Clients { <tr> <td>{client.ClientId}</td> <td>{client.StartTime.In(location).Format(time.DateTime)}</td> <td>{client.SessionType}</td> <td>{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(state *models.State, loc *time.Location) { @BasePage(4) { @Sessions(state, loc) } }