Merge branch 'develop' into angular-18

This commit is contained in:
argirok 2024-09-10 11:47:44 +03:00
commit 7f01e0df5f
11 changed files with 167 additions and 37 deletions

View File

@ -220,19 +220,23 @@ export class AppComponent implements OnInit {
position: 'left',
badge: true
};
let communityInfo = new MenuItem("community", "Community Info", "", "/" + this.community.communityId, false, [], [], {}, {name: 'badge'}, null, null, "/" + this.community.communityId + "/info");
let communityInfo = new MenuItem("communityInfo", "Community Info", "", "/" + this.community.communityId, false, [], [], {}, {name: 'badge'}, null, null, "/" + this.community.communityId + "/info");
communityInfo.items = [
new MenuItem("profile", "Profile", "", "/" + this.community.communityId + "/info/profile", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/profile"),
new MenuItem("organizations", "Organizations", "", "/" + this.community.communityId + "/info/organizations", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/organizations"),
new MenuItem("projects", OpenaireEntities.PROJECTS, "", "/" + this.community.communityId + "/info/projects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/projects"),
new MenuItem("content-providers", OpenaireEntities.DATASOURCES, "", "/" + this.community.communityId + "/info/content-providers", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/content-providers"),
new MenuItem("zenodo-communities", "Zenodo Communities ", "", "/" + this.community.communityId + "/info/zenodo-communities", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/zenodo-communities"),
new MenuItem("advanced-criteria", "Advanced Criteria", "", "/" + this.community.communityId + "/info/advanced-criteria", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/advanced-criteria")
new MenuItem("organizations", "Organizations", "", "/" + this.community.communityId + "/info/organizations", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/organizations")
]
this.sideBarItems.push(communityInfo);
let contentConfiguration = new MenuItem("contentConfiguration", "Content configuration", "", "/" + this.community.communityId +"/config", false, [], [], {}, {name: 'badge'}, null, null, "/" + this.community.communityId + "/config");
contentConfiguration.items = [
new MenuItem("projects", OpenaireEntities.PROJECTS, "", "/" + this.community.communityId + "/config/projects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/config/projects"),
new MenuItem("content-providers", OpenaireEntities.DATASOURCES, "", "/" + this.community.communityId + "/config/content-providers", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/config/content-providers"),
new MenuItem("zenodo-communities", "Zenodo Communities ", "", "/" + this.community.communityId + "/config/zenodo-communities", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/config/zenodo-communities"),
new MenuItem("advanced-criteria", "Advanced Criteria", "", "/" + this.community.communityId + "/config/advanced-criteria", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/config/advanced-criteria")
]
if(this.community.type === 'community') {
communityInfo.items.splice(4, 0, new MenuItem("subjects", "Subjects", "", "/" + this.community.communityId + "/info/subjects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/subjects"))
contentConfiguration.items.splice(2, 0, new MenuItem("subjects", "Subjects", "", "/" + this.community.communityId + "/config/subjects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/config/subjects"))
}
this.sideBarItems.push(communityInfo);
this.sideBarItems.push(contentConfiguration);
this.sideBarItems.push(new MenuItem("users", "Users", "", "/" + this.community.communityId + "/users", false, [], [], {}, {name: 'group'}, null, null, "/" + this.community.communityId + "/users"));
this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Menus", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/" + this.community.communityId + "/admin-tools"));
this.sideBarItems.push(new MenuItem("customization", "Customization", "", "/" + this.community.communityId + "/customize-layout", false, [], [], {}, {name: 'brush'}));

View File

@ -7,12 +7,7 @@ import {ConnectCommunityGuard} from "../../openaireLibrary/connect/communityGuar
RouterModule.forChild([
{path: '', redirectTo: 'profile', pathMatch: 'full'},
{path: 'profile', loadChildren: () => import('./profile/profile.module').then(m => m.ProfileModule)},
{path: 'organizations', loadChildren: () => import('../affiliations/affiliations.module').then(m => m.AffiliationsModule)},
{path: 'projects', loadChildren: () => import('../projects/communityProjects.module').then(m => m.CommunityProjectsModule)},
{path: 'content-providers', loadChildren: () => import('../content-providers/communityContentProviders.module').then(m => m.CommunityContentProvidersModule)},
{path: 'zenodo-communities', loadChildren: () => import('../zenodo-communities/zenodo-communities.module').then(m => m.ZenodoCommunitiesModule)},
{path: 'advanced-criteria', loadChildren: () => import('../advanced-criteria/advanced-criteria.module').then(m => m.AdvancedCriteriaModule)},
{path: 'subjects', canActivateChild: [ConnectCommunityGuard], loadChildren: () => import('../subjects/subjects-edit-form/subjects-edit-form.module').then(m => m.SubjectsEditFormModule)},
{path: 'organizations', loadChildren: () => import('../affiliations/affiliations.module').then(m => m.AffiliationsModule)}
])
],
providers: [ConnectCommunityGuard]

View File

@ -8,6 +8,10 @@ import {ConnectRIGuard} from "../openaireLibrary/connect/communityGuard/connectR
path: 'info',
loadChildren: () => import('./community-info/community-info-routing.module').then(m => m.CommunityInfoRoutingModule),
},
{
path: 'config',
loadChildren: () => import('./content-config/community-content-config-routing.module').then(m => m.CommunityContentConfigRoutingModule),
},
{
path: 'users',
loadChildren: () => import('./users/users-routing.module').then(m => m.UsersRoutingModule)

View File

@ -0,0 +1,19 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {ConnectCommunityGuard} from "../../openaireLibrary/connect/communityGuard/connectCommunityGuard.guard";
@NgModule({
imports: [
RouterModule.forChild([
{path: '', redirectTo: 'projects', pathMatch: 'full'},
{path: 'projects', loadChildren: () => import('../projects/communityProjects.module').then(m => m.CommunityProjectsModule)},
{path: 'content-providers', loadChildren: () => import('../content-providers/communityContentProviders.module').then(m => m.CommunityContentProvidersModule)},
{path: 'zenodo-communities', loadChildren: () => import('../zenodo-communities/zenodo-communities.module').then(m => m.ZenodoCommunitiesModule)},
{path: 'advanced-criteria', loadChildren: () => import('../advanced-criteria/advanced-criteria.module').then(m => m.AdvancedCriteriaModule)},
{path: 'subjects', canActivateChild: [ConnectCommunityGuard], loadChildren: () => import('../subjects/subjects-edit-form/subjects-edit-form.module').then(m => m.SubjectsEditFormModule)}
])
],
providers: [ConnectCommunityGuard]
})
export class CommunityContentConfigRoutingModule {
}

View File

@ -171,6 +171,20 @@
" draftCustomizationOptions.identity.secondaryColor= $event; updateBackgroundsBasedOnIdentity(); updateButtonsBasedOnIdentity()"
label="Secondary"></color>
</div>
<div *ngIf="draftCustomizationOptions.identityIsCustom && community && (this.community.plan == 'Premium' || this.community.plan == 'Advanced') " class=" uk-margin-large-top uk-margin-medium-bottom">
<div class=" uk-margin-xsmall-bottom uk-text-uppercase uk-text-meta uk-text-bold uk-flex uk-flex-middle">
Custom css
<a *ngIf="hasChanges(publishedCustomizationOptions.identity.customCss, draftCustomizationOptions.identity.customCss) &&
draftCustomizationOptions.identityIsCustom" class="uk-margin-small-left uk-button-link"
uk-tooltip="title:<div class='uk-width-large'>Reset to previously saved options</div>"
(click)="resetCustomCssTo(publishedCustomizationOptions.identity.customCss);">
<icon name="settings_backup_restore" flex="true"></icon>
</a>
</div>
<textarea [ngModel]="this.draftCustomizationOptions.identity.customCss" type="textarea"
[rows]="5" style="resize: vertical; font-size: 12px; width: calc(100% - 7px);" placeholder="Add custom css here."
(ngModelChange)="this.draftCustomizationOptions.identity.customCss =$event"></textarea>
</div>
</div>
</ng-template>
<ng-template #backgroundOptions>

View File

@ -14,6 +14,8 @@ import {Subscription} from 'rxjs';
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
import {AlertModal} from "../../openaireLibrary/utils/modal/alert";
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
declare var UIkit;
@ -69,6 +71,9 @@ declare var UIkit;
.menu_section.uk-overflow-auto:hover {
overflow-y: scroll;
}
:host >>>.input-wrapper > .input-box{
padding:0 !important;
}
`]
})
@ -93,7 +98,7 @@ sidebarItems = [{name:"Identity", id : "identity", icon: "desktop_windows" },
{name:"Backgrounds", id : "backgrounds", icon: "wallpaper" },
{name:"Buttons", id : "buttons", icon: "smart_button" }]
@ViewChild('leaveModal') closeModal: AlertModal;
public community: CommunityInfo = null;
constructor(private element: ElementRef,
private route: ActivatedRoute,
private _router: Router,
@ -102,7 +107,8 @@ sidebarItems = [{name:"Identity", id : "identity", icon: "desktop_windows" },
private layoutService: CustomizationService,
private utilsService: UtilitiesService,
private userManagementService: UserManagementService,
private _clearCacheService: ClearCacheService) {
private _clearCacheService: ClearCacheService,
private communityService: CommunityService,) {
}
ngOnDestroy() {
@ -132,6 +138,9 @@ sidebarItems = [{name:"Identity", id : "identity", icon: "desktop_windows" },
this.subscriptions.push(this.route.params.subscribe((params) => {
this.communityId = params['community'];
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.community = community;
}))
if(this.communityId == "covid-19"){
this.defaultCustomizationOptions= new CustomizationOptions(CustomizationOptions.getIdentity(this.communityId).mainColor,CustomizationOptions.getIdentity(this.communityId).secondaryColor);
}
@ -302,6 +311,9 @@ sidebarItems = [{name:"Identity", id : "identity", icon: "desktop_windows" },
this.updateBackgroundsBasedOnIdentity();
}
resetCustomCssTo(cutomCss:string) {
this.draftCustomizationOptions.identity.customCss = cutomCss;
}
updateButtonsBasedOnIdentity(){
let tmp = new CustomizationOptions(this.draftCustomizationOptions.identity.mainColor, this.draftCustomizationOptions.identity.secondaryColor);
if(!this.draftCustomizationOptions.buttonsIsCustom) {

View File

@ -12,7 +12,7 @@ import {ManageCommunityProjectsService} from '../../services/manageProjects.serv
import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs";
import {UntypedFormBuilder, UntypedFormGroup} from "@angular/forms";
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {debounceTime, distinctUntilChanged, skip} from "rxjs/operators";
import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview";
import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
@ -84,7 +84,7 @@ export class AddProjectsComponent implements OnInit {
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges
.pipe(debounceTime(1000), distinctUntilChanged())
.pipe(debounceTime(1000), distinctUntilChanged(), skip(1))
.subscribe(value => {
this.keywordChanged(value);
}));
@ -283,6 +283,7 @@ export class AddProjectsComponent implements OnInit {
goTo(page: number = 1, refineQuery: boolean = true) {
this.openaireSearchUtils.page = page;
this.openaireSearchUtils.status = this.errorCodes.LOADING;
this.selectedIndexes = [];
if(refineQuery) {
this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
this.getFunders();
@ -390,10 +391,9 @@ export class AddProjectsComponent implements OnInit {
}
public selectAll(){
if(this.selectedIndexes.length < this.openaireProjects.length) {
this.selectedIndexes = Array.from(Array(10).keys());
this.selectedIndexes = Array.from(Array(this.openaireProjects.length).keys());
}else{
this.selectedIndexes = [];
}
console.log(this.selectedIndexes)
}
}

View File

@ -23,6 +23,18 @@
</div>
</div>
<div inner>
<div *ngIf="communitySearchUtils.totalResults > 0">
<label>
<input id="checkAll" type="checkbox" (click)="selectAll()" class="uk-checkbox" title="Select all"
[ngModel]="selectedIndexes.length == previewCommunityProjects.length"/>
</label>
<button *ngIf="selectedIndexes.length > 0" class="uk-button uk-button-link uk-margin-xsmall-left" [class.uk-disabled]="selectedIndexes.length == 0"
[disabled]="selectedIndexes.length == 0" (click)="promtToRemoveProjects()" >
Remove ({{selectedIndexes.length}})
</button>
<hr class="uk-margin-remove-top">
</div>
<div class="uk-margin-top">
<results-and-pages [type]="openaireEntiites.PROJECTS | lowercase" [page]="communitySearchUtils.page" [pageSize]="resultsPerPage"
[totalResults]="communitySearchUtils.totalResults"></results-and-pages>
@ -109,6 +121,10 @@
</div>
<div class="uk-card-footer uk-padding-remove-vertical">
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div class="uk-flex uk-flex-middle">
<input [id]="item.id" class="uk-checkbox" type="checkbox" title="Select"
value="{{selectedIndexes.indexOf(i) != -1}}" [ngModel]="selectedIndexes.indexOf(i)!=-1" (click)="toggleSelected(i)">
</div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"

View File

@ -19,8 +19,9 @@ import {CommunityInfo} from "../../openaireLibrary/connect/community/communityIn
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service";
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {debounceTime, distinctUntilChanged, skip} from "rxjs/operators";
import {IndexInfoService} from "../../openaireLibrary/utils/indexInfo.service";
declare var UIkit;
@Component({
selector: 'remove-projects',
@ -65,6 +66,9 @@ export class RemoveProjectsComponent implements OnInit {
public openaireEntiites = OpenaireEntities;
lastDBLoadDate = null;
public selectedIndexes = [];
openaireEntities = OpenaireEntities;
constructor(private route: ActivatedRoute, private _router: Router,
private _fb: UntypedFormBuilder,
private communityService: CommunityService,
@ -87,13 +91,15 @@ export class RemoveProjectsComponent implements OnInit {
sort: this._fb.control(this.sortOptions[0].value)
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.pipe(debounceTime(500), distinctUntilChanged(), skip(1)).subscribe(value => {
this.page = 1;
this._getCommunityProjects(this.page, this.filterForm.get('keyword').value,(this.filterForm.get("funder").value? this.filterForm.get("funder").value.id:null),
this.filterForm.get("sort").value.sort );
}));
this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => {
this.subscriptions.push(this.filterForm.get('sort').valueChanges.pipe(
distinctUntilChanged(), skip(1)
).subscribe(value => {
this.page = 1;
this._getCommunityProjects(this.page, this.filterForm.get('keyword').value, this.filterForm.get("funder").value? this.filterForm.get("funder").value.id:null, this.filterForm.get("sort").value.sort );
}));
@ -129,20 +135,37 @@ export class RemoveProjectsComponent implements OnInit {
}
public confirmedDeleteProject(data: any) {
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, this.selectedCommunityProject.openaireId).subscribe(
data => {
this._clearCacheService.purgeBrowserCache(this.openaireEntiites.PROJECT+" removed", this.community.communityId);
NotificationHandler.rise(OpenaireEntities.PROJECT+' successfully removed!');
this._getCommunityProjects(this.communitySearchUtils.page, this.keyword,null);
if(this.selectedCommunityProject) {
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, this.selectedCommunityProject.openaireId).subscribe(
data => {
this._clearCacheService.purgeBrowserCache(this.openaireEntiites.PROJECT + " removed", this.community.communityId);
NotificationHandler.rise(OpenaireEntities.PROJECT + ' successfully removed!');
this._getCommunityProjects(this.previewCommunityProjects.length == 1 && (this.communitySearchUtils.page - 1) >= 0 ? (this.communitySearchUtils.page -1 ): this.communitySearchUtils.page, this.keyword, null);
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err);
}
));
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err);
}
));
}else if(this.selectedIndexes.length > 0){
this.removeAll();
}
}
public promtToRemoveProjects() {
this.selectedCommunityProject = null;
this.alertModalDeleteCommunity.cancelButton = true;
this.alertModalDeleteCommunity.okButton = true;
this.alertModalDeleteCommunity.alertTitle = "Remove "+OpenaireEntities.PROJECTS;
this.alertModalDeleteCommunity.message = "";
let title = this.selectedIndexes.length + " " + OpenaireEntities.PROJECTS;
if (title) {
this.alertModalDeleteCommunity.message += " <b>" + title + "</b> ";
}
this.alertModalDeleteCommunity.message += " will be removed from your "+OpenaireEntities.COMMUNITY.toLowerCase()+". Are you sure?";
this.alertModalDeleteCommunity.okButtonText = "Yes";
this.alertModalDeleteCommunity.open();
}
public removeProject(communityProject: any) {
this.selectedCommunityProject = communityProject;
this.alertModalDeleteCommunity.cancelButton = true;
@ -176,6 +199,7 @@ export class RemoveProjectsComponent implements OnInit {
this.communitySearchUtils.status = this.errorCodes.LOADING;
this.communitySearchUtils.page = page;
this.communitySearchUtils.keyword = keyword;
this.communitySearchUtils.totalResults = 0;
this.subscriptions.push(this._searchCommunityProjectsService.searchProjectsWithPaging(this.properties, this.community.communityId, this.communitySearchUtils.page, this.resultsPerPage, this.communitySearchUtils.keyword, funder, orderBy).subscribe(
data => {
this.previewCommunityProjects = data.content;
@ -218,6 +242,7 @@ export class RemoveProjectsComponent implements OnInit {
HelperFunctions.scroll();
this.page = $event.value;
this._getCommunityProjects(this.page, this.filterForm.get('keyword').value, null);
this.selectedIndexes = [];
}
addNew() {
@ -258,5 +283,41 @@ export class RemoveProjectsComponent implements OnInit {
return this.filterForm && this.filterForm.get('funder').value && this.filterForm.get('funder').value.id === value;
}
public selectAll(){
if(this.selectedIndexes.length < this.communitySearchUtils.totalResults) {
this.selectedIndexes = Array.from(Array(this.previewCommunityProjects.length).keys());
}else{
this.selectedIndexes = [];
}
}
public toggleSelected(index){
if (this.selectedIndexes.indexOf(index) != -1){
this.selectedIndexes.splice(this.selectedIndexes.indexOf(index), 1);
}else{
this.selectedIndexes.push(index);
}
}
public removeAll(){
let projectList = [];
for(let index of this.selectedIndexes){
projectList.push(this.previewCommunityProjects[index].openaireId);
}
this.subscriptions.push(this._manageCommunityProjectsService.removeProjectList(this.properties, this.community.communityId, projectList).subscribe(
data => {
// this.communityProjects.push(data);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" added", this.community.communityId);
UIkit.notification(this.selectedIndexes.length + " " + this.openaireEntities.PROJECTS+' successfully removed!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this._getCommunityProjects(projectList.length == this.previewCommunityProjects.length && (this.communitySearchUtils.page - 1) > 0 ? (this.communitySearchUtils.page -1 ): this.communitySearchUtils.page, this.keyword, null);
this.selectedIndexes = [];
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
));
}
}

View File

@ -464,7 +464,7 @@ export class HelpContentService {
}
statisticsIsActiveToggle(apiURL: string, id: string): Observable<boolean> {
const url = apiURL + '/statistics/' + encodeURIComponent(id) + '/toggle';
const url = apiURL + 'statistics/' + encodeURIComponent(id) + '/toggle';
return this.http.post<boolean>(url, {}, CustomOptions.getAuthOptionsWithBody()).pipe(catchError(this.handleError));
}
}

View File

@ -16,7 +16,12 @@ export class ManageCommunityProjectsService {
//return this.http.delete(url, options)
return this.http.request('delete', url, { headers: headers})
}
removeProjectList(properties:EnvProperties, pid: string, projects: any[]) {
let headers = new HttpHeaders({'Content-Type': 'application/json'});
let url = properties.communityAPI+pid+"/projectList";
return this.http.delete<any>(url, { headers: headers, body: JSON.stringify(projects)});
}
addProject(properties:EnvProperties, pid: string, project: any) {
let headers = new HttpHeaders({'Content-Type': 'application/json'});
let url = properties.communityAPI+pid+"/projects";