Feat: expose 8002 port on docker ups_predictor service

Feat: added label that shows prediction values in datagetherer index.html
This commit is contained in:
Lorenzo Iovino 2019-11-07 09:15:11 +01:00
parent ae093c0f26
commit 74c96c620d
6 changed files with 56 additions and 21 deletions

View file

@ -1,5 +1,17 @@
<html>
<head>
<script>
UPS_CONFIGS = {
gatherer_ws_url: 'localhost:8001',
predictor_ws_url: 'localhost:8002/predict'
}
</script>
<style>
#prediction {
position: absolute;
bottom: 0;
}
</style>
<script src="../dist/bundle.js"></script>
<script>
/* const interval = setInterval(() => {
@ -16,6 +28,8 @@
</script>
</head>
<body>
<div id="prediction"> Prediction = <div id="prediction_value"></div></div>
<button>ciao</button>
<div id="1" style="width: 50px; height: 70px; background-color:red; position: absolute; top: 20px; left: 100px;"></div>
<div id="2" style="width: 30px; height: 500px; background-color:blue; position: absolute; top: 465px; left: 33px;"></div>

View file

@ -6,6 +6,12 @@
predictor_ws_url: 'localhost:8002/predict'
}
</script>
<style>
#prediction {
position: absolute;
bottom: 0;
}
</style>
<script src="bundle.js"></script>
<script>
/* const interval = setInterval(() => {
@ -22,6 +28,8 @@
</script>
</head>
<body>
<div id="prediction"> Prediction = <div id="prediction_value"></div></div>
<button>ciao</button>
<div id="1" style="width: 50px; height: 70px; background-color:red; position: absolute; top: 20px; left: 100px;"></div>
<div id="2" style="width: 30px; height: 500px; background-color:blue; position: absolute; top: 465px; left: 33px;"></div>

View file

@ -14,7 +14,7 @@ function main() {
]);
//startPrediction(gatherer);
startPrediction(humanGatherer);
// startGathering([humanGatherer, botGatherer]);
startGathering([humanGatherer])
}
@ -30,11 +30,15 @@ function getAgentName() {
}
function startPrediction(gatherer: Gatherer) {
const sender: Sender = new Sender(() => gatherer.getData(), UPS_CONFIGS.gatherer_ws_url,10000);
const sender: Sender = new Sender(() => gatherer.getData(), UPS_CONFIGS.predictor_ws_url,2000);
sender.start('http')
.subscribe(
val => {
console.log(val);
if (val) {
const max = Math.max(...val);
const maxIndex = val.indexOf(max.toString());
document.getElementById("prediction_value").innerText = val + '\n Stato probabile: ' + maxIndex;
}
}
);
}
@ -48,7 +52,6 @@ function startGathering(gatherers: Array<Gatherer>) {
sender.start('ws')
.subscribe(
val => {
console.log(val);
}
);
}