| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="UTF-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| <title>View Resources - Educational Resource Management System</title>
|
| <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
|
| <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
| </head>
|
| <body>
|
| <div class="container">
|
| <div class="header">
|
| <h1><a href="{{ url_for('index') }}">Educational Resource Management System</a></h1>
|
| <a href="{{ url_for('logout') }}" class="logout-btn">Logout</a>
|
| </div>
|
|
|
| <div class="user-welcome">
|
| <h2>Welcome, {{ session['username'] }}!</h2>
|
| <p>You are logged in as a {{ user_type }}</p>
|
| </div>
|
|
|
| <nav>
|
| <ul class="nav-list">
|
| {% if user_type == 'admin' %}
|
| <li><a href="{{ url_for('add_resource') }}">Add Resource</a></li>
|
| {% endif %}
|
| <li><a href="{{ url_for('view_resources') }}">View Resources</a></li>
|
| </ul>
|
| </nav>
|
|
|
| <div class="dashboard-content">
|
| <h2>View Resources</h2>
|
|
|
| {% with messages = get_flashed_messages(with_categories=true) %}
|
| {% if messages %}
|
| {% for category, message in messages %}
|
| <p style="color: {{ 'red' if category == 'error' else 'green' }}">{{ message }}</p>
|
| {% endfor %}
|
| {% endif %}
|
| {% endwith %}
|
|
|
| <form method="POST" action="{{ url_for('view_resources') }}" class="filter-form">
|
| <select name="institution" onchange="this.form.submit()">
|
| <option value="">Select Institution</option>
|
| {% for inst in institutions %}
|
| <option value="{{ inst.institution }}" {% if filters.institution == inst.institution %}selected{% endif %}>{{ inst.institution }}</option>
|
| {% endfor %}
|
| </select>
|
|
|
| <select name="department" onchange="this.form.submit()">
|
| <option value="">Select Department</option>
|
| {% if departments %}
|
| {% for dept in departments %}
|
| <option value="{{ dept.department }}" {% if filters.department == dept.department %}selected{% endif %}>{{ dept.department }}</option>
|
| {% endfor %}
|
| {% endif %}
|
| </select>
|
|
|
| <select name="resource_type" onchange="this.form.submit()">
|
| <option value="">Select Resource Type</option>
|
| {% for rtype in resource_types %}
|
| <option value="{{ rtype.type }}" {% if filters.resource_type == rtype.type %}selected{% endif %}>{{ rtype.type }}</option>
|
| {% endfor %}
|
| </select>
|
| </form>
|
|
|
| {% if resources %}
|
| <table>
|
| <tr>
|
| <th>Resource Name</th>
|
| <th>Resource Type</th>
|
| <th>Institution</th>
|
| <th>Department</th>
|
| {% if user_type == 'admin' %}
|
| <th>Download</th>
|
| <th>Delete</th>
|
| {% else %}
|
| <th>Download</th>
|
| {% endif %}
|
| </tr>
|
| {% for resource in resources %}
|
| <tr>
|
| <td>{{ resource.name }}</td>
|
| <td>{{ resource.type }}</td>
|
| <td>{{ resource.institution }}</td>
|
| <td>{{ resource.department }}</td>
|
| <td>
|
| <a href="{{ url_for('uploaded_file', filename=resource.resource_file) }}" download class="action-btn download-btn">Download</a>
|
| </td>
|
| {% if user_type == 'admin' %}
|
| <td>
|
| <form method="POST" action="{{ url_for('view_resources') }}" style="display: inline;">
|
| <button type="submit" name="delete_resource" value="{{ resource.id }}" class="action-btn delete-btn" onclick="return confirm('Are you sure you want to delete this resource?')">Delete</button>
|
| </form>
|
| </td>
|
| {% endif %}
|
| </tr>
|
| {% endfor %}
|
| </table>
|
| {% else %}
|
| <p>No resources available.</p>
|
| {% endif %}
|
| </div>
|
| </div>
|
| </body>
|
| </html> |