1
|
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
|
2
|
import {ActivatedRoute, Router} from "@angular/router";
|
3
|
|
4
|
import {RemoveContentProvidersComponent} from './remove-content-providers.component';
|
5
|
|
6
|
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
7
|
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
8
|
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
9
|
import {Title} from '@angular/platform-browser';
|
10
|
import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component";
|
11
|
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
|
12
|
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
|
13
|
import {properties} from "../../../environments/environment";
|
14
|
import {Subscriber} from "rxjs";
|
15
|
|
16
|
@Component({
|
17
|
selector: 'manage-content-providers',
|
18
|
template: `
|
19
|
<remove-content-providers (toggleView)="toggleAction()" [communityContentProviders]="communityContentProviders"
|
20
|
[showLoading]="showLoadingInRemove"
|
21
|
(communityContentProvidersChanged)="communityContentProvidersChanged($event)" [toggle]="toggle">
|
22
|
</remove-content-providers>
|
23
|
<fs-modal #fsModal (cancelEmitter)="toggleAction()">
|
24
|
<div actions class="uk-flex uk-flex-middle uk-height-1-1">
|
25
|
<span class="uk-button uk-text-secondary" uk-icon="icon: info; ratio: 1.3"></span>
|
26
|
<div *ngIf="communityId" uk-drop="mode: hover">
|
27
|
<div class="uk-card uk-card-body uk-card-default">
|
28
|
If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant.
|
29
|
Feel free to contact us
|
30
|
(<a
|
31
|
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ communityId + '] report missing Funder' + '&body=' + body"
|
32
|
target="_top">{{properties.feedbackmailForMissingEntities}}</a>)
|
33
|
to let us know and we'll try to get the provider on board!
|
34
|
</div>
|
35
|
</div>
|
36
|
</div>
|
37
|
|
38
|
<add-content-providers [communityContentProviders]="communityContentProviders"
|
39
|
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
|
40
|
</fs-modal>
|
41
|
`
|
42
|
})
|
43
|
|
44
|
export class ManageContentProvidersComponent implements OnInit {
|
45
|
@Input() communityContentProviders = [];
|
46
|
@ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent;
|
47
|
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
|
48
|
|
49
|
public toggle: boolean = false;
|
50
|
|
51
|
private subscriptions: any[] = [];
|
52
|
|
53
|
public showLoadingInRemove: boolean = true;
|
54
|
|
55
|
public body: string = "Send from page";
|
56
|
public properties: EnvProperties = properties;
|
57
|
public communityId: string = "";
|
58
|
|
59
|
constructor(private element: ElementRef,
|
60
|
private title: Title,
|
61
|
private route: ActivatedRoute, private _router: Router) {
|
62
|
}
|
63
|
|
64
|
ngOnInit() {
|
65
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
66
|
this.communityId = params['community'];
|
67
|
|
68
|
if (this.communityId) {
|
69
|
this.title.setTitle(this.communityId.toUpperCase() + ' | Content Providers');
|
70
|
this.body = "[Please write your message here]";
|
71
|
this.body = StringUtils.URIEncode(this.body);
|
72
|
}
|
73
|
}));
|
74
|
|
75
|
this.fullscreen.title = "Search and Add Content Providers";
|
76
|
this.fullscreen.okButtonText = "Done";
|
77
|
this.fullscreen.okButton = true;
|
78
|
}
|
79
|
|
80
|
public ngOnDestroy() {
|
81
|
this.subscriptions.forEach(sub => {
|
82
|
if (sub instanceof Subscriber) {
|
83
|
sub.unsubscribe();
|
84
|
}
|
85
|
});
|
86
|
}
|
87
|
|
88
|
public toggleAction() {
|
89
|
if (!Session.isLoggedIn()) {
|
90
|
this._router.navigate(['/user-info'], {
|
91
|
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
|
92
|
});
|
93
|
} else {
|
94
|
HelperFunctions.scroll();
|
95
|
|
96
|
this.toggle = !this.toggle;
|
97
|
if (this.toggle) {
|
98
|
this.fullscreen.open();
|
99
|
}
|
100
|
}
|
101
|
}
|
102
|
|
103
|
public communityContentProvidersChanged($event) {
|
104
|
this.communityContentProviders = $event.value;
|
105
|
this.showLoadingInRemove = false;
|
106
|
|
107
|
if (this.toggle) {
|
108
|
this.removeContentProvidersComponent.applyFilters();
|
109
|
}
|
110
|
}
|
111
|
}
|