move dashboard script block content into own files with new classes to update, render to have a better code overview
Build and Push Docker Container / build-and-push (push) Successful in 3m55s
Build and Push Docker Container / build-and-push (push) Successful in 3m55s
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
class OverallStats {
|
||||
constructor(statsEl) {
|
||||
this._el = statsEl;
|
||||
}
|
||||
|
||||
render(summary) {
|
||||
const finished = summary.finished_games || 0;
|
||||
const wins = summary.wins || 0;
|
||||
const winRate = finished > 0 ? ((wins / finished) * 100).toFixed(1) + "%" : "-";
|
||||
const items = [
|
||||
["Games", summary.total_games || 0],
|
||||
["Finished", finished],
|
||||
["Wins", wins],
|
||||
["Losses", summary.losses || 0],
|
||||
["Win Rate", winRate],
|
||||
["Avg Turns", summary.avg_turns_finished || 0],
|
||||
];
|
||||
this._el.innerHTML = items.map(([k, v]) => (
|
||||
`<div class="stat"><span class="k">${k}</span><span class="v">${v}</span></div>`
|
||||
)).join("");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user