diff --git a/src/app/app.component.html b/src/app/app.component.html
index 372fa1d..962bea1 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -2,35 +2,36 @@

-
{{housePoints.gryffindor | number}}
-
-
-
+
{{housePoints.gryffindor | number}}
+
+
+

-
{{housePoints.ravenclaw | number}}
-
-
-
+
{{housePoints.ravenclaw | number}}
+
+
+

-
{{housePoints.hufflepuff | number}}
-
-
-
+
{{housePoints.hufflepuff | number}}
+
+
+

-
{{housePoints.slytherin | number}}
-
-
-
+
{{housePoints.slytherin | number}}
+
+
+
+
diff --git a/src/app/app.component.sass b/src/app/app.component.sass
index 898fc34..cf3a897 100644
--- a/src/app/app.component.sass
+++ b/src/app/app.component.sass
@@ -1,14 +1,25 @@
+body
+ background-color: #000000
+
.house-column
display: table-cell !important
float: none !important
border-style: solid
border-width: 1em
+ text-align: center
+
img
margin: 1em
img.banner
max-width: 100%
img.crest
max-width: 65%
+
+@media screen and (max-width: 600px)
+ img.banner
+ max-width: 40% !important
+ img.crest
+ display: none !important
#slytherin
background-color: #011803
@@ -27,6 +38,12 @@
border-color: #00165e
color: #77b7d2
.points
- font-size: 7em
font-family: Garamond
- text-align: center
\ No newline at end of file
+ text-align: center
+
+@media screen and (min-width: 601px)
+ .points
+ font-size: 7em
+@media screen and (max-width: 600px)
+ .points
+ font-size: 4em
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index a0b1207..43e363b 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -13,6 +13,7 @@ export class AppComponent implements OnInit {
ngOnInit() {
this.getHousePoints();
+ setInterval(()=>{this.getHousePoints();}, 10000);
}
getHousePoints(): void {
@@ -20,8 +21,12 @@ export class AppComponent implements OnInit {
.subscribe(points => this.housePoints = points);
}
- updateHousePoints(): void {
- this.housePointsService.updatePoints$(this.housePoints);
+ updateHousePoints(housePoints: HousePoints): void {
+ this.housePointsService.updatePoints$(housePoints)
+ .subscribe(result => {
+ console.log(result);
+ this.getHousePoints();
+ });
}
title = 'Hogwart\'s Point Keeper';
@@ -29,22 +34,43 @@ export class AppComponent implements OnInit {
housePoints: HousePoints;
changeGryffindorPoints($event) {
- this.housePoints.gryffindor += $event;
- this.updateHousePoints();
+ this.housePointsService.getPoints$()
+ .subscribe(points => {
+ points.gryffindor += $event;
+ this.updateHousePoints(points);
+ });
}
changeRavenclawPoints($event) {
- this.housePoints.ravenclaw += $event;
- this.updateHousePoints();
+ this.housePointsService.getPoints$()
+ .subscribe(points => {
+ points.ravenclaw += $event;
+ this.updateHousePoints(points);
+ });
}
changeHufflepuffPoints($event) {
- this.housePoints.hufflepuff += $event;
- this.updateHousePoints();
+ this.housePointsService.getPoints$()
+ .subscribe(points => {
+ points.hufflepuff += $event;
+ this.updateHousePoints(points);
+ });
}
changeSlytherinPoints($event) {
- this.housePoints.slytherin += $event;
- this.updateHousePoints();
+ this.housePointsService.getPoints$()
+ .subscribe(points => {
+ points.slytherin += $event;
+ this.updateHousePoints(points);
+ });
+ }
+
+ resetPoints() {
+ this.updateHousePoints({
+ gryffindor:0,
+ ravenclaw:0,
+ hufflepuff:0,
+ slytherin:0
+ });
}
}
diff --git a/src/app/house-points-remote.service.ts b/src/app/house-points-remote.service.ts
index 961fc25..6dcb202 100644
--- a/src/app/house-points-remote.service.ts
+++ b/src/app/house-points-remote.service.ts
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
+// import { BehaviorSubject } from 'rxjs';
import { HousePoints } from './HousePoints';
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
@@ -26,6 +27,6 @@ export class HousePointsRemoteService {
}
updatePoints$(points: HousePoints): Observable