ehsan-dashboards/dashboards/tech/add_in_progress_support.py

56 lines
2.5 KiB
Python
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
with open("/workspace/prds/index.html", "r", encoding="utf-8") as f:
html = f.read()
# 1. Add CSS for in_progress badge
css_target = ".badge-status.implemented {"
css_addition = """ .badge-status.in_progress {
background: #eff6ff;
color: #1d4ed8;
border: 1px solid #bfdbfe;
}
"""
if ".badge-status.in_progress" not in html:
html = html.replace(css_target, css_addition + css_target)
# 2. Add in_progress stat card
stat_target = """ <div class="stat-card">
<div class="stat-info">
<h5>پیاده‌سازی شده در پروداکشن (Live)</h5>"""
stat_addition = """ <div class="stat-card">
<div class="stat-info">
<h5>در حال توسعه (In Progress)</h5>
<div class="stat-number" id="stat-inprogress" style="color: #1d4ed8;">۰</div>
</div>
<div class="stat-icon" style="background: #eff6ff; color: #1d4ed8;">⚡</div>
</div>
"""
if "stat-inprogress" not in html:
html = html.replace(stat_target, stat_addition + stat_target)
# 3. Add in_progress filter pill
pill_target = '<button class="pill" onclick="filterStatus(\'implemented\', this)">✅ پیاده‌سازی شده</button>'
pill_addition = '<button class="pill" onclick="filterStatus(\'in_progress\', this)">⚡ در حال توسعه</button>\n '
if "filterStatus('in_progress'" not in html:
html = html.replace(pill_target, pill_addition + pill_target)
# 4. Update status display in card rendering
old_badge_render = '${isLive ? "● پیاده‌سازی شده" : "⏳ در انتظار گرومینگ"}'
new_badge_render = '${task.status === "implemented" ? "● پیاده‌سازی شده" : (task.status === "in_progress" ? "⚡ در حال توسعه" : "⏳ در انتظار گرومینگ")}'
html = html.replace(old_badge_render, new_badge_render)
# 5. Update updateStats function
old_stats_fn = 'const backlog = prdsData.filter(t => t.status === "backlog").length;'
new_stats_fn = """const inProgress = prdsData.filter(t => t.status === "in_progress").length;
const backlog = prdsData.filter(t => t.status === "backlog").length;
const elInProgress = document.getElementById("stat-inprogress");
if (elInProgress) elInProgress.innerText = inProgress.toLocaleString("fa-IR");"""
html = html.replace(old_stats_fn, new_stats_fn)
with open("/workspace/prds/index.html", "w", encoding="utf-8") as f:
f.write(html)
print("index.html upgraded with In Progress support!")