room restructure part 1
This commit is contained in:
85
static/css/room_members.css
Normal file
85
static/css/room_members.css
Normal file
@@ -0,0 +1,85 @@
|
||||
.badge.bg-primary.rounded-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.04);
|
||||
font-size: 1em;
|
||||
height: 32px;
|
||||
border-radius: 5px;
|
||||
padding: 0 18px;
|
||||
}
|
||||
|
||||
.btn-sm.member-action {
|
||||
min-width: 70px;
|
||||
height: 32px;
|
||||
font-size: 1em;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.form-check-inline {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.member-row {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.badge.creator-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
font-size: 1em;
|
||||
height: 32px;
|
||||
border-radius: 5px;
|
||||
padding: 0 18px;
|
||||
background-color: rgba(22,118,123,0.08);
|
||||
color: #16767b;
|
||||
border: 1px solid #16767b22;
|
||||
}
|
||||
|
||||
.btn-save-member {
|
||||
background-color: #16767b;
|
||||
color: #fff;
|
||||
border: 1px solid #16767b;
|
||||
min-width: 70px;
|
||||
height: 32px;
|
||||
font-size: 1em;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
transition: background 0.2s, border 0.2s;
|
||||
}
|
||||
|
||||
.btn-save-member:hover {
|
||||
background-color: #1a8a90;
|
||||
border-color: #1a8a90;
|
||||
}
|
||||
|
||||
.btn-remove-member {
|
||||
background-color: rgba(239,68,68,0.1);
|
||||
color: #b91c1c;
|
||||
border: 1px solid #b91c1c22;
|
||||
min-width: 70px;
|
||||
height: 32px;
|
||||
font-size: 1em;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
.btn-remove-member:hover {
|
||||
background-color: #b91c1c;
|
||||
color: #fff;
|
||||
}
|
||||
33
static/css/rooms.css
Normal file
33
static/css/rooms.css
Normal file
@@ -0,0 +1,33 @@
|
||||
.hover-shadow {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.hover-shadow:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 5px;
|
||||
font-weight: 500;
|
||||
padding: 0.5rem 1rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.btn i {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
15
static/js/room_members.js
Normal file
15
static/js/room_members.js
Normal file
@@ -0,0 +1,15 @@
|
||||
$(document).ready(function() {
|
||||
$('.select2').select2({
|
||||
theme: 'bootstrap-5',
|
||||
width: '100%',
|
||||
placeholder: 'Search for a user...',
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
// Auto-submit permission form on checkbox change
|
||||
document.querySelectorAll('.auto-save-perms-form input[type="checkbox"]').forEach(function(checkbox) {
|
||||
checkbox.addEventListener('change', function() {
|
||||
this.closest('form').submit();
|
||||
});
|
||||
});
|
||||
});
|
||||
26
static/js/rooms.js
Normal file
26
static/js/rooms.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// Debounce function
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func.apply(this, args), wait);
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('roomSearchInput');
|
||||
const form = document.getElementById('roomFilterForm');
|
||||
if (searchInput && form) {
|
||||
searchInput.addEventListener('input', debounce(function() {
|
||||
form.submit();
|
||||
}, 300));
|
||||
}
|
||||
// Clear button logic
|
||||
const clearBtn = document.getElementById('clearRoomsFilter');
|
||||
if (clearBtn && searchInput) {
|
||||
clearBtn.addEventListener('click', function() {
|
||||
searchInput.value = '';
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
24
templates/components/add_member_form.html
Normal file
24
templates/components/add_member_form.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{% macro add_member_form(room, available_users) %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="card-title mb-0">Add New Member</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ url_for('rooms.add_member', room_id=room.id) }}" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<div class="mb-3">
|
||||
<label for="user_id" class="form-label">Select User</label>
|
||||
<select class="form-select select2" id="user_id" name="user_id" required>
|
||||
<option value="">Search for a user...</option>
|
||||
{% for user in available_users %}
|
||||
<option value="{{ user.id }}">{{ user.username }} {{ user.last_name }} ({{ user.email }})</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<i class="fas fa-user-plus me-2"></i>Add Member
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
34
templates/components/delete_room_modal.html
Normal file
34
templates/components/delete_room_modal.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% macro delete_room_modal(room) %}
|
||||
<div class="modal fade" id="deleteRoomModal{{ room.id }}" tabindex="-1" aria-labelledby="deleteRoomModalLabel{{ room.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteRoomModalLabel{{ room.id }}">Move to Trash</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex align-items-center gap-3 mb-3">
|
||||
<i class="fas fa-trash text-danger" style="font-size: 2rem;"></i>
|
||||
<div>
|
||||
<h6 class="mb-1">Move to Trash</h6>
|
||||
<p class="text-muted mb-0" id="deleteFileName{{ room.id }}">{{ room.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<i class="fas fa-info-circle me-2"></i>
|
||||
This item will be moved to trash. You can restore it from the trash page within 30 days.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<form action="{{ url_for('rooms.delete_room', room_id=room.id) }}" method="POST" class="d-inline">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<button type="submit" class="btn btn-danger">
|
||||
<i class="fas fa-trash me-2"></i>Move to Trash
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
76
templates/components/member_list.html
Normal file
76
templates/components/member_list.html
Normal file
@@ -0,0 +1,76 @@
|
||||
{% macro member_list(room) %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="card-title mb-0">Current Members</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if room.member_permissions %}
|
||||
<div class="list-group">
|
||||
{% for perm in room.member_permissions %}
|
||||
{% set member = perm.user %}
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center member-row">
|
||||
<div class="d-flex align-items-center">
|
||||
<img src="{{ url_for('profile_pic', filename=member.profile_picture) if member.profile_picture else url_for('static', filename='default-avatar.png') }}"
|
||||
alt="{{ member.username }}"
|
||||
class="rounded-circle me-3"
|
||||
style="width: 40px; height: 40px; object-fit: cover;">
|
||||
<div>
|
||||
<h6 class="mb-0">{{ member.username }} {{ member.last_name }}</h6>
|
||||
<small class="text-muted">{{ member.email }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
{% if member.id != room.created_by %}
|
||||
<form action="{{ url_for('rooms.update_member_permissions', room_id=room.id, user_id=member.id) }}" method="POST" class="d-flex align-items-center gap-2 auto-save-perms-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_view" id="can_view_{{ member.id }}" checked disabled>
|
||||
<input type="hidden" name="can_view" value="1">
|
||||
<label class="form-check-label" for="can_view_{{ member.id }}" title="View permission is always required"><i class="fas fa-eye"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_download" id="can_download_{{ member.id }}" {% if perm.can_download %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_download_{{ member.id }}" title="Can Download Files"><i class="fas fa-download"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_upload" id="can_upload_{{ member.id }}" {% if perm.can_upload %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_upload_{{ member.id }}" title="Can Upload Files"><i class="fas fa-upload"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_delete" id="can_delete_{{ member.id }}" {% if perm.can_delete %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_delete_{{ member.id }}" title="Can Delete Files"><i class="fas fa-trash"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_rename" id="can_rename_{{ member.id }}" {% if perm.can_rename %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_rename_{{ member.id }}" title="Can Rename Files"><i class="fas fa-i-cursor"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_move" id="can_move_{{ member.id }}" {% if perm.can_move %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_move_{{ member.id }}" title="Can Move Files"><i class="fas fa-arrows-alt"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_share" id="can_share_{{ member.id }}" {% if perm.can_share %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_share_{{ member.id }}" title="Can Share Files"><i class="fas fa-share-alt"></i></label>
|
||||
</div>
|
||||
</form>
|
||||
<form action="{{ url_for('rooms.remove_member', room_id=room.id, user_id=member.id) }}" method="POST" class="d-inline ms-2">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<button type="submit" class="btn btn-remove-member px-3 d-flex align-items-center gap-1">
|
||||
<i class="fas fa-user-minus"></i> Remove
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<span class="badge creator-badge px-3 py-2 d-flex align-items-center gap-1" style="height: 32px;">
|
||||
<i class="fas fa-user"></i> Creator
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted mb-0">No members in this room yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
60
templates/components/room_card.html
Normal file
60
templates/components/room_card.html
Normal file
@@ -0,0 +1,60 @@
|
||||
{% macro room_card(room, current_user) %}
|
||||
<div class="col">
|
||||
<div class="card h-100 shadow-sm hover-shadow">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<h5 class="card-title mb-0">{{ room.name }}</h5>
|
||||
<div class="text-muted small mt-1">Created on {{ room.created_at.strftime('%b %d, %Y') }}</div>
|
||||
</div>
|
||||
<span class="badge bg-light text-dark">
|
||||
<i class="fas fa-users"></i> {{ room.member_permissions|length }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="card-text text-muted">{{ room.description or 'No description' }}</p>
|
||||
<div class="d-flex align-items-center mt-3">
|
||||
<img src="{{ url_for('profile_pic', filename=room.creator.profile_picture) if room.creator.profile_picture else url_for('static', filename='default-avatar.png') }}"
|
||||
alt="Creator"
|
||||
class="rounded-circle me-2"
|
||||
style="width: 32px; height: 32px; object-fit: cover;">
|
||||
<div>
|
||||
<small class="text-muted">Created by</small>
|
||||
<div class="fw-medium">{{ room.creator.username }} {{ room.creator.last_name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent border-top-0">
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{{ url_for('rooms.room', room_id=room.id) }}" class="btn btn-primary flex-grow-1">
|
||||
<i class="fas fa-door-open me-2"></i>Open Room
|
||||
</a>
|
||||
{% if current_user.is_admin %}
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="roomActions{{ room.id }}" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="roomActions{{ room.id }}">
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ url_for('rooms.edit_room', room_id=room.id) }}">
|
||||
<i class="fas fa-edit me-2"></i>Edit Room
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ url_for('rooms.room_members', room_id=room.id) }}">
|
||||
<i class="fas fa-users me-2"></i>Manage Members
|
||||
</a>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<button type="button" class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#deleteRoomModal{{ room.id }}">
|
||||
<i class="fas fa-trash me-2"></i>Delete Room
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
13
templates/components/room_search.html
Normal file
13
templates/components/room_search.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% macro room_search(search) %}
|
||||
<div class="bg-white rounded-lg shadow-sm p-4 mb-4">
|
||||
<form method="GET" class="d-flex align-items-center w-100 justify-content-between" id="roomFilterForm" style="gap: 1rem;">
|
||||
<input type="text" name="search" placeholder="Search rooms..." value="{{ search }}" class="form-control flex-grow-1" id="roomSearchInput" autocomplete="off" style="min-width: 0;" />
|
||||
<button type="button" id="clearRoomsFilter" class="px-4 py-2 rounded-lg text-white font-medium transition-colors duration-200 ms-2 flex-shrink-0"
|
||||
style="background-color: #16767b; border: 1px solid #16767b;"
|
||||
onmouseover="this.style.backgroundColor='#1a8a90'"
|
||||
onmouseout="this.style.backgroundColor='#16767b'">
|
||||
Clear
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@@ -5,85 +5,7 @@
|
||||
{% block extra_css %}
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
.badge.bg-primary.rounded-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.04);
|
||||
font-size: 1em;
|
||||
height: 32px;
|
||||
border-radius: 5px;
|
||||
padding: 0 18px;
|
||||
}
|
||||
.btn-sm.member-action {
|
||||
min-width: 70px;
|
||||
height: 32px;
|
||||
font-size: 1em;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.form-check-inline {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.member-row {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.badge.creator-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
font-size: 1em;
|
||||
height: 32px;
|
||||
border-radius: 5px;
|
||||
padding: 0 18px;
|
||||
background-color: rgba(22,118,123,0.08);
|
||||
color: #16767b;
|
||||
border: 1px solid #16767b22;
|
||||
}
|
||||
.btn-save-member {
|
||||
background-color: #16767b;
|
||||
color: #fff;
|
||||
border: 1px solid #16767b;
|
||||
min-width: 70px;
|
||||
height: 32px;
|
||||
font-size: 1em;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
transition: background 0.2s, border 0.2s;
|
||||
}
|
||||
.btn-save-member:hover {
|
||||
background-color: #1a8a90;
|
||||
border-color: #1a8a90;
|
||||
}
|
||||
.btn-remove-member {
|
||||
background-color: rgba(239,68,68,0.1);
|
||||
color: #b91c1c;
|
||||
border: 1px solid #b91c1c22;
|
||||
min-width: 70px;
|
||||
height: 32px;
|
||||
font-size: 1em;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
.btn-remove-member:hover {
|
||||
background-color: #b91c1c;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
<link href="{{ url_for('static', filename='css/room_members.css') }}" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
@@ -97,105 +19,13 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="card-title mb-0">Current Members</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if room.member_permissions %}
|
||||
<div class="list-group">
|
||||
{% for perm in room.member_permissions %}
|
||||
{% set member = perm.user %}
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center member-row">
|
||||
<div class="d-flex align-items-center">
|
||||
<img src="{{ url_for('profile_pic', filename=member.profile_picture) if member.profile_picture else url_for('static', filename='default-avatar.png') }}"
|
||||
alt="{{ member.username }}"
|
||||
class="rounded-circle me-3"
|
||||
style="width: 40px; height: 40px; object-fit: cover;">
|
||||
<div>
|
||||
<h6 class="mb-0">{{ member.username }} {{ member.last_name }}</h6>
|
||||
<small class="text-muted">{{ member.email }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
{% if member.id != room.created_by %}
|
||||
<form action="{{ url_for('rooms.update_member_permissions', room_id=room.id, user_id=member.id) }}" method="POST" class="d-flex align-items-center gap-2 auto-save-perms-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_view" id="can_view_{{ member.id }}" checked disabled>
|
||||
<input type="hidden" name="can_view" value="1">
|
||||
<label class="form-check-label" for="can_view_{{ member.id }}" title="View permission is always required"><i class="fas fa-eye"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_download" id="can_download_{{ member.id }}" {% if perm.can_download %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_download_{{ member.id }}" title="Can Download Files"><i class="fas fa-download"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_upload" id="can_upload_{{ member.id }}" {% if perm.can_upload %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_upload_{{ member.id }}" title="Can Upload Files"><i class="fas fa-upload"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_delete" id="can_delete_{{ member.id }}" {% if perm.can_delete %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_delete_{{ member.id }}" title="Can Delete Files"><i class="fas fa-trash"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_rename" id="can_rename_{{ member.id }}" {% if perm.can_rename %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_rename_{{ member.id }}" title="Can Rename Files"><i class="fas fa-i-cursor"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_move" id="can_move_{{ member.id }}" {% if perm.can_move %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_move_{{ member.id }}" title="Can Move Files"><i class="fas fa-arrows-alt"></i></label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="can_share" id="can_share_{{ member.id }}" {% if perm.can_share %}checked{% endif %}>
|
||||
<label class="form-check-label" for="can_share_{{ member.id }}" title="Can Share Files"><i class="fas fa-share-alt"></i></label>
|
||||
</div>
|
||||
</form>
|
||||
<form action="{{ url_for('rooms.remove_member', room_id=room.id, user_id=member.id) }}" method="POST" class="d-inline ms-2">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<button type="submit" class="btn btn-remove-member px-3 d-flex align-items-center gap-1">
|
||||
<i class="fas fa-user-minus"></i> Remove
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<span class="badge creator-badge px-3 py-2 d-flex align-items-center gap-1" style="height: 32px;">
|
||||
<i class="fas fa-user"></i> Creator
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted mb-0">No members in this room yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% from "components/member_list.html" import member_list %}
|
||||
{{ member_list(room) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="card-title mb-0">Add New Member</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ url_for('rooms.add_member', room_id=room.id) }}" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<div class="mb-3">
|
||||
<label for="user_id" class="form-label">Select User</label>
|
||||
<select class="form-select select2" id="user_id" name="user_id" required>
|
||||
<option value="">Search for a user...</option>
|
||||
{% for user in available_users %}
|
||||
<option value="{{ user.id }}">{{ user.username }} {{ user.last_name }} ({{ user.email }})</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<i class="fas fa-user-plus me-2"></i>Add Member
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% from "components/add_member_form.html" import add_member_form %}
|
||||
{{ add_member_form(room, available_users) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -204,20 +34,5 @@
|
||||
{% block extra_js %}
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.select2').select2({
|
||||
theme: 'bootstrap-5',
|
||||
width: '100%',
|
||||
placeholder: 'Search for a user...',
|
||||
allowClear: true
|
||||
});
|
||||
// Auto-submit permission form on checkbox change
|
||||
document.querySelectorAll('.auto-save-perms-form input[type="checkbox"]').forEach(function(checkbox) {
|
||||
checkbox.addEventListener('change', function() {
|
||||
this.closest('form').submit();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/room_members.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
{% block title %}Rooms - DocuPulse{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
<link href="{{ url_for('static', filename='css/rooms.css') }}" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-4">
|
||||
<div class="row mb-4">
|
||||
@@ -15,182 +19,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search and Filter Section -->
|
||||
<div class="bg-white rounded-lg shadow-sm p-4 mb-4">
|
||||
<form method="GET" class="d-flex align-items-center w-100 justify-content-between" id="roomFilterForm" style="gap: 1rem;">
|
||||
<input type="text" name="search" placeholder="Search rooms..." value="{{ search }}" class="form-control flex-grow-1" id="roomSearchInput" autocomplete="off" style="min-width: 0;" />
|
||||
<button type="button" id="clearRoomsFilter" class="px-4 py-2 rounded-lg text-white font-medium transition-colors duration-200 ms-2 flex-shrink-0"
|
||||
style="background-color: #16767b; border: 1px solid #16767b;"
|
||||
onmouseover="this.style.backgroundColor='#1a8a90'"
|
||||
onmouseout="this.style.backgroundColor='#16767b'">
|
||||
Clear
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% from "components/room_search.html" import room_search %}
|
||||
{{ room_search(search) }}
|
||||
|
||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
|
||||
{% from "components/room_card.html" import room_card %}
|
||||
{% from "components/delete_room_modal.html" import delete_room_modal %}
|
||||
|
||||
{% for room in rooms %}
|
||||
<div class="col">
|
||||
<div class="card h-100 shadow-sm hover-shadow">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<h5 class="card-title mb-0">{{ room.name }}</h5>
|
||||
<div class="text-muted small mt-1">Created on {{ room.created_at.strftime('%b %d, %Y') }}</div>
|
||||
</div>
|
||||
<span class="badge bg-light text-dark">
|
||||
<i class="fas fa-users"></i> {{ room.member_permissions|length }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="card-text text-muted">{{ room.description or 'No description' }}</p>
|
||||
<div class="d-flex align-items-center mt-3">
|
||||
<img src="{{ url_for('profile_pic', filename=room.creator.profile_picture) if room.creator.profile_picture else url_for('static', filename='default-avatar.png') }}"
|
||||
alt="Creator"
|
||||
class="rounded-circle me-2"
|
||||
style="width: 32px; height: 32px; object-fit: cover;">
|
||||
<div>
|
||||
<small class="text-muted">Created by</small>
|
||||
<div class="fw-medium">{{ room.creator.username }} {{ room.creator.last_name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent border-top-0">
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{{ url_for('rooms.room', room_id=room.id) }}" class="btn btn-primary flex-grow-1">
|
||||
<i class="fas fa-door-open me-2"></i>Open Room
|
||||
</a>
|
||||
{% if current_user.is_admin %}
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="roomActions{{ room.id }}" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="roomActions{{ room.id }}">
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ url_for('rooms.edit_room', room_id=room.id) }}">
|
||||
<i class="fas fa-edit me-2"></i>Edit Room
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ url_for('rooms.room_members', room_id=room.id) }}">
|
||||
<i class="fas fa-users me-2"></i>Manage Members
|
||||
</a>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<button type="button" class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#deleteRoomModal{{ room.id }}">
|
||||
<i class="fas fa-trash me-2"></i>Delete Room
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if current_user.is_admin %}
|
||||
<!-- Delete Room Modal -->
|
||||
<div class="modal fade" id="deleteRoomModal{{ room.id }}" tabindex="-1" aria-labelledby="deleteRoomModalLabel{{ room.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteRoomModalLabel{{ room.id }}">Move to Trash</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex align-items-center gap-3 mb-3">
|
||||
<i class="fas fa-trash text-danger" style="font-size: 2rem;"></i>
|
||||
<div>
|
||||
<h6 class="mb-1">Move to Trash</h6>
|
||||
<p class="text-muted mb-0" id="deleteFileName{{ room.id }}">{{ room.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<i class="fas fa-info-circle me-2"></i>
|
||||
This item will be moved to trash. You can restore it from the trash page within 30 days.
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<form action="{{ url_for('rooms.delete_room', room_id=room.id) }}" method="POST" class="d-inline">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<button type="submit" class="btn btn-danger">
|
||||
<i class="fas fa-trash me-2"></i>Move to Trash
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ room_card(room, current_user) }}
|
||||
{% if current_user.is_admin %}
|
||||
{{ delete_room_modal(room) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.hover-shadow {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.hover-shadow:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 5px;
|
||||
font-weight: 500;
|
||||
padding: 0.5rem 1rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.btn i {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
// Debounce function
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func.apply(this, args), wait);
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const searchInput = document.getElementById('roomSearchInput');
|
||||
const form = document.getElementById('roomFilterForm');
|
||||
if (searchInput && form) {
|
||||
searchInput.addEventListener('input', debounce(function() {
|
||||
form.submit();
|
||||
}, 300));
|
||||
}
|
||||
// Clear button logic
|
||||
const clearBtn = document.getElementById('clearRoomsFilter');
|
||||
if (clearBtn && searchInput) {
|
||||
clearBtn.addEventListener('click', function() {
|
||||
searchInput.value = '';
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
<script src="{{ url_for('static', filename='js/rooms.js') }}"></script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user