added UI for handing Reseller user, allows switch, requires EagleEyev3 == 0.0.10

main
Mark Cotton 2023-08-10 13:05:23 -06:00
parent 132addb162
commit 939553b4a5
4 changed files with 74 additions and 2 deletions

43
app.py
View File

@ -91,10 +91,13 @@ def index():
een.get_list_of_cameras() een.get_list_of_cameras()
een.get_list_of_accounts()
values = { values = {
"current_user": een.current_user, "current_user": een.current_user,
"cameras": een.cameras "cameras": een.cameras,
"accounts": een.accounts,
"active_account": een.active_account
} }
return render_template('index.html', template_values=values) return render_template('index.html', template_values=values)
@ -147,6 +150,44 @@ def cameras():
return render_template('cameras_partial.html', template_values=values) return render_template('cameras_partial.html', template_values=values)
@app.route('/accounts')
def accounts():
if 'een' in session:
een = session['een']
else:
een = EagleEyev3(config)
een.get_list_of_accounts()
values = {
"current_user": een.current_user,
"accounts": een.accounts,
"active_account": een.active_account
}
return render_template('accounts_partial.html', template_values=values)
@app.route('/switch_account')
def switch_account():
# This is getting the ?account= querystring value from the HTTP request.
account = request.args.get('account')
if 'een' in session:
een = session['een']
else:
een = EagleEyev3(config)
if (account):
# use the include code parameter to complete login process
een.login_from_reseller(target_account_id=account)
return redirect(url_for('index'))
@app.route('/camera/<esn>/preview_image') @app.route('/camera/<esn>/preview_image')
def camera__preivew_image(esn=None): def camera__preivew_image(esn=None):
if 'een' in session: if 'een' in session:

View File

@ -14,7 +14,7 @@ Werkzeug==2.3.6
gunicorn==20.1.0 gunicorn==20.1.0
cachelib==0.10.2 cachelib==0.10.2
Flask-Session==0.5.0 Flask-Session==0.5.0
EagleEyev3>=0.0.8 EagleEyev3>=0.0.10
tqdm tqdm
pandas pandas
numpy numpy

View File

@ -0,0 +1,27 @@
<div class="row">
<div class="col-4 offset-5">
<h2>
{% for account in template_values['accounts'] %}
{% if account.id == template_values['active_account'] %}
{{ account.name }}
{% endif %}
{% endfor %}
</h2>
</div>
<div class="col-3">
<label >Choose Account:</label>
<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
{% for account in template_values['accounts'] %}
<option value="/switch_account?account={{ account.id }}"
{% if account.id == template_values['active_account'] %}
selected
{% endif %}
title="{{ account.id }}">
{{ account.name }}
</option>
{% endfor %}
</select>
</div>
</div>

View File

@ -126,6 +126,10 @@
{% block main %} {% block main %}
{% if template_values['accounts']|count > 1 %}
{% include 'accounts_partial.html' %}
{% endif %}
<div class="progress" style="height: 3px; background-color: white;"> <div class="progress" style="height: 3px; background-color: white;">
<div class="indeterminate" style="background-color: red;"></div> <div class="indeterminate" style="background-color: red;"></div>
</div> </div>