Merge branch 'tweak/reaction-schedules' into 'dev'

Make default option be selected option in edit

See merge request crafty-controller/crafty-4!462
This commit is contained in:
Iain Powrie 2022-09-19 21:55:58 +00:00
commit 44abbef9c7
3 changed files with 34 additions and 10 deletions

View File

@ -10,6 +10,7 @@ TBD
- Temp fix for `&` issue in pathing and minecraft colour codes ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/457))
- Cache Gravatar pfp's as to not query every page load ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/459))
- Fix crash on client list changing while sending websockets ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/461))
- Set default parent option on edit of reaction schedule ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/462))
### Tweaks
- Add button to scroll to bottom of vterm ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/454))
- Persist schedules and execution commands across backup restores ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/458))

View File

@ -977,6 +977,7 @@ class PanelHandler(BaseHandler):
# We'll just default to basic for new schedules
page_data["schedule"]["difficulty"] = "basic"
page_data["schedule"]["interval_type"] = "days"
page_data["parent"] = None
if not EnumPermissionsServer.SCHEDULE in page_data["user_permissions"]:
if not superuser:
@ -1059,8 +1060,12 @@ class PanelHandler(BaseHandler):
page_data["schedule"]["interval_type"] = schedule.interval_type
if schedule.interval_type == "reaction":
difficulty = "reaction"
page_data["parent"] = self.controller.management.get_scheduled_task(
schedule.parent
)
elif schedule.cron_string == "":
difficulty = "basic"
page_data["parent"] = None
else:
difficulty = "advanced"
page_data["schedule"]["difficulty"] = difficulty

View File

@ -145,17 +145,35 @@
data['lang']) }}</small> </label>
<select id="parent" name="parent" class="form-control form-control-lg select-css"
value="{{ data['schedule']['action'] }}">
{% 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}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.interval}} {{
schedule.interval_type}}</option>
{% if data['parent'] %}
<option id="{{data['parent']['schedule_id']}}" value="{{data['parent']['schedule_id']}}">
{{data['parent']['name']}} | {{data['parent']['command']}} | {{data['parent']['interval']}}
</option>
{% for schedule in data['schedules'] %}
{% if schedule.schedule_id != data['schedule']['schedule_id'] and schedule.schedule_id != data['parent']['schedule_id'] %}
{% if 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}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
{% end %}
{% end %}
{% end %}
{% else %}
<option id="{{schedule.schedule_id}}" value="{{schedule.schedule_id}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
{% end %}
{% end %}
{% for schedule in data['schedules'] %}
{% if schedule.schedule_id != data['schedule']['schedule_id'] and schedule.schedule_id %}
{% if 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}}">
{{schedule.name}} | {{schedule.command}} | {{schedule.cron_string}}</option>
{% end %}
{% end %}
{% end %}
{% end %}
</select>
</div>