Ross Mountjoy 47fe5c34cb 1
2020-01-29 07:21:00 -05:00

312 lines
16 KiB
HTML

{% extends "main/layout.html" %}
{% from 'global_macros.html' import input, button %}
{% from 'main/tcdrop.html' import tcdrop %}
{% block page_vendor_css %}
{% endblock page_vendor_css %}
{% block page_lvl_css %}
<style>
body {
overflow: hidden !important;
}
</style>
{% if settings.background %}
<style>
#main {
background-image: url("{{ settings.background }}");
background-size: cover;
height: 100vh;
}
</style>
{% endif %}
{% endblock page_lvl_css %}
{% block content %}
<div id="main" class="main-full">
<div class="container">
<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="col s12">
<h5>Config
<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 id="config-help-col" class="col s12 hide theme-surface-1 padding-2 border-radius-10">
<h5>Settings Example</h5>
<code class="selectable-all">
[Settings]<br>
theme = dark<br>
accent = orange<br>
background = static/images/backgrounds/background.png<br>
</code>
<table class="mt-4">
<thead>
<tr>
<th>Variable</th>
<th>Required</th>
<th>Description</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td>[Settings]</td>
<td>Yes</td>
<td>Config section name.</td>
<td>string</td>
</tr>
<tr>
<td>theme</td>
<td>Yes</td>
<td>UI theme</td>
<td>light, dark</td>
</tr>
<tr>
<td>accent</td>
<td>Yes</td>
<td>UI accent color</td>
<td>orange, green, blue, green, pink, grey</td>
</tr>
<tr>
<td>background</td>
<td>Yes</td>
<td>Background image for the UI</td>
<td>/static/images/backgrounds/yourpicture.png, external link to image, None, random</td>
</tr>
</tbody>
</table>
<h5>App Example</h5>
<code class="selectable-all">
[App Name]<br>
prefix = https://<br>
url = your-website.com<br>
icon = static/images/apps/default.png<br>
sidebar_icon = static/images/apps/default.png<br>
description = Example description<br>
open_in = iframe<br>
</code>
<table class="mt-4">
<thead>
<tr>
<th>Variable</th>
<th>Required</th>
<th>Description</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td>[App Name]</td>
<td>Yes</td>
<td>The name of your app.</td>
<td>string</td>
</tr>
<tr>
<td>prefix</td>
<td>Yes</td>
<td>The prefix for the app's url.</td>
<td>web prefix, e.g. http:// or https://</td>
</tr>
<tr>
<td>url</td>
<td>Yes</td>
<td>The url for your app.</td>
<td>web url, e.g. myapp.com</td>
</tr>
<tr>
<td>icon</td>
<td>No</td>
<td>Icon for the dashboard.</td>
<td>/static/images/icons/yourpicture.png, external link to image</td>
</tr>
<tr>
<td>sidebar_icon</td>
<td>No</td>
<td>Icon for the sidenav.</td>
<td>/static/images/icons/yourpicture.png, external link to image</td>
</tr>
<tr>
<td>description</td>
<td>No</td>
<td>A short description for the app.</td>
<td>string</td>
</tr>
<tr>
<td>open_in</td>
<td>Yes</td>
<td>open the app in the current tab, an iframe or a new tab</td>
<td>iframe, new_tab, this_tab</td>
</tr>
</tbody>
</table>
</div>
<div class="divider"></div>
<form id="config-form">
{{ input(
size="s12",
class="materialize-textarea",
form_obj=config_form.config,
id="config-textarea"
) }}
</form>
</div>
</div>
</div>
</div>
<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="col s12">
<h5>User</h5>
{{ user_form.hidden_tag() }}
{{ input(
label="Username",
id="user-form-username",
size="s12",
form_obj=user_form.username,
val=current_user.username
) }}
{{ input(
label="Password",
id="user-form-password",
form_obj=user_form.password,
size="s12"
) }}
{{ input(
label="Confirm Password",
id="user-form-confirm_password",
form_obj=user_form.confirm_password,
required='required',
size="s12"
) }}
{{ button(
icon="save",
float="left",
text="save"
) }}
</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>
{% endblock content %}
{% block page_vendor_js %}
{% endblock page_vendor_js %}
{% block page_lvl_js %}
<script type="text/javascript">
var d = document.getElementById("settings-sidenav");
d.className += " active theme-primary";
function apply_settings(settings_theme, settings_accent){
localStorage.setItem('mode', settings_theme);
document.documentElement.setAttribute('data-theme', settings_theme);
localStorage.setItem('accent', settings_accent);
document.documentElement.setAttribute('data-accent', settings_accent);
}
$( document ).ready(function() {
initTCdrop('#images-tcdrop');
$("#save-config-btn").on('click', function(e) {
$.ajax({
url: $(this).attr('data-url'),
type: 'POST',
data: $("#config-form").serialize(),
success: function(data){
if (data.data.msg === "success"){
M.toast({html: 'Config applied successfully'});
apply_settings(data.data.settings.theme, data.data.settings.accent);
location.reload(true);
} else {
M.toast({html: data.data.msg, classes: "theme-warning"});
}
}
});
});
$(".toggle-config-help").on('click', function(e) {
$("#config-help-col").toggleClass('hide');
});
$("#save-images-btn").on('click', function(e) {
$("#add-images-input").val(tcdrop_files['images-tcdrop'].toString());
$.ajax({
url: $(this).attr('data-url'),
type: 'POST',
data: $("#add-images-form").serialize(),
success: function(data){
$("#add-images-form").trigger('reset');
$("#files-div").empty();
$("#files-div").append(data);
tcdropResetAll();
}
});
});
});
</script>
{% endblock page_lvl_js %}