{% extends '@ProductsNotifications/base--full.html.twig' %}
{% block topbar %}
{% include '@ui2022/topbar--wizard.html.twig' with {
steps: [
{
text: 'Create message',
active: true,
button: {
button: 'form',
type: 'submit',
styles: 'wizard',
form: {
name: '',
value: 'save',
formaction: path('app.notifications.dashboard.messages.translations', {
message: message.id,
jump: path('app.notifications.dashboard.messages.update', {
message: message.id,
}),
}),
},
},
},
{
text: 'Review and test',
button: {
button: 'form',
type: 'submit',
styles: 'wizard',
form: {
name: '',
value: 'save',
formaction: path('app.notifications.dashboard.messages.manage', {
message: message.id,
jump: path('app.notifications.dashboard.messages.manage', {
message: message.id,
}),
}),
},
},
},
],
subactions: [
],
actions: [
{
button: 'form',
type: 'submit',
text: 'Next',
styles: 'primary wide md',
},
],
} %}
{% endblock %}
{% block content %}
<div class="py-5">
<div class="mx-auto w-50 text-center">
<img src="/ui2022/images/translation-animation.gif" alt="translating..." style="width: 150px;" />
<div class="pt-4" id="translation-statuses">
{% for locale,status in statuses['statuses'] %}
<div class="row justify-content-md-center">
<div class="col-4 text-left">{{ humanReadableLocaleNames[locale] }}</div>
<div class="col-1" id="translation-statuses-{{ locale }}">
{% if status is same as(null) %}
<i class="fas fa-pause"></i>
{% elseif status is same as(false) %}
<i class="fas fa-spinner fa-spin"></i>
{% elseif status is same as(true) %}
<i class="fas fa-check"></i>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
<script type="text/javascript">
(function (window, document, $, undefined) {
$(function () {
let waitingSince = Date.now();
const translationsCheckUrl = '{{ path('app.notifications.dashboard.messages.check_translation_progress', {message: message.id}) }}';
const redirectUrl = '{{ path('app.notifications.dashboard.messages.manage', {message: message.id}) }}';
toastr.options = {
positionClass: "toast-top-left mt-5 pt-4",
timeOut: 0,
extendedTimeOut: 0,
tapToDismiss: false,
fadeOut: 0,
};
const translationWarning =
'<div class="mb-3">There is a problem with the translation services.</div>' +
'<div><a href="{{ path('app.notifications.dashboard.messages.update', {message: message.id}) }}" class="alert-link">Exit</a> and try again later.</div>' +
'<div>Or <a href="https://www.schoolnow.com/support" target="_blank" class="alert-link">report</a> to the support team.</div>';
let translationWarningElement = null;
let lastResponseJson = '{}';
setInterval(() => {
$.ajax({
method: 'GET',
url: translationsCheckUrl
}).done(function (response) {
if (JSON.stringify(response) !== lastResponseJson) {
lastResponseJson = JSON.stringify(response);
waitingSince = Date.now();
toastr.clear();
translationWarningElement = null;
}
for (var [locale, status] of Object.entries(response.statuses)) {
switch (status) {
case null:
status = 'fas fa-pause';
break;
case false:
status = 'fas fa-spinner fa-spin';
break;
case true:
status = 'fas fa-check';
break;
}
$('#translation-statuses-' + locale + ' i').attr('class', status);
}
let waitSeconds = Math.floor(((Date.now() - waitingSince) / 1000));
if (45 < waitSeconds && !translationWarningElement) {
translationWarningElement = toastr.warning(translationWarning);
}
if ( (response.ready === true)) {
window.location.replace(redirectUrl);
}
});
}, 2000);
});
})(window, document, jQuery);
</script>
{% endblock %}