Add first version of admin table with basic edit capabilities
This commit is contained in:
@@ -1 +1,14 @@
|
||||
<p>admin works!</p>
|
||||
<div *ngIf="!isLoggedIn">
|
||||
<p>Please log in:</p>
|
||||
<input type="password" aria-label="Password" (keyup.enter)="login()" [(ngModel)]="password">
|
||||
<input type="text" aria-label="Your Name" (keyup.enter)="login()" [(ngModel)]="name">
|
||||
</div>
|
||||
<div *ngIf="isLoggedIn">
|
||||
<select [(ngModel)]="selectedCalendar" (change)="getEvents()">
|
||||
<option value="" disabled selected hidden>Select calendar</option>
|
||||
<option>public</option>
|
||||
<option>members</option>
|
||||
<option>management</option>
|
||||
</select>
|
||||
<app-events-table [events]="this.events"></app-events-table>
|
||||
</div>
|
||||
|
||||
@@ -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