mirror of
https://github.com/sensebox/blockly-app
synced 2025-07-03 03:00:23 +02:00
id's are applied to sketch after saving
This commit is contained in:
parent
8439f7581f
commit
28baa05d78
4 changed files with 75 additions and 66 deletions
|
@ -13,7 +13,7 @@
|
|||
<ion-list>
|
||||
|
||||
<ion-item>
|
||||
<ion-label floating>Type</ion-label>
|
||||
<ion-label floating>Typ</ion-label>
|
||||
<ion-select [(ngModel)]="typ">
|
||||
<ion-option value="HDC1080">HDC1080(Air temperature & relative humidity)</ion-option>
|
||||
<ion-option value="BMP280">BMP280(Air pressure)</ion-option>
|
||||
|
@ -25,11 +25,6 @@
|
|||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label floating>Description</ion-label>
|
||||
<ion-input type="text" [(ngModel)]="type"></ion-input>
|
||||
</ion-item>
|
||||
|
||||
|
||||
<ion-item>
|
||||
<ion-label floating>Sensor ID</ion-label>
|
||||
|
|
|
@ -16,14 +16,13 @@ import { IonicPage, NavController, ViewController } from 'ionic-angular';
|
|||
export class AddItemPage {
|
||||
|
||||
title:string;
|
||||
type:string;
|
||||
typ:string;
|
||||
id:string;
|
||||
constructor(public navCtrl: NavController, public view: ViewController) {
|
||||
}
|
||||
saveSensor(){
|
||||
let newSensor = {
|
||||
title:this.title,
|
||||
type:this.type,
|
||||
typ:this.typ,
|
||||
id:this.id
|
||||
}
|
||||
this.view.dismiss(newSensor);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<ion-row *ngFor="let sensor of sensors;let i=index;let last = last;let first=first" >
|
||||
<ion-col col-8>
|
||||
<ion-item (click)="viewSensor(sensor)">
|
||||
<ion-label>{{sensor.title}} {{sensor.id}}</ion-label>
|
||||
<ion-label>{{sensor.typ}} {{sensor.id}}</ion-label>
|
||||
</ion-item>
|
||||
</ion-col>
|
||||
<ion-col *ngIf="!first" col-2>
|
||||
|
|
|
@ -46,7 +46,7 @@ export class ConfigurationPage {
|
|||
|
||||
return returnValue;
|
||||
}
|
||||
async uploadStandardSketch(){
|
||||
uploadStandardSketch() {
|
||||
var values = {
|
||||
SSID: this.ssid,
|
||||
PASSWORD: this.pw,
|
||||
|
@ -54,16 +54,31 @@ export class ConfigurationPage {
|
|||
SENSEBOX_ID: this.senseboxid,
|
||||
defineSensors: this.buildDefines(),
|
||||
NUM_SENSORS: this.sensors.length,
|
||||
TEMPERSENSOR_ID:this.temp,
|
||||
RELLUFSENSOR_ID:this.humi,
|
||||
BELEUCSENSOR_ID:this.lux,
|
||||
UVINTESENSOR_ID:this.uv,
|
||||
LUFTDRSENOSR_ID:this.pressure,
|
||||
REGENMSENSOR_ID:this.rain,
|
||||
PM10SENSOR_ID:this.pm10,
|
||||
PM25SENSOR_ID:this.pm25
|
||||
|
||||
};
|
||||
this.sensors.map((sensor)=>{
|
||||
switch (sensor.typ) {
|
||||
case "HDC1080":
|
||||
values["TEMPERSENSOR_ID"] = sensor.id
|
||||
values["RELLUFSENSOR_ID"] = sensor.id2
|
||||
break;
|
||||
case "BMP280":
|
||||
values["LUFTDRSENSOR_ID"] = sensor.id
|
||||
break;
|
||||
case "TSL45315":
|
||||
values["BELEUCSENSOR_ID"] = sensor.id
|
||||
break;
|
||||
case "VEML6070":
|
||||
values["UVINTESENSOR_ID"] = sensor.id
|
||||
break;
|
||||
case "SDS1001":
|
||||
values["PM10SENSORID"] = sensor.id
|
||||
values["PM25SENSOR_ID"] = sensor.id2
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
this.http.get("assets/templates/homev2Wifi.tpl", { responseType: "text" }).subscribe(data => {
|
||||
let sketch = this.applyTemplate(data, values);
|
||||
console.log(sketch)
|
||||
|
@ -73,7 +88,7 @@ export class ConfigurationPage {
|
|||
buildDefines() {
|
||||
let defineString = ""
|
||||
this.sensors.map((sensor) => {
|
||||
defineString+="#define "+sensor.type+"_CONNECTED\n"
|
||||
defineString += "#define " + sensor.typ + "_CONNECTED\n"
|
||||
})
|
||||
return defineString;
|
||||
}
|
||||
|
@ -109,7 +124,7 @@ export class ConfigurationPage {
|
|||
|
||||
ionViewDidLoad() {
|
||||
this.sensors = [
|
||||
{title:"Temperatur",type:"HDC1080",id:"09327523"},
|
||||
{ typ: "HDC1080", id: "5bb610bf043f3f001b6a4c55" },
|
||||
]
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue