[plugins-functionality | DONE | CHANGED ] create validateEnabledPage.component.ts include it in manage pages

This commit is contained in:
argirok 2024-06-10 09:03:15 +03:00
parent 99758d7319
commit a9945d5da4
13 changed files with 157 additions and 53 deletions

View File

@ -2,10 +2,6 @@
<div actions>
<div class="uk-section-xsmall uk-margin-top">
<div class="uk-flex uk-flex-center uk-flex-right@m">
<button *ngIf="!organizationsEnabled" class="uk-button uk-button-default uk-margin-right" [class.uk-disabled]="loading"
[disabled]="loading"
(click)="enableAffiliations()">Enable Organizations Page
</button>
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
[disabled]="loading" [class.uk-disabled]="loading"
(click)="editAffiliationOpen()">
@ -20,6 +16,7 @@
<div *ngIf="loading" class="uk-position-center">
<loading></loading>
</div>
<validate-page-enabled pageRoute="/organizations"></validate-page-enabled>
<div *ngIf="!loading">
<div *ngIf="affiliations.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">

View File

@ -54,7 +54,6 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
if (this.community) {
this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Organizations');
this.getAffiliations();
this.organizationsPageStatus();
}
}));
}
@ -81,10 +80,6 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
);
}
public get organizationsEnabled(): boolean {
return !this.organizationsPage || this.organizationsPage.isEnabled;
}
editAffiliationOpen(index: number = -1) {
let affiliation: Affiliation;
this.index = index;
@ -179,13 +174,6 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
this.handleUpdateError('An error has been occurred. Try again later!');
});
}
private organizationsPageStatus() {
this.helpContentService.getCommunityPagesByRoute(this.community.communityId, '/organizations', this.properties.adminToolsAPIURL).subscribe((page) => {
this.organizationsPage = page;
})
}
handleUpdateError(message: string) {
NotificationHandler.rise(message, "danger");
this.loading = false;
@ -196,13 +184,4 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
this.loading = false;
}
enableAffiliations() {
this.helpContentService.togglePages(this.community.communityId, [this.organizationsPage._id], true, this.properties.adminToolsAPIURL).subscribe(() => {
this.organizationsPage.isEnabled = true;
this._clearCacheService.purgeBrowserCache("Organizations Page enabled", this.community.communityId);
NotificationHandler.rise('Organizations Page has been <b>enabled successfully</b>');
}, error => {
this.handleUpdateError('An error has been occurred. Try again later!');
});
}
}

View File

