MediaDash/templates/config.html

70 lines
2.6 KiB
HTML
Raw Normal View History

2021-08-29 13:03:28 +00:00
{% extends "base.html" %}
{% from 'utils.html' import custom_render_form_row,make_tabs %}
{% from 'bootstrap/form.html' import render_form, render_field, render_form_row %}
{% set col_size = ('lg',2,6) %}
{% set col_size_seq = ('lg',10,1) %}
{% macro render_fields(fields) %}
{% for field in fields %}
{% if field is sequence %}
{{ custom_render_form_row(field|list,col_map={'transcode_edit':('lg',1),'transcode_new':('lg',1)},render_args={'form_type':'horizontal'}) }}
{% else %}
{{ custom_render_form_row([field],render_args={'form_type':'horizontal','horizontal_columns':col_size}) }}
{% endif %}
{% endfor %}
{% endmacro %}
{% set config_tabs = [] %}
{% for name, fields in [
('Jellyfin',[form.jellyfin_url,form.jellyfin_username,form.jellyfin_passwd]),
('QBittorrent',[form.qbt_url,form.qbt_username,form.qbt_passwd]),
('Sonarr',[form.sonarr_url,form.sonarr_api_key]),
('Radarr',[form.radarr_url,form.radarr_api_key]),
('Portainer',[form.portainer_url,form.portainer_username,form.portainer_passwd]),
('Jackett',[form.jackett_url,form.jackett_api_key]),
('Transcode',[form.transcode_default_profile,form.transcode_profiles]),
] %}
{% do config_tabs.append((name,render_fields(fields))) %}
{% endfor %}
{% block app_content %}
<h1>{{title}}</h1>
{% if test %}
{% if test.success %}
<div class="alert alert-success" role="danger">
<h4>Sucess</h4>
</div>
{% else %}
<div class="alert alert-danger" role="danger">
{% for module,error in test.errors.items() %}
{% if error %}
<h4>{{module}}</h4>
{% if error is mapping %}
{% for key,value in error.items() %}
<p><b>{{key}}</b>: {{value}}</p>
{% endfor %}
{% else %}
<b>{{error}}</b>
{% endif %}
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endif %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger" role="danger">{{error}}</div>
{% endfor %}
{% endfor %}
<div class="row">
<div class="col">
<form method="post" class="form" enctype="multipart/form-data">
{{ form.csrf_token() }}
{{ make_tabs(config_tabs) }}
{{ custom_render_form_row([form.test, form.save],button_map={'test':'primary','save':'success'},col_map={'test':0,'primary':0},render_args={'form_type':'horizontal'})}}
</form>
{# render_form(form, form_type ="horizontal", button_map={'test':'primary','save':'success'}) #}
</div>
</div>
{% endblock %}