|
@@ -15,28 +15,71 @@ import { UserProvider } from '../../providers/user/UserProvider';
|
15
|
15
|
templateUrl: 'userfeed.html',
|
16
|
16
|
})
|
17
|
17
|
export class UserfeedPage {
|
18
|
|
- //user: any;
|
19
|
|
- user= {name:'Froilanda'};
|
|
18
|
+ userName: string;
|
20
|
19
|
post= {timestamp: '3:19PM Sun August 5th 2018',message:'hello world'};
|
21
|
20
|
userid: any;
|
22
|
21
|
postArr: Array<any>;
|
|
22
|
+ data: any;
|
|
23
|
+ errorMessage: string;
|
|
24
|
+ page = 0;
|
|
25
|
+ perPage = 0;
|
|
26
|
+ totalData = 0;
|
|
27
|
+ totalPage = 0;
|
23
|
28
|
|
24
|
29
|
constructor(public navCtrl: NavController, public navParams: NavParams,
|
25
|
30
|
public UserProvider: UserProvider) {
|
26
|
31
|
//this.user.name = this.navParams.get('name');
|
27
|
32
|
this.userid = this.navParams.get('id');
|
|
33
|
+ this.userName = this.navParams.get('name');
|
|
34
|
+ this.getAllPostsByUserId();
|
28
|
35
|
}
|
29
|
36
|
|
30
|
37
|
ionViewDidLoad() {
|
31
|
38
|
console.log('ionViewDidLoad UserfeedPage');
|
|
39
|
+ this.getAllPostsByUserId();
|
32
|
40
|
}
|
33
|
41
|
|
34
|
|
- getAllPostsByUserId(){
|
35
|
|
- return this.UserProvider.getAllPostsByUserId(this.userid).subscribe(response => {
|
36
|
|
- console.log("response: " + response);
|
37
|
|
- this.postArr = response;
|
38
|
|
- console.log("postarr: " + this.postArr);
|
39
|
|
- });
|
|
42
|
+ // getAllPostsByUserId(){
|
|
43
|
+ // return this.UserProvider.getAllPostsByUserId(this.userid).subscribe(response => {
|
|
44
|
+ // console.log("response: " + response);
|
|
45
|
+ // this.postArr = response;
|
|
46
|
+ // console.log("postarr: " + this.postArr);
|
|
47
|
+ // });
|
|
48
|
+ // }
|
|
49
|
+
|
|
50
|
+ getAllPostsByUserId() {
|
|
51
|
+ this.UserProvider.getAllPostsByUserId(this.page, this.userid)
|
|
52
|
+ .subscribe(
|
|
53
|
+ res => {
|
|
54
|
+ console.log(res)
|
|
55
|
+ this.data = res;
|
|
56
|
+ this.postArr = this.data.content;
|
|
57
|
+ this.perPage = this.data.size;
|
|
58
|
+ this.totalData = this.data.totalElements;
|
|
59
|
+ this.totalPage = this.data.totalPages;
|
|
60
|
+ },
|
|
61
|
+ error => this.errorMessage = <any>error);
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ doInfinite(infiniteScroll) {
|
|
65
|
+ this.page = this.page+1;
|
|
66
|
+ setTimeout(() => {
|
|
67
|
+ this.UserProvider.getAllPostsByUserId(this.page, this.userid)
|
|
68
|
+ .subscribe(
|
|
69
|
+ res => {
|
|
70
|
+ this.data = res;
|
|
71
|
+ this.perPage = this.data.size;
|
|
72
|
+ this.totalData = this.data.totalElements;
|
|
73
|
+ this.totalPage = this.data.totalPages;
|
|
74
|
+ for(let i=0; i<this.data.content.length; i++) {
|
|
75
|
+ this.postArr.push(this.data.content[i]);
|
|
76
|
+ }
|
|
77
|
+ },
|
|
78
|
+ error => this.errorMessage = <any>error);
|
|
79
|
+
|
|
80
|
+ console.log('Async operation has ended');
|
|
81
|
+ infiniteScroll.complete();
|
|
82
|
+ }, 1000);
|
40
|
83
|
}
|
41
|
84
|
|
42
|
85
|
|