Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a1eac10beb
|
@ -1,6 +1,5 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { MyCameraService } from '../../services/my-camera-service';
|
import { MyCameraService } from '../../services/my-camera-service';
|
||||||
import { Image } from 'tns-core-modules/ui/image'
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ns-camera-button',
|
selector: 'ns-camera-button',
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
<ActionBar title="Result" class="action-bar"></ActionBar>
|
<ActionBar title="Result" class="action-bar"></ActionBar>
|
||||||
|
|
||||||
<ScrollView class="page">
|
<StackLayout class="page" height="100%">
|
||||||
<AbsoluteLayout>
|
<StackLayout height="10%" class="title-container">
|
||||||
<Button class="btn btn-primary" text="Home" [nsRouterLink]="['/home-page']"></Button>
|
<Label text="{{night}}"></Label>
|
||||||
</AbsoluteLayout>
|
<Label text="{{percentage}}"></Label>
|
||||||
</ScrollView>
|
</StackLayout>
|
||||||
|
<ScrollView height='90%'>
|
||||||
|
<ListView [items]="reasons" class="list-group">
|
||||||
|
<ng-template let-reason="item" let-i="index" let-odd="odd" let-even="even">
|
||||||
|
<StackLayout orientation="vertical" class="list-group-item">
|
||||||
|
<Label class="item-header" [text]="reason.str" width="100%" textWrap="true"></Label>
|
||||||
|
<Label class="item-item" [text]="reason.causestring" width="100%" textWrap="true"></Label>
|
||||||
|
</StackLayout>
|
||||||
|
</ng-template>
|
||||||
|
</ListView>
|
||||||
|
</ScrollView>
|
||||||
|
</StackLayout>
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { RouterExtensions } from 'nativescript-angular/router';
|
import { RouterExtensions } from 'nativescript-angular/router';
|
||||||
|
|
||||||
|
class Reason {
|
||||||
|
constructor(public str: string, public causestring: string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'result-page',
|
selector: 'result-page',
|
||||||
templateUrl: './result-page.component.html',
|
templateUrl: './result-page.component.html',
|
||||||
|
@ -8,8 +14,62 @@ import { RouterExtensions } from 'nativescript-angular/router';
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
})
|
})
|
||||||
export class ResultPageComponent implements OnInit {
|
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<Reason>;
|
||||||
|
|
||||||
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 {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user