Línea 23... |
Línea 23... |
23 |
{
|
23 |
{
|
24 |
"id": "progressbar_test",
|
24 |
"id": "progressbar_test",
|
25 |
"width": "500"
|
25 |
"width": "500"
|
26 |
}
|
26 |
}
|
27 |
}}
|
27 |
}}
|
28 |
<div id="{{id}}" class="progressbar_container mb-3">
|
28 |
<div id="{{idnumber}}" class="progressbar_container mb-3 {{class}}" data-recordid="{{id}}">
|
29 |
<div class="progress">
|
29 |
<div class="progress">
|
30 |
<div id="{{id}}_bar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-value="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
|
30 |
<div id="{{idnumber}}_bar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-value="{{value}}" aria-valuemin="0" aria-valuemax="100" style="width: {{value}}%"></div>
|
31 |
</div>
|
31 |
</div>
|
32 |
<div class="d-flex">
|
32 |
<div class="d-flex">
|
33 |
<div style="flex: 1 1 0; min-width: 0;">
|
33 |
<div style="flex: 1 1 0; min-width: 0;">
|
34 |
<div id="{{id}}_status" class="text-truncate"> </div>
|
34 |
<div id="{{idnumber}}_status" class="text-truncate">{{message}}</div>
|
35 |
</div>
|
35 |
</div>
|
36 |
<div class="text-right pl-3" style="flex: 0 0 content">
|
36 |
<div class="text-end ps-3" style="flex: 0 0 content">
|
37 |
<span id="{{id}}_estimate" class=""> </span>
|
37 |
<span id="{{idnumber}}_estimate" class=""> </span>
|
38 |
<span id="{{id}}_percentage" class="d-inline-block" style="width: 3em">0%</span>
|
38 |
<span id="{{idnumber}}_percentage" class="d-inline-block" style="width: 3em">{{value}}%</span>
|
39 |
</div>
|
39 |
</div>
|
40 |
</div>
|
40 |
</div>
|
41 |
</div>
|
41 |
</div>
|
Línea 42... |
Línea 42... |
42 |
|
42 |
|
43 |
{{! We must not use the JS helper otherwise this gets executed too late. }}
|
43 |
{{! We must not use the JS helper otherwise this gets executed too late. }}
|
44 |
<script>
|
44 |
<script>
|
- |
|
45 |
(function() {
|
45 |
(function() {
|
46 |
|
46 |
var el = document.getElementById('{{id}}'),
|
47 |
let el = document.getElementById('{{idnumber}}');
|
47 |
progressBar = document.getElementById('{{id}}_bar'),
|
48 |
let progressBar = document.getElementById('{{idnumber}}_bar');
|
48 |
statusIndicator = document.getElementById('{{id}}_status'),
|
49 |
let statusIndicator = document.getElementById('{{idnumber}}_status');
|
49 |
estimateIndicator = document.getElementById('{{id}}_estimate');
|
50 |
let estimateIndicator = document.getElementById('{{idnumber}}_estimate');
|
- |
|
51 |
let percentageIndicator = document.getElementById('{{idnumber}}_percentage');
|
- |
|
52 |
|
- |
|
53 |
// Change background colour to red if there was an error.
|
- |
|
54 |
if ({{error}} == 1) {
|
- |
|
55 |
el.querySelector('.progress-bar').style.background = 'red';
|
Línea 50... |
Línea 56... |
50 |
percentageIndicator = document.getElementById('{{id}}_percentage');
|
56 |
}
|
51 |
|
57 |
|
52 |
el.addEventListener('update', function(e) {
|
58 |
el.addEventListener('update', function(e) {
|
53 |
var msg = e.detail.message,
|
59 |
var msg = e.detail.message,
|
- |
|
60 |
percent = e.detail.percent,
|
Línea 54... |
Línea 61... |
54 |
percent = e.detail.percent,
|
61 |
estimate = e.detail.estimate
|
55 |
estimate = e.detail.estimate;
|
62 |
error = e.detail.error;
|
56 |
|
63 |
|
- |
|
64 |
statusIndicator.textContent = msg;
|
- |
|
65 |
progressBar.style.width = percent.toFixed(1) + '%';
|
- |
|
66 |
progressBar.setAttribute('value', percent.toFixed(1));
|
- |
|
67 |
|
- |
|
68 |
if (error) {
|
57 |
statusIndicator.textContent = msg;
|
69 |
progressBar.classList.add('bg-danger');
|
58 |
progressBar.style.width = percent.toFixed(1) + '%';
|
70 |
progressBar.classList.remove('bg-success');
|
59 |
progressBar.setAttribute('value', percent.toFixed(1));
|
71 |
estimateIndicator.textContent = '';
|
60 |
if (percent === 100) {
|
72 |
} else if (percent === 100) {
|
61 |
progressBar.classList.add('bg-success');
|
73 |
progressBar.classList.add('bg-success');
|
62 |
progressBar.classList.remove('progress-bar-striped');
|
74 |
progressBar.classList.remove('progress-bar-striped');
|