99 lines
2.8 KiB
TypeScript
99 lines
2.8 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { DmpListingModel } from '../../../core/model/dmp/dmp-listing';
|
|
import { EnumUtils } from '../../../core/services/utilities/enum-utils.service';
|
|
import { AuthService } from '../../../core/services/auth/auth.service';
|
|
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
|
import { DmpCriteria } from '../../../core/query/dmp/dmp-criteria';
|
|
import { DmpService } from '../../../core/services/dmp/dmp.service';
|
|
import { RecentActivityType } from '../../../core/common/enum/recent-activity-type';
|
|
import { Router } from '@angular/router';
|
|
import { Principal } from '../../../core/model/auth/Principal';
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
@Component({
|
|
selector: 'app-recent-edited-activity',
|
|
templateUrl: './recent-edited-activity.component.html',
|
|
styleUrls: ['./recent-edited-activity.component.css']
|
|
})
|
|
export class RecentEditedActivityComponent implements OnInit {
|
|
dmpActivities: DmpListingModel[];
|
|
recentActivityTypeEnum = RecentActivityType;
|
|
|
|
constructor(
|
|
private router: Router,
|
|
public enumUtils: EnumUtils,
|
|
private authentication: AuthService,
|
|
private dmpService: DmpService,
|
|
private language: TranslateService
|
|
) { }
|
|
|
|
ngOnInit() {
|
|
if (this.isAuthenticated()) {
|
|
const fields: Array<string> = ["-modified"];
|
|
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, 5, { fields: fields });
|
|
dmpDataTableRequest.criteria = new DmpCriteria();
|
|
dmpDataTableRequest.criteria.like = "";
|
|
this.dmpService
|
|
.getPaged(dmpDataTableRequest, "listing")
|
|
.subscribe(response => {
|
|
this.dmpActivities = response.data;
|
|
});
|
|
}
|
|
}
|
|
|
|
public isAuthenticated(): boolean {
|
|
return !!this.authentication.current();
|
|
}
|
|
|
|
redirect(id: string, type: RecentActivityType) {
|
|
switch (type) {
|
|
case RecentActivityType.Project: {
|
|
this.router.navigate(["projects/edit/" + id]);
|
|
return;
|
|
}
|
|
case RecentActivityType.Dataset: {
|
|
this.router.navigate(["datasets/edit/" + id]);
|
|
return;
|
|
}
|
|
case RecentActivityType.Dmp: {
|
|
this.router.navigate(["plans/edit/" + id]);
|
|
return;
|
|
}
|
|
default:
|
|
throw new Error("Unsupported Activity Type ");
|
|
}
|
|
}
|
|
|
|
navigateToUrl() { }
|
|
|
|
roleDisplay(value: any) {
|
|
const principal: Principal = this.authentication.current();
|
|
let role: number;
|
|
if (principal) {
|
|
value.forEach(element => {
|
|
if (principal.id === element.id) {
|
|
role = element.role;
|
|
}
|
|
});
|
|
}
|
|
if (role === 0) {
|
|
return this.language.instant('DMP-LISTING.OWNER');
|
|
}
|
|
else if (role === 1) {
|
|
return this.language.instant('DMP-LISTING.MEMBER');
|
|
}
|
|
else {
|
|
return this.language.instant('DMP-LISTING.OWNER');
|
|
}
|
|
}
|
|
|
|
dmpProfileDisplay(value: any) {
|
|
if (value != null) {
|
|
return value;
|
|
}
|
|
else {
|
|
return "--";
|
|
}
|
|
}
|
|
}
|