Merge branch 'master' of code-repo.d4science.org:MaDgIK/openaire-library

This commit is contained in:
argirok 2021-09-27 11:21:34 +03:00
commit e267955b7f
11 changed files with 78 additions and 60 deletions

View File

@ -38,9 +38,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
@Input()
public inviteDisableMessage: string;
public user: User = null;
public active: any[];
public active: any[] = [];
public showActive: any[] = [];
public managers: any[];
public pending: any[];
public showPending: any[] = [];
public showCurrent: boolean = true;
@ -114,24 +113,11 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
updateLists() {
this.loadActive = true;
this.loadPending = true;
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, this.role).subscribe(users => {
if (this.role === 'member') {
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager').subscribe(managers => {
this.managers = managers;
this.active = users;
this.active.forEach(user => {
user['isManager'] = this.managers.find(manager => manager.email === user.email);
});
this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false;
this.exists = true;
}))
} else {
this.active = users;
this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false;
this.exists = true;
}
this.subs.push(this.userRegistryService.getActive(this.type, this.id, this.role).subscribe(users => {
this.active = users;
this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false;
this.exists = true;
}, error => {
this.active = [];
this.showActive = [];
@ -191,11 +177,12 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.createRoleModal.okButtonLeft = false;
this.createRoleModal.okButtonText = 'Create';
this.roleFb = this.fb.group({
name: this.fb.control(Role.mapType(this.type, (this.role === 'manager')) + '.' + this.id, Validators.required),
description: this.fb.control('', Validators.required)
name: this.fb.control(Role.mapType(this.type) + '.' + this.id, Validators.required),
description: this.fb.control(Role.mapType(this.type) + ' ' + this.id, Validators.required)
});
setTimeout(() => {
this.roleFb.get('name').disable();
this.roleFb.get('description').disable();
}, 0);
this.createRoleModal.open();
}
@ -204,7 +191,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.loadActive = true;
this.subs.push(this.userRegistryService.remove(this.type, this.id, this.selectedUser, this.role).subscribe(() => {
this.active = this.active.filter(user => user.email != this.selectedUser);
if(this.currentActivePage.length === 0) {
if (this.currentActivePage.length === 0) {
this.activePage = 1;
}
this.filterActiveBySearch(this.filterForm.value.active);
@ -230,7 +217,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.subs.push(this.userRegistryService.cancelInvitation(this.type, this.id, this.selectedUser, this.role).subscribe(() => {
this.pending = this.pending.filter(user => user != this.selectedUser);
this.filterPendingBySearch(this.filterForm.value.pending);
if(this.currentPendingPage.length === 0) {
if (this.currentPendingPage.length === 0) {
this.pendingPage = 1;
}
UIkit.notification(StringUtils.capitalize(this.role) + ' invitation to ' + this.selectedUser + ' has been <b>canceled</b>', {
@ -260,7 +247,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.subs.push(this.userRegistryService.invite(this.type, this.id, details, this.role).subscribe(invitation => {
if (!this.pending.includes(this.invited.value)) {
this.pending.push(this.invited.value);
this.pendingPage = Math.ceil(this.pending.length/this.pageSize);
this.pendingPage = Math.ceil(this.pending.length / this.pageSize);
this.filterPendingBySearch(this.filterForm.value.pending);
}
if (this.notificationFn) {
@ -298,7 +285,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.loadActive = true;
this.loadPending = true;
this.roleFb.get('name').enable();
this.userRegistryService.createRole(this.type, this.id, this.roleFb.value).subscribe(() => {
this.userRegistryService.createRole(this.type, this.id).subscribe(() => {
UIkit.notification('Group has been <b> successfully created</b>', {
status: 'success',
timeout: 6000,

View File

@ -40,7 +40,6 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
@Input()
public inviteDisableMessage: string;
public user: User = null;
public managers: any[];
public subscribers: any[];
public showSubscribers: any[];
public subs: any[] = [];
@ -104,14 +103,8 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
updateList() {
this.loading = true;
let data = zip(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager'),
this.userRegistryService.getActiveEmail(this.type, this.id, 'member'));
this.subs.push(data.subscribe(users => {
this.managers = users[0];
this.subscribers = users[1];
this.subscribers.forEach(subscriber => {
subscriber['isManager'] = this.managers.find(manager => manager.email === subscriber.email);
});
this.subs.push( this.userRegistryService.getActive(this.type, this.id, 'member').subscribe(users => {
this.subscribers = users;
this.filterBySearch(this.filterForm.value.keyword);
this.loading = false;
this.exists = true;
@ -147,10 +140,11 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
this.createRoleModal.okButtonText = 'create';
this.roleFb = this.fb.group({
name: this.fb.control(Role.mapType(this.type) + '.' + this.id, Validators.required),
description: this.fb.control('', Validators.required)
description: this.fb.control(Role.mapType(this.type) + ' ' + this.id, Validators.required)
});
setTimeout(() => {
this.roleFb.get('name').disable();
this.roleFb.get('description').disable();
}, 0);
this.createRoleModal.open();
}
@ -182,8 +176,7 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
createGroup() {
this.loading = true;
this.roleFb.get('name').enable();
this.userRegistryService.createRole(this.type, this.id, this.roleFb.value).subscribe(() => {
this.userRegistryService.createRole(this.type, this.id).subscribe(() => {
UIkit.notification('Group has been <b> successfully created</b>', {
status: 'success',
timeout: 6000,

View File

@ -32,7 +32,7 @@ export class ErrorInterceptorService implements HttpInterceptor {
}
isService(req: HttpRequest<any>, service: string | string[]):boolean {
if(isArray(service)) {
if(Array.isArray(service)) {
return !!service.find(element => req.url.indexOf(element) !== -1);
} else {
return req.url.indexOf(service) !== -1;

View File

@ -6,6 +6,8 @@ import {Injectable} from '@angular/core';
providedIn: 'root'
})
export class ParsingFunctions {
public notebookInSubjects: boolean = false;
public open = 'assets/common-assets/unlock.svg';
public closed = 'assets/common-assets/lock.svg';
public unknown = 'assets/common-assets/question.svg';
@ -530,8 +532,12 @@ export class ParsingFunctions {
if (subjects == undefined) {
subjects = new Array<string>();
}
subjects.push(subject.content);
let content: string = subject.content;
if(content && content.toLowerCase().includes("notebook")) {
this.notebookInSubjects = true;
}
subjects.push(content);
} else {
if (otherSubjects == undefined) {
otherSubjects = new Map<string, string[]>();
@ -540,7 +546,13 @@ export class ParsingFunctions {
if (!otherSubjects.has(subject.classname)) {
otherSubjects.set(subject.classname, new Array<string>());
}
otherSubjects.get(subject.classname).push(subject.content);
let content: string = subject.content;
let classname: string = subject.classname;
if( (content && content.toLowerCase().includes("notebook") ||
(classname && classname.toLowerCase().includes("notebook")))) {
this.notebookInSubjects = true;
}
otherSubjects.get(classname).push(content);
}
}
}

View File

@ -23,13 +23,13 @@ import {Component, Input} from '@angular/core';
<span *ngIf="subjects && subjects.length > 0">{{subjects.join(', ')}}</span>
<span *ngIf="(subjects && subjects.length > 0) && (otherSubjects && otherSubjects.size > 0)">, </span>
<span *ngIf="otherSubjects && otherSubjects.size > 0">
<span *ngFor="let key of getKeys(otherSubjects); let i=index">
<span *ngIf="otherSubjects.get(key).length > 0">
<span>{{otherSubjects.get(key).join(', ')}}</span>
<span *ngIf="i < (otherSubjects.size - 1)">, </span>
<span *ngFor="let key of getKeys(otherSubjects); let i=index">
<span *ngIf="otherSubjects.get(key).length > 0">
<span>{{otherSubjects.get(key).join(', ')}}</span>
<span *ngIf="i < (otherSubjects.size - 1)">, </span>
</span>
</span>
</span>
</span>
</span>
</div>
</div>
</div>

View File

@ -121,6 +121,19 @@
<span class="uk-margin-small-left">add annotation</span>
</span>
</li>
<!-- EGI Notebook-->
<li *ngIf="resultLandingInfo.showEgiNotebookButton && properties.adminToolsPortalType == 'explore'
&& (properties.environment == 'beta' || properties.environment == 'development')">
<a class="uk-link-text uk-text-bold uk-text-uppercase"
target="_blank" href="https://marketplace.eosc-portal.eu/services/egi-notebooks?q=EGI+Notebook">
<span class="uk-icon-button notebook-button uk-icon">
<img src="assets/common-assets/egi-fed.notebook.png"
loading="lazy" alt="egi_notebook" style="width:30px; height:21px">
</span>
<span class="uk-margin-small-left"><u>EGI Notebook</u></span>
<span class="custom-external custom-icon space"></span>
</a>
</li>
<!-- Metrics -->
<li *ngIf="hasAltMetrics || hasMetrics" class="uk-margin-medium-top">
<div uk-grid

View File

@ -27,6 +27,10 @@ import {$e} from "codelyzer/angular/styles/chars";
@Component({
styles: [
'.notebook-button { background-color: #f2f2f2; border: 1px solid #f2f2f2; } ' +
'.notebook-button:hover { background-color: #e5e5e5; border-color: #e5e5e5; } '
],
selector: 'result-landing',
templateUrl: 'resultLanding.component.html',
})

View File

@ -312,6 +312,8 @@ export class ResultLandingService {
this.resultLandingInfo.subjects = subjectResults[0];
this.resultLandingInfo.otherSubjects = subjectResults[1];
this.resultLandingInfo.classifiedSubjects = subjectResults[2];
this.resultLandingInfo.showEgiNotebookButton = this.parsingFunctions.notebookInSubjects;
}
this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
@ -487,7 +489,8 @@ export class ResultLandingService {
}
getEnermapsDetails(id: string) {
let url = properties.enermapsURL+"/api/datasets_full?shared_id=eq."+id;
// let url = properties.enermapsURL+"/api/datasets_full?shared_id=eq."+id;
let url = properties.enermapsURL+"/api/metadata?shared_id=eq."+id;
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
// return this.http.get(url)
.pipe(map(res => this.parseEnermapsDetails(res)));

View File

@ -28,6 +28,10 @@ export class StakeholderService {
constructor(private http: HttpClient, private route: ActivatedRoute) {
this.stakeholderSubject = new BehaviorSubject<Stakeholder>(null);
/* let source = new EventSource(properties.monitorServiceAPIURL + "/stakeholder/events", {withCredentials: true});
source.addEventListener('message', message => {
console.log(message.data);
});*/
}
ngOnDestroy() {

View File

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {Observable} from 'rxjs';
import {properties} from '../../../environments/environment';
import {CustomOptions} from './servicesUtils/customOptions.class';
@ -13,8 +13,8 @@ export class UserRegistryService {
constructor(private http: HttpClient) {
}
public createRole(type: string, id: string, role): Observable<any[]> {
return this.http.post<any>(properties.registryUrl + 'createRole', role,
public createRole(type: string, id: string): Observable<any[]> {
return this.http.post<any>(properties.registryUrl + 'create/' + encodeURIComponent(type) + '/' + encodeURIComponent(id), null,
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
}
@ -56,14 +56,15 @@ export class UserRegistryService {
return this.http.delete<any>(properties.registryUrl + 'verification/' + encodeURIComponent(id), CustomOptions.registryOptions());
}
public getActiveEmail(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + "/" + role + 's/email',
CustomOptions.registryOptions()).pipe(map((response:any) => response.response));
}
public getActiveNames(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + "/" + role + 's/',
CustomOptions.registryOptions()).pipe(map((response:any) => response.response));
public getActive(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + "/" + role + 's',
CustomOptions.registryOptions()).pipe(map((response:any) => response.response), map(users => {
if(users.length > 0 && !users[0].email) {
return [];
} else {
return users;
}
}));
}
public getPending(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {

View File

@ -49,6 +49,7 @@ export class ResultLandingInfo {
subjects: string[];
otherSubjects: Map<string, string[]>;
classifiedSubjects: Map<string, string[]>; //<class of subject, subjects>
showEgiNotebookButton: boolean = false;
// percentage is for trust
relatedResearchResults: RelationResult[];