mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 16:48:58 +00:00
list bot accounts on front page
This commit is contained in:
parent
025b56e1b6
commit
c060f8d7ca
2 changed files with 20 additions and 5 deletions
|
@ -17,16 +17,18 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container" style="min-height: 300px;">
|
<div class="container" style="min-height: 300px;">
|
||||||
|
{% for bot in bots %}
|
||||||
<div class="row light">
|
<div class="row light">
|
||||||
<div class="panel-icon online"></div>
|
<div class="panel-icon {% if bot['enabled'] %}online{% else %}offline{% endif %}"></div>
|
||||||
<div class="panel-text">
|
<div class="panel-text">
|
||||||
<div class="panel-name">My bot!!</div>
|
<div class="panel-name">{{ bot['handle'] }}</div>
|
||||||
<div class="panel-status">Online, learning from 3 accounts, 12345 posts in database</div>
|
<div class="panel-status">{% if bot['enabled'] %}Online{% else %}Offline{% endif %}, learning from {{ bot_users[bot['id']] }} accounts</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-actions">
|
<div class="panel-actions">
|
||||||
<a class="button btn-secondary" href="/bot/toggle/insert id here" title="Turn on/off"><i class="fas fa-power-off"></i></a><a class="button btn-secondary" href="/bot/edit/insert id here" title="Configure"><i class="fas fa-cog"></i></a><a class="button btn-secondary" href="/bot/accounts/insert id here" title="Accounts learned from"><i class="fas fa-users"></i></a><a class="button btn-secondary" href="/bot/blacklist/insert id here" title="Banned words"><i class="fas fa-strikethrough"></i></a><a class="button btn-secondary" href="/bot/chat/insert id here" title="Chat"><i class="fas fa-comment"></i></a><a class="button btn-dangerous" href="/bot/delete/insert id here" title="Delete"><i class="fas fa-trash"></i></a>
|
<a class="button btn-secondary" href="/bot/toggle/{{ bot['id'] }}" title="Turn on/off"><i class="fas fa-power-off"></i></a><a class="button btn-secondary" href="/bot/edit/{{ bot['id'] }}" title="Configure"><i class="fas fa-cog"></i></a><a class="button btn-secondary" href="/bot/accounts/{{ bot['id'] }}" title="Accounts learned from"><i class="fas fa-users"></i></a><a class="button btn-secondary" href="/bot/blacklist/{{ bot['id'] }}" title="Banned words"><i class="fas fa-strikethrough"></i></a><a class="button btn-secondary" href="/bot/chat/{{ bot['id'] }}" title="Chat"><i class="fas fa-comment"></i></a><a class="button btn-dangerous" href="/bot/delete/{{ bot['id'] }}" title="Delete"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
15
webui.py
15
webui.py
|
@ -28,11 +28,24 @@ def home():
|
||||||
c.execute("SELECT COUNT(*) FROM `bots` WHERE user_id = %s", (session['user_id'],))
|
c.execute("SELECT COUNT(*) FROM `bots` WHERE user_id = %s", (session['user_id'],))
|
||||||
bot_count = c.fetchone()[0]
|
bot_count = c.fetchone()[0]
|
||||||
active_count = None
|
active_count = None
|
||||||
|
bots = None
|
||||||
|
bot_users = None
|
||||||
|
|
||||||
if bot_count > 0:
|
if bot_count > 0:
|
||||||
c.execute("SELECT COUNT(*) FROM `bots` WHERE user_id = %s AND enabled = TRUE", (session['user_id'],))
|
c.execute("SELECT COUNT(*) FROM `bots` WHERE user_id = %s AND enabled = TRUE", (session['user_id'],))
|
||||||
active_count = c.fetchone()[0]
|
active_count = c.fetchone()[0]
|
||||||
|
dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
|
||||||
|
dc.execute("SELECT * FROM `bots` WHERE user_id = %s", (session['user_id'],))
|
||||||
|
bots = dc.fetchall()
|
||||||
|
dc.close()
|
||||||
|
bot_users = {}
|
||||||
|
|
||||||
|
for bot in bots:
|
||||||
|
c.execute("SELECT COUNT(*) FROM `bot_learned_accounts` WHERE bot_id = %s", (bot['id'],))
|
||||||
|
bot_users[bot['id']] = c.fetchone()[0]
|
||||||
|
|
||||||
c.close()
|
c.close()
|
||||||
return render_template("home.html", bot_count = bot_count, active_count = active_count)
|
return render_template("home.html", bot_count = bot_count, active_count = active_count, bots = bots, bot_users = bot_users)
|
||||||
else:
|
else:
|
||||||
return render_template("front_page.html")
|
return render_template("front_page.html")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue