151 lines
4.4 KiB
HTML
151 lines
4.4 KiB
HTML
<?php if (!$this->fatalError): ?>
|
|
|
|
<div id="executePopup">
|
|
|
|
<div id="executeActivity">
|
|
<div class="modal-body">
|
|
<div class="progress bar-loading-indicator" id="executeLoadingBar">
|
|
<div class="progress-bar"></div>
|
|
</div>
|
|
|
|
<div class="loading-indicator-container">
|
|
<p> </p>
|
|
<div class="loading-indicator transparent">
|
|
<div id="executeMessage"></div>
|
|
<span></span>
|
|
</div>
|
|
</div>
|
|
<p> </p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="executeStatus"></div>
|
|
</div>
|
|
|
|
<script type="text/template" id="executeFailed">
|
|
<div class="modal-body">
|
|
<div class="callout callout-danger">
|
|
<div class="header">
|
|
<h3><?= e(trans('system::lang.updates.update_failed_label')) ?></h3>
|
|
<p>{{ reason }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button
|
|
type="button"
|
|
class="btn btn-primary"
|
|
onclick="retryUpdate()">
|
|
<?= e(trans('system::lang.updates.retry_label')) ?>
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="btn btn-default"
|
|
data-dismiss="popup">
|
|
<?= e(trans('backend::lang.form.cancel')) ?>
|
|
</button>
|
|
</div>
|
|
</script>
|
|
|
|
<script>
|
|
|
|
var updateSteps = <?= json_encode($updateSteps) ?>,
|
|
activeStep = null
|
|
|
|
$('#executePopup').on('popupComplete', function(){
|
|
runUpdate()
|
|
})
|
|
|
|
function runUpdate(fromStep) {
|
|
$.waterfall.apply(this, buildEventChain(updateSteps, fromStep))
|
|
.fail(function(reason){
|
|
var
|
|
template = $('#executeFailed').html(),
|
|
html = Mustache.to_html(template, { reason: reason })
|
|
|
|
$('#executeActivity').hide()
|
|
$('#executeStatus').html(html)
|
|
})
|
|
}
|
|
|
|
function retryUpdate() {
|
|
$('#executeActivity').show()
|
|
$('#executeStatus').html('')
|
|
|
|
runUpdate(activeStep)
|
|
}
|
|
|
|
function buildEventChain(steps, fromStep) {
|
|
var eventChain = [],
|
|
skipStep = fromStep ? true : false
|
|
|
|
$.each(steps, function(index, step){
|
|
|
|
if (step == fromStep)
|
|
skipStep = false
|
|
|
|
if (skipStep)
|
|
return true // Continue
|
|
|
|
eventChain.push(function(){
|
|
var deferred = $.Deferred()
|
|
|
|
activeStep = step
|
|
setLoadingBar(true, step.label)
|
|
|
|
$.request('onExecuteStep', {
|
|
data: step,
|
|
success: function(data){
|
|
setTimeout(function() { deferred.resolve() }, 600)
|
|
|
|
if (step.code == 'completeUpdate' || step.code == 'completeInstall') {
|
|
this.success(data)
|
|
} else {
|
|
setLoadingBar(false)
|
|
}
|
|
},
|
|
error: function(data){
|
|
setLoadingBar(false)
|
|
deferred.reject(data.responseText)
|
|
}
|
|
})
|
|
|
|
return deferred
|
|
})
|
|
})
|
|
|
|
return eventChain
|
|
}
|
|
|
|
function setLoadingBar(state, message) {
|
|
var loadingBar = $('#executeLoadingBar'),
|
|
messageDiv = $('#executeMessage')
|
|
|
|
if (state) {
|
|
loadingBar.removeClass('bar-loaded')
|
|
}
|
|
else {
|
|
loadingBar.addClass('bar-loaded')
|
|
}
|
|
|
|
if (message)
|
|
messageDiv.text(message)
|
|
}
|
|
</script>
|
|
|
|
<?php else: ?>
|
|
|
|
<div class="modal-body">
|
|
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button
|
|
type="button"
|
|
class="btn btn-default"
|
|
data-dismiss="popup">
|
|
<?= e(trans('backend::lang.form.close')) ?>
|
|
</button>
|
|
</div>
|
|
|
|
<?php endif ?>
|