diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts index 8e035eb31..be73632c5 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts @@ -122,7 +122,7 @@ export class DraftsComponent extends BaseComponent implements OnInit { this.datasetDrafts = response.data; this.totalCount = response.totalCount; this.totalCountDraftDatasets.emit(this.datasetDrafts.length); - if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) { + if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) { let queryParams = { type: "drafts", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index 682565fb6..ee7d19c82 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -123,6 +123,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn let keyword = (params['keyword'] === undefined || params['keyword'].length <= 0) ? "" : params['keyword']; this.formGroup.get("like").setValue(keyword); + console.log("init"); this.updateUrl(); } }); @@ -151,20 +152,27 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn } }); this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if(this.allRecentActivities.length > 0 && this.allRecentActivities.length < this.page*this.pageSize && this.page > 1) { + if(this.allRecentActivities.length == 0 && this.page > 1) { let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value; } + console.log(queryParams); this.router.navigate(["/home"], { queryParams: queryParams }) } }); this.formGroup.get('like').valueChanges .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.refresh()); + .subscribe(x => { + console.log("like changed"); + this.refresh() + }); this.formGroup.get('order').valueChanges .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); + .subscribe(x => { + console.log("order changed"); + this.refresh() + }); } else { this.publicMode = true; if(!this.formGroup.get('order').value) { @@ -186,25 +194,33 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn } }); this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if(this.allRecentActivities.length > 0 && this.allRecentActivities.length < this.page*this.pageSize && this.page > 1) { + if(this.allRecentActivities.length == 0 && this.page > 1) { let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value; } + console.log(queryParams); this.router.navigate(["/home"], { queryParams: queryParams }) } }); this.formGroup.get('like').valueChanges .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.refresh()); + .subscribe(x => { + console.log("like changed 1"); + this.refresh() + }); this.formGroup.get('order').valueChanges .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); + .subscribe(x => { + console.log("order changed 1"); + this.refresh() + }); } } ngOnChanges() { if(this.isActive) { + console.log("active"); this.updateUrl(); } } @@ -217,6 +233,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn if(parameters) { parameters = "?type=recent" + parameters; } + console.log(parameters); this.location.go(this.router.url.split('?')[0]+parameters); } @@ -693,6 +710,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn this.datasetOffset = 0; this.dmpOffset = 0; this.page = 1; + console.log("refresh"); this.updateUrl(); const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; @@ -745,6 +763,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn // return []; } else { this.page = this.page + (more ? 1 : -1); + console.log("loadNextOrPrevious"); this.updateUrl(); // if(more) { // result.forEach(recentActivity => { diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts index 4967e0b70..e33f46266 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts @@ -122,7 +122,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen this.datasetActivities = response.data; this.totalCount = response.totalCount; this.totalCountDatasets.emit(this.datasetActivities.length) - if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) { + if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) { let queryParams = { type: "datasets", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value; @@ -146,7 +146,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen this.datasetActivities = response.data; this.totalCount = response.totalCount; this.totalCountDatasets.emit(this.datasetActivities.length); - if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) { + if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) { let queryParams = { type: "datasets", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts index e31593623..1e53f6b9a 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts @@ -133,7 +133,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O this.dmpActivities = response.data; this.totalCount = response.totalCount; this.totalCountDmps.emit(this.dmpActivities.length); - if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) { + if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) { let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value; @@ -182,7 +182,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O this.dmpActivities = response.data; this.totalCount = response.totalCount; this.totalCountDmps.emit(this.dmpActivities.length); - if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) { + if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) { let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; if(this.formGroup.get("like").value) { queryParams['keyword'] = this.formGroup.get("like").value;