openaire-library/claims/claimsAdmin/claimsAdmin.component.ts

77 lines
2.7 KiB
TypeScript

import {Component, Input} from '@angular/core';
import {Title, Meta} from '@angular/platform-browser';
import {Session, User} from "../../login/utils/helper.class";
import {UserManagementService} from "../../services/user-management.service";
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
import {Router} from "@angular/router";
@Component({
selector: 'claims-admin',
template: `
<div id="tm-main" [class]="((isConnect)?'':'uk-section') +' uk-padding-remove-top tm-middle'">
<div uk-grid uk-grid>
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
<div class="uk-container">
<div class="uk-article-title custom-article-title">
Manage links
</div>
<div>
<!--div class="uk-text-right">
<a *ngIf="!fetchBy || fetchBy != 'Context'" routerLink="/participate/claim">Claim more links?</a>
<a *ngIf="isConnect && fetchBy && fetchBy == 'Context' && externalPortalUrl" [href]="externalPortalUrl+'/participate/claim'" target="_blank">Claim more links?</a>
</div-->
<displayClaims *ngIf="user" [user]="user" [enableDelete]=true [myClaims]=false
[isAdmin]=true [fetchBy]="(fetchId=='openaire')?null:fetchBy"
[fetchId]="(fetchId=='openaire')?null:fetchId"
[communityId]="(fetchBy && fetchBy == 'Context' && fetchId && fetchId!='openaire')?fetchId:null"
[externalPortalUrl]=externalPortalUrl [claimsInfoURL]=claimsInfoURL
title="Manage links"></displayClaims>
</div>
</div>
</div>
</div>
</div>
`,
})
export class ClaimsAdminComponent {
@Input() fetchBy: string;
@Input() fetchId: string;
@Input() isConnect: boolean = false;
@Input() externalPortalUrl: string;
@Input() claimsInfoURL: string;
@Input() userInfoURL: string;
public user: User = null;
constructor(private _meta: Meta, private _title: Title,
private userManagementService: UserManagementService, private _router: Router) {
var titleConnect = "OpenAIRE Connect | Manage links ";
var title = "OpenAIRE | Manage links ";
if (this.isConnect) {
this._title.setTitle(titleConnect);
} else {
this._title.setTitle(title);
}
}
ngOnInit() {
this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
if (!user) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
});
}
}