Added basic space selector, need to integrate it into the page

This commit is contained in:
Benjamyn Love 2023-03-14 17:59:36 +11:00
parent a1f97a09fb
commit 23c3aa97dd
5 changed files with 38 additions and 16 deletions

View File

@ -1,6 +1,7 @@
from flask import Blueprint, render_template
from flask_login import login_required, current_user
from .models import Quote
from .chatbot import chat as bot
main = Blueprint('main', __name__)
@ -24,5 +25,13 @@ def profile():
@main.route('/quotes')
@login_required
def quotes():
quotes = [q.quote for q in Quote.query.all()]
return render_template("quotes.html", quotes=quotes)
spaces = bot.spaces().list().execute()['spaces']
space_list = list()
for space in spaces:
if space.get('singleUserBotDm'):
continue
else:
space_list.append([space['name'].split('/')[1], space['displayName']])
quotes = [[q.quote, q.id] for q in Quote.query.all()]
return render_template("quotes.html", quotes=quotes, space_list=space_list)

View File

@ -75,6 +75,6 @@ $box-background-color: $nexi-grey;
$input-background-color: $nexi-darker-grey;
$input-color: $nexi-black;
$table-background-color: $nexi-black;
$table-striped-row-even-background-color: $nexi-lighter-black;
$table-color: $nexi-white;
// $table-background-color: $primary;
// $table-striped-row-even-background-color: $nexi-lighter-black;
// $table-color: $nexi-white;

View File

@ -3137,8 +3137,8 @@ div.icon-text {
background-position: -200% 0; } }
.table {
background-color: #181818;
color: #f8fafb; }
background-color: white;
color: #363636; }
.table td,
.table th {
border: 1px solid #D2D2D2;
@ -3330,7 +3330,7 @@ div.icon-text {
.table.is-narrow th {
padding: 0.25em 0.5em; }
.table.is-striped tbody tr:not(.is-selected):nth-child(even) {
background-color: #353535; }
background-color: #fafafa; }
.table-container {
-webkit-overflow-scrolling: touch;

View File

@ -36,6 +36,16 @@
<a href="{{ url_for('auth.logout') }}" class="navbar-item">
Logout
</a>
{% if space_list is defined %}
<div class="select is-primary" >
<select name="space" id="space">
{% for i in space_list %}
<option value="{{ i[0] }}">{{ i[1] }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{% endif %}
</div>
</div>

View File

@ -1,6 +1,12 @@
{% extends "base.html" %}
{% block content %}
<script>
function sendquote(id) {
let space="AAAAi8Ave9c";
alert("{{ url_for('chatbot.send_quote', space='AAAAi8Ave9c', _external=True) }}");
}
</script>
<div >
<h3 class="title">Quotes</h3>
<div >
@ -11,21 +17,18 @@
</div>
{% endif %}
{% endwith %}
<table class="table is-striped">
<table class="table">
{% for quote in quotes %}
<tr>
<td style="text-align: left">
{{ quote }}
<td class=" is-primary" style="text-align: left">
{{ quote[0] }}
</td>
<td class="is-primary"><button class="is-primary button" onclick='sendquote({{ quote[1] }})' type="submit">Send</button></td>
</tr>
{% endfor %}
</table>
<!-- <ul>
{% for quote in quotes %}
<li style="text-align: left">{{ quote }}</li>
{% endfor %}
</ul> -->
</div>
</div>
{% endblock %}