Spaces:
Sleeping
Sleeping
Commit ·
cab9dc9
1
Parent(s): c7bcb60
Update
Browse files- app.py +19 -0
- templates/dashboard.html +69 -1
app.py
CHANGED
|
@@ -252,14 +252,33 @@ def dashboard():
|
|
| 252 |
username = session["user"]["username"]
|
| 253 |
token = session.get("access_token")
|
| 254 |
|
|
|
|
|
|
|
|
|
|
| 255 |
spaces = fetch_user_spaces(username, token)
|
| 256 |
discussions = get_discussions_feed(username, token)
|
| 257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
return render_template(
|
| 259 |
"dashboard.html",
|
| 260 |
user=session["user"],
|
| 261 |
spaces=spaces,
|
| 262 |
discussions=discussions,
|
|
|
|
|
|
|
| 263 |
)
|
| 264 |
|
| 265 |
|
|
|
|
| 252 |
username = session["user"]["username"]
|
| 253 |
token = session.get("access_token")
|
| 254 |
|
| 255 |
+
sort_by = request.args.get("sort", "score")
|
| 256 |
+
filter_status = request.args.get("status", "all")
|
| 257 |
+
|
| 258 |
spaces = fetch_user_spaces(username, token)
|
| 259 |
discussions = get_discussions_feed(username, token)
|
| 260 |
|
| 261 |
+
# Filter by status
|
| 262 |
+
if filter_status == "open":
|
| 263 |
+
discussions = [d for d in discussions if d["status"] == "open"]
|
| 264 |
+
elif filter_status == "closed":
|
| 265 |
+
discussions = [d for d in discussions if d["status"] in ("closed", "merged")]
|
| 266 |
+
|
| 267 |
+
# Sort discussions
|
| 268 |
+
if sort_by == "comments":
|
| 269 |
+
discussions.sort(key=lambda x: x["num_comments"], reverse=True)
|
| 270 |
+
elif sort_by == "reactions":
|
| 271 |
+
discussions.sort(key=lambda x: x["num_reactions"], reverse=True)
|
| 272 |
+
else:
|
| 273 |
+
discussions.sort(key=lambda x: x["score"], reverse=True)
|
| 274 |
+
|
| 275 |
return render_template(
|
| 276 |
"dashboard.html",
|
| 277 |
user=session["user"],
|
| 278 |
spaces=spaces,
|
| 279 |
discussions=discussions,
|
| 280 |
+
sort_by=sort_by,
|
| 281 |
+
filter_status=filter_status,
|
| 282 |
)
|
| 283 |
|
| 284 |
|
templates/dashboard.html
CHANGED
|
@@ -197,6 +197,56 @@
|
|
| 197 |
color: #444;
|
| 198 |
font-size: 0.875rem;
|
| 199 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
</style>
|
| 201 |
</head>
|
| 202 |
<body>
|
|
@@ -235,10 +285,28 @@
|
|
| 235 |
<h2 class="section-title">Discussions Feed</h2>
|
| 236 |
<span class="section-count">{{ discussions|length }}</span>
|
| 237 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
{% if discussions %}
|
| 239 |
<div class="feed">
|
| 240 |
{% for d in discussions %}
|
| 241 |
-
<a href="{{ d.url }}" target="_blank" class="feed-item">
|
| 242 |
<div class="feed-meta">
|
| 243 |
<span class="feed-space">{{ d.space_name }}</span>
|
| 244 |
<span class="feed-type {{ 'pr' if d.is_pr else 'discussion' }}">
|
|
|
|
| 197 |
color: #444;
|
| 198 |
font-size: 0.875rem;
|
| 199 |
}
|
| 200 |
+
.controls {
|
| 201 |
+
display: flex;
|
| 202 |
+
gap: 1.5rem;
|
| 203 |
+
margin-bottom: 1rem;
|
| 204 |
+
}
|
| 205 |
+
.control-group {
|
| 206 |
+
display: flex;
|
| 207 |
+
align-items: center;
|
| 208 |
+
gap: 0.5rem;
|
| 209 |
+
}
|
| 210 |
+
.control-label {
|
| 211 |
+
font-size: 0.6875rem;
|
| 212 |
+
color: #555;
|
| 213 |
+
text-transform: uppercase;
|
| 214 |
+
letter-spacing: 0.03em;
|
| 215 |
+
}
|
| 216 |
+
.control-options {
|
| 217 |
+
display: flex;
|
| 218 |
+
gap: 0.25rem;
|
| 219 |
+
}
|
| 220 |
+
.control-btn {
|
| 221 |
+
font-size: 0.75rem;
|
| 222 |
+
padding: 0.25rem 0.5rem;
|
| 223 |
+
background: transparent;
|
| 224 |
+
border: 1px solid #222;
|
| 225 |
+
border-radius: 4px;
|
| 226 |
+
color: #666;
|
| 227 |
+
cursor: pointer;
|
| 228 |
+
transition: all 0.15s;
|
| 229 |
+
}
|
| 230 |
+
.control-btn:hover {
|
| 231 |
+
border-color: #333;
|
| 232 |
+
color: #999;
|
| 233 |
+
}
|
| 234 |
+
.control-btn.active {
|
| 235 |
+
background: #1a1a1a;
|
| 236 |
+
border-color: #333;
|
| 237 |
+
color: #e5e5e5;
|
| 238 |
+
}
|
| 239 |
+
.feed-item.status-open {
|
| 240 |
+
border-left: 2px solid #22c55e;
|
| 241 |
+
padding-left: 1rem;
|
| 242 |
+
margin-left: -1rem;
|
| 243 |
+
}
|
| 244 |
+
.feed-item.status-closed,
|
| 245 |
+
.feed-item.status-merged {
|
| 246 |
+
border-left: 2px solid #333;
|
| 247 |
+
padding-left: 1rem;
|
| 248 |
+
margin-left: -1rem;
|
| 249 |
+
}
|
| 250 |
</style>
|
| 251 |
</head>
|
| 252 |
<body>
|
|
|
|
| 285 |
<h2 class="section-title">Discussions Feed</h2>
|
| 286 |
<span class="section-count">{{ discussions|length }}</span>
|
| 287 |
</div>
|
| 288 |
+
<div class="controls">
|
| 289 |
+
<div class="control-group">
|
| 290 |
+
<span class="control-label">Sort</span>
|
| 291 |
+
<div class="control-options">
|
| 292 |
+
<a href="?sort=score&status={{ filter_status }}" class="control-btn {{ 'active' if sort_by == 'score' else '' }}">Score</a>
|
| 293 |
+
<a href="?sort=comments&status={{ filter_status }}" class="control-btn {{ 'active' if sort_by == 'comments' else '' }}">Comments</a>
|
| 294 |
+
<a href="?sort=reactions&status={{ filter_status }}" class="control-btn {{ 'active' if sort_by == 'reactions' else '' }}">Reactions</a>
|
| 295 |
+
</div>
|
| 296 |
+
</div>
|
| 297 |
+
<div class="control-group">
|
| 298 |
+
<span class="control-label">Status</span>
|
| 299 |
+
<div class="control-options">
|
| 300 |
+
<a href="?sort={{ sort_by }}&status=all" class="control-btn {{ 'active' if filter_status == 'all' else '' }}">All</a>
|
| 301 |
+
<a href="?sort={{ sort_by }}&status=open" class="control-btn {{ 'active' if filter_status == 'open' else '' }}">Open</a>
|
| 302 |
+
<a href="?sort={{ sort_by }}&status=closed" class="control-btn {{ 'active' if filter_status == 'closed' else '' }}">Closed</a>
|
| 303 |
+
</div>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
{% if discussions %}
|
| 307 |
<div class="feed">
|
| 308 |
{% for d in discussions %}
|
| 309 |
+
<a href="{{ d.url }}" target="_blank" class="feed-item status-{{ d.status }}">
|
| 310 |
<div class="feed-meta">
|
| 311 |
<span class="feed-space">{{ d.space_name }}</span>
|
| 312 |
<span class="feed-type {{ 'pr' if d.is_pr else 'discussion' }}">
|