107 lines
4.3 KiB
Django/Jinja
107 lines
4.3 KiB
Django/Jinja
{% extends 'base.html.j2' %}
|
|
|
|
{% block title %}Manage Namespace{% endblock %}
|
|
|
|
{% block content %}
|
|
<h1>Manage Namespace: {{ namespace.name }}</h1>
|
|
<form method="POST" action="{{ request.route_url('update_namespace', namespace_short_id=namespace.short_id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ request.session.get_csrf_token() }}">
|
|
<label>
|
|
<input type="checkbox" name="is_public" {% if namespace.is_public %}checked{% endif %}>
|
|
Make Namespace Public
|
|
</label><br><br>
|
|
|
|
<button type="submit">Update Namespace</button>
|
|
</form>
|
|
|
|
<!-- Only owners can see the user management section -->
|
|
{% if request.user_namespace_role == 'owner' %}
|
|
|
|
<h2>Users in Namespace</h2>
|
|
{% for member in users %}
|
|
<div>
|
|
<span>
|
|
{{ member.user.username }}
|
|
{% if request.user.id != member.user.id %}
|
|
<!-- Form to remove user -->
|
|
<form action="{{ request.route_url('remove_user', namespace_short_id=namespace.short_id) }}" method="post" class="inline-form">
|
|
<input type="hidden" name="csrf_token" value="{{ request.session.get_csrf_token() }}">
|
|
<input type="hidden" name="user_id" value="{{ member.user.id }}">
|
|
<button type="submit" class="link-button">Remove</button>
|
|
</form>
|
|
{% endif %}
|
|
</span>
|
|
<span>
|
|
{% if request.user.id != member.user.id %}
|
|
<!-- Form to change role -->
|
|
<form action="{{ request.route_url('change_member_role', namespace_short_id=namespace.short_id) }}" method="post" class="inline-form">
|
|
<input type="hidden" name="csrf_token" value="{{ request.session.get_csrf_token() }}">
|
|
<input type="hidden" name="user_id" value="{{ member.user.id }}">
|
|
<select name="role">
|
|
<option value="owner" {% if member.role == 'owner' %}selected{% endif %}>Owner</option>
|
|
<option value="editor" {% if member.role == 'editor' %}selected{% endif %}>Editor</option>
|
|
<option value="reader" {% if member.role == 'reader' %}selected{% endif %}>Reader</option>
|
|
</select>
|
|
<button type="submit" class="link-button">Change Role</button>
|
|
</form>
|
|
{% else %}
|
|
{{ member.role }}
|
|
{% endif %}
|
|
</span>
|
|
</div>
|
|
<hr />
|
|
{% endfor %}
|
|
|
|
<h2>Invite User</h2>
|
|
<form method="POST" action="{{ request.route_url('invite_user', namespace_short_id=namespace.short_id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ request.session.get_csrf_token() }}">
|
|
<label for="email">User Email:</label>
|
|
<input type="email" name="email" required><br><br>
|
|
|
|
<label for="role">Role:</label>
|
|
<select name="role" required>
|
|
<option value="owner">Owner</option>
|
|
<option value="editor">Editor</option>
|
|
<option value="reader">Reader</option>
|
|
</select><br><br>
|
|
|
|
<button type="submit">Invite User</button>
|
|
</form>
|
|
{% endif %}
|
|
<!-- Only owners can see the user management section -->
|
|
|
|
<h2>Agents</h2>
|
|
{% if agents %}
|
|
<ul>
|
|
{% for agent in agents %}
|
|
<li>
|
|
{{ agent.name }} ({{ agent.role|capitalize }})
|
|
<form method="POST" action="{{ request.route_url('revoke_agent', namespace_short_id=namespace.short_id) }}" class="inline-form">
|
|
<input type="hidden" name="csrf_token" value="{{ request.session.get_csrf_token() }}">
|
|
<input type="hidden" name="agent_id" value="{{ agent.id }}">
|
|
<button type="submit" class="link-button" onclick="return confirm('Revoke access for {{ agent.name }}?')">Revoke Access</button>
|
|
</form>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
<p>No agents found.</p>
|
|
{% endif %}
|
|
|
|
<h2>Generate JWT for Agent</h2>
|
|
<form method="POST" action="{{ request.route_url('generate_agent_jwt', namespace_short_id=namespace.short_id) }}">
|
|
<input type="hidden" name="csrf_token" value="{{ request.session.get_csrf_token() }}">
|
|
<label for="agent_name">Agent Name:</label>
|
|
<input type="text" name="agent_name" required><br><br>
|
|
|
|
<label for="agent_role">Agent Role:</label>
|
|
<select name="agent_role" required>
|
|
<option value="owner">Owner</option>
|
|
<option value="editor" selected>Editor</option>
|
|
<option value="reader">Reader</option>
|
|
</select><br><br>
|
|
|
|
<button type="submit">Generate JWT</button>
|
|
</form>
|
|
|
|
{% endblock %}
|