Add updateSubjects and advanced criteria in community service. Add margin-top in actions of users and subscribers.

This commit is contained in:
Konstantinos Triantafyllou 2023-03-09 16:07:39 +02:00
parent 1d2a0effa8
commit 978d9f0269
5 changed files with 39 additions and 45 deletions

View File

@ -5,6 +5,7 @@ import {map} from "rxjs/operators";
import {BehaviorSubject, from, Observable, Subscriber} from "rxjs"; import {BehaviorSubject, from, Observable, Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {StringUtils} from "../../utils/string-utils.class"; import {StringUtils} from "../../utils/string-utils.class";
import {SelectionCriteria} from "../../utils/entities/contentProvider";
@Injectable({providedIn: 'root'}) @Injectable({providedIn: 'root'})
export class CommunityService { export class CommunityService {
@ -72,57 +73,47 @@ export class CommunityService {
return this.http.post(url, community, options); return this.http.post(url, community, options);
} }
public updateSubjects(subjects: string[], fos: string[], sgd: string[]) {
let communityInfo: CommunityInfo = this.community.value;
communityInfo.subjects = subjects;
communityInfo.fos = fos;
communityInfo.sdg = sdg;
this.community.next(communityInfo);
}
public updateAdvancedCriteria(selectionCriteria: SelectionCriteria) {
let communityInfo: CommunityInfo = this.community.value;
communityInfo.selectionCriteria = selectionCriteria;
this.community.next(communityInfo);
}
public parseCommunity(data: any): CommunityInfo { public parseCommunity(data: any): CommunityInfo {
const resData = Array.isArray(data) ? data[0] : data; const resData = Array.isArray(data) ? data[0] : data;
const community: CommunityInfo = new CommunityInfo(); const community: CommunityInfo = new CommunityInfo();
community['title'] = resData.name; community.title = resData.name;
community['shortTitle'] = resData.shortName; community.shortTitle = resData.shortName;
community['communityId'] = resData.id; community.communityId = resData.id;
community['queryId'] = resData.queryId; community.queryId = resData.queryId;
community['logoUrl'] = resData.logoUrl; community.logoUrl = resData.logoUrl;
community['description'] = resData.description; community.description = resData.description;
community['date'] = resData.creationDate; community.date = resData.creationDate;
community['zenodoCommunity'] = resData.zenodoCommunity; community.zenodoCommunity = resData.zenodoCommunity;
community['status'] = 'all'; community.status = 'all';
community.type = resData.type;
if (resData.hasOwnProperty('status')) { if (resData.hasOwnProperty('status')) {
community['status'] = resData.status; community.status = resData.status;
const status = ['all', 'hidden', 'manager']; const status = ['all', 'hidden', 'manager'];
if (status.indexOf(community['status']) === -1) { if (status.indexOf(community['status']) === -1) {
community['status'] = 'hidden'; community.status = 'hidden';
} }
} }
if (resData.type != null) {
community['type'] = resData.type;
}
if (resData.managers != null) {
if (community['managers'] === undefined) {
community['managers'] = new Array<string>();
}
const managers = resData.managers;
const length = Array.isArray(managers) ? managers.length : 1;
for (let i = 0; i < length; i++) {
const manager = Array.isArray(managers) ? managers[i] : managers;
community.managers[i] = manager;
}
}
if (resData.subjects != null) { if (resData.subjects != null) {
if (community['subjects'] === undefined) { community.subjects = Array.isArray(resData.subjects)?resData.subjects:[resData.subjects];
community['subjects'] = new Array<string>();
}
const subjects = resData.subjects;
const length = Array.isArray(subjects) ? subjects.length : 1;
for (let i = 0; i < length; i++) {
const subject = Array.isArray(subjects) ? subjects[i] : subjects;
community.subjects[i] = subject;
} }
if (resData.advancedConstraint != null) {
community.selectionCriteria = resData.advancedConstraint;
} else {
community.selectionCriteria = new SelectionCriteria();
} }
return CommunityInfo.checkIsUpload(community); return CommunityInfo.checkIsUpload(community);
} }

View File

@ -1,5 +1,6 @@
import {StringUtils} from "../../utils/string-utils.class"; import {StringUtils} from "../../utils/string-utils.class";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {SelectionCriteria} from "../../utils/entities/contentProvider";
export class CommunityInfo { export class CommunityInfo {
title: string; title: string;
@ -18,6 +19,9 @@ export class CommunityInfo {
isUpload: boolean; isUpload: boolean;
isSubscribed: boolean; isSubscribed: boolean;
isManager: boolean; isManager: boolean;
fos: string[] = [];
sdg: string[] = []
selectionCriteria: SelectionCriteria;
public static checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] { public static checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] {
if (Array.isArray(response)) { if (Array.isArray(response)) {

View File

@ -3,7 +3,7 @@
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>
<div actions> <div actions>
<div class="uk-section-xsmall"> <div class="uk-section-xsmall uk-margin-top">
<div class="uk-grid" uk-grid> <div class="uk-grid" uk-grid>
<div class="uk-flex uk-flex-left@m uk-flex-center uk-width-expand"> <div class="uk-flex uk-flex-left@m uk-flex-center uk-width-expand">
<ul class="uk-subnav uk-subnav-pill"> <ul class="uk-subnav uk-subnav-pill">

View File

@ -77,7 +77,6 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.updateLists(); this.updateLists();
this.userManagementService.getUserInfo().subscribe(user => { this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
console.log(this.canDelete)
}); });
} }

View File

@ -3,7 +3,7 @@
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>
<div actions> <div actions>
<div class="uk-section-xsmall"> <div class="uk-section-xsmall uk-margin-top">
<div class="uk-grid uk-flex-right@m uk-flex-center uk-flex-middle" uk-grid> <div class="uk-grid uk-flex-right@m uk-flex-center uk-flex-middle" uk-grid>
<div search-input [searchControl]="filterForm.get('keyword')" placeholder="Search members" <div search-input [searchControl]="filterForm.get('keyword')" placeholder="Search members"
[expandable]="true" [disabled]="loading || !subscriberInvite || subscriberInvite.loading" searchInputClass="outer" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"> [expandable]="true" [disabled]="loading || !subscriberInvite || subscriberInvite.loading" searchInputClass="outer" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1">