1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| {% import ( "{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/lib/exec" "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/components" "{{{ .Package }}}/views/layout" ) %}
{% code type Detail struct { layout.Basic Exec *exec.Exec } %}
{% func (p *Detail) Body(as *app.State, ps *cutil.PageState) %} {%= ExecDetail(p.Exec, ps) %} <div class="card"> <h3>{%= components.SVGIcon("file", ps) %} Output</h3> <div class="mt">{%= components.Terminal("console-list", p.Exec.Buffer.String()) %}</div> </div>{{{ if .HasModule "websocket" }}} {%= ExecScript(as.Debug, "console-list", p.Exec.WebPath() + "/connect", true, ps) %}{{{ end }}} {% endfunc %}
{% func ExecDetail(ex *exec.Exec, ps *cutil.PageState) %} <div class="card"> {%- if ex.Completed == nil -%} <div class="right"> <a href="{%s ex.WebPath() %}/kill"><button>Kill</button></a> </div> {%- endif -%} <h3>{%= components.SVGIcon("desktop", ps) %} Process [{%s ex.String() %}]</h3> <div class="overflow full-width"> <table> <tbody> <tr> <th class="shrink">Key</th> <td>{% if len(ex.Link) > 0 %}<a href="{%s ex.Link %}">{%s ex.Key %}</a>{% else %}{%s ex.Key %}{% endif %}</td> </tr> <tr> <th>Index</th> <td>{%d ex.Idx %}</td> </tr> <tr> <th>PID</th> <td>{%d ex.PID %}</td> </tr> <tr> <th>Command</th> <td>{%s ex.Cmd %}</td> </tr> <tr> <th>Path</th> <td>{%s ex.Path %}</td> </tr> <tr> <th>Environment</th> <td> <ul> {%- for _, x := range ex.Env -%} <li>{%s x %}</li> {%- endfor -%} </ul> </td> </tr> <tr> <th>Started</th> <td title="{%s util.TimeToFull(ex.Started) %}">{%s util.TimeRelative(ex.Started) %}</td> </tr> {%- if ex.Completed != nil -%} <tr> <th>Completed</th> <td title="{%s util.TimeToFull(ex.Completed) %}">{%s util.TimeRelative(ex.Completed) %}</td> </tr> <tr> <th>Exit Code</th> <td>{%d ex.ExitCode %}</td> </tr> {%- endif -%} </tbody> </table> </div> </div> {% endfunc %}
{% func ExecScript(debug bool, id string, connectURL string, terminal bool, ps *cutil.PageState, extraHandlers ...string) %} <script> window.addEventListener('load', () => { {{{ .CleanKey }}}.socketLog({%v debug %}, document.getElementById("{%s id %}"), {%v terminal %}, "{%s= connectURL %}", [{%s= util.StringJoin(extraHandlers, `, `) %}]); }) </script> {% endfunc %}
|