diff options
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/templates/actions/room_details.html | 18 | ||||
-rw-r--r-- | ogcp/templates/scopes.html | 2 | ||||
-rw-r--r-- | ogcp/views.py | 32 |
3 files changed, 52 insertions, 0 deletions
diff --git a/ogcp/templates/actions/room_details.html b/ogcp/templates/actions/room_details.html new file mode 100644 index 0000000..0c9d59f --- /dev/null +++ b/ogcp/templates/actions/room_details.html @@ -0,0 +1,18 @@ +{% extends 'scopes.html' %} +{% import "bootstrap/wtf.html" as wtf %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_room %} active {% endblock %} +{% block nav_room_details %} active {% endblock %} +{% block content %} + +<h1 class="m-5">{{_('Room details')}}</h1> + +{{ wtf.quick_form(form, + method='post', + button_map={'submit': 'primary'}, + extra_classes="mx-5") }} + +{% endblock %} diff --git a/ogcp/templates/scopes.html b/ogcp/templates/scopes.html index 04285be..725454b 100644 --- a/ogcp/templates/scopes.html +++ b/ogcp/templates/scopes.html @@ -47,6 +47,8 @@ form="scopesForm" formaction="{{ url_for('action_room_update') }}" formmethod="get"> <input class="btn btn-light dropdown-item {% block nav_room_delete %}{% endblock %}" type="submit" value="{{ _('Delete room') }}" form="scopesForm" formaction="{{ url_for('action_room_delete') }}" formmethod="get"> + <input class="btn btn-light dropdown-item {% block nav_room_info %}{% endblock %}" type="submit" value="{{ _('Room details') }}" + form="scopesForm" formaction="{{ url_for('action_room_info') }}" formmethod="get"> </div> </div> <div class="dropdown btn"> diff --git a/ogcp/views.py b/ogcp/views.py index 9e1a028..d022d04 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -2410,6 +2410,38 @@ def action_room_update(): return render_template('actions/room_update.html', form=form, scopes=scopes) +@app.route('/action/room/info', methods=['GET']) +@login_required +def action_room_info(): + form = RoomForm(request.form) + params = request.args.to_dict() + room_id = params.get('scope-room') + if not room_id: + flash(_('Please, select a room to update'), category='error') + return redirect(url_for('scopes')) + server = get_server_from_ip_port(params['scope-server']) + + del form.center + + payload = {"id": int(room_id)} + r = server.get('/room/info', payload) + if not r: + return ogserver_down('scopes') + if r.status_code != requests.codes.ok: + return ogserver_error('scopes') + form.name.data = r.json()['name'] + form.name.render_kw = {'readonly': True} + form.gateway.data = r.json()['gateway'] + form.gateway.render_kw = {'readonly': True} + form.netmask.data = r.json()['netmask'] + form.netmask.render_kw = {'readonly': True} + + form.submit.render_kw = {'readonly': True, 'hidden': True} + + scopes, clients = get_scopes() + return render_template('actions/room_details.html', form=form, + scopes=scopes) + @app.route('/action/room/delete', methods=['GET', 'POST']) @login_required def action_room_delete(): |