diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.ts b/client/Nightr/src/app/component/camera-button/camera-button.component.ts index bd916ef..d3bd803 100644 --- a/client/Nightr/src/app/component/camera-button/camera-button.component.ts +++ b/client/Nightr/src/app/component/camera-button/camera-button.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core'; import { MyCameraService } from '../../services/my-camera-service'; -import { Image } from 'tns-core-modules/ui/image' @Component({ selector: 'ns-camera-button', diff --git a/client/Nightr/src/app/result-page/result-page.component.css b/client/Nightr/src/app/result-page/result-page.component.css index bcd4764..c86d424 100644 --- a/client/Nightr/src/app/result-page/result-page.component.css +++ b/client/Nightr/src/app/result-page/result-page.component.css @@ -1 +1,19 @@ -/* Add mobile styles for the component here. */ +.title-container + { + font-family: 'Times New Roman', Times, serif; + font-size: 20px; + color: black; + padding: 5px; + text-align: center; + } +.page { + background-color: lightskyblue; +} +.item-header { + font-family: 'Times New Roman', Times, serif; + font-size: 14px; +} +.item-header { + font-family: 'Times New Roman', Times, serif; + font-size: 10px; +} diff --git a/client/Nightr/src/app/result-page/result-page.component.html b/client/Nightr/src/app/result-page/result-page.component.html index 5a89837..991d737 100644 --- a/client/Nightr/src/app/result-page/result-page.component.html +++ b/client/Nightr/src/app/result-page/result-page.component.html @@ -1,7 +1,18 @@ - - - - - + + + + + + + + + + + + + + + + diff --git a/client/Nightr/src/app/result-page/result-page.component.ts b/client/Nightr/src/app/result-page/result-page.component.ts index a764430..9dc4f15 100644 --- a/client/Nightr/src/app/result-page/result-page.component.ts +++ b/client/Nightr/src/app/result-page/result-page.component.ts @@ -1,6 +1,12 @@ import { Component, OnInit } from '@angular/core'; import { RouterExtensions } from 'nativescript-angular/router'; +class Reason { + constructor(public str: string, public causestring: string) { + + } +} + @Component({ selector: 'result-page', templateUrl: './result-page.component.html', @@ -8,8 +14,62 @@ import { RouterExtensions } from 'nativescript-angular/router'; moduleId: module.id, }) export class ResultPageComponent implements OnInit { + night: string = ""; + percentage: string = ""; + JSONObject = { + night: true, + predictions: [ + { + contribution: 0.08513743614692289, + description: "The number of articles releases in the last few hours on TV2.dk", + name: "tv2news", + night: true, + probability: 0.75, + reasons: [ + "There were few recent articles on TV2 News" + ], + weight: 0.7, + weighted_probability: 0.5249999999999999 + }, + { + contribution: 0.12162490878131842, + description: "It is night if it is night on the ISS and it is currently orbiting above us. http://www.isstracker.com/", + name: "iss", + night: true, + probability: 1.0, + reasons: [ + "The ISS is 6921 km away, so we are on the same side of the earth.", + "It is nighttime on board the ISS.", + "Therefore, it must be nighttime where we are." + ], + weight: 1.0, + weighted_probability: 1.0 + } + ], + weighted_probabilities_mean: 0.6066435714170693, + weighted_probabilities_median: 0.5538043478260869 + } + public reasons: Array; - constructor(private routerExtensions: RouterExtensions) { } + constructor(private routerExtensions: RouterExtensions) { + this.reasons = []; + var stringObject = JSON.stringify(this.JSONObject); + console.log(stringObject); + console.log(JSON.parse(stringObject)); + if (this.JSONObject.night) { + this.night = "It is night"; + } else { + this.night = "It is day"; + } + this.percentage = "At least we are "+Math.floor(this.JSONObject.weighted_probabilities_mean*100)+"% sure, here's why" + for (let i = 0; i < this.JSONObject.predictions.length; i++) { + var causestring = "" + for (let j = 0; j < this.JSONObject.predictions[i].reasons.length; j++) { + causestring = causestring + " - " + this.JSONObject.predictions[i].reasons[j] + "\n"; + } + this.reasons.push(new Reason(""+Math.round(this.JSONObject.predictions[i].contribution*100)+"% - " + this.JSONObject.predictions[i].name, causestring)); + } + } ngOnInit(): void { }