Skip to content

Commit 075881d

Browse files
author
Alexander Geist
committed
ui changes
1 parent f21df7a commit 075881d

File tree

7 files changed

+105
-40
lines changed

7 files changed

+105
-40
lines changed

multibanking-app/src/pages/analytics/analytics.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ion-navbar>
33
<ion-title>Analytics {{ analytics?.analyticsDate | date }}</ion-title>
44
<ion-buttons end>
5-
<button ion-button (click)="syncBookingsPromptPin()">
5+
<button ion-button (click)="syncBookings()">
66
Reload
77
</button>
88
<button ion-button (click)="showBookings()">

multibanking-app/src/pages/analytics/analytics.ts

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {Component} from '@angular/core';
2-
import {NavController, AlertController} from 'ionic-angular';
3-
import {NavParams} from 'ionic-angular';
4-
import {BookingService} from "../../services/bookingService";
1+
import {Component} from "@angular/core";
2+
import {NavController, AlertController, ToastController, NavParams} from "ionic-angular";
53
import {BookingListPage} from "../booking/bookingList";
64
import {BankAccountService} from "../../services/bankAccountService";
75
import {AnalyticsService} from "../../services/analyticsService";
@@ -18,8 +16,13 @@ export class AnalyticsPage {
1816
bankAccountId;
1917
bookings;
2018

21-
constructor(public navCtrl: NavController, private navparams: NavParams, private alertCtrl: AlertController,
22-
private bankAccountService: BankAccountService, private bookingService: BookingService, private analyticsService: AnalyticsService) {
19+
constructor(public navCtrl: NavController,
20+
private navparams: NavParams,
21+
private alertCtrl: AlertController,
22+
private toastCtrl: ToastController,
23+
private bankAccountService: BankAccountService,
24+
private analyticsService: AnalyticsService) {
25+
2326
this.userId = navparams.data.userId;
2427
this.bankAccessId = navparams.data.bankAccessId;
2528
this.bankAccountId = navparams.data.bankAccountId;
@@ -31,9 +34,19 @@ export class AnalyticsPage {
3134
}
3235

3336
loadAnalytics() {
34-
this.analyticsService.getAnalytics(this.userId, this.bankAccessId, this.bankAccountId).subscribe(response => {
35-
this.analytics = response;
36-
})
37+
this.analyticsService.getAnalytics(this.userId, this.bankAccessId, this.bankAccountId).subscribe(
38+
response => {
39+
this.analytics = response;
40+
},
41+
error => {
42+
if (error == "SYNC_IN_PROGRESS") {
43+
this.toastCtrl.create({
44+
message: 'Account sync in progress',
45+
showCloseButton: true,
46+
position: 'top'
47+
}).present();
48+
}
49+
})
3750
}
3851

3952
syncBookingsPromptPin() {
@@ -65,9 +78,19 @@ export class AnalyticsPage {
6578
}
6679

6780
syncBookings(pin) {
68-
this.bankAccountService.syncBookings(this.userId, this.bankAccessId, this.bankAccountId, pin).subscribe(response => {
69-
this.bookings = response;
70-
})
81+
this.bankAccountService.syncBookings(this.userId, this.bankAccessId, this.bankAccountId, pin).subscribe(
82+
response => {
83+
this.bookings = response;
84+
},
85+
error => {
86+
if (error == "SYNC_IN_PROGRESS") {
87+
this.toastCtrl.create({
88+
message: 'Account sync in progress',
89+
showCloseButton: true,
90+
position: 'top'
91+
}).present();
92+
}
93+
})
7194
}
7295

7396
showBookings() {

multibanking-app/src/pages/booking/bookingList.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ion-navbar>
33
<ion-title>Bookings</ion-title>
44
<ion-buttons end>
5-
<button ion-button (click)="syncBookingsPromptPin()">
5+
<button ion-button (click)="syncBookings()">
66
Reload
77
</button>
88
</ion-buttons>
@@ -14,8 +14,8 @@
1414
<ion-item *ngFor="let booking of bookings" (click)="itemSelected(booking)">
1515
<h3>{{ booking.bookingDate | date }}</h3>
1616
<h2>{{ booking.otherAccount !=null ? booking.otherAccount.nameHbciAccount : ""}}</h2>
17-
<h3 *ngIf="booking.category">{{ booking.category.mainCategory}}</h3>
18-
<h3 *ngIf="booking.category">{{ booking.category.specification}}</h3>
17+
<h3 *ngIf="booking.bookingCategory">{{ booking.bookingCategory.mainCategory}}</h3>
18+
<h3 *ngIf="booking.bookingCategory">{{ booking.bookingCategory.subCategory}}</h3>
1919
<h2 item-right>{{ booking.amount | currency:'EUR':true }}</h2>
2020
</ion-item>
2121
</ion-list>

multibanking-app/src/pages/booking/bookingList.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {NavController, AlertController} from 'ionic-angular';
2+
import {NavController, AlertController, ToastController} from 'ionic-angular';
33
import {NavParams} from 'ionic-angular';
44
import {BankAccountService} from "../../services/bankAccountService";
55
import {BookingService} from "../../services/bookingService";
@@ -15,8 +15,13 @@ export class BookingListPage {
1515
bankAccountId;
1616
bookings;
1717

18-
constructor(public navCtrl: NavController, private navparams: NavParams, private alertCtrl: AlertController,
19-
private bankAccountService: BankAccountService, private bookingService: BookingService) {
18+
constructor(public navCtrl: NavController,
19+
private navparams: NavParams,
20+
private alertCtrl: AlertController,
21+
private toastCtrl: ToastController,
22+
private bankAccountService: BankAccountService,
23+
private bookingService: BookingService) {
24+
2025
this.userId = navparams.data.userId;
2126
this.bankAccessId = navparams.data.bankAccessId;
2227
this.bankAccountId = navparams.data.bankAccountId;
@@ -57,9 +62,19 @@ export class BookingListPage {
5762
}
5863

5964
syncBookings(pin) {
60-
this.bankAccountService.syncBookings(this.userId, this.bankAccessId, this.bankAccountId, pin).subscribe(response => {
61-
this.bookings = response;
62-
})
65+
this.bankAccountService.syncBookings(this.userId, this.bankAccessId, this.bankAccountId, pin).subscribe(
66+
response => {
67+
this.bookings = response;
68+
},
69+
error => {
70+
if (error == "SYNC_IN_PROGRESS") {
71+
this.toastCtrl.create({
72+
message: 'Account sync in progress',
73+
showCloseButton: true,
74+
position: 'top'
75+
}).present();
76+
}
77+
})
6378
}
6479

6580
itemSelected(booking) {

multibanking-app/src/services/BankAccountService.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ export class BankAccountService {
2424
.map((res: Response) => {
2525
this.bookingsChangedObservable.next(true);
2626

27-
res.json()._embedded != null ? res.json()._embedded.bookingEntityList : []
27+
return res.json()._embedded != null ? res.json()._embedded.bookingEntityList : []
2828
})
2929
.catch(this.handleError);
3030
}
3131

32-
handleError(error) {
32+
handleError(error): Observable<any> {
3333
console.error(error);
34-
return Observable.throw(error.json().error || 'Server error');
34+
let errorJson = error.json();
35+
if (errorJson) {
36+
if (errorJson.message == "SYNC_IN_PROGRESS") {
37+
return Observable.throw(errorJson.message);
38+
} else {
39+
return Observable.throw(errorJson || 'Server error');
40+
}
41+
} else {
42+
return Observable.throw(error || 'Server error');
43+
}
3544
}
3645

3746

multibanking-app/src/services/BookingService.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ export class BookingService {
1616
.catch(this.handleError);
1717
}
1818

19-
handleError(error) {
19+
handleError(error): Observable<any> {
2020
console.error(error);
21-
return Observable.throw(error.json().error || 'Server error');
21+
let errorJson = error.json();
22+
if (errorJson) {
23+
if (errorJson.message == "SYNC_IN_PROGRESS") {
24+
return Observable.throw(errorJson.message);
25+
} else {
26+
return Observable.throw(errorJson || 'Server error');
27+
}
28+
} else {
29+
return Observable.throw(error || 'Server error');
30+
}
2231
}
2332

2433

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {Injectable} from '@angular/core';
2-
import {AppConfig} from '../app/app.config';
3-
import {Http, Response} from '@angular/http';
4-
import {Observable} from 'rxjs/Observable';
5-
import 'rxjs/Rx';
1+
import {Injectable} from "@angular/core";
2+
import {AppConfig} from "../app/app.config";
3+
import {Http, Response} from "@angular/http";
4+
import {Observable} from "rxjs/Observable";
5+
import "rxjs/Rx";
66

77
@Injectable()
88
export class AnalyticsService {
@@ -13,14 +13,23 @@ export class AnalyticsService {
1313
getAnalytics(userId, accessId, accountId) {
1414
return this.http.get(AppConfig.api_url + "/users/" + userId + "/bankaccesses/" + accessId + "/accounts/" + accountId + "/analytics")
1515
.map((res: Response) => res.json() != null ? res.json() : {})
16-
.catch((error: Response) => {
17-
if (error.json() && error.json().message == "RESCOURCE_NOT_FOUND") {
18-
return Observable.of({});
19-
} else {
20-
console.error(error);
21-
return Observable.throw(error.json().error || 'Server error');
22-
}
23-
});
16+
.catch(this.handleError);
17+
}
18+
19+
handleError(error): Observable<any> {
20+
console.error(error);
21+
let errorJson = error.json();
22+
if (errorJson) {
23+
if (errorJson.message == "RESCOURCE_NOT_FOUND") {
24+
return Observable.of({});
25+
} else if (errorJson.message == "SYNC_IN_PROGRESS") {
26+
return Observable.throw(errorJson.message);
27+
} else {
28+
return Observable.throw(errorJson || 'Server error');
29+
}
30+
} else {
31+
return Observable.throw(error || 'Server error');
32+
}
2433
}
2534

2635
}

0 commit comments

Comments
 (0)