Update to Angular 16 #16
|
@ -7,8 +7,8 @@ import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
|||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {Subscriber} from "rxjs";
|
||||
import {OpenaireEntities} from "../../utils/properties/searchFields";
|
||||
import {CommunityService} from "../../connect/community/community.service";
|
||||
import {CommunitiesService} from "../../connect/communities/communities.service";
|
||||
import {UserManagementService} from "../../services/user-management.service";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
|
@ -49,9 +49,14 @@ export class ClaimContextSearchFormComponent {
|
|||
keyword = "";
|
||||
subscriptions = [];
|
||||
communityLogos = {};
|
||||
communityIds = [];
|
||||
user = null;
|
||||
ngOnInit() {
|
||||
this.entitiesSelectOptions = this.showOptions.selectOptions;
|
||||
//get community logos
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
|
||||
this.subscriptions.push(this._communitiesService.getCommunities(this.properties, this.properties.communityAPI+"/communities/").subscribe(
|
||||
communitiesResults => {
|
||||
if(communitiesResults!=null) {
|
||||
|
@ -61,6 +66,13 @@ export class ClaimContextSearchFormComponent {
|
|||
this.communityLogos[community.communityId] = community;
|
||||
}
|
||||
}
|
||||
this.communityIds = communitiesResults.filter(community => {
|
||||
return community.claim == "all" ||
|
||||
Session.isCommunityCurator(this.user) ||
|
||||
Session.isClaimsCurator(this.user) ||
|
||||
(community.claim == "membersOnly" && Session.isSubscribedTo("community", community.communityId,this.user)) ||
|
||||
(community.claim == "managersOnly" && Session.isManager("community", community.communityId,this.user))
|
||||
}).map(community => community.communityId);
|
||||
this.getCommunities();
|
||||
}
|
||||
},
|
||||
|
@ -69,6 +81,10 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
));
|
||||
|
||||
}, error => {
|
||||
|
||||
}));
|
||||
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
|
@ -77,7 +93,7 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
});
|
||||
}
|
||||
constructor(private _contextService: ContextsService, private router: Router, private _communitiesService: CommunitiesService) {
|
||||
constructor(private _contextService: ContextsService, private router: Router, private _communitiesService: CommunitiesService, private userManagementService: UserManagementService,) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -172,15 +188,16 @@ export class ClaimContextSearchFormComponent {
|
|||
|
||||
} else {
|
||||
this.loading = true;
|
||||
this.subscriptions.push(this._contextService.getPublicCommunitiesByState().subscribe(
|
||||
this.subscriptions.push(this._contextService.getCommunitiesByState().subscribe(
|
||||
data => {
|
||||
this.communities = data;
|
||||
console.log(this.communities)
|
||||
this.communities = data.filter(community => {
|
||||
return this.communityIds.indexOf(community.id) != -1
|
||||
});
|
||||
if (this.communities.length > 0) {
|
||||
this.communities.sort((n1, n2) => n1.label > n2.label);
|
||||
this.communities.sort((n1, n2) => n1.title > n2.title);
|
||||
}
|
||||
this.loading = false;
|
||||
if (this.communityId != null) {
|
||||
if (this.communityId != null && this.communityIds.indexOf(this.communityId) != -1) {
|
||||
//preselect community
|
||||
this.selectedCommunityId = this.communityId;
|
||||
for (let i = 0; i < this.communities.length; i++) {
|
||||
|
|
|
@ -56,12 +56,11 @@ export class CommunitiesService {
|
|||
result['description'] = resData.description;
|
||||
result['date'] = resData.creationDate;
|
||||
result['status'] = 'all';
|
||||
result['claim'] = resData.claim;
|
||||
result['membership'] = resData.membership;
|
||||
if (resData.hasOwnProperty('status')) {
|
||||
result['status'] = resData.status;
|
||||
const status = ['all', 'hidden', 'manager'];
|
||||
if (status.indexOf(result['status']) === -1) {
|
||||
result['status'] = 'hidden';
|
||||
}
|
||||
result.validateStatus();
|
||||
}
|
||||
if (resData.type != null) {
|
||||
result['type'] = resData.type;
|
||||
|
|
|
@ -98,14 +98,14 @@ export class CommunityService {
|
|||
community.description = resData.description;
|
||||
community.date = resData.creationDate;
|
||||
community.zenodoCommunity = resData.zenodoCommunity;
|
||||
community.status = 'all';
|
||||
community.status = 'PUBLIC';
|
||||
community.claim = resData.claim;
|
||||
community.membership = resData.membership;
|
||||
community.type = resData.type;
|
||||
community.otherZenodoCommunities = resData.otherZenodoCommunities;
|
||||
if (resData.hasOwnProperty('status')) {
|
||||
community.status = resData.status;
|
||||
const status = ['all', 'hidden', 'manager'];
|
||||
if (status.indexOf(community['status']) === -1) {
|
||||
community.status = 'hidden';
|
||||
}
|
||||
community.validateStatus();
|
||||
}
|
||||
if (resData.subjects != null) {
|
||||
community.subjects = Array.isArray(resData.subjects)?resData.subjects:[resData.subjects];
|
||||
|
|
|
@ -14,8 +14,11 @@ export class CommunityInfo {
|
|||
managers: string[];
|
||||
date:Date;
|
||||
subjects: string[];
|
||||
status:string;
|
||||
status:"all" | "manager" | "hidden" | "PUBLIC" | "RESTRICTED" | "PRIVATE";
|
||||
claim: "all" | "managersOnly" | "membersOnly";
|
||||
membership: "open" | "byInvitation";
|
||||
zenodoCommunity:string;
|
||||
otherZenodoCommunities: string[];
|
||||
isUpload: boolean;
|
||||
isSubscribed: boolean;
|
||||
isManager: boolean;
|
||||
|
@ -33,5 +36,19 @@ export class CommunityInfo {
|
|||
}
|
||||
return response;
|
||||
}
|
||||
public isPublic(){
|
||||
return this.status == "all" || this.status == "PUBLIC";
|
||||
}
|
||||
public isRestricted(){
|
||||
return this.status == "manager" || this.status == "RESTRICTED";
|
||||
}
|
||||
public isPrivate(){
|
||||
return this.status == "hidden" || this.status == "PRIVATE";
|
||||
}
|
||||
public validateStatus(){
|
||||
if(!(this.isPrivate() || this.isRestricted() || this.isPublic())){
|
||||
this.status = "PRIVATE";
|
||||
}
|
||||
}
|
||||
}
|
||||
// export const prodReadyCommunities = ["dh-ch", "ee", "fam", "mes", "ni", "covid-19", "dariah", "epos", "egi"];
|
||||
|
|
|
@ -54,6 +54,6 @@ export class ConnectHelper {
|
|||
|
||||
|
||||
public static isPrivate(community, user) {
|
||||
return community && (community.status == "hidden" || (community.status == "manager" && !(Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager("community", community.communityId, user))))
|
||||
return community && (community.isPrivate() || (community.isRestricted() && !(Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager("community", community.communityId, user))))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,25 @@ import {map} from "rxjs/operators";
|
|||
export class SearchCommunityProjectsService {
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchProjects (properties:EnvProperties, pid: string):any {
|
||||
let url = properties.communityAPI+pid+"/projects";
|
||||
|
||||
searchProjects (properties:EnvProperties, pid: string, page=1, size=500):any {
|
||||
return this.searchProjectsWithPaging(properties,pid,page, size, null, null);
|
||||
}
|
||||
searchProjectsWithPaging (properties:EnvProperties, pid: string, page=1, size=500, searchFilter, funder, orderBy = "name"):any {
|
||||
let params = funder ? ["funder="+ funder] :[];
|
||||
if (searchFilter) {
|
||||
params.push("searchFilter="+ searchFilter)
|
||||
}
|
||||
params.push("orderBy="+ orderBy);
|
||||
let url = properties.communityAPI+pid+"/projects/"+ (page-1) + "/" + size + (params.length > 0?"?" + params.join("&"):"");
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
||||
//.map(res => <any> res.json())
|
||||
}
|
||||
countTotalProjects(properties:EnvProperties,pid:string) {
|
||||
let url = properties.communityAPI+pid+"/projects";
|
||||
let url = properties.communityAPI+pid+"/projects/0/1";
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
.pipe(map(res => res['length']));
|
||||
.pipe(map(res => res['totalElements']));
|
||||
}
|
||||
getProjectFunders(properties:EnvProperties,pid:string) {
|
||||
let url = properties.communityAPI+pid+"/funders";
|
||||
return this.http.get<string[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
@Injectable()
|
||||
export class SearchZenodoCommunitiesService {
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchZCommunities (properties:EnvProperties, pid: string):any {
|
||||
let url = properties.communityAPI+pid+"/zenodocommunities";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
||||
//.map(res => <any> res.json())
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchZenodoCommunitiesService} from './searchZenodoCommunities.service';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers:[
|
||||
SearchZenodoCommunitiesService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
export class SearchZenodoCommunitiesServiceModule { }
|
|
@ -16,12 +16,11 @@ export class ZenodoCommunitiesService {
|
|||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => [this.parseZenodoCommunities(res['hits'].hits),res['hits'].total]));
|
||||
}
|
||||
getZenodoCommunityById(properties:EnvProperties, url: string, openaireId:string) {
|
||||
getZenodoCommunityById(properties:EnvProperties, url: string) {
|
||||
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => {
|
||||
var community = this.parseZenodoCommunity(res);
|
||||
community["openaireId"]=openaireId;
|
||||
return community;
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -6,5 +6,4 @@ export class ZenodoCommunityInfo {
|
|||
logoUrl: string;
|
||||
date: Date;
|
||||
page: string;
|
||||
openaireId:string;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
<span>Member</span>
|
||||
</div>
|
||||
<div [ngClass]="isMobile?'uk-flex uk-flex-middle uk-margin-left uk-margin-small-top':'uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-column uk-flex-middle'">
|
||||
<div *ngIf="type === 'community' && result.status === 'manager'">
|
||||
<div *ngIf="type === 'community' && result.isRestricted()">
|
||||
<icon [name]="visibilityIcon.get('RESTRICTED')" [ratio]="isMobile?0.8:1.2" [flex]="true"></icon>
|
||||
<span class="uk-text-small uk-text-capitalize" [class.uk-text-xsmall]="isMobile" [class.uk-margin-xsmall-left]="isMobile">restricted</span>
|
||||
</div>
|
||||
<ng-container *ngIf="type === 'community' && result.status === 'hidden'">
|
||||
<ng-container *ngIf="type === 'community' && result.isPrivate()">
|
||||
<icon [name]="visibilityIcon.get('PRIVATE')" [ratio]="isMobile?0.8:1.2" [flex]="true"></icon>
|
||||
<span class="uk-text-small uk-text-capitalize" [class.uk-text-xsmall]="isMobile" [class.uk-margin-xsmall-left]="isMobile">private</span>
|
||||
</ng-container>
|
||||
|
|
Loading…
Reference in New Issue