Add flake.nix and rewrite frontend #5

Merged
torjus merged 12 commits from nixify into master 2025-03-19 21:07:52 +00:00
2 changed files with 6 additions and 3 deletions
Showing only changes of commit db294c171d - Show all commits

View File

@ -68,7 +68,9 @@ export class DummyApiaryAPIClient implements ApiaryAPI {
} }
return { name: randUserName().toString(), count: randNumber().valueOf() } return { name: randUserName().toString(), count: randNumber().valueOf() }
}); });
return Promise.resolve(stats);
const sorted = stats.sort((a, b) => b.count - a.count)
return Promise.resolve(sorted);
} }
async query(_type: string, _query: string): Promise<LoginAttempt[]> { async query(_type: string, _query: string): Promise<LoginAttempt[]> {
const attempts = Array.from({ length: 10 }, () => { const attempts = Array.from({ length: 10 }, () => {
@ -105,7 +107,7 @@ export class ApiaryAPIClient implements ApiaryAPI {
if (!data) { if (!data) {
return [] return []
} }
return data return data.sort((a, b) => b.count - a.count)
} }
async query(queryType: string, query: string): Promise<LoginAttempt[]> { async query(queryType: string, query: string): Promise<LoginAttempt[]> {
const resp = await fetch(`/api/query?type=${queryType}&query=${query}`) const resp = await fetch(`/api/query?type=${queryType}&query=${query}`)

View File

@ -169,6 +169,7 @@ export function StatsPie({ data }: StatsPieProps) {
borderWidth: 1 borderWidth: 1
}] }]
}; };
console.log(piedata)
const getTextColor = () => { const getTextColor = () => {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'white' : 'black' return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'white' : 'black'
} }