mirror of
https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
synced 2024-11-22 22:38:48 +00:00
improved dashboard config view
This commit is contained in:
parent
ffcf0d084e
commit
a730a3ac05
41
app/main.py
41
app/main.py
@ -76,6 +76,28 @@ def __get_token(request: Request) -> dict:
|
|||||||
return jwt.decode(token=token, key=jwt_decode_key, algorithms=ALGORITHMS.RS256, options={'verify_aud': False})
|
return jwt.decode(token=token, key=jwt_decode_key, algorithms=ALGORITHMS.RS256, options={'verify_aud': False})
|
||||||
|
|
||||||
|
|
||||||
|
def __json_config() -> dict:
|
||||||
|
return {
|
||||||
|
'VERSION': str(VERSION),
|
||||||
|
'COMMIT': str(COMMIT),
|
||||||
|
'DEBUG': str(DEBUG),
|
||||||
|
'DLS_URL': str(DLS_URL),
|
||||||
|
'DLS_PORT': str(DLS_PORT),
|
||||||
|
'SITE_KEY_XID': str(SITE_KEY_XID),
|
||||||
|
'INSTANCE_REF': str(INSTANCE_REF),
|
||||||
|
'ALLOTMENT_REF': [str(ALLOTMENT_REF)],
|
||||||
|
'TOKEN_EXPIRE_DELTA': str(TOKEN_EXPIRE_DELTA),
|
||||||
|
'LEASE_EXPIRE_DELTA': str(LEASE_EXPIRE_DELTA),
|
||||||
|
'LEASE_RENEWAL_PERIOD': str(LEASE_RENEWAL_PERIOD),
|
||||||
|
'CORS_ORIGINS': str(CORS_ORIGINS),
|
||||||
|
'TZ': str(TZ),
|
||||||
|
# static / calculated
|
||||||
|
'LEASE_RENEWAL_DELTA': str(LEASE_RENEWAL_DELTA),
|
||||||
|
'LEASE_CALCULATED_RENEWAL': str(Lease.calculate_renewal(LEASE_RENEWAL_PERIOD, LEASE_RENEWAL_DELTA)),
|
||||||
|
'CLIENT_TOKEN_EXPIRE_DELTA': str(CLIENT_TOKEN_EXPIRE_DELTA),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@app.get('/', summary='* Index')
|
@app.get('/', summary='* Index')
|
||||||
async def index():
|
async def index():
|
||||||
return RedirectResponse('/-/')
|
return RedirectResponse('/-/')
|
||||||
@ -93,21 +115,7 @@ async def _health():
|
|||||||
|
|
||||||
@app.get('/-/config', summary='* Config', description='returns environment variables.')
|
@app.get('/-/config', summary='* Config', description='returns environment variables.')
|
||||||
async def _config():
|
async def _config():
|
||||||
return JSONr({
|
return JSONr(__json_config())
|
||||||
'VERSION': str(VERSION),
|
|
||||||
'COMMIT': str(COMMIT),
|
|
||||||
'DEBUG': str(DEBUG),
|
|
||||||
'DLS_URL': str(DLS_URL),
|
|
||||||
'DLS_PORT': str(DLS_PORT),
|
|
||||||
'SITE_KEY_XID': str(SITE_KEY_XID),
|
|
||||||
'INSTANCE_REF': str(INSTANCE_REF),
|
|
||||||
'ALLOTMENT_REF': [str(ALLOTMENT_REF)],
|
|
||||||
'TOKEN_EXPIRE_DELTA': str(TOKEN_EXPIRE_DELTA),
|
|
||||||
'LEASE_EXPIRE_DELTA': str(LEASE_EXPIRE_DELTA),
|
|
||||||
'LEASE_RENEWAL_PERIOD': str(LEASE_RENEWAL_PERIOD),
|
|
||||||
'CORS_ORIGINS': str(CORS_ORIGINS),
|
|
||||||
'TZ': str(TZ),
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@app.get('/-/readme', summary='* Readme')
|
@app.get('/-/readme', summary='* Readme')
|
||||||
@ -126,7 +134,8 @@ async def _manage(request: Request):
|
|||||||
|
|
||||||
@app.get('/-/dashboard', summary='* Dashboard')
|
@app.get('/-/dashboard', summary='* Dashboard')
|
||||||
async def _dashboard(request: Request):
|
async def _dashboard(request: Request):
|
||||||
return templates.TemplateResponse(name='views/dashboard.html', context={'request': request, 'VERSION': VERSION})
|
context = {'request': request, 'VERSION': VERSION, 'CONFIG': __json_config()}
|
||||||
|
return templates.TemplateResponse(name='views/dashboard.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
@app.get('/-/dashboard/origins', summary='* Dashboard - Origins')
|
@app.get('/-/dashboard/origins', summary='* Dashboard - Origins')
|
||||||
|
@ -29,8 +29,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card mb-4">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Configuration</h5>
|
||||||
|
<h6 class="card-subtitle mb-2 text-body-secondary">
|
||||||
|
Using timezone: {{ CONFIG.TZ }}. Make sure this is correct and match your clients!
|
||||||
|
</h6>
|
||||||
|
<p class="card-text">
|
||||||
|
Your clients renew their license every {{ CONFIG.LEASE_CALCULATED_RENEWAL }}.<br/>
|
||||||
|
If the renewal fails, the license is {{ CONFIG.LEASE_RENEWAL_DELTA }} valid.<br/>
|
||||||
|
<br/>
|
||||||
|
Your client-token file (.tok) is valid for {{ CONFIG.CLIENT_TOKEN_EXPIRE_DELTA }}.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
<pre id="config"></pre>
|
<pre id="config"></pre>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
Loading…
Reference in New Issue
Block a user