argos/dmp-frontend/src/app/ui/explore-dmp/listing-item/explore-dmp-listing-item.co...

54 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { DmpListingModel } from '../../../core/model/dmp/dmp-listing';
2020-04-27 15:21:03 +02:00
import { Principal } from '../../../core/model/auth/principal';
import { AuthService } from '../../../core/services/auth/auth.service';
import { TranslateService } from '@ngx-translate/core';
2019-10-23 17:36:29 +02:00
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-explore-dmp-listing-item-component',
templateUrl: './explore-dmp-listing-item.component.html',
styleUrls: ['./explore-dmp-listing-item.component.scss'],
})
export class ExploreDmpListingItemComponent implements OnInit {
@Input() dmp: DmpListingModel;
@Input() showDivider: boolean = true;
@Output() onClick: EventEmitter<DmpListingModel> = new EventEmitter();
constructor(
private authentication: AuthService,
2019-10-23 17:36:29 +02:00
private translate: TranslateService,
private router: Router,
private route: ActivatedRoute
2020-04-27 15:21:03 +02:00
) { }
ngOnInit() {
}
2019-10-23 17:36:29 +02:00
// itemClicked() {
// this.onClick.emit(this.dmp);
// }
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.translate.instant('DMP-PUBLIC-LISTING.OWNER');
}
else if (role === 1) {
return this.translate.instant('DMP-PUBLIC-LISTING.MEMBER');
}
else {
return this.translate.instant('DMP-PUBLIC-LISTING.VIEW-ONLY');
}
}
}