mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add names to schedules
This commit is contained in:
parent
e0377d4b2f
commit
75c8cdef53
@ -76,7 +76,7 @@ class ManagementController:
|
||||
interval_type,
|
||||
start_time,
|
||||
command,
|
||||
comment=None,
|
||||
name,
|
||||
enabled=True,
|
||||
):
|
||||
return HelpersManagement.create_scheduled_task(
|
||||
@ -86,7 +86,7 @@ class ManagementController:
|
||||
interval_type,
|
||||
start_time,
|
||||
command,
|
||||
comment,
|
||||
name,
|
||||
enabled,
|
||||
)
|
||||
|
||||
|
@ -110,7 +110,7 @@ class Schedules(BaseModel):
|
||||
interval_type = CharField()
|
||||
start_time = CharField(null=True)
|
||||
command = CharField(null=True)
|
||||
comment = CharField()
|
||||
name = CharField()
|
||||
one_time = BooleanField(default=False)
|
||||
cron_string = CharField(default="")
|
||||
parent = IntegerField(null=True)
|
||||
@ -265,7 +265,7 @@ class HelpersManagement:
|
||||
interval_type,
|
||||
start_time,
|
||||
command,
|
||||
comment=None,
|
||||
name,
|
||||
enabled=True,
|
||||
one_time=False,
|
||||
cron_string="* * * * *",
|
||||
@ -281,7 +281,7 @@ class HelpersManagement:
|
||||
Schedules.interval_type: interval_type,
|
||||
Schedules.start_time: start_time,
|
||||
Schedules.command: command,
|
||||
Schedules.comment: comment,
|
||||
Schedules.name: name,
|
||||
Schedules.one_time: one_time,
|
||||
Schedules.cron_string: cron_string,
|
||||
Schedules.parent: parent,
|
||||
|
@ -303,7 +303,7 @@ class TasksManager:
|
||||
job_data["interval_type"],
|
||||
job_data["start_time"],
|
||||
job_data["command"],
|
||||
"None",
|
||||
job_data["name"],
|
||||
job_data["enabled"],
|
||||
job_data["one_time"],
|
||||
job_data["cron_string"],
|
||||
@ -318,6 +318,7 @@ class TasksManager:
|
||||
|
||||
# Check to see if it's enabled and is not a chain reaction.
|
||||
if job_data["enabled"] and job_data["interval_type"] != "reaction":
|
||||
new_job = "error"
|
||||
if job_data["cron_string"] != "":
|
||||
try:
|
||||
new_job = self.scheduler.add_job(
|
||||
@ -447,6 +448,7 @@ class TasksManager:
|
||||
)
|
||||
|
||||
if job_data["enabled"] and job_data["interval"] != "reaction":
|
||||
new_job = "error"
|
||||
if job_data["cron_string"] != "":
|
||||
try:
|
||||
new_job = self.scheduler.add_job(
|
||||
|
@ -968,6 +968,10 @@ class PanelHandler(BaseHandler):
|
||||
page_data["schedule"]["server_id"] = server_id
|
||||
page_data["schedule"]["schedule_id"] = schedule.schedule_id
|
||||
page_data["schedule"]["action"] = schedule.action
|
||||
if schedule.name:
|
||||
page_data["schedule"]["name"] = schedule.name
|
||||
else:
|
||||
page_data["schedule"]["name"] = ""
|
||||
page_data["schedule"][
|
||||
"children"
|
||||
] = self.controller.management.get_child_schedules(sch_id)
|
||||
@ -1557,6 +1561,7 @@ class PanelHandler(BaseHandler):
|
||||
difficulty = bleach.clean(self.get_argument("difficulty", None))
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
enabled = bleach.clean(self.get_argument("enabled", "0"))
|
||||
name = bleach.clean(self.get_argument("name", ""))
|
||||
if difficulty == "basic":
|
||||
action = bleach.clean(self.get_argument("action", None))
|
||||
interval = bleach.clean(self.get_argument("interval", None))
|
||||
@ -1621,6 +1626,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
if interval_type == "days":
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": interval_type,
|
||||
@ -1635,6 +1641,7 @@ class PanelHandler(BaseHandler):
|
||||
}
|
||||
elif difficulty == "reaction":
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": interval_type,
|
||||
@ -1650,6 +1657,7 @@ class PanelHandler(BaseHandler):
|
||||
}
|
||||
elif difficulty == "advanced":
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": "",
|
||||
@ -1665,6 +1673,7 @@ class PanelHandler(BaseHandler):
|
||||
}
|
||||
else:
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": interval_type,
|
||||
@ -1714,6 +1723,7 @@ class PanelHandler(BaseHandler):
|
||||
difficulty = bleach.clean(self.get_argument("difficulty", None))
|
||||
server_obj = self.controller.servers.get_server_obj(server_id)
|
||||
enabled = bleach.clean(self.get_argument("enabled", "0"))
|
||||
name = bleach.clean(self.get_argument("name", ""))
|
||||
if difficulty == "basic":
|
||||
action = bleach.clean(self.get_argument("action", None))
|
||||
interval = bleach.clean(self.get_argument("interval", None))
|
||||
@ -1777,6 +1787,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
if interval_type == "days":
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": interval_type,
|
||||
@ -1791,6 +1802,7 @@ class PanelHandler(BaseHandler):
|
||||
}
|
||||
elif difficulty == "advanced":
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": "",
|
||||
@ -1806,6 +1818,7 @@ class PanelHandler(BaseHandler):
|
||||
}
|
||||
elif difficulty == "reaction":
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": interval_type,
|
||||
@ -1821,6 +1834,7 @@ class PanelHandler(BaseHandler):
|
||||
}
|
||||
else:
|
||||
job_data = {
|
||||
"name": name,
|
||||
"server_id": server_id,
|
||||
"action": action,
|
||||
"interval_type": interval_type,
|
||||
|
@ -47,6 +47,12 @@
|
||||
<input type="hidden" name="id" value="{{ data['server_stats']['server_id']['server_id'] }}">
|
||||
<input type="hidden" name="subpage" value="config">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">{{ translate('serverSchedules', 'name' , data['lang']) }}</label>
|
||||
<input type="input" class="form-control" name="name" id="name_input"
|
||||
value="{{ data['schedule']['name']}}" maxlength="30" placeholder="Name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="difficulty">{{ translate('serverScheduleConfig', 'select' , data['lang']) }}<small
|
||||
class="text-muted ml-1"></small> </label><br>
|
||||
@ -141,12 +147,12 @@
|
||||
{% for schedule in data['schedules'] %}
|
||||
{% if schedule.schedule_id != data['schedule']['schedule_id'] %}
|
||||
{% if schedule.interval != '' %}
|
||||
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">ID:
|
||||
{{schedule.schedule_id}} | {{schedule.command}} | {{schedule.interval}} {{
|
||||
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
|
||||
{{schedule.name}} | {{schedule.command}} | {{schedule.interval}} {{
|
||||
schedule.interval_type}}</option>
|
||||
{% else %}
|
||||
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">ID:
|
||||
{{schedule.schedule_id}} {{schedule.command}} {{schedule.cron_string}}</option>
|
||||
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
|
||||
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
|
||||
{% end %}
|
||||
{% end %}
|
||||
{% end %}
|
||||
@ -181,8 +187,8 @@
|
||||
<ul>
|
||||
{% for schedule in data['schedule']['children'] %}
|
||||
<li style="overflow: auto;"><a
|
||||
href="/panel/edit_schedule?id={{schedule.server_id}}&sch_id={{schedule.schedule_id}}">{{schedule.schedule_id}}
|
||||
| {{schedule.command}}</a></li>
|
||||
href="/panel/edit_schedule?id={{schedule.server_id}}&sch_id={{schedule.schedule_id}}">{{schedule.name}}
|
||||
| {{schedule.schedule_id}}</a></li>
|
||||
{% end %}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -81,7 +81,7 @@
|
||||
{% for schedule in data['schedules'] %}
|
||||
<tr>
|
||||
<td id="{{schedule.schedule_id}}" class="id">
|
||||
<p>{{schedule.schedule_id}}</p>
|
||||
<p>{{schedule.name}}</p>
|
||||
</td>
|
||||
<td id="{{schedule.action}}" class="action">
|
||||
<p>{{schedule.action}}</p>
|
||||
@ -94,7 +94,8 @@
|
||||
<p>{{ translate('serverSchedules', 'every', data['lang']) }}</p>
|
||||
<p>{{schedule.interval}} {{schedule.interval_type}}</p>
|
||||
{% elif schedule.interval_type == 'reaction' %}
|
||||
<p>{{schedule.interval_type}}<br><br>child of ID: {{ schedule.parent }}</p>
|
||||
<p>{{schedule.interval_type}}<br><br>{{ translate('serverSchedules', 'child', data['lang'])}}:
|
||||
{{ schedule.parent }}</p>
|
||||
{% else %}
|
||||
<p>Cron String:</p>
|
||||
<p>{{schedule.cron_string}}</p>
|
||||
@ -201,7 +202,11 @@
|
||||
</li>
|
||||
<li id="{{schedule.start_time}}" class="action" style="border-top: .1em solid gray;">
|
||||
<h4>{{ translate('serverSchedules', 'nextRun', data['lang']) }}</h4>
|
||||
{% if schedule.next_run %}
|
||||
<p>{{schedule.next_run}}</p>
|
||||
{% else %}
|
||||
<p>zzzzzzz</p>
|
||||
{% end %}
|
||||
</li>
|
||||
<li id="{{schedule.enabled}}" class="action"
|
||||
style="border-top: .1em solid gray; border-bottom: .1em solid gray">
|
||||
@ -322,7 +327,7 @@
|
||||
$(document).ready(function () {
|
||||
console.log('ready for JS!')
|
||||
$('#schedule_table').DataTable({
|
||||
'order': [4, 'desc']
|
||||
'order': [4, 'asc'],
|
||||
}
|
||||
);
|
||||
|
||||
@ -330,7 +335,7 @@
|
||||
$(document).ready(function () {
|
||||
console.log('ready for JS!')
|
||||
$('#mini_schedule_table').DataTable({
|
||||
'order': [2, 'desc']
|
||||
'order': [2, 'asc']
|
||||
}
|
||||
);
|
||||
document.getElementById('mini_schedule_table_wrapper').hidden = true;
|
||||
|
17
app/migrations/20220805_schedule_rename_comment.py
Normal file
17
app/migrations/20220805_schedule_rename_comment.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by database migrator
|
||||
import peewee
|
||||
|
||||
|
||||
def migrate(migrator, database, **kwargs):
|
||||
migrator.rename_column("schedules", "comment", "name")
|
||||
|
||||
"""
|
||||
Write your migrations here.
|
||||
"""
|
||||
|
||||
|
||||
def rollback(migrator, database, **kwargs):
|
||||
migrator.rename_column("schedules", "name", "comment")
|
||||
"""
|
||||
Write your rollback migrations here.
|
||||
"""
|
@ -433,7 +433,7 @@
|
||||
"no": "No",
|
||||
"cron": "Crong String",
|
||||
"details": "Schedule Details",
|
||||
"child": "Child of schedule named: ",
|
||||
"child": "Child of schedule named ",
|
||||
"areYouSure": "Delete Scheduled Task?",
|
||||
"close": "Close",
|
||||
"delete": "Delete",
|
||||
|
Loading…
Reference in New Issue
Block a user