Add first version of admin table with basic edit capabilities
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user