@@ -5,6 +5,8 @@ import { ClienteDTO } from '../../models/cliente.dto';
5
5
import { ClienteService } from '../../services/domain/cliente.service' ;
6
6
import { API_CONFIG } from '../../config/api.config' ;
7
7
import { CameraOptions , Camera } from '@ionic-native/camera' ;
8
+ import { ImageUtilService } from '../../services/image-util.service' ;
9
+ import { DomSanitizer } from '@angular/platform-browser' ;
8
10
9
11
/**
10
12
* Generated class for the ProfilePage page.
@@ -23,13 +25,19 @@ export class ProfilePage {
23
25
cliente : ClienteDTO ;
24
26
picture : string ;
25
27
cameraOn : boolean = false ;
28
+ // profileImage: string;
29
+ profileImage ;
26
30
27
31
constructor (
28
32
public navCtrl : NavController ,
29
33
public navParams : NavParams ,
30
34
public storage : StorageService ,
31
35
public clienteService : ClienteService ,
32
- public camera : Camera ) {
36
+ public camera : Camera ,
37
+ public imageUtil : ImageUtilService ,
38
+ public sanitizer : DomSanitizer ) {
39
+
40
+ this . profileImage = 'assets/imgs/avatar-blank.png' ;
33
41
}
34
42
35
43
ionViewDidLoad ( ) {
@@ -62,9 +70,16 @@ export class ProfilePage {
62
70
. subscribe (
63
71
response => {
64
72
this . cliente . imageUrl = `${ API_CONFIG . bucketBaseUrl } /cp${ this . cliente . id } .jpg` ;
73
+ this . imageUtil . blobToDataURL ( response )
74
+ . then (
75
+ dataUrl => {
76
+ let imageUrlTemp : string = dataUrl as string ;
77
+ this . profileImage = this . sanitizer . bypassSecurityTrustUrl ( imageUrlTemp ) ;
78
+ }
79
+ ) ;
65
80
} ,
66
81
error => {
67
-
82
+ this . profileImage = 'assets/imgs/avatar-blank.png' ;
68
83
}
69
84
) ;
70
85
}
@@ -121,7 +136,8 @@ export class ProfilePage {
121
136
. subscribe (
122
137
response => {
123
138
this . picture = null ;
124
- this . loadData ( ) ;
139
+ // this.loadData();
140
+ this . getImageIfExists ( ) ;
125
141
} ,
126
142
error => {
127
143
0 commit comments