{# Enable dismissable messages #} $('.message .close') .on('click', function() { $(this) .closest('.message') .transition('fade') ; }) ; {# Apply transitions on inline messages #} $('.message.with-transition') .transition('flash') ; {# Let's see if there are success messages to show #} {% set successes = flash.getMessage('success_detected') %} {% if success_detected is defined and success_detected is iterable %} {% for s in success_detected %} {% set successes = successes|merge([s]) %} {% endfor %} {% endif %} {% if successes is iterable and successes|length > 0 %} {% for success in successes %} $('body') .toast({ displayTime: 'auto', minDisplayTime: 5000, wordsPerMinute: 80, showProgress: 'bottom', closeIcon: true, position: 'top attached', message: '{{ success|e('js') }}', showIcon: 'check circle outline', class: 'success' }) ; {% endfor %} {% endif %} {# Let's see if there are info messages to show #} {% set info = flash.getMessage('info_detected') ?? []|merge(flash.getMessage('info') ?? []) %} {% if info_detected is defined and info_detected is iterable %} {% for i in info_detected %} {% set info = info|merge([i]) %} {% endfor %} {% endif %} {% if info is iterable and info|length > 0 %} {% for i in info %} {% set info_title = '' %} {% if i is iterable %} {% set info_title = i.title %} {% set i = i.message %} {% endif %} $('body') .toast({ displayTime: 'auto', minDisplayTime: 5000, wordsPerMinute: 80, showProgress: 'bottom', closeIcon: true, position: 'top attached', title: '{{ info_title|e('js') }}', message: '{{ i|e('js') }}', showIcon: 'info', class: 'info' }) ; {% endfor %} {% endif %} {# Let's see if there are loginfault messages to show #} {% set loginfaults = flash.getMessage('loginfault') %} {% if loginfault_detected is defined and loginfault_detected is iterable %} {% for l in loginfault_detected %} {% set loginfaults = loginfaults|merge([l]) %} {% endfor %} {% endif %} {# Let's see if there are error messages to show #} {% set errors = flash.getMessage('error_detected') ?? []|merge(flash.getMessage('error') ?? [])|merge(loginfaults ?? []) %} {% if error_detected is defined and error_detected is iterable %} {% for e in error_detected %} {% set errors = errors|merge([e]) %} {% endfor %} {% endif %} {% if errors is iterable and errors|length > 0 %} {% for error in errors %} $('body') .toast({ displayTime: 0, closeIcon: true, position: 'top attached', message: '{{ error|e('js') }}', showIcon: 'exclamation circle', class: 'error' }) ; {% endfor %} {% endif %} {# Let's see if there are warning messages to show #} {% set warnings = flash.getMessage('warning_detected') ?? []|merge(flash.getMessage('warning') ?? []) %} {% if warning_detected is defined and warning_detected is iterable %} {% for w in warning_detected %} {% set warnings = warnings|merge([w]) %} {% endfor %} {% endif %} {% if warnings is iterable and warnings|length > 0 %} {% for warning in warnings %} $('body') .toast({ displayTime: 0, closeIcon: true, position: 'top attached', message: '{{ warning|e('js') }}', showIcon: 'exclamation triangle', class: 'warning' }) ; {% endfor %} {% endif %} {# Renew telemetry #} {% if renew_telemetry is defined and renew_telemetry %} $('body') .toast({ displayTime: 0, position: 'bottom right', message: "{{ _T("Your telemetry data are more than one year old.")|e('js') }} {{ _T("Do you want to send it again?")|e('js') }}", classActions: 'bottom attached', actions: [{ text: "{{ _T("Yes")|e('js') }}", class: 'green', click: function() { $.ajax({ url: '{{ url_for('telemetryInfos') }}', success: function(data) { $('#telemetry_panel .tdata').append(data); $('#telemetry_panel').modal('show'); } }); } },{ text: "{{ _T("No") }}", class: 'red', click: function() { Cookies.set( 'renew_telemetry', 1, { expires: 365, path: '/' } ); $(this).toast('close'); } },{ text: "{{ _T("Later") }}", class: 'blue', click: function() { Cookies.set( 'renew_telemetry', 1, { expires: 182, path: '/' } ); $(this).toast('close'); } }] }) ; {% endif %}