[plugins-functionality | WIP] more updates and fixes

This commit is contained in:
argirok 2024-03-15 15:56:54 +02:00
parent 0aa2ec20e6
commit b91822db64
10 changed files with 69 additions and 74 deletions

View File

@ -69,7 +69,6 @@ export class PagesComponent implements OnInit {
private index: number;
pageHelpContentsCount = {};
pageClassContentsCount = {};
pagePluginsCount = {};
pagePluginTemplatesCount = {};
constructor(private element: ElementRef, private route: ActivatedRoute,
private title: Title,
@ -441,11 +440,6 @@ export class PagesComponent implements OnInit {
this.pageClassContentsCount = pageClassContentsCount;
},
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(
countPlugins => {
this.pagePluginTemplatesCount = countPlugins;

View File

@ -11,6 +11,8 @@ import {OpenaireEntities} from "../../../../utils/properties/searchFields";
import {HttpClient} from "@angular/common/http";
import {Filter} from "../../../../searchPages/searchUtils/searchHelperClasses.class";
import {Router} from "@angular/router";
import {SearchResearchResultsService} from "../../../../services/searchResearchResults.service";
import {properties} from "../../../../../../environments/environment";
export class PluginGatewayInformation extends PluginBaseInfo{
showTitle:boolean = true;
@ -100,6 +102,7 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent<Plugi
private searchCommunityProjectsService: SearchCommunityProjectsService,
private searchCommunityDataprovidersService: SearchCommunityDataprovidersService,
private zenodoCommunitiesService: ZenodoCommunitiesService, private _router: Router,
private _searchResearchResultsService: SearchResearchResultsService,
private cdr: ChangeDetectorRef) {
super();
this.searchLinkToResults = this.properties.searchLinkToResults;
@ -170,7 +173,7 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent<Plugi
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;
}));
}

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 ">
Community info
</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-margin-xsmall-bottom uk-margin-xsmall-top">
<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"
type="textarea" field="paragraph2" (changed)="valueChanged($event)"></plugin-field-edit>
</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-small-top">
<plugin-field-edit [value]=" pluginObject.url.url"

View File

@ -8,7 +8,8 @@ import {PluginBaseFormComponent} from "../../utils/base-plugin.form.component";
<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-alert uk-alert-warning uk-text-small"> Manage community organizations <a routerLink="../../info/organizations" target="_blank">here</a>.</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.selectedTemplate = this.pluginsByPlacement.get(placement)[i].template;
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;

View File

@ -102,7 +102,7 @@
</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">
<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
(click)="selectedPlacementView = 'all'"><span
class="title">All placements</span></a></li>
@ -139,7 +139,7 @@
<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"
<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>
<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 ) &&
@ -154,18 +154,20 @@
</div>
</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}}
</div>
<div class="uk-margin-small-bottom">
<!--<div class="uk-margin-small-bottom">
<span class="uk-text-meta">Order: </span>{{pluginGroup.plugin.order}}
</div>
</div>-->
<ul uk-accordion>
<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">
<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>
</ng-container>
</div>
</li>
</ul>
@ -203,7 +205,7 @@
<button
class="uk-button uk-button-link uk-flex uk-flex-middle"
(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>
</button>
</div>
@ -213,8 +215,8 @@
<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>
<icon name="arrow_downward" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Down</span>
</button>
</div>
</div>

View File

@ -36,7 +36,7 @@ import {PluginEditEvent} from "./utils/base-plugin.form.component";
})
export class PluginsComponent implements OnInit {
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 pluginTemplates: PluginTemplate[] = [];
public selectedTemplate: PluginTemplate = null;
@ -65,6 +65,7 @@ export class PluginsComponent implements OnInit {
public templateCode:string = null;
public template;
public selectedPlacementView = "all";
public sinlgePlacementAvailable = false;
communityInfo:CommunityInfo = null;
editSubmenuOpen = false;
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
@ -158,13 +159,21 @@ export class PluginsComponent implements OnInit {
this.plugins.push(plugin);
}
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){
if(this.pluginsByPlacement.get(placement.value).length > 0){
availablePlacements.push(placement.value);
}
this.pluginsByPlacement.get(placement.value).sort(function (a, b) {
return a.plugin.order - b.plugin.order;
})
}
if(availablePlacements.length == 1){
this.selectedPlacementView == availablePlacements[0];
this.sinlgePlacementAvailable = true
}
this.showLoading = false;
},
error => this.handleError('System error retrieving plugins', error)));
@ -365,7 +374,7 @@ export class PluginsComponent implements OnInit {
this.index = i;
this.selectedTemplate = this.pluginsByPlacement.get(placement)[i].template;
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;

View File

@ -4,65 +4,54 @@ import {CustomOptions} from "./servicesUtils/customOptions.class";
import {PluginTemplate} from "../utils/entities/adminTool/pluginTemplate";
import {Plugin} from "../utils/entities/adminTool/plugin";
import {properties} from "../../../environments/environment";
import {catchError} from "rxjs/operators";
@Injectable()
export class PluginsService {
constructor(private http:HttpClient) {
constructor(private http: HttpClient) {
}
getPluginTemplate(api:string, code:string) {
return this.http.get<PluginTemplate>(api + 'pluginTemplates/' + code)
}
getPluginTemplates(api:string,pageId) {
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates' + (pageId?'/page/'+pageId:''))
getPluginTemplates(api: string, pageId) {
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates' + (pageId ? '/page/' + pageId : ''))
}
savePluginTemplate(pluginTemplate:PluginTemplate, api:string) {
// console.log(pluginTemplate, pluginTemplate.toJsonObj())
savePluginTemplate(pluginTemplate: PluginTemplate, api: string) {
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());
}
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);
updatePluginTemplateOrder(pluginTemplate: PluginTemplate, api: string, position) {
return this.http.post<PluginTemplate>(api + 'pluginTemplate/save/order/' + position, pluginTemplate, CustomOptions.getAuthOptionsWithBody());
}
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());
}
}