1
This commit is contained in:
parent
995d24664f
commit
2644093fc5
@ -2,8 +2,8 @@ import os
|
|||||||
from flask import render_template, request, Blueprint, jsonify
|
from flask import render_template, request, Blueprint, jsonify
|
||||||
from dashmachine.settings_system.forms import ConfigForm
|
from dashmachine.settings_system.forms import ConfigForm
|
||||||
from dashmachine.user_system.forms import UserForm
|
from dashmachine.user_system.forms import UserForm
|
||||||
from dashmachine.main.utils import read_config
|
from dashmachine.main.utils import read_config, row2dict
|
||||||
from dashmachine.main.models import Files
|
from dashmachine.main.models import Files, TemplateApps
|
||||||
from dashmachine.paths import backgrounds_images_folder, icons_images_folder
|
from dashmachine.paths import backgrounds_images_folder, icons_images_folder
|
||||||
from dashmachine.settings_system.utils import load_files_html
|
from dashmachine.settings_system.utils import load_files_html
|
||||||
|
|
||||||
@ -17,11 +17,16 @@ def settings():
|
|||||||
with open("dashmachine/user_data/config.ini", "r") as config_file:
|
with open("dashmachine/user_data/config.ini", "r") as config_file:
|
||||||
config_form.config.data = config_file.read()
|
config_form.config.data = config_file.read()
|
||||||
files_html = load_files_html()
|
files_html = load_files_html()
|
||||||
|
template_apps = []
|
||||||
|
t_apps = TemplateApps.query.all()
|
||||||
|
for t_app in t_apps:
|
||||||
|
template_apps.append(f"{t_app.name}&&{t_app.icon}")
|
||||||
return render_template(
|
return render_template(
|
||||||
"settings_system/settings.html",
|
"settings_system/settings.html",
|
||||||
config_form=config_form,
|
config_form=config_form,
|
||||||
files_html=files_html,
|
files_html=files_html,
|
||||||
user_form=user_form,
|
user_form=user_form,
|
||||||
|
template_apps=",".join(template_apps),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -44,3 +49,13 @@ def add_images():
|
|||||||
new_path = os.path.join(dest_folder, file.name)
|
new_path = os.path.join(dest_folder, file.name)
|
||||||
os.rename(file.path, new_path)
|
os.rename(file.path, new_path)
|
||||||
return load_files_html()
|
return load_files_html()
|
||||||
|
|
||||||
|
|
||||||
|
@settings_system.route("/settings/get_app_template", methods=["GET"])
|
||||||
|
def get_app_template():
|
||||||
|
template_app = TemplateApps.query.filter_by(name=request.args.get("name")).first()
|
||||||
|
template = f"[{template_app.name}]<br>"
|
||||||
|
for key, value in row2dict(template_app).items():
|
||||||
|
if key not in ["id", "name"]:
|
||||||
|
template += f"{key} = {value}<br>"
|
||||||
|
return template
|
||||||
|
@ -9,6 +9,17 @@
|
|||||||
body {
|
body {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-page-card {
|
||||||
|
max-height: calc(100vh - 30px);
|
||||||
|
min-height: calc(100vh - 30px);
|
||||||
|
}
|
||||||
|
|
||||||
|
#apps .dropdown-content {
|
||||||
|
border-top-left-radius: 0px;
|
||||||
|
border-top-right-radius: 0px;
|
||||||
|
background: var(--theme-surface-1);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% if settings.background %}
|
{% if settings.background %}
|
||||||
<style>
|
<style>
|
||||||
@ -22,27 +33,13 @@
|
|||||||
{% endblock page_lvl_css %}
|
{% endblock page_lvl_css %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="main" class="main-full">
|
<div id="config-wiki-modal" class="modal full-height-modal">
|
||||||
<div class="container">
|
<div class="modal-content">
|
||||||
<div class="row">
|
|
||||||
<div class="col s12 m12 l6">
|
|
||||||
<div class="card scrollbar" style="max-height: calc(100vh - 30px)">
|
|
||||||
<div class="card-content">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<h5>Config
|
<h4>Config.ini Readme</h4>
|
||||||
<i class="material-icons-outlined theme-secondary-text icon-btn ml-2 toggle-config-help" style="position: relative; top: 4px;">info</i>
|
|
||||||
</h5>
|
|
||||||
{{ button(
|
|
||||||
icon="save",
|
|
||||||
id="save-config-btn",
|
|
||||||
float="left",
|
|
||||||
class="ml-0 mt-1 mb-1",
|
|
||||||
data={'url': url_for('settings_system.save_config')},
|
|
||||||
text="save"
|
|
||||||
) }}
|
|
||||||
</div>
|
</div>
|
||||||
<div id="config-help-col" class="col s12 hide theme-surface-1 padding-2 border-radius-10">
|
<div id="config-help-col" class="col s12 theme-surface-1 padding-2 border-radius-10">
|
||||||
<h5>Settings Example</h5>
|
<h5>Settings Example</h5>
|
||||||
<code class="selectable-all">
|
<code class="selectable-all">
|
||||||
[Settings]<br>
|
[Settings]<br>
|
||||||
@ -97,6 +94,7 @@
|
|||||||
sidebar_icon = static/images/apps/default.png<br>
|
sidebar_icon = static/images/apps/default.png<br>
|
||||||
description = Example description<br>
|
description = Example description<br>
|
||||||
open_in = iframe<br>
|
open_in = iframe<br>
|
||||||
|
data_template = None
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
<table class="mt-4">
|
<table class="mt-4">
|
||||||
@ -151,10 +149,43 @@
|
|||||||
<td>open the app in the current tab, an iframe or a new tab</td>
|
<td>open the app in the current tab, an iframe or a new tab</td>
|
||||||
<td>iframe, new_tab, this_tab</td>
|
<td>iframe, new_tab, this_tab</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>data_template</td>
|
||||||
|
<td>No</td>
|
||||||
|
<td>Template for displaying variable(s) from rest data *Note: you must have a rest data variable set up in the config</td>
|
||||||
|
<td>example: Data: {{ '{{ your_variable }}' }}</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="main" class="main-full">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12 m12 l6">
|
||||||
|
<div class="card scrollbar settings-page-card">
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12">
|
||||||
|
<h5>Config
|
||||||
|
<a href="#config-wiki-modal" class="modal-trigger">
|
||||||
|
<i class="material-icons-outlined theme-secondary-text icon-btn ml-2 toggle-config-help" style="position: relative; top: 4px;">info</i>
|
||||||
|
</a>
|
||||||
|
</h5>
|
||||||
|
{{ button(
|
||||||
|
icon="save",
|
||||||
|
id="save-config-btn",
|
||||||
|
float="left",
|
||||||
|
class="ml-0 mt-1 mb-1",
|
||||||
|
data={'url': url_for('settings_system.save_config')},
|
||||||
|
text="save"
|
||||||
|
) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<form id="config-form">
|
<form id="config-form">
|
||||||
{{ input(
|
{{ input(
|
||||||
@ -170,10 +201,71 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s12 m12 l6">
|
<div class="col s12 m12 l6">
|
||||||
<div class="card scrollbar" style="max-height: calc(100vh - 30px)">
|
<div class="card scrollbar settings-page-card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12 mb-2">
|
||||||
|
<ul class="tabs tabs-fixed-width">
|
||||||
|
<li class="tab col s3"><a href="#images">
|
||||||
|
<i class="material-icons-outlined">photo_library</i>
|
||||||
|
</a></li>
|
||||||
|
|
||||||
|
<li class="tab col s3"><a href="#apps">
|
||||||
|
<i class="material-icons-outlined">apps</i>
|
||||||
|
</a></li>
|
||||||
|
|
||||||
|
<li class="tab col s3"><a href="#user">
|
||||||
|
<i class="material-icons-outlined">person</i>
|
||||||
|
</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="images" class="col s12">
|
||||||
|
<div class="row">
|
||||||
|
<h5>Images</h5>
|
||||||
|
<form id="add-images-form">
|
||||||
|
<div class="input-field col s12 mt-4">
|
||||||
|
<select name="folder">
|
||||||
|
<option value="icons">Icons</option>
|
||||||
|
<option value="backgrounds">Backgrounds</option>
|
||||||
|
</select>
|
||||||
|
<label>Folder</label>
|
||||||
|
</div>
|
||||||
|
<input name="files" id="add-images-input" class="hide">
|
||||||
|
</form>
|
||||||
|
{{ tcdrop(allowed_types='jpg,jpeg,png,gif', id="images-tcdrop", max_files="30") }}
|
||||||
|
{{ button(text="save", icon="save", id="save-images-btn", float="left", data={"url": url_for('settings_system.add_images')}) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div id="files-div">{{ files_html|safe }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="apps" class="col s12">
|
||||||
|
<h5>App Templates</h5>
|
||||||
|
<div class="row card-filter-container">
|
||||||
|
<div class="col s12 input-field">
|
||||||
|
<span>
|
||||||
|
<i class="material-icons prefix card-search-icon">search</i>
|
||||||
|
<input type="text" id="templates-filter"
|
||||||
|
class="card-filter theme-surface-1 autocomplete"
|
||||||
|
data-url="{{ url_for('settings_system.get_app_template') }}"
|
||||||
|
data-template_apps="{{ template_apps }}"
|
||||||
|
placeholder="Search for app (e.g. Nextcloud)">
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
|
<div id="template-div" class="selectable-all"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="user" class="col s12">
|
||||||
<h5>User</h5>
|
<h5>User</h5>
|
||||||
{{ user_form.hidden_tag() }}
|
{{ user_form.hidden_tag() }}
|
||||||
|
|
||||||
@ -206,44 +298,9 @@
|
|||||||
text="save"
|
text="save"
|
||||||
) }}
|
) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col s12">
|
|
||||||
<h5>App Templates</h5>
|
|
||||||
<div class="row card-filter-container">
|
|
||||||
<div class="col s12 input-field">
|
|
||||||
<span>
|
|
||||||
<i class="material-icons prefix card-search-icon">search</i>
|
|
||||||
<input type="text" id="templates-filter" class="card-filter theme-surface-1" placeholder="Search for app (e.g. Nextcloud)">
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="divider"></div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col s12">
|
|
||||||
<h5>Images</h5>
|
|
||||||
<form id="add-images-form">
|
|
||||||
<div class="input-field col s12 mt-4">
|
|
||||||
<select name="folder">
|
|
||||||
<option value="icons">Icons</option>
|
|
||||||
<option value="backgrounds">Backgrounds</option>
|
|
||||||
</select>
|
|
||||||
<label>Folder</label>
|
|
||||||
</div>
|
|
||||||
<input name="files" id="add-images-input" class="hide">
|
|
||||||
</form>
|
|
||||||
{{ tcdrop(allowed_types='jpg,jpeg,png,gif', id="images-tcdrop", max_files="30") }}
|
|
||||||
{{ button(text="save", icon="save", id="save-images-btn", float="left", data={"url": url_for('settings_system.add_images')}) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="files-div">{{ files_html|safe }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -270,6 +327,7 @@
|
|||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
initTCdrop('#images-tcdrop');
|
initTCdrop('#images-tcdrop');
|
||||||
|
$("#config-wiki-modal").modal();
|
||||||
$("#save-config-btn").on('click', function(e) {
|
$("#save-config-btn").on('click', function(e) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $(this).attr('data-url'),
|
url: $(this).attr('data-url'),
|
||||||
@ -287,10 +345,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".toggle-config-help").on('click', function(e) {
|
|
||||||
$("#config-help-col").toggleClass('hide');
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#save-images-btn").on('click', function(e) {
|
$("#save-images-btn").on('click', function(e) {
|
||||||
$("#add-images-input").val(tcdrop_files['images-tcdrop'].toString());
|
$("#add-images-input").val(tcdrop_files['images-tcdrop'].toString());
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -306,6 +360,28 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var template_apps = $("#templates-filter").attr("data-template_apps").split(',');
|
||||||
|
var autocomplete_data = {}
|
||||||
|
$.each(template_apps, function(i, e) {
|
||||||
|
autocomplete_data[e.split('&&')[0]] = e.split('&&')[1]
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#templates-filter").autocomplete({
|
||||||
|
limit: 16,
|
||||||
|
data: autocomplete_data,
|
||||||
|
onAutocomplete: function () {
|
||||||
|
$.ajax({
|
||||||
|
url: $("#templates-filter").attr('data-url'),
|
||||||
|
type: 'GET',
|
||||||
|
data: {name: $("#templates-filter").val()},
|
||||||
|
success: function(data){
|
||||||
|
$("#template-div").empty();
|
||||||
|
$("#template-div").append(data)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock page_lvl_js %}
|
{% endblock page_lvl_js %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user