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

@ -35,7 +35,7 @@ export interface ApiaryAPI {
function fakeLoginAttempt(): LoginAttempt {
return {
date: randRecentDate({days: 2}).toISOString(),
date: randRecentDate({ days: 2 }).toISOString(),
remoteIP: randIp().toString(),
username: randUserName().toString(),
password: randPassword().toString(),
@ -68,7 +68,9 @@ export class DummyApiaryAPIClient implements ApiaryAPI {
}
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[]> {
const attempts = Array.from({ length: 10 }, () => {
@ -105,7 +107,7 @@ export class ApiaryAPIClient implements ApiaryAPI {
if (!data) {
return []
}
return data
return data.sort((a, b) => b.count - a.count)
}
async query(queryType: string, query: string): Promise<LoginAttempt[]> {
const resp = await fetch(`/api/query?type=${queryType}&query=${query}`)

View File

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