Skip to content

Commit

Permalink
Merge pull request #31 from spreaker/improve-ui
Browse files Browse the repository at this point in the history
Improve rendering of recent issues
  • Loading branch information
lele85 authored Nov 3, 2023
2 parents 50f2f8d + 02149cd commit aff48c0
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions website/src/lib/Ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,34 +161,31 @@ export function updateDetailedGrid(data: Detail[]) {
})
}

function padCenter(str, maxLen, padChar = '\xa0') {
return str.padStart((str.length + maxLen) / 2, padChar).padEnd(maxLen, padChar)
}

function renderIssue(issue: Issue) {
return `
<li class="pt-1">
<div
onclick="document.getElementById('${`issue-detail-${issue.id}`}').classList.toggle('hidden')"
class="underline cursor-pointer text-sm"
>
<code class="rounded px-2 py-1 text-xs font-bold">
${new Intl.DateTimeFormat('default', {
timeZone: 'UTC',
year: '2-digit',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}).format(new Date(issue.timestamp))} |${padCenter(issue.type, 11)}| ${issue.region}
</code>
</div>
<pre id="issue-detail-${issue.id}" class="text-xs hidden pt-1 overflow-x-scroll">${JSON.stringify(
issue,
null,
2
)}</pre>
<span class="text-xs cursor-pointer underline font-mono font-bold">${new Intl.DateTimeFormat(
'default',
{
timeZone: 'UTC',
year: '2-digit',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}
).format(new Date(issue.timestamp))}</span>
<span class="text-xs"> | </span>
<span class="text-xs cursor-pointer underline ">${issue.type}</span>
<span class="text-xs"> | </span>
<span class="text-xs cursor-pointer underline ">${issue.region}</span>
<pre id="issue-detail-${
issue.id
}" class="text-xs hidden pt-1 overflow-x-scroll">${JSON.stringify(issue, null, 2)}</pre>
</li>`
}

Expand Down

0 comments on commit aff48c0

Please sign in to comment.