Skip to content
Snippets Groups Projects
Commit 6807d513 authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Outsource list-statistic stuff

parent aeae65a5
Branches
Tags
No related merge requests found
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { RoomService } from '../../../services/http/room.service';
import { Content } from '../../../models/content';
import { ContentService } from '../../../services/http/content.service';
import { ContentGroup } from '../../../models/content-group';
import { Room } from '../../../models/room';
/* TODO: Use TranslateService */
export interface ContentPercents {
content: string;
percent: string;
}
@Component({
selector: 'app-statistics',
......@@ -20,32 +14,16 @@ export interface ContentPercents {
export class StatisticsComponent implements OnInit {
contents: string[] = ['TEST', 'TEST'];
room: Room;
contentGroups: ContentGroup[];
contentGroup: ContentGroup = new ContentGroup('Choice', ['53d8dc160260a1724b7c9930ed00102c', '53d8dc160260a1724b7c9930ed000b38'], true);
percents: number[];
displayedColumns = ['content', 'percentage'];
dataSource: ContentPercents[] = [
{ content: '', percent: '' },
{ content: '', percent: '' },
{ content: '', percent: '' }
];
constructor(
private route: ActivatedRoute,
private roomService: RoomService,
private contentService: ContentService) {
private roomService: RoomService) {
}
ngOnInit(): void {
this.getRoom(localStorage.getItem('roomId'));
this.getContents();
this.percents = [73, 87, 69, 92, 77];
for (let i = 0; i < 2; i++) {
this.dataSource[i].content = this.contents[i];
this.dataSource[i].percent = this.percents[i].toFixed(0);
}
}
getRoom(id: string): void {
......@@ -54,14 +32,6 @@ export class StatisticsComponent implements OnInit {
});
}
getContents(): void {
this.contentService.getContentsByIds(this.contentGroup.contentIds).subscribe( contents => {
for (let i = 0; i < 2; i++) {
this.contents[i] = contents[i].subject;
}
});
}
}
/*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment