mirror of
https://github.com/sensebox/blockly-app
synced 2025-07-03 11:30:23 +02:00
updated provider to get sketch
This commit is contained in:
parent
457a3b7711
commit
1089bb0126
5 changed files with 33 additions and 17 deletions
|
@ -17,6 +17,7 @@ import { SensorDetailPage } from '../pages/sensor-detail/sensor-detail';
|
||||||
import { MySenseBoxPage } from '../pages/my-sense-box/my-sense-box';
|
import { MySenseBoxPage } from '../pages/my-sense-box/my-sense-box';
|
||||||
import { LoginProvider } from '../providers/LoginProvider/LoginProvider';
|
import { LoginProvider } from '../providers/LoginProvider/LoginProvider';
|
||||||
import { SensorsPage } from '../pages/sensors/sensors';
|
import { SensorsPage } from '../pages/sensors/sensors';
|
||||||
|
import { ConfigurationPage } from '../pages/configuration/configuration';
|
||||||
|
|
||||||
// For AoT compilation (production builds) we need to have a factory for the loader of translation files.
|
// For AoT compilation (production builds) we need to have a factory for the loader of translation files.
|
||||||
// @TODO: we possibly could optimize this by using a static loader in combination with webpack:
|
// @TODO: we possibly could optimize this by using a static loader in combination with webpack:
|
||||||
|
@ -31,7 +32,8 @@ export function createTranslateLoader(http: HttpClient) {
|
||||||
AddItemPage,
|
AddItemPage,
|
||||||
SensorDetailPage,
|
SensorDetailPage,
|
||||||
MySenseBoxPage,
|
MySenseBoxPage,
|
||||||
SensorsPage
|
SensorsPage,
|
||||||
|
ConfigurationPage
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
|
@ -53,7 +55,9 @@ export function createTranslateLoader(http: HttpClient) {
|
||||||
AddItemPage,
|
AddItemPage,
|
||||||
SensorDetailPage,
|
SensorDetailPage,
|
||||||
MySenseBoxPage,
|
MySenseBoxPage,
|
||||||
SensorsPage
|
SensorsPage,
|
||||||
|
ConfigurationPage
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -35,7 +35,7 @@ export class LoginPage {
|
||||||
catch(err){
|
catch(err){
|
||||||
console.log(err.message)
|
console.log(err.message)
|
||||||
}
|
}
|
||||||
this.navCtrl.push(MySenseBoxPage,this.boxes);
|
this.navCtrl.push(MySenseBoxPage,[this.boxes,this.token]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ionViewDidLoad() {
|
ionViewDidLoad() {
|
||||||
|
|
|
@ -31,13 +31,10 @@
|
||||||
ID: <code>{{box._id}}</code>
|
ID: <code>{{box._id}}</code>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col col-4>
|
<ion-col col-6>
|
||||||
<button class="actionButton" ion-button color="light"(click)="forwardShow(box)">Show</button>
|
<button class="actionButton" ion-button color="light"(click)="forwardShow(box)">Show</button>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col col-4>
|
<ion-col col-6>
|
||||||
<button class="actionButton" ion-button color="light" (click)="forwardEdit(box)">Edit</button>
|
|
||||||
</ion-col>
|
|
||||||
<ion-col col-4>
|
|
||||||
<button class="actionButton" ion-button color="light" (click)="forwardSketch(box)">Sketch</button>
|
<button class="actionButton" ion-button color="light" (click)="forwardSketch(box)">Sketch</button>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Component } from '@angular/core';
|
||||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||||
import {LoginProvider} from "../../providers/LoginProvider/LoginProvider";
|
import {LoginProvider} from "../../providers/LoginProvider/LoginProvider";
|
||||||
import { SensorsPage } from '../sensors/sensors';
|
import { SensorsPage } from '../sensors/sensors';
|
||||||
|
import { ConfigurationPage } from '../configuration/configuration';
|
||||||
/**
|
/**
|
||||||
* Generated class for the MySenseBoxPage page.
|
* Generated class for the MySenseBoxPage page.
|
||||||
*
|
*
|
||||||
|
@ -15,8 +16,8 @@ import { SensorsPage } from '../sensors/sensors';
|
||||||
templateUrl: 'my-sense-box.html',
|
templateUrl: 'my-sense-box.html',
|
||||||
})
|
})
|
||||||
export class MySenseBoxPage {
|
export class MySenseBoxPage {
|
||||||
token:string;
|
public boxes:Array<Object> = this.navParams.data[0].data.boxes;
|
||||||
public boxes:Array<any>;
|
private token:string = this.navParams.data[1];
|
||||||
constructor(public navCtrl: NavController,
|
constructor(public navCtrl: NavController,
|
||||||
public navParams: NavParams,
|
public navParams: NavParams,
|
||||||
private loginProvider: LoginProvider
|
private loginProvider: LoginProvider
|
||||||
|
@ -26,18 +27,14 @@ export class MySenseBoxPage {
|
||||||
forwardShow(box){
|
forwardShow(box){
|
||||||
this.navCtrl.push(SensorsPage,box)
|
this.navCtrl.push(SensorsPage,box)
|
||||||
}
|
}
|
||||||
|
|
||||||
forwardEdit(box){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
forwardSketch(box){
|
forwardSketch(box){
|
||||||
|
// Call sketch
|
||||||
|
// forward to config page
|
||||||
|
this.navCtrl.push(ConfigurationPage,box)
|
||||||
}
|
}
|
||||||
|
|
||||||
ionViewDidLoad() {
|
ionViewDidLoad() {
|
||||||
console.log('ionViewDidLoad MySenseBoxPage');
|
console.log('ionViewDidLoad MySenseBoxPage');
|
||||||
this.boxes = this.navParams.data.data.boxes
|
|
||||||
console.log(this.boxes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { timeout } from 'rxjs/operators'
|
import { timeout } from 'rxjs/operators'
|
||||||
const URL_login = 'https://api.opensensemap.org/users/sign-in';
|
const URL_login = 'https://api.opensensemap.org/users/sign-in';
|
||||||
const URL_user = 'https://api.opensensemap.org/users/me/boxes';
|
const URL_user = 'https://api.opensensemap.org/users/me/boxes';
|
||||||
|
const URL_sketch = 'https://api.opensensemap.org/boxes/';
|
||||||
|
|
||||||
// const URL = "http://compiler.snsbx.nroo.de"
|
// const URL = "http://compiler.snsbx.nroo.de"
|
||||||
|
|
||||||
|
@ -54,4 +55,21 @@ export class LoginProvider {
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getUserSketch(token:string,id:string):Promise<string>{
|
||||||
|
let URL_sketch_final = URL_sketch+id+"/script";
|
||||||
|
console.log(URL_sketch_final)
|
||||||
|
const headers = new HttpHeaders({'Authorization':"Bearer "+token,responseType:'text'})
|
||||||
|
return this.http.get(URL_sketch_final,{headers})
|
||||||
|
.pipe(timeout(30000))
|
||||||
|
.toPromise()
|
||||||
|
.catch(err=>{
|
||||||
|
let msg = err.message;
|
||||||
|
console.log(msg);
|
||||||
|
})
|
||||||
|
.then((response:any)=>{
|
||||||
|
console.log(response);
|
||||||
|
return response
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue