mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Add better formatting for lists.
This commit is contained in:
parent
5d3dbc6f9c
commit
bea48d9059
@ -1720,6 +1720,27 @@ class PanelHandler(BaseHandler):
|
||||
self.tasks_manager.reload_schedule_from_db()
|
||||
self.redirect(f"/panel/server_detail?id={server_id}&subpage=backup")
|
||||
|
||||
elif page == "config_json":
|
||||
try:
|
||||
data = {}
|
||||
with open(self.helper.settings_file, "r", encoding="utf-8") as f:
|
||||
print("open")
|
||||
keys = json.load(f).keys()
|
||||
for key in keys:
|
||||
print(self.get_argument(key))
|
||||
data[key] = self.get_argument(key)
|
||||
print("data:", data)
|
||||
"""
|
||||
with open(self.helper.settings_file, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
"""
|
||||
except Exception as e:
|
||||
logger.critical(
|
||||
f"Config File Error: Unable to read {self.helper.settings_file} due to {e}"
|
||||
)
|
||||
|
||||
self.redirect("/panel/config_json")
|
||||
|
||||
if page == "new_schedule":
|
||||
server_id = self.check_server_id()
|
||||
if not server_id:
|
||||
|
@ -37,36 +37,47 @@
|
||||
<div class="col-md-12 grid-margin">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form class="forms-sample" method="post" action="/panel/config-json">
|
||||
<form id="config-form" class="forms-sample" method="post" action="/panel/config_json">
|
||||
{% raw xsrf_form_html() %}
|
||||
{% for item in data['config-json'].items() %}
|
||||
<br />
|
||||
<br />
|
||||
<label for="{{item[0]}}">{{item[0]}}
|
||||
<small class="text-muted ml-1">
|
||||
</small> </label>
|
||||
{% if isinstance(item[1], bool) %}
|
||||
{% if isinstance(item[1], list) %}
|
||||
<ul>
|
||||
{% for li in item[1] %}
|
||||
<input style="color: black;" form="config-form" class="form-control" type="text" value="{{li}}"
|
||||
name="{{item[0]}}" readonly><br />
|
||||
{% end %}
|
||||
</ul>
|
||||
{% elif isinstance(item[1], bool) %}
|
||||
|
||||
{% if item[1] == True %}
|
||||
<div style="margin-left: 30px;">
|
||||
<input type="radio" class="form-check-input" name="{{item[0]}}" id="True" value="True" checked>
|
||||
<label for="True">True</label><br>
|
||||
<input type="radio" class="form-check-input" name="{{item[0]}}" id="False" value="False">
|
||||
<label for="False">False</label><br>
|
||||
<label for="False">False</label>
|
||||
</div>
|
||||
{% else %}
|
||||
<div style="margin-left: 30px;">
|
||||
<input type="radio" class="form-check-input" name="{{item[0]}}" id="True" value="True">
|
||||
<label for="True">True</label><br>
|
||||
<input type="radio" class="form-check-input" name="{{item[0]}}" id="False" value="False" checked>
|
||||
<label for="False">False</label><br>
|
||||
<label for="False">False</label>
|
||||
</div>
|
||||
{% end %}
|
||||
{% elif isinstance(item[1], int) %}
|
||||
<input type="number" class="form-control" name="{{item[0]}}" id="{{item[0]}}" value="{{ item[1] }}"
|
||||
step="2" min="0" required>
|
||||
step="1" min="0" required>
|
||||
{% else %}
|
||||
<input type="text" class="form-control" name="{{item[0]}}" id="{{item[0]}}" value="{{ item[1] }}" step="2"
|
||||
min="0" required>
|
||||
{% end %}
|
||||
{% end %}
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user