mirror of
https://github.com/sensebox/blockly-app
synced 2025-06-09 03:05:51 +02:00
Added error messages
This commit is contained in:
parent
ce3216c159
commit
8fa93adf37
4 changed files with 49 additions and 26 deletions
|
@ -11,8 +11,8 @@
|
||||||
<ion-row>
|
<ion-row>
|
||||||
There was an error when trying to login. The error code is:<code>{{error.message}}</code>.
|
There was an error when trying to login. The error code is:<code>{{error.message}}</code>.
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row class="errorMessage">
|
||||||
<p> {{errorMessages[error.message]}} </p>
|
<p > {{errorMessages[error.message]}} </p>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col col-8>
|
<ion-col col-8>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
page-error {
|
page-error {
|
||||||
|
font-size:2.5rem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ page-ota-wizard {
|
||||||
color:lightslategray;
|
color:lightslategray;
|
||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-slide {
|
ion-slide {
|
||||||
h4 {
|
h4 {
|
||||||
margin-bottom: 40px;
|
margin-bottom: 40px;
|
||||||
|
|
|
@ -10,6 +10,8 @@ import {
|
||||||
Slides,
|
Slides,
|
||||||
NavController,
|
NavController,
|
||||||
NavParams,
|
NavParams,
|
||||||
|
ModalController,
|
||||||
|
LoadingController,
|
||||||
} from 'ionic-angular'
|
} from 'ionic-angular'
|
||||||
import { Network } from '@ionic-native/network'
|
import { Network } from '@ionic-native/network'
|
||||||
import { Subscription } from 'rxjs/Subscription';
|
import { Subscription } from 'rxjs/Subscription';
|
||||||
|
@ -17,7 +19,7 @@ import { Subscription } from 'rxjs/Subscription';
|
||||||
import { OtaWifiProvider, WifiStrategy } from '../../providers/ota-wifi/ota-wifi';
|
import { OtaWifiProvider, WifiStrategy } from '../../providers/ota-wifi/ota-wifi';
|
||||||
import { CompilerProvider } from '../../providers/compiler/compiler';
|
import { CompilerProvider } from '../../providers/compiler/compiler';
|
||||||
import { LoggingProvider } from '../../providers/logging/logging';
|
import { LoggingProvider } from '../../providers/logging/logging';
|
||||||
|
import {ErrorPage} from '../../pages/error/error'
|
||||||
@IonicPage()
|
@IonicPage()
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-ota-wizard',
|
selector: 'page-ota-wizard',
|
||||||
|
@ -57,8 +59,10 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
private navCtrl: NavController,
|
private navCtrl: NavController,
|
||||||
private webcompiler: CompilerProvider,
|
private webcompiler: CompilerProvider,
|
||||||
private changedetect: ChangeDetectorRef,
|
private changedetect: ChangeDetectorRef,
|
||||||
|
public loadingController: LoadingController,
|
||||||
|
public modalCtrl: ModalController,
|
||||||
logger: LoggingProvider,
|
logger: LoggingProvider,
|
||||||
navParams : NavParams,
|
navParams: NavParams,
|
||||||
) {
|
) {
|
||||||
// for OTA to work, the new sketch has to include the OTA logic as well.
|
// for OTA to work, the new sketch has to include the OTA logic as well.
|
||||||
// to ensure that, we're prepending it here to the sketch.
|
// to ensure that, we're prepending it here to the sketch.
|
||||||
|
@ -108,55 +112,72 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
this.log.debug('initialized')
|
this.log.debug('initialized')
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy () {
|
ngOnDestroy() {
|
||||||
this.onlineSub.unsubscribe()
|
this.onlineSub.unsubscribe()
|
||||||
this.offlineSub.unsubscribe()
|
this.offlineSub.unsubscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
onWifiRefresh () {
|
onWifiRefresh() {
|
||||||
this.handleWifiSelection(true)
|
this.handleWifiSelection(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose () {
|
onClose() {
|
||||||
this.navCtrl.pop()
|
this.navCtrl.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleManual(){
|
toggleManual() {
|
||||||
if(this.modus === "manual"){
|
if (this.modus === "manual") {
|
||||||
this.modus = "automatic"
|
this.modus = "automatic"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.modus = "manual"
|
this.modus = "manual"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showAutomatic(){
|
showAutomatic() {
|
||||||
this.automatic = true;
|
this.automatic = true;
|
||||||
this.manual = false;
|
this.manual = false;
|
||||||
this.slides.slideNext()
|
this.slides.slideNext()
|
||||||
}
|
}
|
||||||
|
|
||||||
showManual(){
|
showManual() {
|
||||||
this.manual = true;
|
this.manual = true;
|
||||||
this.automatic = false;
|
this.automatic = false;
|
||||||
this.slides.slideNext()
|
this.slides.slideNext()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async makeRequest(){
|
|
||||||
|
|
||||||
try{
|
showModal(message){
|
||||||
|
let modal = this.modalCtrl.create(ErrorPage,message);
|
||||||
|
|
||||||
|
modal.onDidDismiss(()=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
modal.present();
|
||||||
|
}
|
||||||
|
|
||||||
|
async makeRequest() {
|
||||||
|
const loading = await this.loadingController.create({
|
||||||
|
content: 'Pinging senseBox...'
|
||||||
|
});
|
||||||
|
try {
|
||||||
// open modal that shows loading
|
// open modal that shows loading
|
||||||
|
|
||||||
|
loading.present();
|
||||||
await this.otaWifi.activateOtaMode();
|
await this.otaWifi.activateOtaMode();
|
||||||
this.requestSuccessful = true;
|
this.requestSuccessful = true;
|
||||||
}
|
}
|
||||||
catch(err){
|
catch (err) {
|
||||||
|
this.showModal(err);
|
||||||
console.log(err)
|
console.log(err)
|
||||||
}
|
}
|
||||||
|
loading.dismiss();
|
||||||
// Sends request; upon successful response go to next slide (wifi selection)
|
// Sends request; upon successful response go to next slide (wifi selection)
|
||||||
|
|
||||||
}
|
}
|
||||||
// call logic for each slide
|
// call logic for each slide
|
||||||
onSlideChange () {
|
onSlideChange() {
|
||||||
this.slideHistory.push(OtaSlides[this.currentSlide])
|
this.slideHistory.push(OtaSlides[this.currentSlide])
|
||||||
console.log(this.currentSlide)
|
console.log(this.currentSlide)
|
||||||
switch (this.currentSlide) {
|
switch (this.currentSlide) {
|
||||||
|
@ -182,24 +203,24 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentSlide (): OtaSlides {
|
get currentSlide(): OtaSlides {
|
||||||
const current = this.slides.getActiveIndex()
|
const current = this.slides.getActiveIndex()
|
||||||
const hiddenOffset = this.hiddenSlides.filter(slide => slide <= current).length
|
const hiddenOffset = this.hiddenSlides.filter(slide => slide <= current).length
|
||||||
return current + hiddenOffset
|
return current + hiddenOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
slideIsHidden (slide: OtaSlides): boolean {
|
slideIsHidden(slide: OtaSlides): boolean {
|
||||||
return this.hiddenSlides.indexOf(slide) !== -1
|
return this.hiddenSlides.indexOf(slide) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
private hideSlide (slide: OtaSlides) {
|
private hideSlide(slide: OtaSlides) {
|
||||||
if (this.currentSlide === slide) return
|
if (this.currentSlide === slide) return
|
||||||
if (this.slideIsHidden(slide)) return
|
if (this.slideIsHidden(slide)) return
|
||||||
this.hiddenSlides.push(slide)
|
this.hiddenSlides.push(slide)
|
||||||
this.slides.update()
|
this.slides.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
async connectToSensebox (ssid: string) {
|
async connectToSensebox(ssid: string) {
|
||||||
this.counts.connect++
|
this.counts.connect++
|
||||||
this.state.wifiSelection = 'connecting'
|
this.state.wifiSelection = 'connecting'
|
||||||
try {
|
try {
|
||||||
|
@ -214,14 +235,14 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleCompilation () {
|
private handleCompilation() {
|
||||||
this.slides.lockSwipeToNext(!this.compiledSketch)
|
this.slides.lockSwipeToNext(!this.compiledSketch)
|
||||||
|
|
||||||
// need to go online for compilation. compilation is retriggered via this.onlineSub
|
// need to go online for compilation. compilation is retriggered via this.onlineSub
|
||||||
if (!this.state.isOnline) {
|
if (!this.state.isOnline) {
|
||||||
switch (this.otaWifi.strategy) {
|
switch (this.otaWifi.strategy) {
|
||||||
case WifiStrategy.Automatic:
|
case WifiStrategy.Automatic:
|
||||||
// TODO: auto connect to previous network, if available
|
// TODO: auto connect to previous network, if available
|
||||||
default:
|
default:
|
||||||
this.state.compilation = 'go-online'
|
this.state.compilation = 'go-online'
|
||||||
break
|
break
|
||||||
|
@ -231,7 +252,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleWifiSelection (force = false) {
|
private async handleWifiSelection(force = false) {
|
||||||
if (this.otaWifi.strategy === WifiStrategy.Automatic) {
|
if (this.otaWifi.strategy === WifiStrategy.Automatic) {
|
||||||
this.slides.lockSwipeToNext(true)
|
this.slides.lockSwipeToNext(true)
|
||||||
|
|
||||||
|
@ -255,7 +276,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleUpload () {
|
private async handleUpload() {
|
||||||
this.counts.upload++
|
this.counts.upload++
|
||||||
this.state.upload = 'uploading'
|
this.state.upload = 'uploading'
|
||||||
try {
|
try {
|
||||||
|
@ -271,7 +292,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async compileSketch () {
|
private async compileSketch() {
|
||||||
this.counts.compile++
|
this.counts.compile++
|
||||||
this.state.compilation = 'compiling'
|
this.state.compilation = 'compiling'
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue