plugins-functionality #43

Merged
argiro.kokogiannaki merged 86 commits from plugins-functionality into develop 2024-06-13 09:14:22 +02:00
10 changed files with 69 additions and 74 deletions
Showing only changes of commit b91822db64 - Show all commits

View File

@ -69,7 +69,6 @@ export class PagesComponent implements OnInit {
private index: number; private index: number;
pageHelpContentsCount = {}; pageHelpContentsCount = {};
pageClassContentsCount = {}; pageClassContentsCount = {};
pagePluginsCount = {};
pagePluginTemplatesCount = {}; pagePluginTemplatesCount = {};
constructor(private element: ElementRef, private route: ActivatedRoute, constructor(private element: ElementRef, private route: ActivatedRoute,
private title: Title, private title: Title,
@ -441,11 +440,6 @@ export class PagesComponent implements OnInit {
this.pageClassContentsCount = pageClassContentsCount; this.pageClassContentsCount = pageClassContentsCount;
}, },
error => this.handleError('System error retrieving page contents', error))); error => this.handleError('System error retrieving page contents', error)));
this.subscriptions.push(this._pluginsService.countPluginPerPage( this.properties.adminToolsAPIURL, community_pid).subscribe(
countPlugins => {
this.pagePluginsCount = countPlugins;
},
error => this.handleError('System error retrieving page contents', error)));
this.subscriptions.push(this._pluginsService.countPluginTemplatePerPage( this.properties.adminToolsAPIURL, community_pid).subscribe( this.subscriptions.push(this._pluginsService.countPluginTemplatePerPage( this.properties.adminToolsAPIURL, community_pid).subscribe(
countPlugins => { countPlugins => {
this.pagePluginTemplatesCount = countPlugins; this.pagePluginTemplatesCount = countPlugins;

View File

@ -11,6 +11,8 @@ import {OpenaireEntities} from "../../../../utils/properties/searchFields";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {Filter} from "../../../../searchPages/searchUtils/searchHelperClasses.class"; import {Filter} from "../../../../searchPages/searchUtils/searchHelperClasses.class";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {SearchResearchResultsService} from "../../../../services/searchResearchResults.service";
import {properties} from "../../../../../../environments/environment";
export class PluginGatewayInformation extends PluginBaseInfo{ export class PluginGatewayInformation extends PluginBaseInfo{
showTitle:boolean = true; showTitle:boolean = true;
@ -100,6 +102,7 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent<Plugi
private searchCommunityProjectsService: SearchCommunityProjectsService, private searchCommunityProjectsService: SearchCommunityProjectsService,
private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, private searchCommunityDataprovidersService: SearchCommunityDataprovidersService,
private zenodoCommunitiesService: ZenodoCommunitiesService, private _router: Router, private zenodoCommunitiesService: ZenodoCommunitiesService, private _router: Router,
private _searchResearchResultsService: SearchResearchResultsService,
private cdr: ChangeDetectorRef) { private cdr: ChangeDetectorRef) {
super(); super();
this.searchLinkToResults = this.properties.searchLinkToResults; this.searchLinkToResults = this.properties.searchLinkToResults;
@ -170,7 +173,7 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent<Plugi
this.contentProvidersCalculated = true; this.contentProvidersCalculated = true;
} }
)); ));
this.subscriptions.push(this.http.get(this.properties.utilsService + "/portals/countResults?field=communityid&value=" + this.community.communityId).subscribe(res => { this.subscriptions.push(this._searchResearchResultsService.countResults("communityid", this.community.communityId).subscribe(res => {
this.resultCounts = res; this.resultCounts = res;
})); }));
} }

View File

