mirror of
https://github.com/sensebox/blockly-app
synced 2025-07-04 04:30:21 +02:00
updated sensor detail and removed startup errors
This commit is contained in:
parent
40718824b3
commit
8c00e7eeec
9 changed files with 44 additions and 37 deletions
|
@ -40,11 +40,6 @@ export class openSenseApp {
|
|||
icon: 'settings',
|
||||
component: 'SettingsPage'
|
||||
},
|
||||
{
|
||||
title: 'MENU.CONFIGURATION',
|
||||
icon: 'settings',
|
||||
component: 'ConfigurationPage'
|
||||
},
|
||||
{
|
||||
title: 'MENU.MYSENSEBOX',
|
||||
icon: "settings",
|
||||
|
|
|
@ -57,8 +57,6 @@ export function createTranslateLoader(http: HttpClient) {
|
|||
MySenseBoxPage,
|
||||
SensorsPage,
|
||||
ConfigurationPage
|
||||
|
||||
|
||||
],
|
||||
providers: [
|
||||
StatusBar,
|
||||
|
|
|
@ -17,7 +17,10 @@ import { LoginProvider } from "../../providers/LoginProvider/LoginProvider"
|
|||
selector: 'page-configuration',
|
||||
templateUrl: 'configuration.html',
|
||||
})
|
||||
|
||||
|
||||
export class ConfigurationPage {
|
||||
|
||||
public sensors = [];
|
||||
ssid:string;
|
||||
pw:string;
|
||||
|
@ -44,7 +47,7 @@ export class ConfigurationPage {
|
|||
return returnValue;
|
||||
}
|
||||
async uploadStandardSketch() {
|
||||
const sketch = await this.loginProvider.getUserSketch(this.token,this.box._id,this.ssid,this.pw)
|
||||
const sketch = await this.loginProvider.getUserSketch(this.token,this.box['_id'],this.ssid,this.pw)
|
||||
this.navCtrl.push(OtaWizardPage,{sketch})
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
<ion-input name="password" type="password" placeholder="Password" ngModel required></ion-input>
|
||||
</ion-item>
|
||||
</ion-row>
|
||||
<ion-row class="errorMessage" *ngIf="errorInput">
|
||||
{{'LOGIN.ERRORINPUT' | translate}}
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col col-8>
|
||||
</ion-col>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from 'ionic-angular';
|
||||
import { LoginPage } from './login';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -8,6 +9,7 @@ import { LoginPage } from './login';
|
|||
],
|
||||
imports: [
|
||||
IonicPageModule.forChild(LoginPage),
|
||||
TranslateModule
|
||||
],
|
||||
})
|
||||
export class LoginPageModule {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import {MySenseBoxPage} from "../my-sense-box/my-sense-box"
|
||||
import { MySenseBoxPage } from "../my-sense-box/my-sense-box"
|
||||
import { LoginProvider } from "../../providers/LoginProvider/LoginProvider"
|
||||
/**
|
||||
* Generated class for the LoginPage page.
|
||||
|
@ -17,9 +17,11 @@ import { LoginProvider } from "../../providers/LoginProvider/LoginProvider"
|
|||
export class LoginPage {
|
||||
userName: string;
|
||||
password: string;
|
||||
private token:string
|
||||
private boxes:Object;
|
||||
public loading=false;
|
||||
private token: string
|
||||
private boxes: Object;
|
||||
public loading = false;
|
||||
public errorInput = false;
|
||||
|
||||
constructor(
|
||||
public navCtrl: NavController,
|
||||
public navParams: NavParams,
|
||||
|
@ -27,19 +29,25 @@ export class LoginPage {
|
|||
) {
|
||||
}
|
||||
|
||||
private async submitLogin(form){
|
||||
private async submitLogin(form) {
|
||||
if (form.value.email && form.value.password) {
|
||||
try {
|
||||
this.token = await this.loginProvider.login(form.value.email,form.value.password)
|
||||
this.token = await this.loginProvider.login(form.value.email, form.value.password)
|
||||
this.boxes = await this.loginProvider.getUserBoxes(this.token);
|
||||
}
|
||||
catch(err){
|
||||
catch (err) {
|
||||
console.log(err.message)
|
||||
}
|
||||
this.navCtrl.push(MySenseBoxPage,[this.boxes,this.token]);
|
||||
this.navCtrl.push(MySenseBoxPage, [this.boxes, this.token]);
|
||||
}
|
||||
else {
|
||||
this.errorInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad LoginPage');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<ion-header>
|
||||
<ion-navbar color="secondary">
|
||||
<ion-title>
|
||||
{{title}}
|
||||
{{sensor.title}}
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
|
@ -9,8 +9,16 @@
|
|||
<ion-content>
|
||||
<ion-card>
|
||||
<ion-card-content>
|
||||
Type: {{type}}<br>
|
||||
ID: {{id}}
|
||||
<ul>
|
||||
<li>{{sensor.title}}</li>
|
||||
<li>{{sensor.unit}}</li>
|
||||
<li>{{sensor.sensorType}}</li>
|
||||
<li>{{sensor.icon}}</li>
|
||||
<li>{{sensor._id}}</li>
|
||||
<li>{{sensor.lastMeasurement.value}}</li>
|
||||
<li>{{sensor.lastMeasurement.createdAt}}</li>
|
||||
</ul>
|
||||
</ion-card-content>
|
||||
|
||||
</ion-card>
|
||||
</ion-content>
|
|
@ -15,18 +15,13 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
|||
})
|
||||
export class SensorDetailPage {
|
||||
|
||||
title;
|
||||
type;
|
||||
id;
|
||||
|
||||
public sensor:Object=this.navParams.data.sensor
|
||||
constructor(public navParams: NavParams) {
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad SensorDetailPage');
|
||||
this.title=this.navParams.get('sensor').title;
|
||||
this.type = this.navParams.get('sensor').type;
|
||||
this.id = this.navParams.get('sensor').id;
|
||||
console.log(this.navParams.data.sensor)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,12 +60,7 @@ export class LoginProvider {
|
|||
let URL_sketch_final = URL_sketch+id+"/script";
|
||||
const headers = new HttpHeaders({'Authorization':"Bearer "+token})
|
||||
const params = new HttpParams({fromObject:{ssid,password}})
|
||||
const options = {
|
||||
headers,
|
||||
params,
|
||||
'responseType':'text'
|
||||
}
|
||||
return this.http.get(URL_sketch_final,options)
|
||||
return this.http.get(URL_sketch_final,{headers,params,responseType:'text'})
|
||||
.pipe(timeout(30000))
|
||||
.toPromise()
|
||||
.catch(err=>{
|
||||
|
|
Loading…
Add table
Reference in a new issue