mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
add notifications and error messages to settings page
This commit is contained in:
parent
8e976922e9
commit
a500f9ec63
@ -175,11 +175,30 @@ class ScheduleBuilder:
|
||||
for key, value in form_post.items():
|
||||
to_check = value[0]
|
||||
if key in self.SCHEDULES and to_check:
|
||||
to_write = self.value_builder(key, to_check)
|
||||
try:
|
||||
to_write = self.value_builder(key, to_check)
|
||||
except ValueError:
|
||||
print(f"failed: {key} {to_check}")
|
||||
mess_dict = {
|
||||
"status": "message:setting",
|
||||
"level": "error",
|
||||
"title": "Scheduler update failed.",
|
||||
"message": "Invalid schedule input",
|
||||
}
|
||||
RedisArchivist().set_message("message:setting", mess_dict)
|
||||
return
|
||||
|
||||
redis_config["scheduler"][key] = to_write
|
||||
if key in self.CONFIG and to_check:
|
||||
redis_config["scheduler"][key] = int(to_check)
|
||||
RedisArchivist().set_message("config", redis_config, expire=False)
|
||||
mess_dict = {
|
||||
"status": "message:setting",
|
||||
"level": "info",
|
||||
"title": "Scheduler changed.",
|
||||
"message": "Please restart container for changes to take effect",
|
||||
}
|
||||
RedisArchivist().set_message("message:setting", mess_dict)
|
||||
|
||||
def value_builder(self, key, to_check):
|
||||
"""validate single cron form entry and return cron dict"""
|
||||
@ -196,7 +215,8 @@ class ScheduleBuilder:
|
||||
values = to_check.split()
|
||||
|
||||
if len(keys) != len(values):
|
||||
raise ValueError(f"failed to parse {to_check} for {key}")
|
||||
print(f"failed to parse {to_check} for {key}")
|
||||
raise ValueError("invalid input")
|
||||
|
||||
to_write = dict(zip(keys, values))
|
||||
if "*" in to_write["minute"]:
|
||||
|
@ -162,6 +162,7 @@ class RedisArchivist:
|
||||
"subchannel",
|
||||
"subplaylist",
|
||||
"playlistscan",
|
||||
"setting",
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
|
@ -1,6 +1,8 @@
|
||||
{% extends "home/base.html" %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<div class="boxed-content">
|
||||
<div id="notifications" data="setting"></div>
|
||||
<div class="title-bar">
|
||||
<h1>User Configurations</h1>
|
||||
</div>
|
||||
@ -163,8 +165,8 @@
|
||||
{{ scheduler_form.check_reindex }}
|
||||
</div>
|
||||
<div class="settings-item">
|
||||
<p>Current refresh for metadata older than, in days: <span class="settings-current">{{ config.scheduler.check_reindex_days }}</span></p>
|
||||
<p>Refresh videos older than, in days:</p>
|
||||
<p>Current refresh for metadata older than x days: <span class="settings-current">{{ config.scheduler.check_reindex_days }}</span></p>
|
||||
<p>Refresh older than x days, recommended 90:</p>
|
||||
{{ scheduler_form.check_reindex_days }}
|
||||
</div>
|
||||
</div>
|
||||
@ -273,4 +275,5 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<script type="text/javascript" src="{% static 'progress.js' %}"></script>
|
||||
{% endblock content %}
|
@ -948,6 +948,7 @@ class SettingsView(View):
|
||||
print(form_post)
|
||||
ScheduleBuilder().update_schedule_conf(form_post)
|
||||
|
||||
sleep(1)
|
||||
return redirect("settings", permanent=True)
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Handle progress bar on /download
|
||||
* Handle multi channel notifications
|
||||
*
|
||||
*/
|
||||
|
||||
@ -10,7 +10,8 @@ const messageTypes = {
|
||||
"download": ["message:download", "message:add", "message:rescan"],
|
||||
"channel": ["message:subchannel"],
|
||||
"channel_id": ["message:playlistscan"],
|
||||
"playlist": ["message:subplaylist"]
|
||||
"playlist": ["message:subplaylist"],
|
||||
"setting": ["message:setting"]
|
||||
}
|
||||
|
||||
// start to look for messages
|
||||
|
Loading…
Reference in New Issue
Block a user