2023-10-25 16:47:48 +02:00
|
|
|
import { Location } from '@angular/common';
|
2023-12-05 21:36:00 +01:00
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
|
|
|
import { UntypedFormBuilder, UntypedFormControl } from '@angular/forms';
|
2023-10-25 16:47:48 +02:00
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
|
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
|
2023-12-05 21:36:00 +01:00
|
|
|
import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-item';
|
|
|
|
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
|
|
|
|
import { Description } from '@app/core/model/description/description';
|
|
|
|
import { Dmp, DmpUser } from '@app/core/model/dmp/dmp';
|
|
|
|
import { DmpReference, Reference } from '@app/core/model/reference/reference';
|
|
|
|
import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
2023-10-25 16:47:48 +02:00
|
|
|
import { DashboardService } from '@app/core/services/dashboard/dashboard.service';
|
|
|
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
2023-10-25 16:47:48 +02:00
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2023-12-05 21:36:00 +01:00
|
|
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
2023-10-25 16:47:48 +02:00
|
|
|
import { nameof } from 'ts-simple-nameof';
|
2019-04-24 11:26:53 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-04-25 11:03:22 +02:00
|
|
|
selector: 'app-recent-edited-activity',
|
|
|
|
templateUrl: './recent-edited-activity.component.html',
|
|
|
|
styleUrls: ['./recent-edited-activity.component.css']
|
2019-04-24 11:26:53 +02:00
|
|
|
})
|
2019-06-04 13:34:30 +02:00
|
|
|
export class RecentEditedActivityComponent extends BaseComponent implements OnInit {
|
2020-07-02 18:34:27 +02:00
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
|
2020-07-02 18:34:27 +02:00
|
|
|
pageSize: number = 5;
|
2023-12-05 21:36:00 +01:00
|
|
|
listingItems: RecentActivityItem[];
|
|
|
|
|
|
|
|
|
2023-10-05 15:39:17 +02:00
|
|
|
public formGroup = new UntypedFormBuilder().group({
|
|
|
|
like: new UntypedFormControl(),
|
|
|
|
order: new UntypedFormControl()
|
2020-07-10 15:52:35 +02:00
|
|
|
});
|
2020-08-03 10:40:38 +02:00
|
|
|
publicMode = false;
|
2019-04-24 11:26:53 +02:00
|
|
|
|
2020-07-13 12:01:03 +02:00
|
|
|
order = RecentActivityOrder;
|
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
totalCount: number;
|
|
|
|
startIndex: number = 0;
|
|
|
|
offsetLess: number = 0;
|
2023-04-25 16:55:31 +02:00
|
|
|
page: number = 1;
|
|
|
|
@Input() isActive: boolean = false;
|
|
|
|
|
2019-04-25 11:03:22 +02:00
|
|
|
constructor(
|
2023-04-25 16:55:31 +02:00
|
|
|
private route: ActivatedRoute,
|
2019-04-26 18:08:51 +02:00
|
|
|
private router: Router,
|
2019-04-25 11:03:22 +02:00
|
|
|
public enumUtils: EnumUtils,
|
|
|
|
private authentication: AuthService,
|
2020-07-02 18:34:27 +02:00
|
|
|
private dashboardService: DashboardService,
|
2020-07-23 11:35:08 +02:00
|
|
|
private location: Location,
|
2023-12-05 21:36:00 +01:00
|
|
|
private matomoService: MatomoService
|
2019-06-04 13:34:30 +02:00
|
|
|
) {
|
|
|
|
super();
|
|
|
|
}
|
2019-04-24 11:26:53 +02:00
|
|
|
|
2019-04-25 11:03:22 +02:00
|
|
|
ngOnInit() {
|
2023-12-05 21:36:00 +01:00
|
|
|
this.matomoService.trackPageView('Recent DMP Activity');
|
2023-04-25 16:55:31 +02:00
|
|
|
this.route.queryParams.subscribe(params => {
|
2023-10-25 16:47:48 +02:00
|
|
|
if (this.isActive) {
|
2023-04-25 16:55:31 +02:00
|
|
|
let page = (params['page'] === undefined) ? 1 : +params['page'];
|
|
|
|
this.page = (page <= 0) ? 1 : page;
|
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
this.startIndex = (this.page - 1) * this.pageSize;
|
2023-10-25 16:47:48 +02:00
|
|
|
if (this.page > 1) {
|
|
|
|
this.offsetLess = (this.page - 2) * this.pageSize;
|
2023-04-25 16:55:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let order = params['order'];
|
|
|
|
if (this.isAuthenticated()) {
|
2023-12-05 21:36:00 +01:00
|
|
|
if (order === undefined || (order != this.order.UpdatedAt && order != this.order.Label && order != this.order.Status)) {
|
|
|
|
order = this.order.UpdatedAt;
|
2023-04-25 16:55:31 +02:00
|
|
|
}
|
|
|
|
} else {
|
2023-10-25 16:47:48 +02:00
|
|
|
if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) {
|
2023-04-25 16:55:31 +02:00
|
|
|
order = this.order.PUBLISHED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.formGroup.get('order').setValue(order);
|
|
|
|
|
|
|
|
let keyword = (params['keyword'] === undefined || params['keyword'].length <= 0) ? "" : params['keyword'];
|
|
|
|
this.formGroup.get("like").setValue(keyword);
|
|
|
|
|
|
|
|
this.updateUrl();
|
|
|
|
}
|
|
|
|
});
|
2019-04-25 11:03:22 +02:00
|
|
|
if (this.isAuthenticated()) {
|
2023-12-05 21:36:00 +01:00
|
|
|
this.refresh();
|
2020-07-10 15:52:35 +02:00
|
|
|
}
|
2019-04-25 11:03:22 +02:00
|
|
|
}
|
|
|
|
|
2023-04-25 16:55:31 +02:00
|
|
|
ngOnChanges() {
|
2023-10-25 16:47:48 +02:00
|
|
|
if (this.isActive) {
|
2023-04-25 16:55:31 +02:00
|
|
|
this.updateUrl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateUrl() {
|
2023-12-05 21:36:00 +01:00
|
|
|
let parameters = "?type=dmps" +
|
|
|
|
(this.page != 1 ? "&page=" + this.page : "") +
|
|
|
|
(((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") +
|
|
|
|
(this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : "");
|
2023-10-25 16:47:48 +02:00
|
|
|
this.location.go(this.router.url.split('?')[0] + parameters);
|
2023-04-25 16:55:31 +02:00
|
|
|
}
|
|
|
|
|
2019-04-25 11:03:22 +02:00
|
|
|
public isAuthenticated(): boolean {
|
2023-10-11 16:53:12 +02:00
|
|
|
return this.authentication.currentAccountIsAuthenticated();
|
2019-04-25 11:03:22 +02:00
|
|
|
}
|
2019-04-24 11:26:53 +02:00
|
|
|
|
2020-07-10 15:52:35 +02:00
|
|
|
refresh(): void {
|
2023-12-05 21:36:00 +01:00
|
|
|
if (!this.formGroup.get('order').value) {
|
|
|
|
this.formGroup.get('order').setValue(this.order.UpdatedAt);
|
|
|
|
}
|
|
|
|
this.lookup.page = { size: this.pageSize, offset: 0 };
|
|
|
|
this.lookup.orderField = this.formGroup.get('order').value;
|
|
|
|
this.lookup.like = this.formGroup.get('like').value;
|
|
|
|
this.lookup.project = {
|
|
|
|
|
|
|
|
fields: [
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.label)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.status)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.accessType)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.version)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.groupId)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.updatedAt)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.label)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
|
|
|
|
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.label)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.status)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.updatedAt)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.label)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.groupId)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.label)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.accessType)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.type)].join('.'),
|
|
|
|
[nameof<RecentActivityItem>(x => x.description), nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.reference)].join('.'),
|
|
|
|
]
|
|
|
|
};
|
2021-04-06 08:57:17 +02:00
|
|
|
|
2020-07-10 15:52:35 +02:00
|
|
|
this.dashboardService
|
2023-12-05 21:36:00 +01:00
|
|
|
.getMyRecentActivityItems(this.lookup)
|
2021-07-09 12:03:09 +02:00
|
|
|
.pipe(takeUntil(this._destroyed))
|
2020-07-10 15:52:35 +02:00
|
|
|
.subscribe(response => {
|
2023-12-05 21:36:00 +01:00
|
|
|
this.listingItems = response;
|
|
|
|
//this.totalCount = response.totalCount;
|
2021-04-06 08:57:17 +02:00
|
|
|
|
2020-07-02 18:34:27 +02:00
|
|
|
|
2023-12-05 21:36:00 +01:00
|
|
|
//this.totalCountDmps.emit(this.dmpActivities.length);
|
|
|
|
// 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;
|
|
|
|
// }
|
|
|
|
// this.router.navigate(["/home"], { queryParams: queryParams })
|
2023-04-25 16:55:31 +02:00
|
|
|
// }
|
2023-12-05 21:36:00 +01:00
|
|
|
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);
|
|
|
|
// this.totalCountDmps.emit(this.totalCount);
|
|
|
|
// this.dmpActivities.forEach(dmpActivity => {
|
|
|
|
// const recentActivity: RecentActivity = {
|
|
|
|
// activityData: dmpActivity,
|
|
|
|
// activityType: RecentActivityType.Dmp
|
|
|
|
// };
|
|
|
|
// this.allRecentActivities.push(recentActivity)
|
|
|
|
// })
|
|
|
|
});
|
|
|
|
this.formGroup.get('like').valueChanges
|
|
|
|
.pipe(takeUntil(this._destroyed), debounceTime(500))
|
|
|
|
.subscribe(x => this.refresh());
|
|
|
|
this.formGroup.get('order').valueChanges
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(x => this.refresh());
|
2020-07-28 14:54:21 +02:00
|
|
|
}
|
2019-04-24 11:26:53 +02:00
|
|
|
}
|