[plugins-functionality | WIP] updates on plugins

This commit is contained in:
argirok 2024-02-28 13:07:31 +02:00
parent d6dc2b040d
commit c011c9b38c
34 changed files with 1085 additions and 747 deletions

View File

@ -10,7 +10,6 @@ export class PluginDiscoverBySubcommunity extends PluginBaseInfo{
templateUrl: 'plugin-discover-by-subcommunity.component.html'
})
export class PluginDiscoverBySubcommunityComponent extends PluginBaseComponent<PluginDiscoverBySubcommunity>{
default = new PluginDiscoverBySubcommunity();
subcommunities = null;
community;
constructor(http:HttpClient, private communityService: CommunityService) {

View File

@ -1,7 +1,6 @@
import {Component} from '@angular/core';
import {PluginBaseComponent} from "../../utils/base-plugin.component";
import {HttpClient} from "@angular/common/http";
import {PluginDiscoverBySubcommunity} from "./plugin-discover-by-subcommunity.component";
import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-discover-by-subcommunity-form',
@ -15,11 +14,8 @@ import {PluginDiscoverBySubcommunity} from "./plugin-discover-by-subcommunity.co
})
export class PluginDiscoverBySubcommunityFormComponent extends PluginBaseComponent<PluginDiscoverBySubcommunity> {
default = new PluginDiscoverBySubcommunity();
selectedIndex = null;
constructor(http:HttpClient) {
export class PluginDiscoverBySubcommunityFormComponent extends PluginBaseFormComponent<PluginDiscoverBySubcommunity> {
constructor() {
super()
}
}

View File

@ -12,11 +12,11 @@
{{pluginObject.textLine2}}
</div>
</div>
<no-load-paging *ngIf="fetchFeaturedDatasets && fetchFeaturedDatasets.searchUtils.totalResults > size" [type]="'Featured Datasets'"
<!-- <no-load-paging *ngIf="fetchFeaturedDatasets && fetchFeaturedDatasets.searchUtils.totalResults > size" [type]="'Featured Datasets'"
(pageChange)="updatePage($event)"
[page]="fetchFeaturedDatasets.searchUtils.page" [pageSize]="size"
[totalResults]="fetchFeaturedDatasets.searchUtils.totalResults" >
</no-load-paging>
</no-load-paging>-->
<search-result [properties]="properties"
[results]="fetchFeaturedDatasets.results"
[status]="fetchFeaturedDatasets.searchUtils.status"

View File

@ -1,9 +1,9 @@
import {Component} from '@angular/core';
import {PluginBaseComponent} from "../../utils/base-plugin.component";
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
import {FetchResearchResults} from "../../../../utils/fetchEntitiesClasses/fetchResearchResults.class";
import {SearchResearchResultsService} from "../../../../services/searchResearchResults.service";
export class PluginFeaturedDatasets {
export class PluginFeaturedDatasets extends PluginBaseInfo{
title: string = "Featured datasets";
textLine1: string = "Here are listed some of the most important energy datasets as selected by energy experts.";
textLine2: string = "Check them if you want to easily explore and visualize the European energy landscape, using only well-known datasets which you can trust.";
@ -25,12 +25,12 @@ export class PluginFeaturedDatasetsComponent extends PluginBaseComponent<PluginF
super()
this.fetchFeaturedDatasets = new FetchResearchResults(this._searchResearchResultsService);
this.fetchFeaturedDatasets.searchUtils.size = this.size;
this.fetchFeaturedDatasets.getAllResultsForCommunity("dataset", "enermaps", 1, 100, this.properties, "enermaps::selection");
this.fetchFeaturedDatasets.getAllResultsForCommunity("dataset", "enermaps", 1, 50, this.properties, "enermaps::selection");
}
public updatePage(event) {
/* public updatePage(event) {
this.page = event.value;
this.fetchFeaturedDatasets.searchUtils.page = event.value;
this.fetchFeaturedDatasets.results = this.fetchFeaturedDatasets.allResults.slice((this.page - 1) * this.size, this.page * this.size);
}
}*/
}

View File

@ -1,29 +1,35 @@
import {Component} from '@angular/core';
import {PluginBaseComponent} from "../../utils/base-plugin.component";
import {HttpClient} from "@angular/common/http";
import {OpenaireEntities} from "../../../../utils/properties/searchFields";
import {PluginFeaturedDatasets} from "./plugin-featured-datasets.component";
import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-featured-datasets-form',
template: `
<div *ngIf="pluginObject" class="uk-padding-xsmall">
<plugin-field-edit [value]="pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
<plugin-field-edit [value]="pluginObject.textLine1"
type="text" field="textLine1" (changed)="valueChanged($event)"></plugin-field-edit>
<plugin-field-edit [value]="pluginObject.textLine2"
type="text" field="textLine2" (changed)="valueChanged($event)"></plugin-field-edit>
<div class="uk-margin-bottom">
<plugin-field-edit [value]="pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
</div>
<div class="uk-margin-bottom">
<plugin-field-edit [value]="pluginObject.textLine1"
type="text" field="textLine1" (changed)="valueChanged($event)"></plugin-field-edit>
</div>
<div class="uk-margin-bottom">
<plugin-field-edit [value]="pluginObject.textLine2"
type="text" field="textLine2" (changed)="valueChanged($event)"></plugin-field-edit>
</div>
</div>
`,
})
export class PluginFeaturedDatasetsFormComponent extends PluginBaseComponent<PluginFeaturedDatasets> {
default = new PluginFeaturedDatasets();
export class PluginFeaturedDatasetsFormComponent extends PluginBaseFormComponent<PluginFeaturedDatasets> {
selectedIndex = null;
openaireEntities= OpenaireEntities;
constructor(http: HttpClient) {
openaireEntities = OpenaireEntities;
constructor() {
super()
}

View File

@ -1,5 +1,5 @@
import {Component} from '@angular/core';
import {PluginBaseComponent} from "../../utils/base-plugin.component";
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
import {ConfigurationService} from '../../../../../openaireLibrary/utils/configuration/configuration.service';
import {CommunityService} from '../../../../../openaireLibrary/connect/community/community.service';
import {SearchCommunityProjectsService} from '../../../../../openaireLibrary/connect/projects/searchProjects.service';
@ -11,7 +11,7 @@ import {RouterHelper} from "../../../../utils/routerHelper.class";
import {OpenaireEntities} from "../../../../utils/properties/searchFields";
import {HttpClient} from "@angular/common/http";
export class PluginGatewayInformation{
export class PluginGatewayInformation extends PluginBaseInfo{
title:string ="Gateway Information";
curators:boolean = true;
date:boolean = true;

View File

@ -1,7 +1,7 @@
import {Component} from '@angular/core';
import {PluginBaseComponent} from "../../utils/base-plugin.component";
import {PluginGatewayInformation} from "./plugin-gateway-information.component";
import {OpenaireEntities} from "../../../../utils/properties/searchFields";
import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-gateway-information-form',
@ -9,89 +9,106 @@ import {OpenaireEntities} from "../../../../utils/properties/searchFields";
<div *ngIf="pluginObject" class="uk-padding-xsmall">
<plugin-field-edit [value]="pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
<div class="uk-margin-top uk-text-meta uk-text-small">
<div class="uk-margin-top uk-text-meta uk-text-small uk-margin-small-bottom">
Show or hide the following information:
</div>
<div class="uk-grid uk-child-width-1-1">
<div>
Curated by:
<div class="uk-margin-top uk-text-meta uk-text-xsmall ">
Community info
</div>
<div class="uk-grid uk-child-width-1-1 uk-text-small uk-hr ">
<div class="uk-margin-xsmall-bottom uk-margin-xsmall-top">
<plugin-field-edit [value]=" pluginObject.curators"
type="boolean" field="curators" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="curators" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
</plugin-field-edit>Curated by
</div>
<div>
Created:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.date"
type="boolean" field="date" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="date" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
</plugin-field-edit> Created
</div>
<div>
{{openaireEntities.PROJECTS}}:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.projects"
type="boolean" field="projects" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="projects" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
</plugin-field-edit>
{{openaireEntities.PROJECTS}}
</div>
<div>
Linked Zenodo communities:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.communities"
type="boolean" field="communities" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="communities" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
Linked Zenodo communities
</div>
<div>
{{openaireEntities.DATASOURCES}}
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.datasources"
type="boolean" field="datasources" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="datasources" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
{{openaireEntities.DATASOURCES}}
</div>
<div>
Subjects:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.subjects"
type="boolean" field="subjects" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="subjects" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
Subjects
</div>
<div>
{{openaireEntities.PUBLICATIONS}}:
<div class="uk-margin-top uk-text-meta uk-text-xsmall">
Pages & menus
</div>
<div class="uk-margin-xsmall-bottom uk-hr uk-margin-xsmall-top">
<plugin-field-edit [value]=" pluginObject.publications"
type="boolean" field="publications" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="publications" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
{{openaireEntities.PUBLICATIONS}}
</div>
<div>
{{openaireEntities.DATASETS}}:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.datasets"
type="boolean" field="datasets" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="datasets" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
{{openaireEntities.DATASETS}}
</div>
<div>
{{openaireEntities.SOFTWARE}}:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.software"
type="boolean" field="software" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="software" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
{{openaireEntities.SOFTWARE}}
</div>
<div>
{{openaireEntities.OTHER}}:
<div class="uk-margin-xsmall-bottom">
<plugin-field-edit [value]=" pluginObject.other"
type="boolean" field="other" (editClicked)="pluginEditEvent = $event"
type="checkbox" field="other" (editClicked)="pluginEditEvent = $event"
(changed)="valueChanged($event)">
</plugin-field-edit>
{{openaireEntities.OTHER}}
</div>
</div>
<div class="uk-alert uk-alert-warning uk-text-small"> If some information is enabled here,
but still not visible, please check related <a routerLink="../entities" target="_blank">entity</a> or <a routerLink="../pages" target="_blank">page</a>.</div>
</div>
`,
})
export class PluginGatewayInformationFormComponent extends PluginBaseComponent<PluginGatewayInformation> {
export class PluginGatewayInformationFormComponent extends PluginBaseFormComponent<PluginGatewayInformation> {
default = new PluginGatewayInformation();
selectedIndex = null;
openaireEntities= OpenaireEntities;

View File

@ -17,7 +17,7 @@
<div class="uk-text-center uk-margin-bottom description">
{{card.description}}
</div>
<a *ngFor="let url of card.urls" [href]="card.url"
<a *ngFor="let url of card.urlsArray" [href]="card.url"
class="uk-display-inline-block uk-text-uppercase uk-button uk-button-text uk-text-default"
[target]="url.target">
{{url.linkText}}

View File

@ -1,12 +1,20 @@
import {Component} from '@angular/core';
import {PluginBaseComponent, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component";
export class PluginHowToUse{
import {PluginBaseComponent, PluginBaseInfo, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component";
export class PluginHowToUse extends PluginBaseInfo{
title:string ="How to use the gateway?";
cardInfoArray: PluginInfoCards[] = [
{title: "Tutorials", description: "The mini-video tutorials can help you find quick answers on specific gateway functionalities.", urls:[ new PluginURL("","View all")], show:true},
{title: "Guides", description: "Textual guides to all gateway functionalities.", urls:[ new PluginURL("","Guide for the users"), new PluginURL("","Guide for the managers")], show:true},
{title: "Webinars", description: "Recordings and slides of webinars on different aspects of Open Science.", urls:[ new PluginURL("","View all")], show:true}
{title: "Tutorials", description: "Mini-video tutorials for gateway managers", urlsArray:[ new PluginURL("https://www.youtube.com/playlist?list=PL0c4IRNUxuKcyRUQ_J9BH_EE1amXU6kgp","View all")], show:true},
{title: "Guides", description: "Textual guides on gateway functionalities.", urlsArray:[ new PluginURL("https://www.openaire.eu/research-community-gateway-guide","Guide for the users")/*, new PluginURL("","Guide for the managers")*/], show:true},
{title: "Webinars", description: "Recordings and slides of webinars on different aspects of Open Science.", urlsArray:[ new PluginURL("","View all")], show:true}
];
compare(oldObject){
oldObject = super.compare(oldObject)
for(let card of this.cardInfoArray){
}
return oldObject;
}
}
@Component({
selector: 'plugin-how-to-use',

View File

@ -0,0 +1,140 @@
import {Component, Input, SimpleChanges} from '@angular/core';
import {PluginHowToUse} from "./plugin-how-to-use.component";
import {PluginBaseFormComponent, PluginEditEvent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-how-to-use-form',
template: `
<div *ngIf="pluginObject" class="uk-padding-xsmall">
<ng-container *ngIf="selectedIndex == -1">
<plugin-field-edit [value]=" pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
<div class="uk-margin-top uk-text-muted">
Cards:
</div>
<ng-container *ngFor="let card of pluginObject.cardInfoArray; let i = index">
<div class="uk-grid uk-grid-small uk-margin-xsmall-top">
<div *ngIf="selectedIndex != i" class="uk-text-small uk-width-expand">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].show" type="checkbox" field="cardInfoArray"
(editClicked)="pluginEditEvent = $event"
(changed)="cardShowChanged(i,$event)"></plugin-field-edit>
{{card.title}}
</div>
<div class="uk-padding-remove-left uk-margin-medium-right">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(i)">
<icon name="edit" [flex]="true"></icon>
</button>
</div>
</div>
</ng-container>
</ng-container>
<ng-container *ngIf="selectedIndex > -1">
<div *ngIf="editTemplate" class="back uk-margin-bottom">
<a (click)="close()" class="uk-flex uk-flex-middle uk-flex-center">
<div class="uk-width-auto">
<icon name="west" ratio="1.3"
[flex]="true"></icon>
</div>
<span class="uk-text-small">Plugin Options</span>
</a>
</div>
<!--<div class="uk-text-small">
Enable
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].show"
type="boolean" field="cardInfoArray" (editClicked)="pluginEditEvent = $event"
(changed)="cardShowChanged(selectedIndex,$event)">
</plugin-field-edit>
</div>-->
<div class="uk-margin-top">
<plugin-field-edit [value]="pluginObject.cardInfoArray[selectedIndex].title"
type="text" field="title"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].description"
type="text" field="description"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<ng-container *ngFor="let cardUrl of pluginObject.cardInfoArray[selectedIndex].urlsArray; let j = index ">
<div class=" uk-margin-top uk-text-meta uk-text-xsmall"> Link #{{j+1}}</div>
<div class="uk-margin-small-top">
<plugin-field-edit [value]=" cardUrl.url"
type="text" field="url"
(changed)="cardUrlValueChanged(selectedIndex, j, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" cardUrl.linkText"
type="text" field="linkText" placeholder="Link text"
(changed)="cardUrlValueChanged(selectedIndex, j, $event)"></plugin-field-edit>
</div>
</ng-container>
</ng-container>
</div>
`,
})
export class PluginHowToUseFormComponent extends PluginBaseFormComponent<PluginHowToUse> {
selectedIndex = -1;
@Input() editSubmenuOpen;
constructor() {
super()
}
ngOnChanges(changes: SimpleChanges) {
if (this.editSubmenuOpen == false && this.selectedIndex > -1) {
this.close();
}
}
cardShowChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i].show = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i].show = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field: $event.field, value: $event.value, type: 'parent'})
}
cardValueChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginObject.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.pluginObject.cardInfoArray
} else {
this.pluginObject.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.pluginObject.cardInfoArray;
}
this.valuesChanged.emit({field: "cardInfoArray", value: $event.value, type: 'parent'})
}
cardUrlValueChanged(i, j, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginObject.cardInfoArray[i].urlsArray[j][$event.field] = $event.value;
$event.value = this.pluginObject.cardInfoArray;
} else {
this.pluginObject.cardInfoArray[i].urlsArray[j][$event.field] = $event.value;
$event.value = this.pluginObject.cardInfoArray;
}
this.valuesChanged.emit({field: "cardInfoArray", value: $event.value, type: 'parent'})
}
edit(i) {
this.selectedIndex = i;
this.toggleSubMenu(true);
}
close() {
this.selectedIndex = -1;
this.toggleSubMenu(false);
}
}

View File

@ -1,12 +1,12 @@
import {Component} from '@angular/core';
import {PluginBaseComponent, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component";
export class PluginLearnAndConnect{
import {PluginBaseComponent, PluginBaseInfo, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component";
export class PluginLearnAndConnect extends PluginBaseInfo{
title:string ="Learn & Connect with Open Science";
cardInfoArray:PluginInfoCards[] = [
{title: "OS Practices", description: "Open Science best practices for your community, policies and mandates.",
urls:[ new PluginURL("","Learn more")], show:true},
{title: "OS Guides for beginners", description: "New to Open Science? Learn the basics!",urls:[ new PluginURL("","Learn more")], show:true},
{title: "Webinars", description: "Recordings and slides of webinars on different aspects of Open Science.",urls:[ new PluginURL("","Learn more")], show:true}
urlsArray:[ new PluginURL("","")], show:true},
{title: "OS Guides for beginners", description: "New to Open Science? Learn the basics!",urlsArray:[ new PluginURL("https://www.openaire.eu/guides","Learn more")], show:true},
{title: "Webinars", description: "Recordings and slides of webinars on different aspects of Open Science.",urlsArray:[ new PluginURL("https://www.openaire.eu/support/webinars","Learn more")], show:true}
];
}
@Component({

View File

@ -1,115 +1,131 @@
import {Component, EventEmitter, OnChanges, Output, SimpleChanges} from '@angular/core';
import {PluginBaseComponent, PluginEditEvent} from "../../utils/base-plugin.component";
import {HttpClient} from "@angular/common/http";
import {Component, Input, SimpleChanges} from '@angular/core';
import {PluginLearnAndConnect} from "./plugin-learn-and-connect.component";
import {PluginOpenAIREProducts} from "../openaireProducts/plugin-openaire-products.component";
import {PluginBaseFormComponent, PluginEditEvent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-learn-and-connect-form',
template: `
<div *ngIf="pluginObject" class="uk-padding-xsmall">
<plugin-field-edit [value]=" pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)" ></plugin-field-edit>
<div class="uk-margin-top uk-text-muted">
Cards:
</div>
<ng-container *ngFor="let card of pluginObject.cardInfoArray; let i = index">
<div class="uk-grid uk-grid-small uk-margin-xsmall-top">
<div *ngIf="selectedIndex != i" class="uk-text-small uk-width-3-4">{{card.title}}</div>
<div *ngIf="selectedIndex == i"class="uk-margin-top">
<plugin-field-edit [value]="pluginObject.cardInfoArray[i].title"
type="text" field="title" (changed)="cardValueChanged(i, $event)" ></plugin-field-edit>
</div>
<div class=" uk-width-auto">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].show"
type="boolean" field="cardInfoArray" (editClicked)="pluginEditEvent = $event" (changed)="cardShowChanged(i,$event)" >
</plugin-field-edit>
</div>
<div class=" uk-width-auto">
<a *ngIf="selectedIndex != i" (click)="edit(i)">edit</a>
<a *ngIf="selectedIndex == i" (click)="selectedIndex = null">hide</a>
</div>
<div *ngIf="selectedIndex == i" class="width-1-1">
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].description"
type="text" field="description" (changed)="cardValueChanged(i, $event)" ></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].url"
type="text" field="url" (changed)="cardValueChanged(i, $event)" ></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].linkText"
type="text" field="linkText" (changed)="cardValueChanged(i, $event)" ></plugin-field-edit>
</div>
<!--<div class="uk-margin-top">
<plugin-field-edit [value]="pluginObject && pluginObject.cardInfoArray[i].show?pluginObject.cardInfoArray[i].show:pluginDefaultObject.cardInfoArray[i].show"
type="boolean" field="show" (changed)="cardValueChanged(i, $event)" ></plugin-field-edit>
</div>-->
</div>
</div>
</ng-container>
<ng-container *ngIf="selectedIndex == -1">
<plugin-field-edit [value]=" pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
<div class="uk-margin-top uk-text-muted">
Cards:
</div>
<ng-container *ngFor="let card of pluginObject.cardInfoArray; let i = index">
<div class="uk-grid uk-grid-small uk-margin-xsmall-top">
<div *ngIf="selectedIndex != i" class="uk-text-small uk-width-expand">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].show" type="checkbox" field="cardInfoArray"
(editClicked)="pluginEditEvent = $event"
(changed)="cardShowChanged(i,$event)"></plugin-field-edit>
{{card.title}}
</div>
<div class="uk-padding-remove-left uk-margin-medium-right">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(i)">
<icon name="edit" [flex]="true"></icon>
</button>
</div>
</div>
</ng-container>
</ng-container>
<ng-container *ngIf="selectedIndex > -1">
<div *ngIf="editTemplate" class="back uk-margin-bottom">
<a (click)="close()" class="uk-flex uk-flex-middle uk-flex-center">
<div class="uk-width-auto">
<icon name="west" ratio="1.3"
[flex]="true"></icon>
</div>
<span class="uk-text-small">Plugin Options</span>
</a>
</div>
<!--<div class="uk-text-small">
Enable
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].show"
type="boolean" field="cardInfoArray" (editClicked)="pluginEditEvent = $event"
(changed)="cardShowChanged(selectedIndex,$event)">
</plugin-field-edit>
</div>-->
<div class="uk-margin-top">
<plugin-field-edit [value]="pluginObject.cardInfoArray[selectedIndex].title"
type="text" field="title"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].description"
type="text" field="description"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<!--<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].urlsArray"
type="text" field="url"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].urlsArray"
type="text" field="linkText" placeholder="Link text"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>-->
</ng-container>
</div>
`,
})
export class PluginLearnAndConnectFormComponent extends PluginBaseComponent<PluginLearnAndConnect> /*implements OnChanges*/{
selectedIndex = null;
default = new PluginLearnAndConnect();
constructor(http:HttpClient) {
export class PluginLearnAndConnectFormComponent extends PluginBaseFormComponent<PluginLearnAndConnect> {
selectedIndex = -1;
@Input() editSubmenuOpen;
constructor() {
super()
// this.default = new PluginLearnAndConnect();
}
/*ngOnInit(): void {
if(this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title)){
this.pluginTemplate.object = new PluginLearnAndConnect();
}
}*/
/*ngOnChanges(changes: SimpleChanges) {
console.log("changes")
if(changes.plugin){
console.log("changes plugin", changes.plugin)
}else if (changes.pluginTemplate){
console.log("changes pluginTemplate", changes.pluginTemplate)
ngOnChanges(changes: SimpleChanges) {
if (this.editSubmenuOpen == false && this.selectedIndex > -1) {
this.close();
}
}
*/
cardShowChanged(i,$event:PluginEditEvent){
if(this.editTemplate){
this.pluginTemplate.object.cardInfoArray[i].show=$event.value;
$event.value =this.pluginTemplate.object.cardInfoArray;
}else{
this.plugin.object.cardInfoArray[i].show=$event.value;
$event.value =this.plugin.object.cardInfoArray;
cardShowChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i].show = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i].show = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field:$event.field, value: $event.value, type: 'parent'})
this.valuesChanged.emit({field: $event.field, value: $event.value, type: 'parent'})
}
cardValueChanged(i,$event:PluginEditEvent){
if(this.editTemplate){
this.pluginTemplate.object.cardInfoArray[i][$event.field]=$event.value;
$event.value =this.pluginTemplate.object.cardInfoArray;
}else{
this.plugin.object.cardInfoArray[i][$event.field]=$event.value;
$event.value =this.plugin.object.cardInfoArray;
cardValueChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field:"cardInfoArray", value: $event.value, type: 'parent'})
this.valuesChanged.emit({field: "cardInfoArray", value: $event.value, type: 'parent'})
}
edit(i){
edit(i) {
this.selectedIndex = i;
this.toggleSubMenu(true);
}
close() {
this.selectedIndex = -1;
this.toggleSubMenu(false);
}
}

View File

@ -1,18 +1,19 @@
import {Component} from '@angular/core';
import {PluginBaseComponent, PluginBaseInfo, PluginEditEvent} from "../../utils/base-plugin.component";
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
import {HttpClient} from "@angular/common/http";
export class PluginOpenAIREProducts extends PluginBaseInfo{
title:string ="OpenAIRE services for your community";
serviceIdsArray = ["zenodo","graph","explore"];
compare(oldObject): any {
return super.compare(oldObject);
}
}
@Component({
selector: 'plugin-openaire-products',
template: `
<div *ngIf="pluginObject">
<h3 [class.uk-invisible]=" (pluginEditEvent && pluginEditEvent.field == 'title')">
{{pluginObject.title}} </h3>
<h3>{{pluginObject.title}} </h3>
<div class="uk-child-width-1-3 uk-grid">
<ng-container *ngFor="let service of services">
<div *ngIf="pluginObject && pluginObject.serviceIdsArray.indexOf(service.id)!=-1" class="uk-padding-xsmall">