@ -15,6 +15,7 @@ import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
<div class="uk-margin-top uk-text-meta uk-text-xsmall "> <div class="uk-margin-top uk-text-meta uk-text-xsmall ">
Community info Community info
</div> </div>
<div class="uk-alert uk-alert-warning uk-text-small"> Manage community info <a routerLink="../../info/profile" target="_blank">here</a>.</div>
<div class="uk-grid uk-child-width-1-1 uk-text-small uk-hr "> <div class="uk-grid uk-child-width-1-1 uk-text-small uk-hr ">
<div class="uk-margin-xsmall-bottom uk-margin-xsmall-top"> <div class="uk-margin-xsmall-bottom uk-margin-xsmall-top">
<plugin-field-edit [value]=" pluginObject.showTitle" <plugin-field-edit [value]=" pluginObject.showTitle"

View File

@ -16,10 +16,6 @@ import {PluginGraphInfo} from "./plugin-graph-info.component";
<plugin-field-edit [value]="pluginObject.paragraph2" class="uk-margin-xsmall-top" <plugin-field-edit [value]="pluginObject.paragraph2" class="uk-margin-xsmall-top"
type="textarea" field="paragraph2" (changed)="valueChanged($event)"></plugin-field-edit> type="textarea" field="paragraph2" (changed)="valueChanged($event)"></plugin-field-edit>
</div> </div>
<div class="uk-margin-top">
<plugin-field-edit [value]="pluginObject.contributeLine" class="uk-margin-xsmall-top"
type="text" field="contributeLine" (changed)="valueChanged($event)"></plugin-field-edit>
</div>
<div class=" uk-margin-top uk-text-meta uk-text-xsmall"> Link</div> <div class=" uk-margin-top uk-text-meta uk-text-xsmall"> Link</div>
<div class="uk-margin-small-top"> <div class="uk-margin-small-top">
<plugin-field-edit [value]=" pluginObject.url.url" <plugin-field-edit [value]=" pluginObject.url.url"

View File

@ -9,6 +9,7 @@ import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
<plugin-field-edit [value]="pluginObject.title" <plugin-field-edit [value]="pluginObject.title"
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit> type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
<div class="uk-alert uk-alert-warning uk-text-small"> Manage community organizations <a routerLink="../../info/organizations" target="_blank">here</a>.</div>
</div> </div>
`, `,

File diff suppressed because one or more lines are too long

View File

