aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/mrj_section.html
blob: 480dfef2553d523832224a5dc9c2ca1f9dd54dea (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{% load static %}
{% load humanize %}
<script src="{% static 'js/mrjsection.js' %}"></script>

{% if mru %}
  <div id="latest-jobs">
    {% for job in mru %}
      <div id="job-instance-{{job.id}}" data-latest-job-result="{{job.id}}" class="alert job-result {% if job.status == job.SUCCESS %}alert-success{% elif job.status == job.ERRORS %}alert-danger{% else %}alert-info{% endif %}">
        <!-- job title -->
        <div class="row job-name">
          <div class="col-md-12">
            <small>
                {{job.name}}{% if request.user.is_admin %} ({{job.id}}){% endif %}
            </small>
          </div>
        </div>

        <div class="row" data-role="job-status-container">
          <div class="col-md-12">
            Loading...
          </div>
        </div>
      </div>
    {% endfor %}
  </div>
{% endif %}

<!-- job main template -->
<script id="job-template" type="text/x-jsrender">
  <div class="col-md-3">
    <!-- only show link for completed jobs -->
    <%if state == 'Success' || state == 'Errors'%>
        <%:targets%>
    <%else%>
      <span data-toggle="tooltip" id="job-message-done-<%:id%>" data-role="targets-text" title="Job: <%:targets%>">
        <%:targets%>
      </span>
    <%/if%>
  </div>

  <div data-job-state="<%:state%>">
    <%if state == 'Success' || state == 'Errors'%>
      <%include tmpl='#succeeded-or-failed-job-template'/%>
    <%else state == 'Cancelling'%>
      <%include tmpl='#cancelling-job-template'/%>
    <%else state == 'NotStarted'%>
      <%include tmpl='#starting-template'/%>
    <%else state == 'InProgress'%>
      <%include tmpl='#in-progress-job-template'/%>
    <%else state == 'Cancelled'%>
      <%include tmpl='#cancelled-job-template'/%>
    <%/if%>
  </div>
</script>

<!-- queued job -->
<script id="queued-job-template" type="text/x-jsrender">
  <div class="col-md-5">
    <span class="glyphicon glyphicon-question-sign get-help get-help-blue"
          title="This job is waiting for the background application to start">
    </span>

    Job queued
  </div>

  <div class="col-md-4">
    <!-- cancel button -->
    <%include tmpl='#cancel-template'/%>
  </div>
</script>

<!-- in progress job; at least one task finished -->
<script id="in-progress-job-template" type="text/x-jsrender">
  <!-- progress bar and task completion percentage -->
  <div data-role="job-status" class="col-md-4 col-md-offset-1 progress-info">
    <!-- progress bar -->
    <div class="progress" id="job-pc-done-title-<%:id%>">
      <div id="job-pc-done-bar-<%:id%>"
           style="width: <%:tasks_complete_percentage%>%;"
           class="progress-bar">
      </div>
    </div>
  </div>

  <div class="col-md-4 progress-info">
    <!-- task completion percentage -->
    <span id="job-pc-done-<%:id%>"><%:tasks_complete_percentage%></span>% of
    tasks complete

    <!-- cancel button -->
    <%include tmpl='#cancel-template'/%>
  </div>
</script>

<!-- cancelling job -->
<script id="cancelling-job-template" type="text/x-jsrender">
  <div class="col-md-9">
    Cancelling the job ...
  </div>
</script>

<!-- succeeded or failed job -->
<script id="succeeded-or-failed-job-template" type="text/x-jsrender">
  <!-- completed_on -->
  <div class="col-md-2">
    <%:completed_on%>
  </div>

  <!-- errors -->
  <div class="col-md-2">
    <%if errors%>
      <span class="glyphicon glyphicon-minus-sign"></span>
      <a href="<%:dashboard_errors_url%>" class="alert-link">
        <%:errors%> error<%:errors_pluralise%>
      </a>
    <%/if%>
  </div>

  <!-- warnings -->
  <div class="col-md-2">
    <%if warnings%>
      <span class="glyphicon glyphicon-warning-sign job-warnings"></span>
      <a href="<%:dashboard_warnings_url%>" class="alert-link job-warnings">
        <%:warnings%> warning<%:warnings_pluralise%>
      </a>
    <%/if%>
  </div>

<!--  <%if errors == 0 and warnings == 0%>
    <div class="col-md-2">
      No Errors
    </div>
  <%/if%>
-->

  <!-- job time -->
  <div class="col-md-3">
    Job time:
    <span data-role="data-recent-job-jobtime-field">
      <b><%:jobtime%></b>
    </span>
	<form id="downloadbanner-log" enctype="multipart/form-data" method="post" >{% csrf_token %}
		<input type="hidden" name="action" value="download-log">
		<input type="hidden" name="report_path" value="JOBLOG">
		<a href="/srtgui/joblog/<%:id%>" class="glyphicon glyphicon-download-alt submit-download-joblog" x-data="log" target="_blank"></a>
	</form>
  </div>
</script>

<!-- cancelled job -->
<script id="cancelled-job-template" type="text/x-jsrender">
  <!-- job cancelled message -->
  <div class="col-md-6">
    Job cancelled
  </div>
</script>

<!-- cancel button or no cancel icon -->
<script id="cancel-template" type="text/x-jsrender">
    <!-- cancel button -->
    <span class="cancel-job-btn pull-right alert-link"
    data-jobrequest-id="<%:id%>" data-request-url="<%:cancel_url%>">
      <span class="glyphicon glyphicon-remove-circle"></span>
      Cancel
    </span>
</script>

<script>
  $(document).ready(function () {
    var ctx = {
    }

    try {
      mrjSectionInit(ctx);
		$('.submit-download-joblog').click(function() {
			alert("submit-download-joblog:"+this.getAttribute("x-data"));
			$("#downloadbanner-"+this.getAttribute("x-data")).submit();
		});
    } catch (e) {
      document.write("Sorry, An error has occurred loading this page");
      console.warn(e);
    }

	$('.submit-downloadattachment').click(function() {
		$("#downloadbanner-"+this.getAttribute("x-data")).submit();
	});

		$('.submit-download-joblog').click(function() {
			alert("submit-download-joblog:"+this.getAttribute("x-data"));
			$("#downloadbanner-job").submit();
		});

  });
</script>