Task Engine

/views/vtask/Result.html (2.5 KB)

 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
{% import (
"strings"

"{{{ .Package }}}/app"
"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/lib/task"
"{{{ .Package }}}/app/util"
"{{{ .Package }}}/views/components"
"{{{ .Package }}}/views/components/view"
) %}

{% func Result(as *app.State, res *task.Result, ps *cutil.PageState) %}
{%- if res.Error != "" -%}
<div class="card">
<h3>{%= components.SVGIcon("error", ps) %} Error</h3>
<div class="mt">
<pre class="error">Error: {%s res.Error %}</pre>
</div>
</div>
{%- endif -%}

{%- if len(res.Logs) > 0 -%}
<div class="card">
<h3>{%= components.SVGIcon("file", ps) %} {%s res.Task.TitleSafe() %} Logs</h3>
<div class="mt">{%= components.Terminal("console-list", strings.Join(res.Logs, "\n")) %}</div>
</div>
{%- endif -%}

<div class="card">
<div class="right">
{%s util.MicrosToMillis(res.Elapsed) %}
<a href="#modal-result-{%s res.ID.String() %}" title="JSON"><button>{%= components.SVGButton(`code`, ps) %}</button></a>
</div>
<h3>{%= components.SVGIcon(res.Task.IconSafe(), ps) %} {%s res.Task.TitleSafe() %} Result</h3>
<div><em>{%= view.TimestampRelative(&res.Started, false) %}</em></div>
<div class="mt">
{%= renderResult(res, as, ps) %}
</div>
</div>
{%= components.JSONModal("result-" + res.ID.String(), "Result [" + res.String() + "] JSON", res, 1) %}
{% endfunc %}

{% func ResultSummary(as *app.State, res *task.Result, ps *cutil.PageState) %}
{%- if res.Error != "" -%}
<div class="card">
<h3>{%= components.SVGIcon("error", ps) %} Error</h3>
<div class="mt">
<pre class="error">Error: {%s res.Error %}</pre>
</div>
</div>
{%- endif -%}

<div class="card">
<div class="right">
{%s util.MicrosToMillis(res.Elapsed) %}
<a href="#modal-result" title="JSON"><button>{%= components.SVGButton(`code`, ps) %}</button></a>
</div>
<h3>{%= components.SVGIcon("cog", ps) %} Result</h3>
<div><em>{%= view.TimestampRelative(&res.Started, false) %}</em></div>
<div class="mt">
{%= renderResult(res, as, ps) %}
</div>
</div>
{%= components.JSONModal("result", "Result [" + res.String() + "] JSON", res, 1) %}
{% endfunc %}

{% func renderResult(res *task.Result, as *app.State, ps *cutil.PageState) %}{% stripspace %}
{%- if res.Data == nil -%}
<em>no data</em>
{%- else -%}
{%= components.JSON(res.Data) %}
{%- endif -%}
{% endstripspace %}{% endfunc %}