@ -365,7 +365,7 @@ export class PluginsFormComponent implements OnInit {
this.index = i; this.index = i;
this.selectedTemplate = this.pluginsByPlacement.get(placement)[i].template; this.selectedTemplate = this.pluginsByPlacement.get(placement)[i].template;
if(id) { if(id) {
this.subscriptions.push(this._pluginsService.togglePages(id, status, this.properties.adminToolsAPIURL).subscribe( this.subscriptions.push(this._pluginsService.togglePlugin(id, status, this.properties.adminToolsAPIURL).subscribe(
() => { () => {
this.pluginsByPlacement.get(placement)[i].plugin.active = status; this.pluginsByPlacement.get(placement)[i].plugin.active = status;

View File

@ -102,7 +102,7 @@
</span> </span>
<h1 *ngIf="page" class="uk-h5 uk-margin-remove">{{page.name}}</h1> <h1 *ngIf="page" class="uk-h5 uk-margin-remove">{{page.name}}</h1>
</a> </a>
<ul class="uk-subnav uk-subnav-pill uk-margin-medium-top"> <ul *ngIf="!sinlgePlacementAvailable" class="uk-subnav uk-subnav-pill uk-margin-medium-top">
<li [class.uk-active]="selectedPlacementView === 'all'" class="uk-margin-small-bottom"><a <li [class.uk-active]="selectedPlacementView === 'all'" class="uk-margin-small-bottom"><a
(click)="selectedPlacementView = 'all'"><span (click)="selectedPlacementView = 'all'"><span
class="title">All placements</span></a></li> class="title">All placements</span></a></li>
@ -139,7 +139,7 @@
<ng-container *ngFor="let placement of pluginUtils.placementsOptions"> <ng-container *ngFor="let placement of pluginUtils.placementsOptions">
<ng-container *ngIf="selectedPlacementView == placement.value || selectedPlacementView == 'all'"> <ng-container *ngIf="selectedPlacementView == placement.value || selectedPlacementView == 'all'">
<div *ngIf="pluginsByPlacement.get(placement.value).length >0 && page" <div *ngIf="pluginsByPlacement.get(placement.value).length >0 && page && !sinlgePlacementAvailable"
class="uk-heading-divider uk-h6 uk-margin-left uk-padding-remove-left uk-text-capitalize ">{{placement.value}}</div> 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 *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 ) && <ng-container *ngIf="(pluginGroup.template.portalSpecific.length == 0 || pluginGroup.template.portalSpecific.indexOf(communityInfo.communityId) != -1 ) &&
@ -154,18 +154,20 @@
</div> </div>
</ng-container> </ng-container>
<div class="uk-margin-small-bottom"> <div *ngIf="!sinlgePlacementAvailable" class="uk-margin-small-bottom">
<span class="uk-text-meta">Placement: </span>{{pluginGroup.plugin.placement}} <span class="uk-text-meta">Placement: </span>{{pluginGroup.plugin.placement}}
</div> </div>
<div class="uk-margin-small-bottom"> <!--<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Order: </span>{{pluginGroup.plugin.order}} <span class="uk-text-meta">Order: </span>{{pluginGroup.plugin.order}}
</div> </div>-->
<ul uk-accordion> <ul uk-accordion>
<li> <li>
<a class="uk-accordion-title">Preview</a> <a (click)="pluginGroup.openPreview = !pluginGroup.openPreview" class="uk-accordion-title">Preview</a>
<div class="uk-accordion-content"> <div class="uk-accordion-content">
<plugin-wrapper [pluginTemplate]="pluginGroup.template" [plugin]="pluginGroup.plugin" <ng-container *ngIf="pluginGroup.openPreview">
<plugin-wrapper [pluginTemplate]="pluginGroup.template" [plugin]="pluginGroup.plugin"
[pluginObject]="pluginGroup.plugin.object"></plugin-wrapper> [pluginObject]="pluginGroup.plugin.object"></plugin-wrapper>
</ng-container>
</div> </div>
</li> </li>
</ul> </ul>
@ -203,7 +205,7 @@
<button <button
class="uk-button uk-button-link uk-flex uk-flex-middle" class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="swap(i, i-1, placement.value)"> (click)="swap(i, i-1, placement.value)">
<!-- <icon name="" [flex]="true"></icon>--> <icon name="arrow_upward" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Up</span> <span class="uk-margin-xsmall-left"> Up</span>
</button> </button>
</div> </div>
@ -213,8 +215,8 @@
<button <button
class="uk-button uk-button-link uk-flex uk-flex-middle" class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="swap(i+1, i, placement.value)"> (click)="swap(i+1, i, placement.value)">
<!-- <icon name="" [flex]="true"></icon>--> <icon name="arrow_downward" [flex]="true"></icon>
<span class="uk-margin-xsmall-left"> Down</span> <span class="uk-margin-xsmall-left">Down</span>
</button> </button>
</div> </div>
</div> </div>

View File

@ -36,7 +36,7 @@ import {PluginEditEvent} from "./utils/base-plugin.form.component";
}) })
export class PluginsComponent implements OnInit { export class PluginsComponent implements OnInit {
private selectedId: string; private selectedId: string;
public pluginsByPlacement: Map<string,{plugin:Plugin, template:PluginTemplate}[]> = new Map(); public pluginsByPlacement: Map<string,{plugin:Plugin, template:PluginTemplate, openPreview:boolean}[]> = new Map();
public plugins: Plugin[] = []; public plugins: Plugin[] = [];
public pluginTemplates: PluginTemplate[] = []; public pluginTemplates: PluginTemplate[] = [];
public selectedTemplate: PluginTemplate = null; public selectedTemplate: PluginTemplate = null;
@ -65,6 +65,7 @@ export class PluginsComponent implements OnInit {
public templateCode:string = null; public templateCode:string = null;
public template; public template;
public selectedPlacementView = "all"; public selectedPlacementView = "all";
public sinlgePlacementAvailable = false;
communityInfo:CommunityInfo = null; communityInfo:CommunityInfo = null;
editSubmenuOpen = false; editSubmenuOpen = false;
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
@ -158,13 +159,21 @@ export class PluginsComponent implements OnInit {
this.plugins.push(plugin); this.plugins.push(plugin);
} }
plugin.object = PluginUtils.initializeObjectAndCompare(_.code,plugin.object) plugin.object = PluginUtils.initializeObjectAndCompare(_.code,plugin.object)
this.pluginsByPlacement.get(plugin.placement).push({plugin: plugin, template: _ }); this.pluginsByPlacement.get(plugin.placement).push({plugin: plugin, template: _ , openPreview:false});
}); });
let availablePlacements = [];
for(let placement of this.pluginUtils.placementsOptions){ for(let placement of this.pluginUtils.placementsOptions){
if(this.pluginsByPlacement.get(placement.value).length > 0){
availablePlacements.push(placement.value);
}
this.pluginsByPlacement.get(placement.value).sort(function (a, b) { this.pluginsByPlacement.get(placement.value).sort(function (a, b) {
return a.plugin.order - b.plugin.order; return a.plugin.order - b.plugin.order;
}) })
} }
if(availablePlacements.length == 1){
this.selectedPlacementView == availablePlacements[0];
this.sinlgePlacementAvailable = true
}
this.showLoading = false; this.showLoading = false;
}, },
error => this.handleError('System error retrieving plugins', error))); error => this.handleError('System error retrieving plugins', error)));
@ -365,7 +374,7 @@ export class PluginsComponent implements OnInit {
this.index = i; this.index = i;
this.selectedTemplate = this.pluginsByPlacement.get(placement)[i].template; this.selectedTemplate = this.pluginsByPlacement.get(placement)[i].template;
if(id) { if(id) {
this.subscriptions.push(this._pluginsService.togglePages(id, status, this.properties.adminToolsAPIURL).subscribe( this.subscriptions.push(this._pluginsService.togglePlugin(id, status, this.properties.adminToolsAPIURL).subscribe(
() => { () => {
this.pluginsByPlacement.get(placement)[i].plugin.active = status; this.pluginsByPlacement.get(placement)[i].plugin.active = status;

View File

@ -4,65 +4,54 @@ import {CustomOptions} from "./servicesUtils/customOptions.class";
import {PluginTemplate} from "../utils/entities/adminTool/pluginTemplate"; import {PluginTemplate} from "../utils/entities/adminTool/pluginTemplate";
import {Plugin} from "../utils/entities/adminTool/plugin"; import {Plugin} from "../utils/entities/adminTool/plugin";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {catchError} from "rxjs/operators";
@Injectable() @Injectable()
export class PluginsService { export class PluginsService {
constructor(private http:HttpClient) { constructor(private http: HttpClient) {
} }
getPluginTemplates(api: string, pageId) {
getPluginTemplate(api:string, code:string) { return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates' + (pageId ? '/page/' + pageId : ''))
return this.http.get<PluginTemplate>(api + 'pluginTemplates/' + code)
}
getPluginTemplates(api:string,pageId) {
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates' + (pageId?'/page/'+pageId:''))
} }
savePluginTemplate(pluginTemplate:PluginTemplate, api:string) { savePluginTemplate(pluginTemplate: PluginTemplate, api: string) {
// console.log(pluginTemplate, pluginTemplate.toJsonObj())
return this.http.post<PluginTemplate>(api + 'pluginTemplate/save', pluginTemplate, CustomOptions.getAuthOptionsWithBody()); return this.http.post<PluginTemplate>(api + 'pluginTemplate/save', pluginTemplate, CustomOptions.getAuthOptionsWithBody());
} }
updatePluginTemplateOrder(pluginTemplate:PluginTemplate, api:string, position) {
return this.http.post<PluginTemplate>(api + 'pluginTemplate/save/order/'+position, pluginTemplate, CustomOptions.getAuthOptionsWithBody()); updatePluginTemplateOrder(pluginTemplate: PluginTemplate, api: string, position) {
} return this.http.post<PluginTemplate>(api + 'pluginTemplate/save/order/' + position, pluginTemplate, CustomOptions.getAuthOptionsWithBody());
updatePluginOrder(plugin:Plugin, api:string, position) {
return this.http.post<Plugin>(api + 'plugin/save/order/'+position, plugin, CustomOptions.getAuthOptionsWithBody());
}
savePlugin(plugin, api:string) {
return this.http.post<Plugin>(api + 'plugin/save', JSON.stringify(plugin), CustomOptions.getAuthOptionsWithBody());
}
deletePlugin(id, api:string) {
return this.http.delete<Plugin>(api + 'plugin/'+id, CustomOptions.getAuthOptionsWithBody());
}
deletePluginTemplate(id, api:string) {
return this.http.delete<PluginTemplate>(api + 'pluginTemplate/'+id, CustomOptions.getAuthOptionsWithBody());
}
countPluginPerPage( api:string, pid:string){
return this.http.get(api + properties.adminToolsPortalType + '/' +pid+'/plugin/page/count');
}
countPluginTemplatePerPage( api:string, pid:string){
return this.http.get(api + properties.adminToolsPortalType + '/' +pid+'/pluginTemplate/page/count');
}
countPluginTemplatePerPageForAllPortals( api:string){
return this.http.get(api + '/pluginTemplate/page/count');
}
countPluginPerTemplate( api:string){
return this.http.get(api + '/plugin/template/count');
}
getPluginsByPage(api:string, pid:string, pageId:string){
return this.http.get<Array<Plugin>>(api + properties.adminToolsPortalType + '/' +pid+'/plugins/page/' + pageId);
}
getPluginTemplatesByPage(api:string, pid:string, pageId:string){
return this.http.get<Array<PluginTemplate>>(api + properties.adminToolsPortalType + '/' +pid+'/pluginTemplates/page/' + pageId);
}
getPluginsByTemplatesCode(api:string, pid:string, code:string){
return this.http.get<Array<Plugin>>(api +'/plugins/template/' + code);
} }
togglePages(id : string,status : boolean, api:string) { updatePluginOrder(plugin: Plugin, api: string, position) {
return this.http.post<Plugin>(api + 'plugin/save/order/' + position, plugin, CustomOptions.getAuthOptionsWithBody());
}
savePlugin(plugin, api: string) {
return this.http.post<Plugin>(api + 'plugin/save', JSON.stringify(plugin), CustomOptions.getAuthOptionsWithBody());
}
deletePluginTemplate(id, api: string) {
return this.http.delete<PluginTemplate>(api + 'pluginTemplate/' + id, CustomOptions.getAuthOptionsWithBody());
}
countPluginTemplatePerPage(api: string, pid: string) {
return this.http.get(api + properties.adminToolsPortalType + '/' + pid + '/pluginTemplate/page/count');
}
countPluginTemplatePerPageForAllPortals(api: string) {
return this.http.get(api + '/pluginTemplate/page/count');
}
getPluginsByPage(api: string, pid: string, pageId: string) {
return this.http.get<Array<Plugin>>(api + properties.adminToolsPortalType + '/' + pid + '/plugins/page/' + pageId);
}
getPluginTemplatesByPage(api: string, pid: string, pageId: string) {
return this.http.get<Array<PluginTemplate>>(api + properties.adminToolsPortalType + '/' + pid + '/pluginTemplates/page/' + pageId);
}
togglePlugin(id: string, status: boolean, api: string) {
return this.http.post(api + 'plugin/status/' + id, status, CustomOptions.getAuthOptionsWithBody()); return this.http.post(api + 'plugin/status/' + id, status, CustomOptions.getAuthOptionsWithBody());
} }
} }