56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
import { BaseComponent } from '../../core/common/base/base.component';
|
|
import { UserReferenceService } from '../../services/user-reference/user-reference-data.service';
|
|
import { RecentActivityTypes } from '../../users/activity/RecentActivityTypes';
|
|
|
|
@Component({
|
|
selector: 'app-recent-activity',
|
|
templateUrl: './recent-activity.component.html',
|
|
styleUrls: ['./recent-activity.component.scss'],
|
|
providers: [
|
|
UserReferenceService
|
|
]
|
|
})
|
|
export class RecentActivityComponent extends BaseComponent implements OnInit {
|
|
|
|
datasetActivities: any[];
|
|
projectActivities: any[];
|
|
dmpActivities: any[];
|
|
public RecentActivityTypes = RecentActivityTypes;
|
|
constructor(
|
|
private router: Router,
|
|
private userReferenceService: UserReferenceService
|
|
) { super(); }
|
|
|
|
ngOnInit() {
|
|
this.userReferenceService.getRecentActivity()
|
|
.pipe(takeUntil(this._destroyed))
|
|
.subscribe(response => {
|
|
this.datasetActivities = response['recentDatasetActivities'];
|
|
this.dmpActivities = response['recentDmpActivities'];
|
|
this.projectActivities = response['recentProjectActivities'];
|
|
});
|
|
}
|
|
|
|
redirect(id: string, type: RecentActivityTypes) {
|
|
switch (type) {
|
|
case RecentActivityTypes.PROJECT: {
|
|
this.router.navigate(['projects/edit/' + id]);
|
|
return;
|
|
}
|
|
case RecentActivityTypes.DATASET: {
|
|
this.router.navigate(['datasets/edit/' + id]);
|
|
return;
|
|
}
|
|
case RecentActivityTypes.DMP: {
|
|
this.router.navigate(['dmps/edit/' + id]);
|
|
return;
|
|
}
|
|
default: throw new Error('Unsupported Activity Type ');
|
|
}
|
|
|
|
}
|
|
}
|