argos/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.comp...

66 lines
2.0 KiB
TypeScript
Raw Normal View History

2019-04-24 11:26:53 +02:00
import { Component, OnInit } from '@angular/core';
2019-04-25 11:03:22 +02:00
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';
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
})
export class RecentEditedActivityComponent implements OnInit {
2019-04-25 11:03:22 +02:00
dmpActivities: DmpListingModel[];
recentActivityTypeEnum = RecentActivityType;
2019-04-24 11:26:53 +02:00
2019-04-25 11:03:22 +02:00
constructor(
private router: Router,
2019-04-25 11:03:22 +02:00
public enumUtils: EnumUtils,
private authentication: AuthService,
private dmpService: DmpService
) { }
2019-04-24 11:26:53 +02:00
2019-04-25 11:03:22 +02:00
ngOnInit() {
if (this.isAuthenticated()) {
2019-05-06 12:50:48 +02:00
const fields: Array<string> = ["-modified"];
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, 5, { fields: fields });
2019-04-25 11:03:22 +02:00
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();
}
2019-04-24 11:26:53 +02:00
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() { }
2019-04-24 11:26:53 +02:00
}