Skip to content
Snippets Groups Projects
Commit 14b9a2bf authored by kaiyou's avatar kaiyou
Browse files

Add Synapse room display

parent 69aada79
No related branches found
No related tags found
1 merge request!20Add 'remember me' button
Pipeline #1874 passed
...@@ -47,10 +47,6 @@ class SynapseApplication(base.SAMLApplication): ...@@ -47,10 +47,6 @@ class SynapseApplication(base.SAMLApplication):
admin_token = fields.PasswordField(_("Synapse administrator token")) admin_token = fields.PasswordField(_("Synapse administrator token"))
submit = fields.SubmitField(_('Submit')) submit = fields.SubmitField(_('Submit'))
class SearchForm(flask_wtf.FlaskForm):
keyword = fields.StringField(_("Search keyword"))
submit = fields.SubmitField(_("Search"))
def populate_service(self, form, service): def populate_service(self, form, service):
service.config.update({ service.config.update({
"application_uri": form.application_uri.data, "application_uri": form.application_uri.data,
...@@ -81,14 +77,39 @@ class SynapseApplication(base.SAMLApplication): ...@@ -81,14 +77,39 @@ class SynapseApplication(base.SAMLApplication):
""" Search by keyword among server rooms, including non-published """ Search by keyword among server rooms, including non-published
rooms rooms
""" """
form = SynapseApplication.SearchForm() class SearchForm(flask_wtf.FlaskForm):
keyword = fields.StringField(_("Search keyword"))
submit = fields.SubmitField(_("Search"))
form = SearchForm()
if form.validate_on_submit(): if form.validate_on_submit():
client = self.get_axon(service) client = self.get_axon(service)
results = client.list_rooms(False, search_term=form.keyword.data) results = client.list_rooms(False, search_term=form.keyword.data)
else: else:
results = [] results = []
return flask.render_template( return flask.render_template(
"application_synapse/rooms.html", form=form, results=results) "application_synapse/rooms.html", form=form, results=results,
service=service
)
@base.action("Get room details")
def get_room(self, service):
""" Display some room details, including members
"""
class RoomForm(flask_wtf.FlaskForm):
roomid = fields.StringField(_("RoomID"))
submit = fields.SubmitField(_("Display"))
form = RoomForm()
roomid = flask.request.values.get("roomid")
if roomid:
client = self.get_axon(service)
room = client.get_room(roomid)
members = client.get_room_members(roomid)
else:
room = members = None
return flask.render_template(
"application_synapse/room.html", form=form, room=room,
members=members
)
@register("writefreely") @register("writefreely")
......
{% import "macros.html" as macros %}
{{ macros.form(form) }}
{% if room.get("room_id") %}
<div class="row">
<div class="col-md-6">
<div class="table-responsive no-padding">
<table class="table table-hover">
<tr>
<th>{% trans %}Member{% endtrans %}</th>
</tr>
{% for member in members["members"] %}
<tr>
<td>{{ member }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="col-md-6">
<dl>
{% for name, value in room.items() %}
<dt>{{ name }}</dt>
<dd>{{ value }}</dd>
{% endfor %}
</dl>
</div>
</div>
</div>
</div>
{% endif %}
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</tr> </tr>
{% for room in results["rooms"] %} {% for room in results["rooms"] %}
<tr> <tr>
<td>{{ room["room_id"] }}</td> <td><a href="{{ url_for("service.action", service_uuid=service.uuid, action="get_room", roomid=room["room_id"]) }}">{{ room["room_id"] }}</a></td>
<td>{{ room["canonical_alias"] }}</td> <td>{{ room["canonical_alias"] }}</td>
<td>{{ room["name"] }}</td> <td>{{ room["name"] }}</td>
<td>{{ room["joined_members"] }} ({{ room["joined_local_members"] }})</td> <td>{{ room["joined_members"] }} ({{ room["joined_local_members"] }})</td>
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<td> <td>
<a href="{{ url_for("profile.list_for_service", service_uuid=service.uuid)}}">Profiles</a>&nbsp; <a href="{{ url_for("profile.list_for_service", service_uuid=service.uuid)}}">Profiles</a>&nbsp;
<a href="{{ url_for(".edit", service_uuid=service.uuid)}}">Edit</a>&nbsp; <a href="{{ url_for(".edit", service_uuid=service.uuid)}}">Edit</a>&nbsp;
{% for action, (label, profile, quick) in app.actions.items() %} {% for action, (label, profile, quick, function) in app.actions.items() %}
{% if quick and not profile %} {% if quick and not profile %}
<a href="{{ url_for(".action", service_uuid=service.uuid, action=action) }}">{{ label }}</a>&nbsp; <a href="{{ url_for(".action", service_uuid=service.uuid, action=action) }}">{{ label }}</a>&nbsp;
{% endif %} {% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment