Completed first-found updates for the basic settings view.

This commit is contained in:
Matt Scott 2023-02-20 10:08:09 -05:00
parent 5a4279d7b8
commit a5d69e3e40

View File

@ -1,116 +1,114 @@
{% extends "base.html" %} {% extends "base.html" %}
{% set active_page = "admin_settings" %} {% set active_page = "admin_settings" %}
{% block title %}<title>Basic Settings - {{ SITE_NAME }}</title>{% endblock %}
{% block title %}
<title>
Basic Settings - {{ SITE_NAME }}
</title>
{% endblock %}
{% block dashboard_stat %} {% block dashboard_stat %}
<div class="content-header"> <div class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-sm-6"> <div class="col-sm-6">
<h1 class="m-0 text-dark"> <h1 class="m-0 text-dark">Basic Settings</h1>
Settings </div>
<small>Basic</small> <div class="col-sm-6">
</h1> <ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item active">Basic Settings</li>
</ol>
</div>
</div>
</div> </div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item active">Settings - Basic</li>
</ol>
</div>
</div>
</div> </div>
</div>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
<div class="card"> <div class="card card-outline card-primary shadow">
<div class="card-header with-border"> <div class="card-header with-border">
<h3 class="card-title">Basic Settings</h3> <h3 class="card-title">Settings Editor</h3>
</div> </div>
<div class="card-body"> <!-- /.card-header -->
<table id="tbl_settings" class="table table-bordered table-striped"> <div class="card-body table-responsive">
<thead> <table id="tbl_settings" class="table table-bordered table-striped table-hover table-sm">
<tr> <thead>
<th>Setting Name</th> <tr>
<th>Current Value</th> <th>Setting Name</th>
<th>Action</th> <th>Current Value</th>
</tr> <th>Action</th>
</thead> </tr>
<tbody> </thead>
{% for setting in settings %} <tbody>
<tr class="odd"> {% for setting in settings %}
<td> <tr class="odd">
{{ setting }} <td>
</td> <label for="value{{ loop.index }}">{{ setting }}</label>
{% if SETTING.get(setting) in [False] %} </td>
<td><i class="fas fa-toggle-off"></i>&nbsp;Off</td> {% if SETTING.get(setting) in [False] %}
<td width="20%"> <td><i class="fas fa-toggle-off"></i>&nbsp;Off</td>
<button type="button" class="btn btn-success setting-toggle-button" id="{{ setting }}"> <td>
<i class="fa-solid fa-toggle-on"></i>&nbsp;Turn On <button type="button" class="btn btn-success setting-toggle-button"
</button> id="{{ setting }}">
</td> <i class="fa-solid fa-toggle-on"></i>&nbsp;Turn On
{% elif SETTING.get(setting) in [True] %} </button>
<td><i class="fas fa-toggle-on"></i>&nbsp;On</td> </td>
<td width="20%"> {% elif SETTING.get(setting) in [True] %}
<button type="button" class="btn btn-danger setting-toggle-button" id="{{ setting }}"> <td><i class="fas fa-toggle-on"></i>&nbsp;On</td>
<i class="fa-solid fa-toggle-off"></i>&nbsp;Turn Off <td>
</button> <button type="button" class="btn btn-danger setting-toggle-button"
</td> id="{{ setting }}">
{% else %} <i class="fa-solid fa-toggle-off"></i>&nbsp;Turn Off
<td> </button>
<input name="value" id="value" value="{{ SETTING.get(setting) }}"> </td>
</td> {% else %}
<td width="20%"> <td>
<button type="button" class="btn btn-primary setting-save-button" id="{{ setting }}"> <input name="value" id="value{{ loop.index }}" value="{{ SETTING.get(setting) }}">
<i class="fa-solid fa-save"></i>&nbsp;Save </td>
</button> <td>
</td> <button type="button" class="btn btn-primary setting-save-button"
{% endif %} id="{{ setting }}">
</tr> <i class="fa-solid fa-save"></i>&nbsp;Save
{% endfor %} </button>
</tbody> </td>
</table> {% endif %}
</div> </tr>
</div> {% endfor %}
</div> </tbody>
</section> </table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.container-fluid -->
</section>
{% endblock %} {% endblock %}
{% block extrascripts %} {% block extrascripts %}
<script> <script>
// set up settings table // set up settings table
$("#tbl_settings").DataTable({ $("#tbl_settings").DataTable({
"paging": false, "paging": false,
"lengthChange": false, "lengthChange": false,
"searching": true, "searching": true,
"ordering": true, "ordering": true,
"info": true, "info": true,
"autoWidth": false "autoWidth": false
}); });
$(document.body).on('click', '.setting-toggle-button', function () { $(document.body).on('click', '.setting-toggle-button', function () {
var setting = $(this).prop('id'); var setting = $(this).prop('id');
applyChanges({ applyChanges({
'_csrf_token': '{{ csrf_token() }}' '_csrf_token': '{{ csrf_token() }}'
}, $SCRIPT_ROOT + '/admin/setting/basic/' + setting + '/toggle', false, true) }, $SCRIPT_ROOT + '/admin/setting/basic/' + setting + '/toggle', false, true)
}); });
$(document.body).on('click', '.setting-save-button', function () { $(document.body).on('click', '.setting-save-button', function () {
var setting = $(this).prop('id'); var setting = $(this).prop('id');
var value = $(this).parents('tr').find('#value')[0].value; var value = $(this).parents('tr').find('#value')[0].value;
var postdata = { var postdata = {
'value': value, 'value': value,
'_csrf_token': '{{ csrf_token() }}' '_csrf_token': '{{ csrf_token() }}'
}; };
applyChanges(postdata, $SCRIPT_ROOT + '/admin/setting/basic/' + setting + '/edit', false, true) applyChanges(postdata, $SCRIPT_ROOT + '/admin/setting/basic/' + setting + '/edit', false, true)
}); });
</script> </script>
{% endblock %} {% endblock %}