View File

@ -1,7 +1,7 @@
import {Component, EventEmitter, Output} from '@angular/core';
import {PluginBaseComponent, PluginEditEvent} from "../../utils/base-plugin.component";
import {Component} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {PluginOpenAIREProducts} from "./plugin-openaire-products.component";
import {PluginBaseFormComponent, PluginEditEvent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-openaire-products-form',
@ -31,7 +31,8 @@ import {PluginOpenAIREProducts} from "./plugin-openaire-products.component";
})
export class PluginOpenaireProductsFormComponent extends PluginBaseComponent<PluginOpenAIREProducts>{
//TODO make it extend PluginOpenaireProductsComponent (to avoid call in constructor..)
export class PluginOpenaireProductsFormComponent extends PluginBaseFormComponent<PluginOpenAIREProducts>{
default = new PluginOpenAIREProducts();
services = [];
excludedServiceIds = ["openaire_login","research_community_dashboard"]

View File

@ -0,0 +1,7 @@
<div *ngIf=" portal && isRouteEnabled('/organizations')" class="plugin-featured-datasets uk-container uk-container-large uk-section">
<affiliations [longView]="false" [getAffiliationsFromAPI]="true" [communityFirstPage]="true"></affiliations>
</div>
<div *ngIf="!portal " class="uk-text-muted uk-text-center">
No community info available available
</div>

View File

@ -0,0 +1,34 @@
import {Component} from '@angular/core';
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
import {ConfigurationService} from "../../../../utils/configuration/configuration.service";
export class PluginOrganizations extends PluginBaseInfo{
title: string = "Supporting Organizations";
}
@Component({
selector: 'plugin-organizations',
templateUrl: 'plugin-organizations.component.html'
})
export class PluginOrganizationsComponent extends PluginBaseComponent<PluginOrganizations> {
portal;
constructor(private config: ConfigurationService) {
super()
this.subscriptions.push(this.config.portalAsObservable.subscribe(
res => {
this.portal = res;
},
error => {
console.log(error);
}
));
}
isRouteEnabled(route: string) {
return this.portal && this.portal.pages.some(x => x['route'] == route && x['isEnabled'] === true);
}
}

View File

@ -0,0 +1,23 @@
import {Component} from '@angular/core';
import {PluginOrganizations} from "./plugin-organizations.component";
import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-organizations-form',
template: `
<div *ngIf="pluginObject" class="uk-padding-xsmall">
<plugin-field-edit [value]="pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
</div>
`,
})
export class PluginOrganizationsFormComponent extends PluginBaseFormComponent<PluginOrganizations> {
constructor() {
super()
}
}

