Merge branch 'master' of code-repo.d4science.org:MaDgIK/openaire-library
This commit is contained in:
commit
1475fb754b
|
@ -98,6 +98,6 @@ export class CommunitiesService {
|
||||||
communities.push(result);
|
communities.push(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return communities;
|
return CommunityInfo.checkIsUpload(communities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,18 +55,6 @@ export class CommunityService {
|
||||||
return this.community.getValue();
|
return this.community.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] {
|
|
||||||
if (Array.isArray(response)) {
|
|
||||||
response.forEach(value => {
|
|
||||||
value.isUpload = value.logoUrl && !StringUtils.isValidUrl(value.logoUrl);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
response.isUpload = response.logoUrl && !StringUtils.isValidUrl(response.logoUrl);
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
updateCommunity(url: string, community: any) {
|
updateCommunity(url: string, community: any) {
|
||||||
if (!community.logoUrl) {
|
if (!community.logoUrl) {
|
||||||
community.logoUrl = '';
|
community.logoUrl = '';
|
||||||
|
@ -131,7 +119,7 @@ export class CommunityService {
|
||||||
community.subjects[i] = subject;
|
community.subjects[i] = subject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.checkIsUpload(community);
|
return CommunityInfo.checkIsUpload(community);
|
||||||
}
|
}
|
||||||
|
|
||||||
isRIType(community: string): Observable<boolean> {
|
isRIType(community: string): Observable<boolean> {
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
|
import {StringUtils} from "../../utils/string-utils.class";
|
||||||
|
import {properties} from "../../../../environments/environment";
|
||||||
|
|
||||||
export class CommunityInfo {
|
export class CommunityInfo {
|
||||||
title: string;
|
title: string;
|
||||||
shortTitle:string;
|
shortTitle:string;
|
||||||
communityId: string;
|
communityId: string;
|
||||||
queryId: string;
|
queryId: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
/** @warning Use pipe in HTML or StringUtils.getLogoUrl in components */
|
||||||
logoUrl: string;
|
logoUrl: string;
|
||||||
description: string;
|
description: string;
|
||||||
managers: string[];
|
managers: string[];
|
||||||
|
@ -14,5 +18,16 @@ export class CommunityInfo {
|
||||||
isUpload: boolean;
|
isUpload: boolean;
|
||||||
isSubscribed: boolean;
|
isSubscribed: boolean;
|
||||||
isManager: boolean;
|
isManager: boolean;
|
||||||
|
|
||||||
|
public static checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] {
|
||||||
|
if (Array.isArray(response)) {
|
||||||
|
response.forEach(value => {
|
||||||
|
value.isUpload = value.logoUrl && !StringUtils.isValidUrl(value.logoUrl);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
response.isUpload = response.logoUrl && !StringUtils.isValidUrl(response.logoUrl);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// export const prodReadyCommunities = ["dh-ch", "ee", "fam", "mes", "ni", "covid-19", "dariah", "epos", "egi"];
|
// export const prodReadyCommunities = ["dh-ch", "ee", "fam", "mes", "ni", "covid-19", "dariah", "epos", "egi"];
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {CommunityService} from '../../connect/community/community.service';
|
||||||
import {ConnectHelper} from '../../connect/connectHelper';
|
import {ConnectHelper} from '../../connect/connectHelper';
|
||||||
import {UserManagementService} from '../../services/user-management.service';
|
import {UserManagementService} from '../../services/user-management.service';
|
||||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
|
import {StringUtils} from "../../utils/string-utils.class";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'relatedTo',
|
selector: 'relatedTo',
|
||||||
|
@ -147,7 +148,7 @@ export class RelatedToComponent implements OnInit {
|
||||||
context.link = url;
|
context.link = url;
|
||||||
// grabbing the logoUrl for the gateway links
|
// grabbing the logoUrl for the gateway links
|
||||||
if(community.logoUrl) {
|
if(community.logoUrl) {
|
||||||
context.logo = community.logoUrl;
|
context.logo = StringUtils.getLogoUrl(community);
|
||||||
}
|
}
|
||||||
for(let gateway of this.gateways) {
|
for(let gateway of this.gateways) {
|
||||||
if(gateway.link == context.link) {
|
if(gateway.link == context.link) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ export class Stakeholder {
|
||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
creationDate: Date = null;
|
creationDate: Date = null;
|
||||||
updateDate: Date;
|
updateDate: Date;
|
||||||
|
/** @warning Use pipe in HTML or StringUtils.getLogoUrl in components */
|
||||||
logoUrl: string;
|
logoUrl: string;
|
||||||
isUpload: boolean = false;
|
isUpload: boolean = false;
|
||||||
description: string;
|
description: string;
|
||||||
|
|
|
@ -105,13 +105,11 @@
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<ng-template #resultPreview let-result="result">
|
<ng-template #resultPreview let-result="result">
|
||||||
<div class="uk-flex uk-flex-center">
|
<div class="uk-flex uk-flex-center">
|
||||||
<img *ngIf="result.logoUrl && result.logoUrl != '' && result.isUpload "
|
<img *ngIf="result.logoUrl"
|
||||||
[src]="properties.utilsService + '/download/' + result.logoUrl"
|
[src]="result | logoUrl"
|
||||||
alt="{{(result.title)?result.title:result.shortTitle}} logo" loading="lazy">
|
alt="{{(result.title)?result.title:result.shortTitle}} logo" loading="lazy">
|
||||||
<img *ngIf="result.logoUrl && result.logoUrl != '' && !result.isUpload " [src]="result.logoUrl | urlPrefix"
|
<span *ngIf="!result.logoUrl" class="uk-icon">
|
||||||
alt="{{(result.title)?result.title:result.shortTitle}} logo" loading="lazy">
|
<svg viewBox="0 0 20 20" class="uk-width-1-1" xmlns="http://www.w3.org/2000/svg" ratio="2.5"> <circle fill="none"
|
||||||
<span *ngIf="result.logoUrl == null || result.logoUrl == ''" class="uk-icon">
|
|
||||||
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="2.5"> <circle fill="none"
|
|
||||||
stroke="#000"
|
stroke="#000"
|
||||||
stroke-width="1.1"
|
stroke-width="1.1"
|
||||||
cx="7.7" cy="8.6"
|
cx="7.7" cy="8.6"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
|
import {Component, Input, OnInit, ViewChild} from '@angular/core';
|
||||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {IconsModule} from "../../utils/icons/icons.module";
|
||||||
import {UrlPrefixModule} from "../../utils/pipes/url-prefix.module";
|
import {UrlPrefixModule} from "../../utils/pipes/url-prefix.module";
|
||||||
import {IconsService} from "../../utils/icons/icons.service";
|
import {IconsService} from "../../utils/icons/icons.service";
|
||||||
import {group, lock} from "../../utils/icons/icons";
|
import {group, lock} from "../../utils/icons/icons";
|
||||||
|
import {LogoUrlPipeModule} from "../../utils/pipes/logoUrlPipe.module";
|
||||||
// import {IconsService} from "../../utils/icons/icons.service";
|
// import {IconsService} from "../../utils/icons/icons.service";
|
||||||
// import {group, lock} from "../../utils/icons/icons";
|
// import {group, lock} from "../../utils/icons/icons";
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ import {group, lock} from "../../utils/icons/icons";
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, FormsModule,
|
CommonModule, FormsModule,
|
||||||
RouterModule, ErrorMessagesModule,
|
RouterModule, ErrorMessagesModule,
|
||||||
AlertModalModule, ManageModule, IconsModule, UrlPrefixModule
|
AlertModalModule, ManageModule, IconsModule, UrlPrefixModule, LogoUrlPipeModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
PortalSearchResultComponent
|
PortalSearchResultComponent
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
import { Pipe, PipeTransform} from '@angular/core'
|
|
||||||
|
|
||||||
|
|
||||||
@Pipe({
|
|
||||||
name: 'claimsDatatable'
|
|
||||||
})
|
|
||||||
export class ClaimsDatatablePipe implements PipeTransform {
|
|
||||||
|
|
||||||
transform(array: any[], args: any[]): any {
|
|
||||||
let query: string = args[0];
|
|
||||||
let counter:any = args[1];
|
|
||||||
let active: any = args[2];
|
|
||||||
|
|
||||||
active.page = 1;
|
|
||||||
|
|
||||||
if (query) {
|
|
||||||
var result = array.filter(row=>this.filterAll(row, query));
|
|
||||||
counter.count = result.length;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
filterAll(row: any, query: string) {
|
|
||||||
if(row.userMail.indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(row.targetType != 'project' && row.target.title.indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(row.sourceType != 'project' && row.source.title.indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(row.date.indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(row.curatedBy != null && row.curatedBy.indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(row.curationDate != null && row.curationDate.indexOf(query) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -1,113 +0,0 @@
|
||||||
// import { Pipe, PipeTransform} from '@angular/core';
|
|
||||||
// import { Filter, Value} from '../../searchPages/searchUtils/searchHelperClasses.class';
|
|
||||||
// import { SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
|
|
||||||
// import { ErrorCodes} from '../properties/openaireProperties';
|
|
||||||
//
|
|
||||||
// @Pipe({
|
|
||||||
// name: 'contentProvidersDatatable'
|
|
||||||
// })
|
|
||||||
// export class ContentProvidersDatatablePipe implements PipeTransform {
|
|
||||||
//
|
|
||||||
// transform(array: any[], args: any[]): any {
|
|
||||||
// if(array.length > 0) {
|
|
||||||
// let searchUtils: SearchUtilsClass = args[0];
|
|
||||||
// let filters:Filter[] = args[1];
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// var errorCodes:ErrorCodes = new ErrorCodes();
|
|
||||||
// searchUtils.status = errorCodes.LOADING;
|
|
||||||
//
|
|
||||||
// var result = array.filter(row=>this.filterAll(row, searchUtils.keyword.toLowerCase(), filters));
|
|
||||||
//
|
|
||||||
// let oldTotal = searchUtils.totalResults;
|
|
||||||
//
|
|
||||||
// searchUtils.totalResults = result.length;
|
|
||||||
//
|
|
||||||
// var errorCodes:ErrorCodes = new ErrorCodes();
|
|
||||||
// searchUtils.status = errorCodes.DONE;
|
|
||||||
// if(searchUtils.totalResults == 0 ){
|
|
||||||
// searchUtils.status = errorCodes.NONE;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(oldTotal != searchUtils.totalResults) {
|
|
||||||
// args[3].detectChanges();
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
// return [];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// filterAll(row: any, query: string, filters:Filter[]) {
|
|
||||||
// let returnValue: boolean = false;
|
|
||||||
//
|
|
||||||
// if(query) {
|
|
||||||
// if(row.title.name.toLowerCase().indexOf(query) > -1) {
|
|
||||||
// returnValue = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(row.type.toLowerCase().indexOf(query) > -1) {
|
|
||||||
// returnValue = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(row.countries && row.countries.length > 0) {
|
|
||||||
// for(let country of row.countries) {
|
|
||||||
// if(country.toLowerCase().indexOf(query) > -1) {
|
|
||||||
// returnValue = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(row.compatibility && row.compatibility.toLowerCase().indexOf(query) > -1) {
|
|
||||||
// returnValue = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(row.organizations && row.organizations.length > 0) {
|
|
||||||
// for(let organization of row.organizations) {
|
|
||||||
// if(organization.name.toLowerCase().indexOf(query) > -1) {
|
|
||||||
// returnValue = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(!returnValue) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (let filter of filters){
|
|
||||||
// if(filter.countSelectedValues > 0){
|
|
||||||
// for (let value of filter.values){
|
|
||||||
// if(value.selected == true){
|
|
||||||
//
|
|
||||||
// // make it generic in future commit
|
|
||||||
// let field:string = "";
|
|
||||||
// if(filter.title == "Type") {
|
|
||||||
// field = "type";
|
|
||||||
// } else if(filter.title == "Compatibility Level") {
|
|
||||||
// field = "compatibility";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(row[field] == value.name) {
|
|
||||||
// returnValue = true;
|
|
||||||
// if(filter.filterOperator == "or") {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if(filter.filterOperator == "and") {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// returnValue = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(!returnValue) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import {Pipe, PipeTransform} from '@angular/core'
|
||||||
|
import {Stakeholder} from "../../monitor/entities/stakeholder";
|
||||||
|
import {CommunityInfo} from "../../connect/community/communityInfo";
|
||||||
|
import {StringUtils} from "../string-utils.class";
|
||||||
|
|
||||||
|
@Pipe({ name: 'logoUrl'})
|
||||||
|
export class LogoUrlPipe implements PipeTransform {
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
transform(value: Stakeholder | CommunityInfo): string {
|
||||||
|
return StringUtils.getLogoUrl(value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
import {NgModule} from '@angular/core';
|
||||||
|
import {LogoUrlPipe} from "./logoUrl.pipe";
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [],
|
||||||
|
declarations: [
|
||||||
|
LogoUrlPipe
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
exports: [
|
||||||
|
LogoUrlPipe
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class LogoUrlPipeModule {
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
import {UrlSegment} from '@angular/router';
|
import {UrlSegment} from '@angular/router';
|
||||||
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
||||||
|
import {Stakeholder} from "../monitor/entities/stakeholder";
|
||||||
|
import {CommunityInfo} from "../connect/community/communityInfo";
|
||||||
|
import {properties} from "../../../environments/environment";
|
||||||
|
|
||||||
export class Dates {
|
export class Dates {
|
||||||
public static yearMin = 1800;
|
public static yearMin = 1800;
|
||||||
|
@ -13,9 +16,7 @@ export class Dates {
|
||||||
var year = parseInt(yearString, 10);
|
var year = parseInt(yearString, 10);
|
||||||
|
|
||||||
// Check the ranges of month and year
|
// Check the ranges of month and year
|
||||||
if (year < yearMin || year > yearMax)
|
return !(year < yearMin || year > yearMax);
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//format YYYY-MM-DD
|
//format YYYY-MM-DD
|
||||||
|
@ -289,6 +290,10 @@ export class StringUtils {
|
||||||
return !!email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$");
|
return !!email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static getLogoUrl(result: Stakeholder | CommunityInfo): string {
|
||||||
|
return (result.isUpload && result.logoUrl)?(properties.utilsService + '/download/' + result.logoUrl):result.logoUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public static isValidUrl(url: string): boolean {
|
public static isValidUrl(url: string): boolean {
|
||||||
return new RegExp(this.urlRegex).test(url);
|
return new RegExp(this.urlRegex).test(url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue