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
| {% import ( "github.com/samber/lo"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/components" "{{{ .Package }}}/views/layout" ) %}
{% code type Detail struct { layout.Basic Path string Script string LoadResult any Results map[string]map[string]any } %}
{% func (p *Detail) Body(as *app.State, ps *cutil.PageState) %} <div class="card"> <div class="right"><a href="/admin/scripting/{%u p.Path %}/edit"><button type="button">Edit</button></a></div> <h3>{%= components.SVGRefIcon(`file-code`, ps) %} {%s p.Path %}</h3> <div class="mt"> {%- code out, err := cutil.FormatLang(p.Script, "js") -%} {%- if err == nil -%} {%s= out %} {%- else -%} {%s err.Error() %} {%- endif -%} </div> </div> {% if p.LoadResult != nil -%} <div class="card"> <h3>{%= components.SVGRefIcon(`cog`, ps) %} Load Result</h3> {%= components.JSON(p.LoadResult) %} </div> {%- endif -%} {% for _, f := range util.ArraySorted(lo.Keys(p.Results)) -%} {%- code res := p.Results[f] -%} {% if len(res) > 0 -%} <div class="card"> <h3>{%= components.SVGRefIcon(`play`, ps) %} [{%s f %}] Example Results</h3> <div class="mt"> <div class="overflow full-width"> <table class="expanded min-200"> <thead> <tr> <th class="shrink">Example</th> <th>Result</th> </tr> </thead> <tbody> {%- for _, k := range util.ArraySorted(lo.Keys(res)) -%} {%- code v := res[k] -%} <tr> <td><pre>{%s k %}</pre></td> <td><pre>{%s util.ToJSONCompact(v) %}</pre></td> </tr> {%- endfor -%} </tbody> </table> </div> </div> </div> {%- endif -%} {%- endfor -%} {% endfunc %}
|