Fix home component
This commit is contained in:
parent
65fb8254f5
commit
b7893b61eb
@ -55,40 +55,60 @@ interface TotalStatsResult {
|
||||
|
||||
@Component
|
||||
export default class Home extends Vue {
|
||||
totalLoginAttempts?: number;
|
||||
totalLoginAttempts: number;
|
||||
|
||||
uniquePasswords?: number;
|
||||
uniquePasswords: number;
|
||||
|
||||
uniqueUsernames?: number;
|
||||
uniqueUsernames: number;
|
||||
|
||||
uniqueIPs?: number;
|
||||
uniqueIPs: number;
|
||||
|
||||
uniqueCountries?: number;
|
||||
uniqueCountries: number;
|
||||
|
||||
ready = false;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.totalLoginAttempts = 0;
|
||||
this.uniquePasswords = 0;
|
||||
this.uniqueUsernames = 0;
|
||||
this.uniqueIPs = 0;
|
||||
this.uniqueCountries = 0;
|
||||
}
|
||||
|
||||
updateStats(): void {
|
||||
const url = `/api/stats?type=total`;
|
||||
axios
|
||||
.get<TotalStatsResult[]>(url)
|
||||
.then((resp) => {
|
||||
this.totalLoginAttempts = resp.data.find(
|
||||
(e) => e.name === 'TotalLoginAttempts',
|
||||
)?.count;
|
||||
const totals = resp.data.find((e) => e.name === 'TotalLoginAttempts')
|
||||
?.count;
|
||||
if (totals) {
|
||||
this.totalLoginAttempts = totals;
|
||||
}
|
||||
|
||||
this.uniquePasswords = resp.data.find(
|
||||
(e) => e.name === 'UniquePasswords',
|
||||
)?.count;
|
||||
const passwords = resp.data.find((e) => e.name === 'UniquePasswords')
|
||||
?.count;
|
||||
if (passwords) {
|
||||
this.uniquePasswords = passwords;
|
||||
}
|
||||
|
||||
this.uniqueUsernames = resp.data.find(
|
||||
(e) => e.name === 'UniqueUsernames',
|
||||
)?.count;
|
||||
const usernames = resp.data.find((e) => e.name === 'UniqueUsernames')
|
||||
?.count;
|
||||
if (usernames) {
|
||||
this.uniqueUsernames = usernames;
|
||||
}
|
||||
|
||||
this.uniqueIPs = resp.data.find((e) => e.name === 'UniqueIPs')?.count;
|
||||
const ips = resp.data.find((e) => e.name === 'UniqueIPs')?.count;
|
||||
if (ips) {
|
||||
this.uniqueIPs = ips;
|
||||
}
|
||||
|
||||
this.uniqueCountries = resp.data.find(
|
||||
(e) => e.name === 'UniqueCountries',
|
||||
)?.count;
|
||||
const countries = resp.data.find((e) => e.name === 'UniqueCountries')
|
||||
?.count;
|
||||
if (countries) {
|
||||
this.uniqueCountries = countries;
|
||||
}
|
||||
|
||||
this.ready = true;
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user