2018-11-27 18:33:17 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2018-03-21 14:15:06 +01:00
|
|
|
import { Router } from '@angular/router';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { RecentActivityType } from '@app/core/common/enum/recent-activity-type';
|
|
|
|
import { UserService } from '@app/core/services/user/user.service';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2018-11-27 18:33:17 +01:00
|
|
|
import { takeUntil } from 'rxjs/operators';
|
2018-03-21 14:15:06 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-recent-activity',
|
|
|
|
templateUrl: './recent-activity.component.html',
|
2019-01-18 18:03:45 +01:00
|
|
|
styleUrls: ['./recent-activity.component.scss']
|
2018-03-21 14:15:06 +01:00
|
|
|
})
|
2018-11-27 18:33:17 +01:00
|
|
|
export class RecentActivityComponent extends BaseComponent implements OnInit {
|
2018-05-14 08:44:35 +02:00
|
|
|
|
2018-05-28 11:50:42 +02:00
|
|
|
datasetActivities: any[];
|
2019-08-01 09:54:40 +02:00
|
|
|
grantActivities: any[];
|
2018-05-28 11:50:42 +02:00
|
|
|
dmpActivities: any[];
|
2019-01-18 18:03:45 +01:00
|
|
|
recentActivityTypeEnum = RecentActivityType;
|
|
|
|
|
2018-03-21 14:15:06 +01:00
|
|
|
constructor(
|
|
|
|
private router: Router,
|
2019-01-18 18:03:45 +01:00
|
|
|
private userService: UserService
|
2018-11-27 18:33:17 +01:00
|
|
|
) { super(); }
|
2018-03-21 14:15:06 +01:00
|
|
|
|
|
|
|
ngOnInit() {
|
2019-01-18 18:03:45 +01:00
|
|
|
this.userService.getRecentActivity()
|
2018-11-27 18:33:17 +01:00
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
|
|
|
this.datasetActivities = response['recentDatasetActivities'];
|
|
|
|
this.dmpActivities = response['recentDmpActivities'];
|
2019-08-01 09:54:40 +02:00
|
|
|
this.grantActivities = response['recentGrantActivities'];
|
2018-11-27 18:33:17 +01:00
|
|
|
});
|
2018-03-21 14:15:06 +01:00
|
|
|
}
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
redirect(id: string, type: RecentActivityType) {
|
2018-03-21 14:15:06 +01:00
|
|
|
switch (type) {
|
2019-08-01 09:54:40 +02:00
|
|
|
case RecentActivityType.Grant: {
|
|
|
|
this.router.navigate(['grants/edit/' + id]);
|
2018-03-21 14:15:06 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
case RecentActivityType.Dataset: {
|
2018-10-05 17:00:54 +02:00
|
|
|
this.router.navigate(['datasets/edit/' + id]);
|
2018-03-21 14:15:06 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
case RecentActivityType.Dmp: {
|
|
|
|
this.router.navigate(['plans/edit/' + id]);
|
2018-03-21 14:15:06 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-10-05 17:00:54 +02:00
|
|
|
default: throw new Error('Unsupported Activity Type ');
|
2018-03-21 14:15:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|