Task-management/templates/index.html
2024-10-06 00:38:32 +08:00

167 lines
7.5 KiB
HTML

<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>任務管理器</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
}
.navbar {
background-color: #007bff;
}
.card {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.card:hover {
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
.task-card {
height: 100%;
}
.priority-high {
border-left: 5px solid #dc3545;
}
.priority-medium {
border-left: 5px solid #ffc107;
}
.priority-low {
border-left: 5px solid #28a745;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark mb-4">
<div class="container">
<a class="navbar-brand" href="{{ url_for('index') }}">
<i class="bi bi-list-check"></i> 任務管理器
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#addTaskModal">
<i class="bi bi-plus-circle"></i> 新增任務
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('logout') }}">
<i class="bi bi-box-arrow-right"></i> 登出
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="row mb-4">
<div class="col-md-6 offset-md-3">
<form action="{{ url_for('index') }}" method="get">
<div class="input-group">
<input type="text" class="form-control" placeholder="搜索任務..." name="search" value="{{ search }}">
<button class="btn btn-outline-secondary" type="submit">
<i class="bi bi-search"></i> 搜索
</button>
</div>
</form>
</div>
</div>
<div class="row">
{% for task in tasks %}
<div class="col-md-4 mb-4">
<div class="card task-card priority-{{ task.priority.lower() }}">
<div class="card-body">
<h5 class="card-title">{{ task.title }}</h5>
<p class="card-text">{{ task.description }}</p>
<p class="card-text">
<small class="text-muted">建立時間: {{ task.created_at.strftime('%Y-%m-%d %H:%M') }}</small>
</p>
<p class="card-text">
狀態:
<a href="{{ url_for('update_status', task_id=task.id, new_status='待辦') }}" class="badge bg-secondary">待辦</a>
<a href="{{ url_for('update_status', task_id=task.id, new_status='進行中') }}" class="badge bg-primary">進行中</a>
<a href="{{ url_for('update_status', task_id=task.id, new_status='已完成') }}" class="badge bg-success">已完成</a>
</p>
<p class="card-text">
優先級:
<span class="badge bg-{{ 'danger' if task.priority == '高' else 'warning' if task.priority == '中' else 'success' }}">
{{ task.priority }}
</span>
</p>
</div>
<div class="card-footer text-end">
<a href="{{ url_for('edit_task', task_id=task.id) }}" class="btn btn-warning btn-sm">
<i class="bi bi-pencil"></i> 編輯
</a>
<a href="{{ url_for('delete_task', task_id=task.id) }}" class="btn btn-danger btn-sm">
<i class="bi bi-trash"></i> 移除
</a>
</div>
</div>
</div>
{% else %}
<div class="col-12">
<div class="alert alert-warning" role="alert">
<i class="bi bi-exclamation-triangle"></i> 沒有可顯示的任務
</div>
</div>
{% endfor %}
</div>
</div>
<!-- 新增任務模態框 -->
<div class="modal fade" id="addTaskModal" tabindex="-1" aria-labelledby="addTaskModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addTaskModalLabel">新增任務</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="{{ url_for('add_task') }}" method="post">
<div class="mb-3">
<label for="title" class="form-label">任務標題:</label>
<input type="text" class="form-control" id="title" name="title" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">描述:</label>
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
</div>
<div class="mb-3">
<label for="priority" class="form-label">優先級:</label>
<select class="form-select" id="priority" name="priority">
<option value="低"></option>
<option value="中" selected></option>
<option value="高"></option>
</select>
</div>
<button type="submit" class="btn btn-primary">新增任務</button>
</form>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>