From 8c00e7eeec749972d444c96a122a615d6e87eec7 Mon Sep 17 00:00:00 2001 From: Thiemann96 Date: Thu, 5 Mar 2020 14:07:36 +0100 Subject: [PATCH] updated sensor detail and removed startup errors --- src/app/app.component.ts | 5 --- src/app/app.module.ts | 2 -- src/pages/configuration/configuration.ts | 5 ++- src/pages/login/login.html | 3 ++ src/pages/login/login.module.ts | 2 ++ src/pages/login/login.ts | 34 ++++++++++++-------- src/pages/sensor-detail/sensor-detail.html | 14 ++++++-- src/pages/sensor-detail/sensor-detail.ts | 9 ++---- src/providers/LoginProvider/LoginProvider.ts | 7 +--- 9 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 77ffa2e..1045b96 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -40,11 +40,6 @@ export class openSenseApp { icon: 'settings', component: 'SettingsPage' }, - { - title: 'MENU.CONFIGURATION', - icon: 'settings', - component: 'ConfigurationPage' - }, { title: 'MENU.MYSENSEBOX', icon: "settings", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1e4225d..43be734 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -57,8 +57,6 @@ export function createTranslateLoader(http: HttpClient) { MySenseBoxPage, SensorsPage, ConfigurationPage - - ], providers: [ StatusBar, diff --git a/src/pages/configuration/configuration.ts b/src/pages/configuration/configuration.ts index ecbc2c0..dc7eacc 100644 --- a/src/pages/configuration/configuration.ts +++ b/src/pages/configuration/configuration.ts @@ -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}) } diff --git a/src/pages/login/login.html b/src/pages/login/login.html index e9c8ade..186557f 100644 --- a/src/pages/login/login.html +++ b/src/pages/login/login.html @@ -32,6 +32,9 @@ + + {{'LOGIN.ERRORINPUT' | translate}} + diff --git a/src/pages/login/login.module.ts b/src/pages/login/login.module.ts index ca073ba..5e60e29 100644 --- a/src/pages/login/login.module.ts +++ b/src/pages/login/login.module.ts @@ -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 {} diff --git a/src/pages/login/login.ts b/src/pages/login/login.ts index 7a7fb83..65e1cf1 100644 --- a/src/pages/login/login.ts +++ b/src/pages/login/login.ts @@ -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. @@ -14,32 +14,40 @@ import { LoginProvider } from "../../providers/LoginProvider/LoginProvider" selector: 'page-login', templateUrl: 'login.html', }) -export class LoginPage { +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, private loginProvider: LoginProvider - ) { + ) { } - private async submitLogin(form){ - try { - this.token = await this.loginProvider.login(form.value.email,form.value.password) - this.boxes = await this.loginProvider.getUserBoxes(this.token); + 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.boxes = await this.loginProvider.getUserBoxes(this.token); + } + catch (err) { + console.log(err.message) + } + this.navCtrl.push(MySenseBoxPage, [this.boxes, this.token]); } - catch(err){ - console.log(err.message) + else { + this.errorInput = true; } - this.navCtrl.push(MySenseBoxPage,[this.boxes,this.token]); } ionViewDidLoad() { console.log('ionViewDidLoad LoginPage'); + } } diff --git a/src/pages/sensor-detail/sensor-detail.html b/src/pages/sensor-detail/sensor-detail.html index 0352ed7..e96923b 100644 --- a/src/pages/sensor-detail/sensor-detail.html +++ b/src/pages/sensor-detail/sensor-detail.html @@ -1,7 +1,7 @@ - {{title}} + {{sensor.title}} @@ -9,8 +9,16 @@ - Type: {{type}}
- ID: {{id}} +
    +
  • {{sensor.title}}
  • +
  • {{sensor.unit}}
  • +
  • {{sensor.sensorType}}
  • +
  • {{sensor.icon}}
  • +
  • {{sensor._id}}
  • +
  • {{sensor.lastMeasurement.value}}
  • +
  • {{sensor.lastMeasurement.createdAt}}
  • +
+
\ No newline at end of file diff --git a/src/pages/sensor-detail/sensor-detail.ts b/src/pages/sensor-detail/sensor-detail.ts index cb533f7..21a3341 100644 --- a/src/pages/sensor-detail/sensor-detail.ts +++ b/src/pages/sensor-detail/sensor-detail.ts @@ -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) } } diff --git a/src/providers/LoginProvider/LoginProvider.ts b/src/providers/LoginProvider/LoginProvider.ts index 11a2459..2a761bc 100644 --- a/src/providers/LoginProvider/LoginProvider.ts +++ b/src/providers/LoginProvider/LoginProvider.ts @@ -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=>{