Skip to content

Commit

Permalink
Poll service implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Jul 30, 2019
1 parent 81d40ad commit 8f7d718
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/app/master/master.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IssueSource } from './issue-source';
import { DefaultSourceComponent } from './default-source/default-source.component';
import { Statistic } from '../statistic';
import { Topic } from '../topic';
import { PollService } from '../poll.service';

@Component({
selector: 'app-master',
Expand All @@ -29,22 +30,21 @@ export class MasterComponent implements OnInit, AfterViewInit {
flipped: boolean;

constructor(
private route: ActivatedRoute) {
private route: ActivatedRoute,
private pollService: PollService) {

}

ngOnInit() {
// TODO: Read from service
var session = new Session();
session.id = +this.route.snapshot.paramMap.get('id');
session.name = "Hi";
this.session = session;

this.flipped = true;
this.votes = [
{id: 1, value: '1', active: false,name: 'Thomas',confirmed: true,placed: true, canDelete: true},
{id: 1, value: '3', active: false,name: 'Sandra',confirmed: true,placed: true, canDelete: true},
];
this.session.id = +this.route.snapshot.paramMap.get('id');
this.pollService.currentPoll(this.session).subscribe(pr => {
this.session.name = pr.name;
this.flipped = pr.flipped;
this.votes = pr.votes;
if (pr.topic === '')
return;
this.teamComplete = true;
});
this.statistics = [
{ name: "Test", value: "123", enabled: true}
]
Expand Down
24 changes: 23 additions & 1 deletion src/app/poll.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Session } from './session';
import { MemberVote } from './card';
import { Observable } from 'rxjs';

export class PollResponse {
name: string;
timestamp: number;

topic: string;
description: string;
url: string;

flipped: boolean;
consensus: boolean;

votes: MemberVote[];
}

@Injectable({
providedIn: 'root'
})
export class PollService {

constructor() { }
constructor(private http: HttpClient) { }

currentPoll(session: Session) : Observable<PollResponse> {
return this.http.get<PollResponse>('/api/poll/current/' + session.id);
}
}

0 comments on commit 8f7d718

Please sign in to comment.