@ -17,11 +17,12 @@ import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"
import {UrlPrefixModule} from "../../openaireLibrary/utils/pipes/url-prefix.module";
import {HelpContentService} from "../../services/help-content.service";
import {PagingModule} from "../../openaireLibrary/utils/paging.module";
import {ValidateEnabledPageModule} from "../../utils/validateEnabledPage.module";
@NgModule({
imports: [
AffiliationsRoutingModule, CommonModule, FormsModule, RouterModule,
AlertModalModule, ReactiveFormsModule, InputModule, PageContentModule, IconsModule, NoLoadPaging, LoadingModule, UrlPrefixModule, PagingModule
AlertModalModule, ReactiveFormsModule, InputModule, PageContentModule, IconsModule, NoLoadPaging, LoadingModule, UrlPrefixModule, PagingModule, ValidateEnabledPageModule
],
declarations: [
AffiliationsComponent

View File

@ -30,6 +30,7 @@ import {SearchDataprovidersService} from "../../openaireLibrary/services/searchD
import {CriteriaModule} from "./criteria/criteria.module";
import {MatSlideToggleModule} from "@angular/material/slide-toggle";
import {CKEditorModule} from "ng2-ckeditor";
import {ValidateEnabledPageModule} from "../../utils/validateEnabledPage.module";
@NgModule({
imports: [
@ -50,7 +51,7 @@ import {CKEditorModule} from "ng2-ckeditor";
path: '', component: ManageContentProvidersComponent
}
]),
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule, MatSlideToggleModule, CKEditorModule, ReactiveFormsModule
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule, MatSlideToggleModule, CKEditorModule, ReactiveFormsModule, ValidateEnabledPageModule
],
declarations: [
ManageContentProvidersComponent,

View File

@ -1,4 +1,4 @@
<div class="uk-position-relative" style="min-height: 60vh">
<div class="uk-position-relative" [style]=" height == -1?'': 'min-height:60vh'">
<div *ngIf="loading" class="uk-position-center">
<loading></loading>
</div>

View File

@ -35,11 +35,30 @@ import {UntypedFormBuilder} from "@angular/forms";
<fs-modal #filtersModal (okEmitter)="saveCriteria()" (cancelEmitter)="criteria.reset(); depositReset();"
[okButtonDisabled]="(criteria && criteria.disabled && !depositInfoChanged)">
<div class="uk-container uk-container-large">
<div class="uk-flex uk-flex-center">
<div>
<mat-slide-toggle [checked]="enabled" (change)="enabled = !enabled; depositInfoChanged = true;"></mat-slide-toggle>
<label class="uk-margin-medium-top uk-margin-small-left ">Content source</label>
<br>
</div>
<div class="uk-margin-small-left">
<mat-slide-toggle [checked]="deposit" (change)="deposit = !deposit; depositInfoChanged = true;"></mat-slide-toggle>
<label class="uk-margin-medium-top uk-margin-small-left ">Suggest for deposit</label>
</div>
</div>
<div *ngIf="enabled" class="uk-hr">
<div class="uk-text-center uk-text-bold uk-text-large uk-margin-top ">Content filters</div>
<criteria #criteria *ngIf="dataProvider" [height]="'-1'"
[selectionCriteria]="dataProvider.selectioncriteria">
<div no-criteria>
<h5 class="uk-margin-small-bottom">No Filters for {{dataProvider.officialname}} yet</h5>
<i class="uk-display-block">If no Filters are specified, all {{openaireEntities.RESULTS | lowercase}} of this {{openaireEntities.DATASOURCE | lowercase}} will be included in your
{{openaireEntities.COMMUNITY | lowercase}}.
</i>
</div>
</criteria>
</div>
<div *ngIf="deposit" class="uk-hr">
<!--<div class="uk-width-1-1 uk-margin-medium-top" input placeholder="Type a message or instruction for researchers about deposition in this datasource"
[value]="message" (valueChange)="message=$event; depositInfoChanged = true;">
</div>-->
@ -54,16 +73,7 @@ import {UntypedFormBuilder} from "@angular/forms";
'Subscript,Superscript,Anchor,Smiley,Iframe,Styles,Font,About,Language,JustifyLeft,JustifyRight,JustifyCenter,JustifyBlock,FontSize,TextColor,BGColor',
extraPlugins: 'divarea'}">
</ckeditor>
<div class="uk-text-center uk-text-bold uk-text-large uk-margin-medium-top">Content filters</div>
<criteria #criteria *ngIf="dataProvider" [height]="filtersModal.bodyHeight - 200"
[selectionCriteria]="dataProvider.selectioncriteria">
<div no-criteria>
<h5 class="uk-margin-small-bottom">No Filters for {{dataProvider.officialname}} yet</h5>
<i class="uk-display-block">If no Filters are specified, all {{openaireEntities.RESULTS | lowercase}} of this {{openaireEntities.DATASOURCE | lowercase}} will be included in your
{{openaireEntities.COMMUNITY | lowercase}}.
</i>
</div>
</criteria>
</div>
</fs-modal>
`

View File

@ -22,6 +22,8 @@
<loading></loading>
</div>
<div *ngIf="!loading">
<validate-page-enabled pageRoute="/search/find/dataproviders"></validate-page-enabled>
<validate-page-enabled pageRoute="/participate/deposit/suggested"></validate-page-enabled>
<div *ngIf="previewCommunityContentProviders.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No <span class="uk-text-lowercase">{{openAIREEntities.DATASOURCES}} </span>

View File

@ -24,6 +24,7 @@ import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/re
import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.module";
import {DropdownFilterModule} from "../../openaireLibrary/utils/dropdown-filter/dropdown-filter.module";
import {SearchFilterModule} from "../../openaireLibrary/searchPages/searchUtils/searchFilter.module";
import {ValidateEnabledPageModule} from "../../utils/validateEnabledPage.module";
@NgModule({
imports: [
@ -44,7 +45,7 @@ import {SearchFilterModule} from "../../openaireLibrary/searchPages/searchUtils/
path: '', component: ManageProjectsComponent
}
]),
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, DropdownFilterModule, SearchFilterModule
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, DropdownFilterModule, SearchFilterModule, ValidateEnabledPageModule
],
declarations: [
ManageProjectsComponent,

View File

@ -67,6 +67,7 @@
<div *ngIf="loading" class="uk-position-center">
<loading></loading>
</div>
<validate-page-enabled pageRoute="/search/find/projects"></validate-page-enabled>
<div *ngIf="!loading">
<div class="uk-margin-medium-bottom">
<div *ngIf="previewCommunityProjects.length == 0"

View File

@ -21,6 +21,7 @@
<div *ngIf="loading" class="uk-position-center">
<loading></loading>
</div>
<validate-page-enabled pageRoute="/subjects"></validate-page-enabled>
<div *ngIf="!loading">
<div *ngIf="displayedSubjects?.length == 0 && displayedSdg?.length == 0 && displayedFos?.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">

View File

@ -18,12 +18,13 @@ import {FullScreenModalModule} from 'src/app/openaireLibrary/utils/modal/full-sc
import {PagingModule} from "../../../openaireLibrary/utils/paging.module";
import {SdgSelectionModule} from '../../../openaireLibrary/sdg/sdg-selection/sdg-selection.module';
import {FosSelectionModule} from '../../../openaireLibrary/fos/fos-selection/fos-selection.module';
import {ValidateEnabledPageModule} from "../../../utils/validateEnabledPage.module";
@NgModule({
imports: [
SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule,
PageContentModule, IconsModule, AlertModalModule, NoLoadPaging, LoadingModule, InputModule,
SearchInputModule, FullScreenModalModule, PagingModule, SdgSelectionModule, FosSelectionModule
SearchInputModule, FullScreenModalModule, PagingModule, SdgSelectionModule, FosSelectionModule, ValidateEnabledPageModule
],
declarations: [
SubjectsEditFormComponent

View File

@ -0,0 +1,93 @@
import {Component, Input, OnDestroy, OnInit, ViewChild} from "@angular/core";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
import {UntypedFormBuilder} from "@angular/forms";
import {CommunityInfo} from "../openaireLibrary/connect/community/communityInfo";
import {Page} from "../openaireLibrary/utils/entities/adminTool/page";
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
import {ActivatedRoute, Router} from "@angular/router";
import {Title} from "@angular/platform-browser";
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {AffiliationService} from "../openaireLibrary/connect/affiliations/affiliation.service";
import {HelpContentService} from "../services/help-content.service";
import {ClearCacheService} from "../openaireLibrary/services/clear-cache.service";
import {Subscription} from "rxjs";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {NotificationHandler} from "../openaireLibrary/utils/notification-handler";
import {properties} from "src/environments/environment";
@Component({
selector: 'validate-page-enabled',
template: `
<div *ngIf="page && !pageEnabled" class="uk-width-1-1 uk-alert uk-alert-warning">
<b>{{page.name}}</b> page is not enabled. Manage pages <a [href]="community.communityId + '/admin-tools/pages'" target="_blank">here</a> or
<a *ngIf="!pageEnabled" class=" uk-margin-right" [class.uk-disabled]="loading" [disabled]="loading"
(click)="enablePage()">enable it now</a>
</div>
`
})
export class ValidateEnabledPageComponent implements OnInit, OnDestroy {
@Input() pageRoute:string;
public properties: EnvProperties = properties;
public community: CommunityInfo;
public page: Page;
loading;
private subs: any[] = [];
@ViewChild('affiliationModal') affiliationModal: AlertModal;
@ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal;
constructor(private route: ActivatedRoute,
private router: Router,
private title: Title,
private fb: UntypedFormBuilder,
private communityService: CommunityService,
private helpContentService: HelpContentService,
private _clearCacheService: ClearCacheService) {
}
ngOnInit() {
this.subs.push(this.communityService.getCommunityAsObservable().subscribe( community => {
this.community = community;
this.getPageStatus();
}));
}
ngOnDestroy() {
this.subs.forEach(sub => {
if (sub instanceof Subscription) {
sub.unsubscribe();
}
})
}
public get pageEnabled(): boolean {
return !this.page || this.page.isEnabled;
}
public updatePage(event) {
HelperFunctions.scroll();
this.page = event.value;
}
private getPageStatus() {
this.helpContentService.getCommunityPagesByRoute(this.community.communityId, this.pageRoute, this.properties.adminToolsAPIURL).subscribe((page) => {
this.page = page;
})
}
enablePage() {
this.loading = true;
this.helpContentService.togglePages(this.community.communityId, [this.page._id], true, this.properties.adminToolsAPIURL).subscribe(() => {
this.page.isEnabled = true;
this._clearCacheService.purgeBrowserCache("Page enabled", this.community.communityId);
NotificationHandler.rise(this.page.name + ' has been <b>enabled successfully</b>');
this.loading = false;
}, error => {
});
}
}

View File

@ -0,0 +1,17 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule} from "@angular/router";
import {ValidateEnabledPageComponent} from "./validateEnabledPage.component";
import {AdminToolServiceModule} from "../openaireLibrary/services/adminToolService.module";
import {HelpContentService} from "../services/help-content.service";
@NgModule({
declarations: [ValidateEnabledPageComponent],
imports: [
CommonModule, RouterModule, AdminToolServiceModule
],
exports:[ValidateEnabledPageComponent],
providers:[HelpContentService]
})
export class ValidateEnabledPageModule {
}