Improved css, updated sweetalert2, and added new config confirmation prompt (#237)

This commit is contained in:
Chris Caron 2025-02-18 18:42:57 -05:00 committed by GitHub
parent 86e80921b6
commit 9592b9b801
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 114 additions and 65 deletions

View File

@ -51,7 +51,7 @@
<a class="collection-item" href="{% url 'config' DEFAULT_CONFIG_ID %}"><i class="material-icons">settings</i>
{% trans "Configuration Manager" %}</a>
{% if not CONFIG_LOCK %}
<a class="collection-item" href="{% url 'config' UNIQUE_CONFIG_ID %}"><i class="material-icons">refresh</i>
<a class="collection-item" id='cfg-gen' href="{% url 'config' UNIQUE_CONFIG_ID %}"><i class="material-icons">refresh</i>
{% trans "New Configuration" %}</a>
{% endif %}
</ul>
@ -144,6 +144,22 @@
}
});
}
document.querySelector('#cfg-gen').addEventListener('click', function(e) {
e.preventDefault();
Swal.fire({
title: '{% trans "New Configuration" %}',
html: `{% blocktrans with default_config_id=DEFAULT_CONFIG_ID %}This will generate a new Apprise configuration ID and transition over to it. It is important that you have bookmarked or noted the current ID <code>{{ default_config_id }}</code> before continuing. Do you still wish to proceed?{% endblocktrans %}`,
icon: "warning",
showCancelButton: true,
confirmButtonText: '{% trans "Yes" %}',
cancelButtonText: '{% trans "No" %}'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = e.target.href;
}
});
});
</script>
</body>

View File

@ -515,25 +515,25 @@ function config_init() {
main_init();
// user notification
Swal.fire(
'{% trans "Save" %}',
'{% trans "Successfully saved the specified URL(s)." %}',
'success'
);
Swal.fire({
title: '{% trans "Save" %}',
html: '{% trans "Successfully saved the specified URL(s)." %}',
icon: 'success'
});
} else if(response.status == 500) {
// Disk issue
Swal.fire(
'{% trans "Save" %}',
'{% trans "There was an issue writing the configuration to disk. Check your file permissions and try again." %}',
'error'
);
Swal.fire({
title: '{% trans "Save" %}',
html: '{% trans "There was an issue writing the configuration to disk. Check your file permissions and try again." %}',
icon: 'error'
});
} else {
// user notification
Swal.fire(
'{% trans "Save" %}',
'{% trans "Failed to save the specified URL(s). Check your syntax and try again." %}',
'error'
);
Swal.fire({
title: '{% trans "Save" %}',
html: '{% trans "Failed to save the specified URL(s). Check your syntax and try again." %}',
icon: 'error'
});
}
});
} else {
@ -549,18 +549,18 @@ function config_init() {
main_init();
// user notification
Swal.fire(
'{% trans "Delete" %}',
'{% trans "Successfully removed configuration." %}',
'success'
);
Swal.fire({
title: '{% trans "Delete" %}',
html: '{% trans "Successfully removed configuration." %}',
icon: 'success'
});
} else {
// user notification
Swal.fire(
'{% trans "Delete" %}',
'{% trans "There was an issue removing the configuration." %}',
'error'
);
Swal.fire({
title: '{% trans "Delete" %}',
html: '{% trans "There was an issue removing the configuration." %}',
icon: 'error'
});
}
});
}
@ -655,10 +655,10 @@ function notify_init() {
const form = new FormData(this);
// perform our notification
Swal.fire(
'{% trans "Notification" %}',
'{% trans "Sending notification(s)..." %}',
);
Swal.fire({
title: '{% trans "Notification" %}',
html: '{% trans "Sending notification(s)..." %}',
});
Swal.showLoading()
let response = fetch('{% url "notify" key %}', {
method: 'POST',
@ -672,25 +672,28 @@ function notify_init() {
if(response.status == 200)
{
// user notification
Swal.fire(
'{% trans "Notification" %}',
'{% trans "Successfully sent the notification(s)." %}' + html,
'success'
);
Swal.fire({
title: '{% trans "Notification" %}',
html: '{% trans "Successfully sent the notification(s)." %}' + html,
icon: 'success',
width: '80em'
});
} else if(response.status == 424) {
// user notification
Swal.fire(
'{% trans "Notification" %}',
'{% trans "One or more of the notification(s) were not sent." %}' + html,
'warning'
);
Swal.fire({
title: '{% trans "Notification" %}',
html: '{% trans "One or more of the notification(s) were not sent." %}' + html,
icon: 'warning',
width: '80em'
});
} else {
// user notification
Swal.fire(
'{% trans "Notification" %}',
'{% trans "Failed to send the notification(s)." %}' + html,
'error'
);
Swal.fire({
title: '{% trans "Notification" %}',
html: '{% trans "Failed to send the notification(s)." %}' + html,
icon: 'error',
width: '80em'
});
}
});
});

View File

@ -783,11 +783,13 @@ class NotifyView(View):
if not content.get('attachment'):
if 'attachment' in request.POST:
# Acquire attachments to work with them
content['attachment'] = request.POST.getlist('attachment')
content['attachment'] = \
[a for a in request.POST.getlist('attachment') if isinstance(a, str) and a.strip()]
elif 'attach' in request.POST:
# Acquire kw (alias) attach to work with them
content['attachment'] = request.POST.getlist('attach')
content['attachment'] = \
[a for a in request.POST.getlist('attach') if isinstance(a, str) and a.strip()]
elif content.get('attach'):
# Acquire kw (alias) attach from payload to work with

View File

@ -189,22 +189,6 @@ ul.logs li div.log_msg {
flex: 1;
}
ul.logs li.log_INFO {
color: black;
}
ul.logs li.log_DEBUG {
color: #606060;
}
ul.logs li.log_WARNING {
color: orange;
}
ul.logs li.log_ERROR {
color: #8B0000;
}
.url-enabled {
color:#004d40;
}

View File

@ -1335,8 +1335,10 @@ input[type=range]::-ms-thumb {
.swal2-popup {
background-color: #2e3440;
color: #e5e9f0;
}
.swal-icon--success__ring {
border: 4px solid rgba(194, 26, 90, 0.2);
}
@ -1380,3 +1382,24 @@ input[type=range]::-ms-thumb {
.swal-icon--info:before {
background-color: #d119c8;
}
ul.logs {
background-color: #1b1e26;
color: #e5e9f0;
}
ul.logs li.log_INFO {
color: #e5e9f0;
}
ul.logs li.log_DEBUG {
color: #606060;
}
ul.logs li.log_WARNING {
color: orange;
}
ul.logs li.log_ERROR {
color: #8B0000;
}

View File

@ -27,3 +27,20 @@
color: #fff;
background-color: #258528!important;
}
ul.logs li.log_INFO {
color: black;
}
ul.logs li.log_DEBUG {
color: #606060;
}
ul.logs li.log_WARNING {
color: orange;
}
ul.logs li.log_ERROR {
color: #8B0000;
}

File diff suppressed because one or more lines are too long