ehsan-dashboards/dashboards/tech/patch_conic.py

25 lines
1.4 KiB
Python
Executable file

with open('/workspace/prds/generate_template.py', 'r', encoding='utf-8') as f:
c = f.read()
dev_donut_replacement = """ const stop1 = pDone;
const stop2 = Math.min(100, pDone + pInProg);
container.innerHTML = `
<div style="width: 170px; height: 170px; border-radius: 50%; background: conic-gradient(#10b981 0% ${stop1}%, #0284c7 ${stop1}% ${stop2}%, #cbd5e1 ${stop2}% 100%); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.04);">
<div style="width: 124px; height: 124px; border-radius: 50%; background: #ffffff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);">
<div style="font-size: 26px; font-weight: 900; color: #0f172a; line-height: 1;">${s.completionRate}٪</div>
<div style="font-size: 11px; color: #64748b; margin-top: 4px;">نرخ موفقیت</div>
</div>
</div>"""
idx_start = c.find("const C = 238.76;")
idx_end = c.find("</div>\n </div>", idx_start) + 14
if idx_start != -1 and idx_end != -1:
c = c[:idx_start] + dev_donut_replacement + c[idx_end:]
print("Dev donut updated to conic-gradient!")
else:
print("Dev donut boundaries not found!", idx_start, idx_end)
with open('/workspace/prds/generate_template.py', 'w', encoding='utf-8') as f:
f.write(c)