View File

@ -0,0 +1,22 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {PluginsService} from "../../../../services/plugins.service";
import {IconsService} from "../../../../utils/icons/icons.service";
import {PluginOrganizationsComponent} from './plugin-organizations.component';
import {AffiliationsModule} from "../../../../connect/affiliations/affiliations.module";
@NgModule({
imports: [
CommonModule, RouterModule, FormsModule, AffiliationsModule,
],
providers:[PluginsService],
declarations: [PluginOrganizationsComponent],
exports: [PluginOrganizationsComponent]
})
export class PluginOrganizationsModule {
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([])
}
}

View File

@ -1,9 +1,8 @@
<div *ngIf="pluginObject" #parent class="uk-section ">
<div class="uk-container uk-container-large uk-margin-large-bottom">
<div class="uk-width-1-1 uk-margin-medium-bottom">
<!-- <span class="uk-h6 uk-text-primary">Benefits.</span>-->
<h2 class="uk-margin-remove-top uk-width-1-2@m">
{{pluginObject.title}}<!--<span class="uk-text-primary">.</span>-->
<h2 class="uk-margin-remove-top ">
{{pluginObject.title}}<span class="uk-text-primary">.</span>
</h2>
</div>
<slider-container [total]="activeCards.length" [navigation]="'progress'" [period]="6000" [infinite]="true" [parent]="parent">

View File

@ -1,22 +1,21 @@
import {Component} from '@angular/core';
import {PluginBaseComponent, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component";
import {PluginBaseComponent, PluginBaseInfo, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component";
import {OpenaireEntities} from "../../../../utils/properties/searchFields";
import {properties} from "../../../../../../environments/environment";
export class PluginSearchDepositLink{
title:string ="Search, link and deposit your research in one place.";
// description: string = "Lorem ipsum";
export class PluginSearchDepositLink extends PluginBaseInfo{
title:string ="Search, link and deposit your research in one place";
cardInfoArray: PluginInfoCards[] = [
{tag: "SEARCH & BROWSE", title: "Discover research products in your community.", description:
"A view of the OpenAIRE Graph, configured by experts of your research community, who want to help you out with the data and literature deluge.",
urls:[ new PluginURL("/search/find/research-outcomes","Start searching", null, true)],
urlsArray:[ new PluginURL("/search/find/research-outcomes","Start searching", null, true)],
image:'https://' + (properties.environment == 'production'?'':'beta.')
+ 'connect.openaire.eu/assets/connect-assets/home/4.png',show:true},
{tag: "DEPOSIT YOUR RESEARCH OUTCOME", title: "Publish your research in Open Access.", description:""
, urls:[ new PluginURL("/participate/deposit/learn-how","Start searching", null, true)],
, urlsArray:[ new PluginURL("/participate/deposit/learn-how","Start searching", null, true)],
image:'https://' + (properties.environment == 'production'?'':'beta.')
+ 'connect.openaire.eu/assets/connect-assets/home/1.png',show:true},
{tag: "LINK YOUR RESEARCH", title: "Contribute to your community.", description:""
, urls:[ new PluginURL("/participate/claim","Start searching", null, true)],
, urlsArray:[ new PluginURL("/participate/claim","Start searching", null, true)],
image:'https://' + (properties.environment == 'production'?'':'beta.')
+ 'connect.openaire.eu/assets/connect-assets/home/2.png',show:true},
];

View File

@ -1,54 +1,130 @@
import {Component} from '@angular/core';
import {PluginBaseComponent, PluginEditEvent} from "../../utils/base-plugin.component";
import {HttpClient} from "@angular/common/http";
import {Component, Input, SimpleChanges} from '@angular/core';
import {PluginSearchDepositLink} from "./plugin-search-deposit-link.component";
import {PluginBaseFormComponent, PluginEditEvent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-search-deposit-link-form',
template: `
<div *ngIf="pluginObject" class="uk-padding-xsmall">
<plugin-field-edit [value]=" pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)" ></plugin-field-edit>
<div class="uk-margin-top uk-text-muted">
Cards:
</div>
<ng-container *ngFor="let card of pluginObject.cardInfoArray; let i = index">
<div class="uk-grid uk-grid-small uk-margin-xsmall-top">
<div class="uk-text-small uk-width-3-4">{{card.tag}}</div>
<div class=" uk-width-auto">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].show"
type="boolean" field="cardInfoArray" (editClicked)="pluginEditEvent = $event" (changed)="cardShowChanged(i,$event)" >
</plugin-field-edit>
</div>
</div>
</ng-container>
<ng-container *ngIf="selectedIndex == -1">
<plugin-field-edit [value]=" pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
<div class="uk-margin-top uk-text-muted">
Cards:
</div>
<ng-container *ngFor="let card of pluginObject.cardInfoArray; let i = index">
<div class="uk-grid uk-grid-small uk-margin-xsmall-top">
<div *ngIf="selectedIndex != i" class="uk-text-small uk-width-expand">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].show" type="checkbox" field="cardInfoArray"
(editClicked)="pluginEditEvent = $event"
(changed)="cardShowChanged(i,$event)"></plugin-field-edit>
{{card.title}}
</div>
<div class="uk-padding-remove-left uk-margin-medium-right">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(i)">
<icon name="edit" [flex]="true"></icon>
</button>
</div>
</div>
</ng-container>
</ng-container>
<ng-container *ngIf="selectedIndex > -1">
<div *ngIf="editTemplate" class="back uk-margin-bottom">
<a (click)="close()" class="uk-flex uk-flex-middle uk-flex-center">
<div class="uk-width-auto">
<icon name="west" ratio="1.3"
[flex]="true"></icon>
</div>
<span class="uk-text-small">Plugin Options</span>
</a>
</div>
<!--<div class="uk-text-small">
Enable
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].show"
type="boolean" field="cardInfoArray" (editClicked)="pluginEditEvent = $event"
(changed)="cardShowChanged(selectedIndex,$event)">
</plugin-field-edit>
</div>-->
<div class="uk-margin-top">
<plugin-field-edit [value]="pluginObject.cardInfoArray[selectedIndex].title"
type="text" field="title"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].description"
type="text" field="description"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].url"
type="text" field="url"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
<div class="uk-margin-top">
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].linkText"
type="text" field="linkText" placeholder="Link text"
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
</div>
</ng-container>
</div>
`,
})
export class PluginSearchDepositLinkFormComponent extends PluginBaseComponent<PluginSearchDepositLink> /*implements OnChanges*/{
constructor(http:HttpClient) {
export class PluginSearchDepositLinkFormComponent extends PluginBaseFormComponent<PluginSearchDepositLink> /*implements OnChanges*/ {
selectedIndex = -1;
@Input() editSubmenuOpen;
constructor() {
super()
}
cardShowChanged(i,$event:PluginEditEvent){
if(this.editTemplate){
this.pluginTemplate.object.cardInfoArray[i].show=$event.value;
$event.value =this.pluginTemplate.object.cardInfoArray;
}else{
this.plugin.object.cardInfoArray[i].show=$event.value;
$event.value =this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field:$event.field, value: $event.value, type: 'parent'})
ngOnChanges(changes: SimpleChanges) {
if (this.editSubmenuOpen == false && this.selectedIndex > -1) {
this.close();
}
}
cardShowChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i].show = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i].show = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field: $event.field, value: $event.value, type: 'parent'})
}
cardValueChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field: "cardInfoArray", value: $event.value, type: 'parent'})
}
edit(i) {
this.selectedIndex = i;
this.toggleSubMenu(true);
}
close() {
this.selectedIndex = -1;
this.toggleSubMenu(false);
}
}

View File

