Added rudimentary frontend

This commit is contained in:
2023-07-16 21:56:43 +02:00
parent 3b8ca17fd0
commit 27586902b0
52 changed files with 22586 additions and 0 deletions
@@ -0,0 +1,31 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {MatTableDataSource} from "@angular/material/table";
import {ElectionService} from "../elections/election.service";
import {Election} from "../elections/election";
import {Subscription} from "rxjs";
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit, OnDestroy {
electionColumns = ['name', 'day', 'totalNumberOfSeats', 'votingThreshold'];
dataSource = new MatTableDataSource<Election>();
private subscription: Subscription|null = null;
constructor(private electionService: ElectionService) {
}
ngOnInit() {
this.subscription = this.electionService.getElections().subscribe(
(elections) => {
this.dataSource.data = elections;
}
);
}
ngOnDestroy() {
this.subscription?.unsubscribe();
}
}