Add first version of admin table with basic edit capabilities

This commit is contained in:
2022-12-25 21:24:17 +01:00
parent 6822bb8a04
commit c80312de9d
12 changed files with 230 additions and 15 deletions
+37 -1
View File
@@ -1,4 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {ApiService} from '../../services/api.service';
import {UtilsService} from '../../services/utils.service';
import {Event} from '../../models/event';
@Component({
selector: 'app-admin',
@@ -7,10 +10,43 @@ import {Component, OnInit} from '@angular/core';
})
export class AdminComponent implements OnInit {
constructor() {
isLoggedIn: boolean = false;
events: Event[] = [];
selectedCalendar: string = '';
password: string = '';
name: string = '';
constructor(
private api: ApiService
) {
}
ngOnInit(): void {
if (UtilsService.getPasswordFromLocalStorage() !== '') {
this.isLoggedIn = true;
this.getEvents();
}
}
getEvents(): void {
if(this.selectedCalendar === '') {
return;
}
this.api.getEvents(this.selectedCalendar).subscribe((events: Event[]): void => {
events.forEach((event: Event) => {
this.events.push({
...event,
startDateTime: new Date(event.startDateTime),
endDateTime: new Date(event.endDateTime),
createdDate: new Date(event.createdDate)
})
})
})
}
login(): void {
UtilsService.saveUserInfoToLocalStorage(this.password, this.name);
this.isLoggedIn = true;
this.getEvents();
}
}