@ -1,6 +1,6 @@
import {Component} from '@angular/core';
import {PluginBaseComponent} from "../../utils/base-plugin.component";
export class PluginSuggestedRepositories{
import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component";
export class PluginSuggestedRepositories extends PluginBaseInfo{
title:string ="Lorem ipsum";
description: string = "Lorem ipsum";
}

View File

@ -2,51 +2,78 @@
<aside id="sidebar_main" class="uk-sticky" uk-sticky="start: 0; end: .sidebar_main_swipe">
<div sidebar-content>
<div *ngIf="editView" class="back">
<a (click)="editView = false; selectedTemplate = null; selectedPlugin = null;" class="uk-flex uk-flex-middle uk-flex-center">
<a *ngIf="!editSubmenuOpen" (click)="editView = false; selectedTemplate = null; selectedPlugin = null;"
class="uk-flex uk-flex-middle uk-flex-center">
<div class="uk-width-auto">
<icon name="west" ratio="1.3"
[flex]="true"> </icon>
<icon name="west" ratio="1.3"
[flex]="true"></icon>
</div>
<span class="uk-text-small">Plugins list</span>
</a>
<div *ngIf="templateForm" class="uk-width-auto uk-margin-top">
<button class="uk-button uk-button-default uk-margin-right"
(click)="reset()" [class.uk-disabled]="!templateForm.dirty"
[disabled]="!templateForm.dirty || showLoading">Reset
</button>
<button class="uk-button uk-button-primary" [class.uk-disabled]="templateForm.invalid || !templateForm.dirty || templateForm.disabled"
(click)="saveConfirmed(index)" [disabled]="templateForm.invalid ||!templateForm.dirty || templateForm.disabled || showLoading">Save
</button>
<div *ngIf="editSubmenuOpen" class="back uk-margin-bottom">
<a (click)="editSubmenuOpen = false" class="uk-flex uk-flex-middle uk-flex-center">
<div class="uk-width-auto">
<icon name="west" ratio="1.3"
[flex]="true"></icon>
</div>
<span class="uk-text-small">Plugin Options</span>
</a>
</div>
<div *ngIf="templateForm" class="uk-width-auto uk-margin-top uk-margin-left">
<button class="uk-button uk-button-default uk-margin-right"
(click)="reset()" [class.uk-disabled]="!templateForm.dirty"
[disabled]="!templateForm.dirty || showLoading">Reset
</button>
<button class="uk-button uk-button-primary"
[class.uk-disabled]="templateForm.invalid || !templateForm.dirty || templateForm.disabled"
(click)="saveConfirmed(index)"
[disabled]="templateForm.invalid ||!templateForm.dirty || templateForm.disabled || showLoading">Save
</button>
</div>
</div>
</div>
<div class="menu_section uk-margin-large-top">
<div *ngIf="!editView">Select a plugin to edit </div>
<div class="menu_section uk-margin-top uk-margin-left">
<div *ngIf="!editView">Select a plugin to edit</div>
<ng-container *ngIf="editView">
<form *ngIf="!selectTemplateView" [formGroup]="templateForm" class="uk-grid" uk-grid>
<div>Status <mat-slide-toggle [checked]="templateForm.get('active').value"
(change)="templateForm.get('active').setValue($event.checked); templateForm.markAsDirty()"></mat-slide-toggle></div>
<plugin-wrapper-form [pluginTemplate]="selectedTemplate" [plugin]="this.templateForm.getRawValue()"
(changed)="pluginFieldChanged($event)" [pluginObject]="this.templateForm.getRawValue().object"></plugin-wrapper-form>
<form *ngIf="!selectTemplateView" [formGroup]="templateForm" >
<div *ngIf="!editSubmenuOpen" class="uk-text-small uk-margin-small-left">Enable
<mat-slide-toggle [checked]="templateForm.get('active').value"
(change)="templateForm.get('active').setValue($event.checked); templateForm.markAsDirty()"></mat-slide-toggle>
</div>
<plugin-wrapper-form [pluginTemplate]="selectedTemplate" [plugin]="this.templateForm.getRawValue()"
(changed)="pluginFieldChanged($event)"
[pluginObject]="this.selectedPlugin.object"
[editSubmenuOpen]="editSubmenuOpen" ></plugin-wrapper-form>
<ng-container *ngIf="selectedTemplate || selectedPlugin">
<div *ngIf="attrFormArray.controls.length > 0" class="uk-heading-divider uk-text-small uk-width-1-1 uk-margin-bottom uk-text-meta">
<div *ngIf="attrFormArray.controls.length > 0"
class="uk-heading-divider uk-text-small uk-width-1-1 uk-margin-bottom uk-text-meta">
<div class="uk-grid">
<div>Plugin settings</div>
</div>
</div>
<div *ngFor="let attrForm of attrFormArray.controls; let i=index" class="uk-width-1-1 uk-grid uk-child-width-1-2 uk-margin-top" uk-grid>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'text'" input [formInput]="attrForm.get('value')" [placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="text" ></div>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'URL'" input [formInput]="attrForm.get('value')" [placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="URL" [validators]="urlValidator"></div>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'boolean'" input [formInput]="attrForm.get('value')" [placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="select"
[options]="[{label: 'yes', value:true}, {label: 'no', value:false}]"></div>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'HTML'" class="uk-width-1-1">
<div *ngFor="let attrForm of attrFormArray.controls; let i=index"
class="uk-width-1-1 uk-grid uk-child-width-1-2 uk-margin-top" uk-grid>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'text'" input
[formInput]="attrForm.get('value')"
[placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="text"></div>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'URL'" input
[formInput]="attrForm.get('value')"
[placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="URL"
[validators]="urlValidator"></div>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'boolean'" input
[formInput]="attrForm.get('value')"
[placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="select"
[options]="[{label: 'yes', value:true}, {label: 'no', value:false}]"></div>
<div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'HTML'"
class="uk-width-1-1">
<label>
{{selectedTemplate.settings[attrForm.get('key').value].name}}:
</label>
<ckeditor [readonly]="false"
debounce="500"
[formControl]="attrForm.get('value')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',
<ckeditor [readonly]="false"
debounce="500"
[formControl]="attrForm.get('value')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',
removeButtons: 'Save,NewPage,DocProps,Preview,Print,' +
'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' +
'CreateDiv,Flash,PageBreak,' +
@ -58,234 +85,165 @@
</ng-container>
</form>
</ng-container> </div>
</ng-container>
</div>
</div>
</aside>
<div page-content class="uk-width-1-1">
<div header>
<div class="uk-section-xsmall uk-margin-top">
<div class="uk-flex-middle uk-grid" uk-grid>
<ng-container>
<div *ngIf="!templateView && !editView" class="uk-width-expand">
<a routerLink="../pages" class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
<div header>
<div class="uk-section-xsmall uk-margin-top">
<div class="uk-flex-middle uk-grid" uk-grid>
<ng-container>
<div *ngIf="!templateView && !editView" class="uk-width-expand">
<a routerLink="../pages" class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
<span class="uk-margin-right">
<icon name="west" ratio="1.7" [flex]="true"></icon>
</span>
<h1 *ngIf="page" class="uk-h5 uk-margin-remove">{{page.name}}</h1>
</a>
<ul class="uk-subnav uk-subnav-pill uk-margin-medium-top">
<li [class.uk-active]="selectedPlacementView === 'all'" class="uk-margin-small-bottom"><a
(click)="selectedPlacementView = 'all'"><span
class="title">All placements</span></a></li>
<li *ngFor="let position of pluginUtils.placementsOptions; let i=index"
[class.uk-active]="selectedPlacementView === position.value" class="uk-margin-small-bottom"><a
(click)="selectedPlacementView = position.value"><span
class="title">{{position.label}}</span></a></li>
</ul>
</div>
<div *ngIf="templateView" class="uk-width-expand">
<a routerLink="../.." class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
<h1 *ngIf="page" class="uk-h5 uk-margin-remove">{{page.name}}</h1>
</a>
<ul class="uk-subnav uk-subnav-pill uk-margin-medium-top">
<li [class.uk-active]="selectedPlacementView === 'all'" class="uk-margin-small-bottom"><a
(click)="selectedPlacementView = 'all'"><span
class="title">All placements</span></a></li>
<li *ngFor="let position of pluginUtils.placementsOptions; let i=index"
[class.uk-active]="selectedPlacementView === position.value" class="uk-margin-small-bottom"><a
(click)="selectedPlacementView = position.value"><span
class="title">{{position.label}}</span></a></li>
</ul>
</div>
<div *ngIf="templateView" class="uk-width-expand">
<a routerLink="../.." class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
<span class="uk-margin-right">
<icon name="west" ratio="1.7" [flex]="true"></icon>
</span>
<h1 *ngIf="template" class="uk-h5 uk-margin-remove">{{template.name}}</h1>
</a>
</div>
<h1 *ngIf="template" class="uk-h5 uk-margin-remove">{{template.name}}</h1>
</a>
</div>
</ng-container>
</div>
</div>
</div>
<div inner>
<div> <!--class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">-->
<div *ngIf="showLoading" class="uk-position-center">
<loading></loading>
</div>
<ng-container *ngIf="!showLoading && !editView">
<div *ngIf="pluginTemplates.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No plugins found</div>
</div>
<ng-container *ngFor="let placement of pluginUtils.placementsOptions">
<ng-container *ngIf="selectedPlacementView == placement.value || selectedPlacementView == 'all'">
<div *ngIf="pluginsByPlacement.get(placement.value).length >0 && page"
class="uk-heading-divider uk-h6 uk-margin-left uk-padding-remove-left uk-text-capitalize ">{{placement.value}}</div>
<ng-container *ngFor="let pluginGroup of pluginsByPlacement.get(placement.value) ; let i=index">
<ng-container *ngIf="(pluginGroup.template.portalSpecific.length == 0 || pluginGroup.template.portalSpecific.indexOf(communityInfo.communityId) != -1 ) &&
(pluginGroup.template.plan == 'starter'|| pluginGroup.template.plan == communityInfo.plan )">
<div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body uk-flex">
<div class="uk-width-expand uk-text-small">
<ng-container *ngIf="pluginGroup.template && !templateView">
<h6>{{pluginGroup.template.name}}</h6>
<div class="uk-margin-small-bottom">
{{pluginGroup.template.description}}
</div>
</ng-container>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Placement: </span>{{pluginGroup.plugin.placement}}
</div>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Order: </span>{{pluginGroup.plugin.order}}
</div>
<ul uk-accordion>
<li>
<a class="uk-accordion-title">Preview</a>
<div class="uk-accordion-content">
<plugin-wrapper [pluginTemplate]="pluginGroup.template" [plugin]="pluginGroup.plugin"
[pluginObject]="pluginGroup.plugin.object"></plugin-wrapper>
</div>
</li>
</ul>
</div>
</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>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="edit(pluginGroup.plugin, pluginGroup.template, placement, i)"
[class.uk-disabled]="!pluginGroup.template">
<icon name="edit" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Edit</span>
</button>
</div>
</div>
<!-- Maybe change delete to reset to default values ? -->
<!--<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="confirmDelete(check.plugin._id)">
<icon name="delete" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Delete</span>
</button>
</div>
</div>-->
<div *ngIf="pluginGroup.plugin.order>0">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="swap(i, i-1, placement.value)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Up</span>
</button>
</div>
</div>
<div *ngIf="pluginGroup.plugin.order < pluginsByPlacement.get(placement.value).length -1 ">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="swap(i+1, i, placement.value)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Down</span>
</button>
</div>
</div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<mat-slide-toggle [checked]="pluginGroup.plugin.active"
(change)="($event.source.checked = pluginGroup.plugin.active);togglePlugin(!pluginGroup.plugin.active,pluginGroup.plugin._id,i, placement.value)"
>
<span class="uk-text-small">Enable</span>
</mat-slide-toggle>
</div>
</div>
</div>
</div>
</div>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
<ng-container *ngIf="editView">
<plugin-wrapper *ngIf="this.templateForm" [pluginTemplate]="selectedTemplate"
[plugin]="this.templateForm.getRawValue()"
[pluginObject]="this.selectedPlugin.object"
class="uk-width-1-1"></plugin-wrapper>
</ng-container>
</div>
</div>
</div>
<div inner>
<div> <!--class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">-->
<div *ngIf="showLoading" class="uk-position-center">
<loading></loading>
</div>
<ng-container *ngIf="!showLoading && !editView">
<div *ngIf="pluginTemplates.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No plugins found</div>
</div>
<ng-container *ngFor="let placement of pluginUtils.placementsOptions">
<ng-container *ngIf="selectedPlacementView == placement.value || selectedPlacementView == 'all'">
<div *ngIf="pluginsByPlacement.get(placement.value).length >0 && page"
class="uk-heading-divider uk-h6 uk-margin-left uk-padding-remove-left uk-text-capitalize ">{{placement.value}}</div>
<ng-container *ngFor="let pluginGroup of pluginsByPlacement.get(placement.value) ; let i=index">
<ng-container *ngIf="(pluginGroup.template.portalSpecific.length == 0 || pluginGroup.template.portalSpecific.indexOf(communityInfo.communityId) != -1 ) &&
(pluginGroup.template.plan == 'starter'|| pluginGroup.template.plan == communityInfo.plan )">
<div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body uk-flex">
<div class="uk-width-expand uk-text-small">
<ng-container *ngIf="pluginGroup.template && !templateView">
<h6>{{pluginGroup.template.name}}</h6>
<div class="uk-margin-small-bottom">
{{pluginGroup.template.description}}
</div>
</ng-container>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Placement: </span>{{pluginGroup.plugin.placement}}
</div>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Order: </span>{{pluginGroup.plugin.order}}
</div>
<ul uk-accordion>
<li>
<a class="uk-accordion-title" >Preview</a>
<div class="uk-accordion-content">
<plugin-wrapper [pluginTemplate]="pluginGroup.template" [plugin]="pluginGroup.plugin" [pluginObject]="pluginGroup.plugin.object"></plugin-wrapper>
</div>
</li>
</ul>
</div>
</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>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(pluginGroup.plugin, pluginGroup.template, placement, i)"
[class.uk-disabled]="!pluginGroup.template">
<icon name="edit" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Edit</span>
</button>
</div>
</div>
<!-- Maybe change delete to reset to default values ? -->
<!--<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="confirmDelete(check.plugin._id)">
<icon name="delete" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Delete</span>
</button>
</div>
</div>-->
<div *ngIf="pluginGroup.plugin.order>0">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i, i-1, placement.value)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Up</span>
</button>
</div>
</div>
<div *ngIf="pluginGroup.plugin.order < pluginsByPlacement.get(placement.value).length -1 ">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i+1, i, placement.value)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Down</span>
</button>
</div>
</div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<mat-slide-toggle [checked]="pluginGroup.plugin.active"
(change)="($event.source.checked = pluginGroup.plugin.active);togglePlugin(!pluginGroup.plugin.active,pluginGroup.plugin._id,i, placement.value)"
>
<span class="uk-text-small">Enable</span>
</mat-slide-toggle>
</div>
</div>
</div>
</div>
</div>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
<ng-container *ngIf="editView">
<!--<div *ngIf="selectTemplateView">
<div> Select a Template for your plugin. </div>
<div *ngIf="pluginTemplates.length > 0" class="uk-grid uk-child-width-1-1" uk-height-match=".uk-card-body" uk-grid>
<div *ngFor="let template of pluginTemplates; let i=index">
<div class="uk-card uk-card-default">
<div class="uk-card-body uk-flex">
<div class="uk-width-expand uk-text-small">
<h6>{{template.name}}</h6>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Placements: </span>{{template.placements.join(", ")}}
</div>
<div class="uk-margin-small-bottom">
{{template.description}}
</div>
</div>
</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>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="newPlugin(template)">
&lt;!&ndash; <icon name="edit" [flex]="true"></icon>&ndash;&gt;
<span class="uk-margin-xsmall-left"> Select Template</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>-->
<!-- <form *ngIf="!selectTemplateView" [formGroup]="templateForm" class="uk-grid" uk-grid>-->
<!-- <ng-container *ngIf="selectedTemplate || selectedPlugin">-->
<!-- <div class="uk-text-large ">{{selectedTemplate.name}}</div>-->
<!-- <div class="uk-text-meta uk-width-1-1">{{selectedTemplate.description}}</div>-->
<!--&lt;!&ndash; <div input [formInput]="templateForm.get('placement')" placeholder="Placements" [options]="placementsOptions" type="select" class="uk-width-1-2"></div>&ndash;&gt;-->
<!-- <plugin-wrapper [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="selectedTemplate" [plugin]="this.templateForm.getRawValue()"-->
<!-- class="uk-width-1-1" (changed)="pluginFieldChanged($event)"></plugin-wrapper>-->
<!-- <div *ngIf="attrFormArray.controls.length > 0" class="uk-heading-divider uk-text-small uk-width-1-1 uk-margin-bottom uk-text-meta">-->
<!-- <div class="uk-grid">-->
<!-- <div>Plugin settings</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div *ngFor="let attrForm of attrFormArray.controls; let i=index" class="uk-width-1-1 uk-grid uk-child-width-1-2 uk-margin-top" uk-grid>-->
<!-- <div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'text'" input [formInput]="attrForm.get('value')" [placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="text" ></div>-->
<!-- <div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'URL'" input [formInput]="attrForm.get('value')" [placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="URL" [validators]="urlValidator"></div>-->
<!-- <div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'boolean'" input [formInput]="attrForm.get('value')" [placeholder]="selectedTemplate.settings[attrForm.get('key').value].name" type="select"-->
<!-- [options]="[{label: 'yes', value:true}, {label: 'no', value:false}]"></div>-->
<!-- <div *ngIf="this.selectedTemplate.settings[attrForm.get('key').value].type == 'HTML'" class="uk-width-1-1">-->
<!-- <label>-->
<!-- {{selectedTemplate.settings[attrForm.get('key').value].name}}:-->
<!-- </label>-->
<!-- <ckeditor [readonly]="false"-->
<!-- debounce="500"-->
<!-- [formControl]="attrForm.get('value')"-->
<!-- [config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',-->
<!-- removeButtons: 'Save,NewPage,DocProps,Preview,Print,' +-->
<!-- 'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' +-->
<!-- 'CreateDiv,Flash,PageBreak,' +-->
<!-- 'Subscript,Superscript,Anchor,Smiley,Iframe,Styles,Font,About,Language',-->
<!-- extraPlugins: 'divarea'}">-->
<!-- </ckeditor>-->
<!-- </div>-->
<!-- </div>-->
<!-- </ng-container>-->
<!-- </form>-->
<plugin-wrapper *ngIf="this.templateForm" [pluginTemplate]="selectedTemplate" [plugin]="this.templateForm.getRawValue()" [pluginObject]="this.templateForm.getRawValue().object"
class="uk-width-1-1"></plugin-wrapper>
</ng-container>
</div>
</div>
</div>
</div>

View File

@ -1,8 +1,9 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {Component, ElementRef, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {HelpContentService} from "../../services/help-content.service";
import {
FormArray, FormGroup,
FormArray,
FormGroup,
UntypedFormArray,
UntypedFormBuilder,
UntypedFormGroup,
@ -15,7 +16,6 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
import {PortalUtils} from "../portal/portalHelper";
import {AlertModal} from "../../utils/modal/alert";
import {Option} from "../../sharedComponents/input/input.component";
import {Title} from "@angular/platform-browser";
import {ClearCacheService} from "../../services/clear-cache.service";
@ -25,10 +25,10 @@ import {Plugin} from "../../utils/entities/adminTool/plugin";
import {StringUtils} from "../../utils/string-utils.class";
import {Portal} from "../../utils/entities/adminTool/portal";
import {PluginTemplate} from "../../utils/entities/adminTool/pluginTemplate";
import {PluginEditEvent} from "./utils/base-plugin.component";
import {PluginUtils} from "./utils/pluginUtils";
import {CommunityService} from "../../connect/community/community.service";
import {CommunityInfo} from "../../connect/community/communityInfo";
import {PluginEditEvent} from "./utils/base-plugin.form.component";
@Component({
selector: 'plugins',
@ -66,6 +66,7 @@ export class PluginsComponent implements OnInit {
public template;
public selectedPlacementView = "all";
communityInfo:CommunityInfo = null;
editSubmenuOpen = false;
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
private communityService: CommunityService,
private title: Title, private _helpContentService: HelpContentService,
@ -156,8 +157,7 @@ export class PluginsComponent implements OnInit {
plugin = new Plugin(this.selectedPageId, this.selectedCommunityPid,_);
this.plugins.push(plugin);
}
let defaultObj = PluginUtils.initializeObject(_.code);
plugin.object = PluginUtils.updateExistingObject(plugin.object, PluginUtils.updateExistingObject(_.object, defaultObj))
plugin.object = PluginUtils.initializeObjectAndCompare(_.code,plugin.object)
this.pluginsByPlacement.get(plugin.placement).push({plugin: plugin, template: _ });
});
for(let placement of this.pluginUtils.placementsOptions){
@ -175,7 +175,7 @@ export class PluginsComponent implements OnInit {
public edit(plugin:Plugin, template:PluginTemplate, placement, index) {
this.editView = true;
this.selectedPlugin = plugin;
this.selectedPlugin = JSON.parse(JSON.stringify(plugin)); // deep copy object with nested objects
this.selectedTemplate = template;
this.index = index;
this.pagesCtrl = this._fb.array([], Validators.required);
@ -189,15 +189,7 @@ export class PluginsComponent implements OnInit {
order: this._fb.control(plugin.order),
active: this._fb.control(plugin.active),
values: this._fb.array([]),
object: this._fb.group({})
});
for (let attrKey of Object.keys(plugin.object)) {
if(attrKey.indexOf("Array")==-1) {
(this.templateForm.get("object") as FormGroup).addControl(attrKey, this._fb.control(plugin.object[attrKey]));
}else{
(this.templateForm.get("object") as FormGroup).addControl(attrKey,this._fb.array(plugin.object[attrKey]));
}
}
if (template.settings) {
for (let attrKey of Object.keys(template.settings)) {
@ -208,7 +200,6 @@ export class PluginsComponent implements OnInit {
));
}
}
console.log("aaa", this.templateForm.getRawValue())
}
public newPluginSelectTemplate() {
@ -250,6 +241,7 @@ export class PluginsComponent implements OnInit {
public saveConfirmed(index) {
this.showLoading = true;
let plugin: Plugin = <Plugin>this.templateForm.getRawValue();
plugin.object = this.selectedPlugin.object;
plugin.settingsValues = new Map<string, string>();
for (let fields of this.templateForm.getRawValue().values) {
plugin.settingsValues[fields.key] = fields.value;
@ -361,7 +353,8 @@ export class PluginsComponent implements OnInit {
reset() {
if (this.selectedPlugin) {
this.edit(this.selectedPlugin, this.selectedTemplate, this.selectedTemplate.placement, this.index)
this.edit(this.pluginsByPlacement.get(this.selectedTemplate.placement)[this.index].plugin, this.selectedTemplate, this.selectedTemplate.placement, this.index)
} else {
this.newPlugin(this.selectedTemplate)
}
@ -388,18 +381,16 @@ export class PluginsComponent implements OnInit {
}
}
pluginFieldChanged($event:PluginEditEvent){
let object = this.templateForm.get("object").getRawValue();
object[$event.field]=$event.value;
if($event.field.indexOf("Array") == -1) {
this.templateForm.get("object").get($event.field).setValue($event.value);
}else{
((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).clear();
$event.value.forEach(id => {
((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).push(this._fb.control(id))
});
console.log(((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).getRawValue());
if($event.type == "open-submenu"){
this.editSubmenuOpen = true;
return;
}
if($event.type == "close-submenu"){
this.editSubmenuOpen = false;
return;
}
this.selectedPlugin.object[$event.field]=$event.value;
this.templateForm.markAsDirty();
}

View File

@ -6,7 +6,7 @@
<span class="uk-margin-right">
<icon name="west" ratio="1.7" [flex]="true"></icon>
</span>
<h1 class="uk-h5 uk-margin-remove">{{page.name}}</h1>
<h1 class="uk-h5 uk-margin-remove">{{page.name}}</h1>
</a>
</div>
<ul *ngIf="page" class="uk-subnav uk-subnav-pill uk-margin-medium-top">
@ -20,9 +20,9 @@
</ul>
</div>
<div actions>
<div class="uk-section-xsmall">
<div class="uk-section-xsmall">
<div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
<!-- <div search-input [disabled]="showLoading" [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" placeholder="Search class" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>-->
<!-- <div search-input [disabled]="showLoading" [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" placeholder="Search class" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>-->
<div>
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="newPlugin()"
[disabled]="showLoading" [class.uk-disabled]="showLoading">
@ -43,91 +43,100 @@
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No templates found</div>
</div>-->
<div class="uk-grid uk-child-width-1-1">
<div class="uk-grid uk-child-width-1-1">
<ng-container *ngFor="let placement of pluginUtils.placementsOptions">
<ng-container *ngIf="filterForm.get('position').value == placement.value || filterForm.get('position').value == 'all'">
<div *ngIf="templatesByPlacement.get(placement.value).length >0 && page"
class="uk-heading-divider uk-h6 uk-margin-left uk-padding-remove-left uk-text-capitalize ">{{placement.value}}</div>
<ng-container
*ngIf="filterForm.get('position').value == placement.value || filterForm.get('position').value == 'all'">
<div
*ngIf="templatesByPlacement.get(placement.value) && templatesByPlacement.get(placement.value).length >0 && page"
class="uk-heading-divider uk-h6 uk-margin-left uk-padding-remove-left uk-text-capitalize ">{{placement.value}}</div>
<div *ngFor="let template of templatesByPlacement.get(placement.value) ; let i=index">
<div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body uk-flex">
<div class="uk-width-expand uk-text-small">
<h6>{{template.name}}</h6>
<div class="uk-margin-small-bottom">
<span class="uk-label uk-padding-xsmall uk-text-capitalize" [class.uk-label-success]="template.plan !='extended'" [class.uk-label-danger]="template.plan =='extended'">Plan: {{template.plan}} </span>
<span *ngIf="template.portalSpecific && template.portalSpecific.length > 0" class="uk-label uk-label-primary uk-padding-xsmall uk-text-capitalize uk-margin-left">Communities: {{template.portalSpecific.join(', ')}} </span>
<span *ngIf="template.defaultIsActive" class="uk-label uk-label-success uk-padding-xsmall uk-text-capitalize uk-margin-left">Default status: Active </span>
</div>
<div class="uk-margin-small-bottom">
{{template.description}}
</div>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Page: </span>{{getPageAsString(template.page)}} -
<span class="uk-text-meta">Placement: </span>{{template.placement}} -
<span class="uk-text-meta">Order: </span>{{template.order}}
</div>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Portal type: </span>{{template.portalType}}
</div>
<ul uk-accordion>
<li>
<a class="uk-accordion-title" >Preview</a>
<div class="uk-accordion-content">
<plugin-wrapper [pluginTemplate]="template" [pluginObject]="template.object" ></plugin-wrapper>
<div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body uk-flex">
<div class="uk-width-expand uk-text-small">
<h6>{{template.name}}</h6>
<div class="uk-margin-small-bottom">
<span class="uk-label uk-padding-xsmall uk-text-capitalize"
[class.uk-label-success]="template.plan !='extended'"
[class.uk-label-danger]="template.plan =='extended'">Plan: {{template.plan}} </span>
<span *ngIf="template.portalSpecific && template.portalSpecific.length > 0"
class="uk-label uk-label-primary uk-padding-xsmall uk-text-capitalize uk-margin-left">Communities: {{template.portalSpecific.join(', ')}} </span>
<span *ngIf="template.defaultIsActive"
class="uk-label uk-label-success uk-padding-xsmall uk-text-capitalize uk-margin-left">Default status: Active </span>
</div>
</li>
</ul>
</div>
</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-margin-small-bottom">
{{template.description}}
</div>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Page: </span>{{getPageAsString(template.page)}} -
<span class="uk-text-meta">Placement: </span>{{template.placement}} -
<span class="uk-text-meta">Order: </span>{{template.order}}
</div>
<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Portal type: </span>{{template.portalType}}
</div>
<ul uk-accordion>
<li>
<a class="uk-accordion-title">Preview</a>
<div class="uk-accordion-content">
<plugin-wrapper [pluginTemplate]="template"
[pluginObject]="template.object"></plugin-wrapper>
</div>
</li>
</ul>
</div>
</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>
<ng-container *ngIf="page">
<div *ngIf="template.order>0">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i, i-1, template.placement)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Up</span>
</button>
</div>
</div>
<div *ngIf="template.order < templatesByPlacement.get(placement.value).length -1 ">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i+1, i, template.placement)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Down</span>
</button>
</div>
</div>
</ng-container>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(template)">
<icon name="edit" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Edit</span>
</button>
</div>
</div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="confirmDelete(template)">
<icon name="delete" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Delete</span>
</button>
<ng-container *ngIf="page">
<div *ngIf="template.order>0">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="swap(i, i-1, template.placement)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Up</span>
</button>
</div>
</div>
<div *ngIf="template.order < templatesByPlacement.get(placement.value).length -1 ">
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="swap(i+1, i, template.placement)">
<!-- <icon name="" [flex]="true"></icon>-->
<span class="uk-margin-xsmall-left"> Down</span>
</button>
</div>
</div>
</ng-container>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(template)">
<icon name="edit" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Edit</span>
</button>
</div>
</div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="confirmDelete(template)">
<icon name="delete" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Delete</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- </div>-->
</div>
<!-- </div>-->
<!-- </div>-->
</div>
<!-- </div>-->
</ng-container>
</ng-container>
</div>
@ -136,74 +145,96 @@
</div>
</div>
<modal-alert #editModal (alertOutput)="saveConfirmed($event)" [large]="true"
[okDisabled]="templateForm && (templateForm.invalid || !templateForm.dirty)" classTitle="uk-background-primary uk-light">
[okDisabled]="templateForm && (templateForm.invalid || !templateForm.dirty)"
classTitle="uk-background-primary uk-light">
<form *ngIf="templateForm" [formGroup]="templateForm" class="uk-grid " uk-grid>
<div class="uk-width-1-3" *ngIf="templateForm.getRawValue()['_id']">
<div class="uk-text-muted uk-text-bold uk-text-center uk-margin-bottom">Plugin options</div>
<plugin-wrapper-form [pluginTemplate]="templateForm.getRawValue()" [pluginObject]="this.templateForm.getRawValue().object"
(changed)="pluginFieldChanged($event)" [editTemplate]="true"> </plugin-wrapper-form>
</div>
<div class="uk-grid uk-width-expand uk-child-width-1-2" uk-grid>
<div input [formInput]="templateForm.get('name')" placeholder="Template Name"></div>
<div input [formInput]="templateForm.get('code')" placeholder="Template Code" [options]="pluginUtils.availablePluginCodes" type="select"></div>
<div class="uk-width-1-1" input [formInput]="templateForm.get('description')" placeholder="Description" type="textarea"> </div>
<div input [formInput]="templateForm.get('plan')" placeholder="Plan" [options]="pluginUtils.planOptions" type="select"></div>
<div input [formInput]="templateForm.get('image')" placeholder="Image"></div>
<div input [formInput]="templateForm.get('portalType')" placeholder="Portal Type" [options]="portalUtils.portalTypes" type="select"></div>
<div input [formInput]="templateForm.get('placement')" placeholder="Placement" [options]="pluginUtils.placementsOptions" type="select"></div>
<div *ngIf="!templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page" [options]="allPages" type="select" ></div>
<div *ngIf="templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page" [options]="allPagesByPortal.get(templateForm.get('portalType').value)" type="select" ></div>
<div input [formInput]="templateForm.get('portalSpecific')" placeholder="Available to communities" hint="community ids, comma seperated, no spaces"></div>
<div input [formInput]="templateForm.get('order')" placeholder="Order" ></div>
<div>Default Status <mat-slide-toggle [checked]="templateForm.get('defaultIsActive').value"
(change)="templateForm.get('defaultIsActive').setValue($event.checked); templateForm.markAsDirty()"></mat-slide-toggle></div>
<plugin-wrapper *ngIf="selectedTemplate " [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="this.templateForm.getRawValue()"
class="uk-width-1-1" [editTemplate]="true" (changed)="pluginFieldChanged($event)"></plugin-wrapper>
<div *ngFor="let attrForm of attrFormArray.controls; let i=index" class="uk-width-1-1 uk-grid uk-child-width-1-2" uk-grid>
<div class="uk-heading-divider uk-text-small uk-width-1-1 uk-margin-bottom uk-text-meta">
<div class="uk-grid">
<div>Setting #{{i +1}}</div>
<div class=" uk-width-expand uk-text-right ">
<a class=" " (click)="removeAttr(i)">Remove</a>
</div>
<div class="uk-width-1-3 " *ngIf="templateForm.getRawValue()['_id']">
<div class="uk-card uk-card-default uk-padding-small">
<div *ngIf="!editSubmenuOpen" class="uk-text-muted uk-text-bold uk-text-center uk-margin-bottom">Plugin
options
</div>
<plugin-wrapper-form [pluginTemplate]="templateForm.getRawValue()"
[pluginObject]="selectedTemplate.object"
(changed)="pluginFieldChanged($event)" [editTemplate]="true" [editSubmenuOpen]="editSubmenuOpen"></plugin-wrapper-form>
</div>
<div input [formInput]="attrForm.get('key')" placeholder="Key"></div>
<div input [formInput]="attrForm.get('name')" placeholder="Name"></div>
<div input [formInput]="attrForm.get('type')" placeholder="Type" [options]="pluginUtils.attrTypeOptions" type="select" (valueChange)="attributeTypeChanged(attrForm)"></div>
</div>
<div class="uk-grid uk-width-expand uk-child-width-1-2" uk-grid>
<div input [formInput]="templateForm.get('name')" placeholder="Template Name"></div>
<div input [formInput]="templateForm.get('code')" placeholder="Template Code"
[options]="pluginUtils.availablePluginCodes" type="select"></div>
<div class="uk-width-1-1" input [formInput]="templateForm.get('description')" placeholder="Description"
type="textarea"></div>
<div input [formInput]="templateForm.get('plan')" placeholder="Plan" [options]="pluginUtils.planOptions"
type="select"></div>
<div input [formInput]="templateForm.get('image')" placeholder="Image"></div>
<div input [formInput]="templateForm.get('portalType')" placeholder="Portal Type"
[options]="portalUtils.portalTypes" type="select"></div>
<div input [formInput]="templateForm.get('placement')" placeholder="Placement"
[options]="pluginUtils.placementsOptions" type="select"></div>
<div *ngIf="!templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page"
[options]="allPages" type="select"></div>
<div *ngIf="templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page"
[options]="allPagesByPortal.get(templateForm.get('portalType').value)" type="select"></div>
<div input [formInput]="templateForm.get('portalSpecific')" placeholder="Available to communities"
hint="community ids, comma seperated, no spaces"></div>
<div input [formInput]="templateForm.get('order')" placeholder="Order"></div>
<div>Default Status
<mat-slide-toggle [checked]="templateForm.get('defaultIsActive').value"
(change)="templateForm.get('defaultIsActive').setValue($event.checked); templateForm.markAsDirty()"></mat-slide-toggle>
</div>
<!--<plugin-wrapper *ngIf="selectedTemplate "
[pluginTemplate]="this.templateForm.getRawValue()" [pluginObject]="this.templateForm.getRawValue().object" class="uk-width-1-1" ></plugin-wrapper>-->
<div *ngIf="attrForm.get('type').value == 'text'" input [formInput]="attrForm.get('value')" placeholder="Default value" [type]="attrForm.get('type').value" ></div>
<div *ngIf="attrForm.get('type').value == 'URL'" input [formInput]="attrForm.get('value')" placeholder="Default value" [type]="attrForm.get('type').value" [validators]="urlValidator"></div>
<div *ngIf="attrForm.get('type').value == 'boolean'" input [formInput]="attrForm.get('value')" placeholder="Default value" type="select"
[options]="[{label: 'yes', value:true}, {label: 'no', value:false}]"></div>
<div *ngIf="attrForm.get('type').value == 'HTML'" class="uk-width-1-1">
<ckeditor [readonly]="false"
debounce="500"
[formControl]="attrForm.get('value')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',
<div *ngFor="let attrForm of attrFormArray.controls; let i=index" class="uk-width-1-1 uk-grid uk-child-width-1-2"
uk-grid>
<div class="uk-heading-divider uk-text-small uk-width-1-1 uk-margin-bottom uk-text-meta">
<div class="uk-grid">
<div>Setting #{{i + 1}}</div>
<div class=" uk-width-expand uk-text-right ">
<a class=" " (click)="removeAttr(i)">Remove</a>
</div>
</div>
</div>
<div input [formInput]="attrForm.get('key')" placeholder="Key"></div>
<div input [formInput]="attrForm.get('name')" placeholder="Name"></div>
<div input [formInput]="attrForm.get('type')" placeholder="Type" [options]="pluginUtils.attrTypeOptions"
type="select" (valueChange)="attributeTypeChanged(attrForm)"></div>
<div *ngIf="attrForm.get('type').value == 'text'" input [formInput]="attrForm.get('value')"
placeholder="Default value" [type]="attrForm.get('type').value"></div>
<div *ngIf="attrForm.get('type').value == 'URL'" input [formInput]="attrForm.get('value')"
placeholder="Default value" [type]="attrForm.get('type').value" [validators]="urlValidator"></div>
<div *ngIf="attrForm.get('type').value == 'boolean'" input [formInput]="attrForm.get('value')"
placeholder="Default value" type="select"
[options]="[{label: 'yes', value:true}, {label: 'no', value:false}]"></div>
<div *ngIf="attrForm.get('type').value == 'HTML'" class="uk-width-1-1">
<ckeditor [readonly]="false"
debounce="500"
[formControl]="attrForm.get('value')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]',
removeButtons: 'Save,NewPage,DocProps,Preview,Print,' +
'Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,' +
'CreateDiv,Flash,PageBreak,' +
'Subscript,Superscript,Anchor,Smiley,Iframe,Styles,Font,About,Language',
extraPlugins: 'divarea'}">
</ckeditor>
</ckeditor>
</div>
</div>
<hr class="uk-width-1-1">
<div class="uk-width-1-1 uk-text-center ">
<a (click)="addNewAttr()">Add settings</a>
</div>
</div>
<hr class="uk-width-1-1">
<div class="uk-width-1-1 uk-text-center ">
<a (click)="addNewAttr()">Add settings</a>
</div>
<div *ngIf="templateForm.getRawValue()['_id']" class="uk-width-1-1">
<hr class="uk-width-1-1">
<div class="uk-text-muted uk-text-bold uk-width-1-1 uk-text-center">Plugin preview</div>
<plugin-wrapper [pluginTemplate]="templateForm.getRawValue()" [pluginObject]="this.templateForm.getRawValue().object"></plugin-wrapper>
<plugin-wrapper [pluginTemplate]="templateForm.getRawValue()"
[pluginObject]="selectedTemplate.object"></plugin-wrapper>
</div>
</div>
</form>
</modal-alert>
<modal-alert #deleteModal (alertOutput)="confirmedDelete()" classTitle="uk-background-primary uk-light"></modal-alert>
<modal-alert #deleteModal (alertOutput)="confirmedDelete()" classTitle="uk-background-primary uk-light"></modal-alert>

View File

@ -16,8 +16,8 @@ import {NotificationHandler} from "../../../utils/notification-handler";
import {PluginsService} from "../../../services/plugins.service";
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
import {StringUtils} from "../../../utils/string-utils.class";
import {PluginEditEvent} from "../utils/base-plugin.component";
import {PluginUtils} from "../utils/pluginUtils";
import {PluginEditEvent} from "../utils/base-plugin.form.component";
@Component({
selector: 'plugin-templates',
@ -44,7 +44,7 @@ export class PluginTemplatesComponent implements OnInit {
public selectedPageId: string;
public selectedPortalPid: string;
public page: Page;
editSubmenuOpen = false;
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
private title: Title, private _helpContentService: HelpContentService,
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
@ -59,10 +59,6 @@ export class PluginTemplatesComponent implements OnInit {
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.searchText = new RegExp(value, 'i');
// this.applyFilters();
}));
this.subscriptions.push(this.filterForm.get('position').valueChanges.subscribe(value => {
// this.applyFilters();
}));
this.subscriptions.push(this.route.queryParams.subscribe(params => {
@ -118,17 +114,10 @@ export class PluginTemplatesComponent implements OnInit {
this.templatesByPlacement.set(pos.value,[]);
}
for(let template of templates){
let defaultObj = PluginUtils.initializeObject(template.code);
console.log(defaultObj)
template.object = PluginUtils.updateExistingObject(template.object, defaultObj)
template.object = PluginUtils.initializeObjectAndCompare(template.code,template.object)
this.templatesByPlacement.get(template.placement).push(template);
}
// this.checkboxes = [];
let self = this;
/*templates.forEach(_ => {
self.checkboxes.push({template: _, checked: false});
});*/
this.showLoading = false;
},
error => this.handleError('System error retrieving classes', error)));
@ -168,7 +157,7 @@ export class PluginTemplatesComponent implements OnInit {
}
public edit(pluginTemplate) {
this.selectedTemplate = pluginTemplate;
this.selectedTemplate = JSON.parse(JSON.stringify(pluginTemplate)); // deep copy object with nested objects
this.templateForm = this._fb.group({
_id: this._fb.control(pluginTemplate._id),
name: this._fb.control(pluginTemplate.name),
@ -183,15 +172,7 @@ export class PluginTemplatesComponent implements OnInit {
portalSpecific: this._fb.control(pluginTemplate.portalSpecific?pluginTemplate.portalSpecific.join(','):''),
defaultIsActive: this._fb.control(pluginTemplate.defaultIsActive),
settings: this._fb.array([]),
object: this._fb.group({})
});
for (let attrKey of Object.keys(pluginTemplate.object)) {
if(attrKey.indexOf("Array")==-1) {
(this.templateForm.get("object") as FormGroup).addControl(attrKey, this._fb.control(pluginTemplate.object[attrKey]));
}else{
(this.templateForm.get("object") as FormGroup).addControl(attrKey,this._fb.array(pluginTemplate.object[attrKey]));
}
}
this.templateForm.get('portalType').disable();
if (pluginTemplate.settings) {
for (let attrKey of Object.keys(pluginTemplate.settings)) {
@ -203,7 +184,6 @@ export class PluginTemplatesComponent implements OnInit {
}));
}
}
// console.log(this.templateForm.getRawValue(),this.templateForm.get("object").value)
this.modalOpen("Edit Template", "Save Changes");
}
@ -220,7 +200,7 @@ export class PluginTemplatesComponent implements OnInit {
description: this._fb.control(''),
page: this._fb.control(this.page?this.getPageById(this.page):'', Validators.required),
portalType: this._fb.control('community', Validators.required),
placement: this._fb.control('', Validators.required),
placement: this._fb.control('top', Validators.required),
order: this._fb.control(''),
portalSpecific: this._fb.control(''),
defaultIsActive: this._fb.control(false),
@ -262,7 +242,9 @@ export class PluginTemplatesComponent implements OnInit {
let template: PluginTemplate = <PluginTemplate>this.templateForm.getRawValue();
template.page = this.templateForm.getRawValue().page._id
template.portalSpecific = this.templateForm.getRawValue().portalSpecific.length > 0? this.templateForm.getRawValue().portalSpecific.split(','):[];
template.object = this.selectedTemplate?this.selectedTemplate.object:PluginUtils.initializeObjectAndCompare(template.code);
template.settings = new Map<string, { name: string; type: string; value: string }>();
this.editSubmenuOpen = false;
if(!template._id){
template.order = this.templatesByPlacement.get(template.placement).length > 0 ? this.templatesByPlacement.get(template.placement).length:0;
}
@ -288,30 +270,13 @@ export class PluginTemplatesComponent implements OnInit {
// TODO sort
// this.templatesByPlacement.get(this.selectedTemplate.placement) = this.templatesByPlacement.get(this.selectedTemplate.placement).sort()
} else {
let defaultObj = PluginUtils.initializeObject(template.code);
template.object = PluginUtils.updateExistingObject(template.object, defaultObj)
template.object = PluginUtils.initializeObjectAndCompare(template.code, template.object)
this.templatesByPlacement.get(this.selectedTemplate.placement).push(template);
}
// this.applyFilters();
// this.applyCheck(false);
this.showLoading = false;
}
/* public applyFilters() {
this.checkboxes = [];
this.templates.filter(item => this.filterByPosition(item)).forEach(
item => this.checkboxes.push({template: item, checked: false})
);
this.checkboxes = this.checkboxes.filter(item => this.filter(item.template));
}*/
/*public filterByPosition(template: PluginTemplate): boolean {
let position = this.filterForm.get("position").value;
return position == "all" || (template.placement == position);
}*/
public filter(plugin: PluginTemplate): boolean {
return this.searchText.toString() == '' || (plugin.name + ' ' + plugin.portalType).match(this.searchText) != null;
}
@ -398,19 +363,16 @@ export class PluginTemplatesComponent implements OnInit {
pluginFieldChanged($event:PluginEditEvent){
console.log($event)
// let object = this.templateForm.get("object").getRawValue();
// object[$event.field]=$event.value;
if($event.field.indexOf("Array") == -1) {
this.templateForm.get("object").get($event.field).setValue($event.value);
}else{
((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).clear();
$event.value.forEach(id => {
((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).push(this._fb.control(id))
});
console.log(((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).getRawValue());
if($event.type == "open-submenu"){
this.editSubmenuOpen = true;
return;
}
if($event.type == "close-submenu"){
this.editSubmenuOpen = false;
return;
}
this.selectedTemplate.object[$event.field]=$event.value;
this.templateForm.markAsDirty();
}
public getPagesByPortal(portal) {

View File

@ -5,20 +5,24 @@ import {EnvProperties} from "../../../utils/properties/env-properties";
import {properties} from 'src/environments/environment';
import {Subscriber} from "rxjs";
export class PluginEditEvent {
field:string;
type:"text" | "HTML" | "boolean" | 'parent';
value?:any;
}
export class PluginBaseInfo {
title: string = "Lorem ipsum";
constructor() {
}
compare(oldObject){
if(!oldObject) {
oldObject = Object.assign(this)
}else{
if (!oldObject['title'] ) {
oldObject['title'] = this.title;
}
}
return oldObject;
}
}
export class PluginURL {
url:string;
linkText:string;
linkText: string;
target:string;
route:boolean;
constructor(url,linkText, target = "_blank",route = false) {
@ -34,31 +38,21 @@ export class PluginInfoCards{
tag?:string;
title:string;
description:string;
urls:PluginURL[];
urlsArray:PluginURL[];
image?:string;
show:boolean;
}
@Directive()
export abstract class PluginBaseComponent<T extends PluginBaseInfo> implements OnDestroy {
public properties: EnvProperties = properties;
@Input() editMode =false;
@Input() plugin:Plugin;
@Input() pluginTemplate:PluginTemplate;
@Input() editTemplate:boolean = false;
@Input() pluginObject:T;
@Output() valuesChanged:EventEmitter<PluginEditEvent> = new EventEmitter<any>();
subscriptions = [];
pluginEditEvent:PluginEditEvent;
/*default:T;*/
constructor() {
}
ngOnInit(): void {
// console.log(this.default)
/*if (this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title) && this.default) {
this.pluginTemplate.object = Object.assign(this.default);
}*/
}
ngOnDestroy() {
@ -74,25 +68,10 @@ export class PluginInfoCards{
}
});
}
valueChanged($event:PluginEditEvent){
if(this.editTemplate){
this.pluginTemplate.object[$event.field]=$event.value;
this.pluginObject[$event.field]=$event.value;
}else{
this.plugin.object[$event.field]=$event.value;
}
this.valuesChanged.emit($event)
}
isVisible(field){
return (this.plugin && this.plugin.object && this.plugin.object[field] == true) /* plugin is on anyway */
|| (!this.plugin && this.pluginTemplate && this.pluginTemplate.object && this.pluginTemplate.object[field] == true) /* template is on */
return (this.plugin && this.pluginObject && this.pluginObject[field] == true) /* plugin is on anyway */
|| (!this.plugin && this.pluginTemplate && this.pluginObject && this.pluginObject[field] == true) /* template is on */
}
/*get pluginObject():T{
return this.plugin?this.plugin.object:null;
}
get pluginDefaultObject():T{
return this.pluginTemplate?this.pluginTemplate.object:null;
}*/
}

View File

@ -0,0 +1,48 @@
import {Directive, EventEmitter, Input, OnDestroy, Output} from '@angular/core';
import {Plugin} from "../../../utils/entities/adminTool/plugin";
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
import {EnvProperties} from "../../../utils/properties/env-properties";
import {properties} from 'src/environments/environment';
import {PluginBaseComponent, PluginBaseInfo} from "./base-plugin.component";
export class PluginEditEvent {
field:string;
type:"text" | "HTML" | "boolean" | 'parent' |'open-submenu' | 'close-submenu';
value?:any;
constructor(field: string, type: "text" | "HTML" | "boolean" | 'parent' |'open-submenu' | 'close-submenu', value= null) {
this.field = field;
this.type = type;
this.value = value;
}
}
@Directive()
export abstract class PluginBaseFormComponent<T extends PluginBaseInfo> extends PluginBaseComponent<T> implements OnDestroy {
public properties: EnvProperties = properties;
@Input() editMode =false;
@Input() plugin:Plugin;
@Input() pluginTemplate:PluginTemplate;
@Input() editTemplate:boolean = false;
@Input() pluginObject:T;
@Output() valuesChanged:EventEmitter<PluginEditEvent> = new EventEmitter<any>();
subscriptions = [];
pluginEditEvent:PluginEditEvent;
valueChanged($event:PluginEditEvent){
if(this.editTemplate){
// this.pluginTemplate.object[$event.field]=$event.value;
this.pluginObject[$event.field]=$event.value;
}else{
this.pluginObject[$event.field]=$event.value;
}
this.valuesChanged.emit($event)
}
toggleSubMenu(open:boolean){
this.valuesChanged.emit(new PluginEditEvent(null,open?'open-submenu':'close-submenu'))
}
isVisible(field){
return (this.plugin && this.pluginObject && this.pluginObject[field] == true) /* plugin is on anyway */
|| (!this.plugin && this.pluginTemplate && this.pluginObject && this.pluginObject[field] == true) /* template is on */
}
}

View File

@ -1,5 +1,5 @@
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {PluginEditEvent} from "./base-plugin.component";
import {PluginEditEvent} from "./base-plugin.form.component";
@Component({
@ -14,7 +14,11 @@ import {PluginEditEvent} from "./base-plugin.component";
<ng-container *ngIf="editingModeOn">
<!-- <a *ngIf="editingModeOn" class="uk-float-right" (click)="editClicked.emit(null); editingModeOn = false ">close</a>-->
<!-- <br>-->
<div *ngIf="type == 'text'" input [value]="value" [placeholder]="field.toUpperCase()" type="text" (valueChange)="updateObject($event)" inputClass=" border-bottom "></div>
<!--<input id="checkAll" type="checkbox" (click)="selectAll()" class="uk-checkbox"
[ngModel]="getSelectedPages().length ==checkboxes.length"/>-->
<input *ngIf="type == 'checkbox'" [(ngModel)]="value" [checked]="value" (ngModelChange)="updateObject($event)" type="checkbox" class="uk-checkbox">
<div *ngIf="type == 'text'" input [value]="value" [placeholder]="placeholder?placeholder:field.toUpperCase()" type="text" (valueChange)="updateObject($event)" inputClass=" border-bottom "></div>
<!--<div *ngIf="type == 'URL'" input [value]="value" [placeholder]="name" type="URL" ></div>
<div *ngIf="type == 'HTML'" class="uk-width-1-1">
<ckeditor [readonly]="false"
@ -39,6 +43,7 @@ export class PluginFieldEditComponent {
@Input() type;
@Input() value;
@Input() field;
@Input() placeholder;
@Output() editClicked:EventEmitter<PluginEditEvent> = new EventEmitter<PluginEditEvent>();
@Output() changed:EventEmitter<PluginEditEvent> = new EventEmitter()
editingModeOn: boolean = true;

View File

@ -1,12 +1,14 @@
import {Option} from "../../../sharedComponents/input/input.component";
import {PluginOpenAIREProducts} from "../components/openaireProducts/plugin-openaire-products.component";
import {PluginDiscoverBySubcommunity} from "../components/discover-by-subcommunity/plugin-discover-by-subcommunity.component";
import {PluginBaseInfo} from "./base-plugin.component";
import {PluginBaseInfo, PluginInfoCards, PluginURL} from "./base-plugin.component";
import {PluginGatewayInformation} from "../components/gateway-information/plugin-gateway-information.component";
import {PluginLearnAndConnect} from "../components/learn-and-connect/plugin-learn-and-connect.component";
import {PluginFeaturedDatasets} from "../components/featured-datasets/plugin-featured-datasets.component";
import {PluginHowToUse} from "../components/how-to-use/plugin-how-to-use.component";
import {PluginSearchDepositLink} from "../components/search-deposit-link/plugin-search-deposit-link.component";
import {PluginOrganizations} from "../components/organizations/plugin-organizations.component";
import {FormArray, FormGroup, Validators} from "@angular/forms";
export class PluginUtils{
public attrTypeOptions: Option[] = [
@ -17,23 +19,28 @@ export class PluginUtils{
];
public availablePluginCodes: Option[] = [
{label:"openaire-products", value:"openaire-products"},
{label:"discover-by-subcommunity", value:"discover-by-subcommunity"},
{label:"gateway-information", value:"gateway-information"},
{label:"search-deposit-link", value:"search-deposit-link"},
{label:"learn-and-connect", value:"learn-and-connect"},
{label:"how-to-use", value:"how-to-use"},
{label:"suggested-repositories", value:"suggested-repositories"},
{label:"featured-datasets", value:"featured-datasets"},
{label:"OpenAIRE products", value:"penaire-products"},
{label:"Discover by subcommunity", value:"discover-by-subcommunity"},
{label:"Gateway information", value:"gateway-information"},
{label:"Search/ deposit/ link", value:"search-deposit-link"},
{label:"Learn and Connect", value:"learn-and-connect"},
{label:"How to use", value:"how-to-use"},
{label:"Suggested Repositories", value:"suggested-repositories"},
{label:"Featured Datasets", value:"featured-datasets"},
{label:"Organizations", value:"organizations"},
{label:"Fos / SDGs", value:"fos-sdgs"},
{label:"Graph info", value:"graph-info"},
{label:"Social", value:"social"},
{label:"Contact us", value:"organizations"},
];
public placementsOptions: Option[] = [
{label:"Right", value:"right"},
{label:"Top", value:"top"},
{label:"Bottom", value:"bottom"},
// {label:"Top Right", value:"top-right"},
// {label:"Center", value:"center"},
{label:"Right", value:"right"},
{label:"Bottom", value:"bottom"},
{label:"Left", value:"left"},
];
public planOptions: Option[] = [
@ -41,37 +48,42 @@ export class PluginUtils{
{value: 'extended', label: 'Extended'}
];
public static initializeObject(code){
public static initializeObjectAndCompare(code, oldObject = null){
switch(code) {
case 'openaire-products': {
return new PluginOpenAIREProducts();
return (new PluginOpenAIREProducts()).compare(oldObject);
}
case 'discover-by-subcommunity': {
return new PluginDiscoverBySubcommunity();
return (new PluginDiscoverBySubcommunity()).compare(oldObject);
}
case 'gateway-information': {
return new PluginGatewayInformation();
return (new PluginGatewayInformation()).compare(oldObject);
}
case 'search-deposit-link': {
return new PluginSearchDepositLink();
return (new PluginSearchDepositLink()).compare(oldObject);
}
case 'learn-and-connect': {
return new PluginLearnAndConnect();
return (new PluginLearnAndConnect()).compare(oldObject);
}
case 'how-to-use': {
return new PluginHowToUse();
return (new PluginHowToUse()).compare(oldObject);
}
case 'suggested-repositories': {
return new PluginBaseInfo();
return (new PluginBaseInfo()).compare(oldObject);
}
case 'featured-datasets': {
return new PluginFeaturedDatasets();
return (new PluginFeaturedDatasets()).compare(oldObject);
}
case 'organizations': {
return (new PluginOrganizations()).compare(oldObject);
}
default: {
return new PluginBaseInfo();
return (new PluginBaseInfo()).compare(oldObject);
}
}
}
//
public static updateExistingObject(oldObject, object ){
if(!oldObject) {
oldObject = Object.assign(object)

View File

@ -1,12 +1,12 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Plugin} from "../../../utils/entities/adminTool/plugin";
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
import {PluginEditEvent} from "../utils/base-plugin.component";
import {PluginEditEvent} from "../utils/base-plugin.form.component";
@Component({
selector: 'plugin-wrapper-form',
template: `
<div class="uk-width-1-1" *ngIf="pluginObject">
<div class="uk-margin-small-right uk-margin-top" *ngIf="pluginObject">
<ng-container *ngIf="pluginTemplate.code == 'openaire-products'">
<plugin-openaire-products-form [pluginTemplate]="pluginTemplate" [plugin]="plugin" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-openaire-products-form>
</ng-container>
@ -20,10 +20,10 @@ import {PluginEditEvent} from "../utils/base-plugin.component";
<plugin-search-deposit-link-form [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-search-deposit-link-form>
</ng-container>
<ng-container *ngIf="pluginTemplate.code == 'learn-and-connect'">
<plugin-learn-and-connect-form [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-learn-and-connect-form>
<plugin-learn-and-connect-form [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate" [editSubmenuOpen]="editSubmenuOpen"></plugin-learn-and-connect-form>
</ng-container>
<ng-container *ngIf="pluginTemplate.code == 'how-to-use'">
<plugin-how-to-use [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-how-to-use>
<plugin-how-to-use-form [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate" [editSubmenuOpen]="editSubmenuOpen"></plugin-how-to-use-form>
</ng-container>
<ng-container *ngIf="pluginTemplate.code == 'suggested-repositories'">
<plugin-suggested-repositories [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-suggested-repositories>
@ -31,6 +31,9 @@ import {PluginEditEvent} from "../utils/base-plugin.component";
<ng-container *ngIf="pluginTemplate.code == 'featured-datasets'">
<plugin-featured-datasets-form [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-featured-datasets-form>
</ng-container>
<ng-container *ngIf="pluginTemplate.code == 'organizations'">
<plugin-organizations-form [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" (valuesChanged)="changed.emit($event)" [editTemplate]="editTemplate"></plugin-organizations-form>
</ng-container>
</div>
`,
@ -43,7 +46,7 @@ export class PluginEditWrapperComponent implements OnInit {
@Input() editTemplate:boolean;
@Input() pluginObject;
@Output() changed:EventEmitter<PluginEditEvent> = new EventEmitter();
@Input() editSubmenuOpen;
ngOnInit(): void {
}

View File

@ -10,13 +10,16 @@ import {PluginDiscoverBySubcommunityFormComponent} from "../components/discover-
import {PluginFeaturedDatasetsFormComponent} from "../components/featured-datasets/plugin-featured-datasets.form.component";
import {PluginGatewayInformationFormComponent} from "../components/gateway-information/plugin-gateway-information.form.component";
import {PluginSearchDepositLinkFormComponent} from "../components/search-deposit-link/plugin-search-deposit-link.form.component";
import {PluginOrganizationsFormComponent} from "../components/organizations/plugin-organizations.form.component";
import {IconsModule} from "../../../utils/icons/icons.module";
import {PluginHowToUseFormComponent} from "../components/how-to-use/plugin-how-to-use.form.component";
@NgModule({
imports: [
CommonModule, RouterModule, FormsModule, PluginFieldEditModule
CommonModule, RouterModule, FormsModule, PluginFieldEditModule, IconsModule
],
declarations: [PluginEditWrapperComponent, PluginOpenaireProductsFormComponent, PluginLearnAndConnectFormComponent,
PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginFeaturedDatasetsFormComponent, PluginGatewayInformationFormComponent, PluginSearchDepositLinkFormComponent],
PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginDiscoverBySubcommunityFormComponent, PluginFeaturedDatasetsFormComponent, PluginGatewayInformationFormComponent, PluginSearchDepositLinkFormComponent, PluginOrganizationsFormComponent, PluginHowToUseFormComponent],
exports: [PluginEditWrapperComponent]
})

View File

@ -1,8 +1,6 @@
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import {Plugin} from "../../../utils/entities/adminTool/plugin";
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
import {PluginEditEvent} from "../utils/base-plugin.component";
import {PluginUtils} from "../utils/pluginUtils";
@Component({
selector: 'plugin-wrapper',
@ -33,6 +31,9 @@ import {PluginUtils} from "../utils/pluginUtils";
<ng-container *ngIf="pluginTemplate.code == 'featured-datasets'">
<plugin-featured-datasets [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" ></plugin-featured-datasets>
</ng-container>
<ng-container *ngIf="pluginTemplate.code == 'organizations'">
<plugin-organizations [plugin]="plugin" [pluginTemplate]="pluginTemplate" [pluginObject]="pluginObject" ></plugin-organizations>
</ng-container>
</div>
</ng-container>
`

View File

@ -11,12 +11,13 @@ import {PluginLearnAndConnectModule} from '../components/learn-and-connect/plugi
import {PluginHowToUseModule} from '../components/how-to-use/plugin-how-to-use.module';
import {PluginSuggestedRepositoriesModule} from '../components/suggested-repositories/plugin-suggested-repositories.module';
import {PluginFeaturedDatasetsModule} from '../components/featured-datasets/plugin-featured-datasets.module';
import {PluginOrganizationsModule} from "../components/organizations/plugin-organizations.module";
@NgModule({
imports: [
CommonModule, RouterModule, FormsModule, PluginOpenaireProductsModule,
PluginDiscoverBySubcommunityModule, PluginSearchDepositLinkModule, PluginLearnAndConnectModule,
PluginHowToUseModule, PluginSuggestedRepositoriesModule, PluginFeaturedDatasetsModule, PluginGatewayInformationModule
PluginHowToUseModule, PluginSuggestedRepositoriesModule, PluginFeaturedDatasetsModule, PluginGatewayInformationModule, PluginOrganizationsModule
],
declarations: [PluginWrapperComponent],
exports: [PluginWrapperComponent]