[plugin-functionalities | WIP] : update plugin forms, add reording, filtering by position, create multiple templates per position, etc
This commit is contained in:
parent
3ec805c51c
commit
a260ed17bd
|
@ -94,8 +94,7 @@
|
||||||
[queryParams]="{pageId: check.page._id}"
|
[queryParams]="{pageId: check.page._id}"
|
||||||
routerLink="../plugins">
|
routerLink="../plugins">
|
||||||
Manage plugins
|
Manage plugins
|
||||||
<span *ngIf="pagePluginsCount[check.page._id]">({{pagePluginsCount[check.page._id]}}
|
<span *ngIf="pagePluginTemplatesCount[check.page._id]">({{pagePluginTemplatesCount[check.page._id]}})</span>
|
||||||
)</span>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -105,8 +104,7 @@
|
||||||
[queryParams]="{pageId: check.page._id}"
|
[queryParams]="{pageId: check.page._id}"
|
||||||
routerLink="../helptexts">
|
routerLink="../helptexts">
|
||||||
Manage page help texts
|
Manage page help texts
|
||||||
<span *ngIf="pageHelpContentsCount[check.page._id]">({{pageHelpContentsCount[check.page._id]}}
|
<span *ngIf="pageHelpContentsCount[check.page._id]">({{pageHelpContentsCount[check.page._id]}})</span>
|
||||||
)</span>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -116,8 +114,7 @@
|
||||||
[queryParams]="{ pageId: check.page._id}"
|
[queryParams]="{ pageId: check.page._id}"
|
||||||
routerLink="../classContents">Manage class help texts
|
routerLink="../classContents">Manage class help texts
|
||||||
<span
|
<span
|
||||||
*ngIf="pageClassContentsCount[check.page._id]">({{pageClassContentsCount[check.page._id]}}
|
*ngIf="pageClassContentsCount[check.page._id]">({{pageClassContentsCount[check.page._id]}})</span>
|
||||||
)</span>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -133,6 +130,16 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngIf="isPortalAdministrator || (check.page.portalType == properties.adminToolsPortalType && check.page.portalPid == portal)">
|
*ngIf="isPortalAdministrator || (check.page.portalType == properties.adminToolsPortalType && check.page.portalPid == portal)">
|
||||||
|
<div *ngIf="pagePluginTemplatesCount[check.page._id]>0" >
|
||||||
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
|
<a class="uk-button uk-button-link uk-text-truncate"
|
||||||
|
[queryParams]="{pageId: check.page._id}"
|
||||||
|
routerLink="../templates">
|
||||||
|
Manage plugin templates {{check.page.portalPid}}
|
||||||
|
<span *ngIf="pagePluginTemplatesCount[check.page._id]">({{pagePluginTemplatesCount[check.page._id]}})</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
<button [disabled]="!portal && check.page.portalPid"
|
<button [disabled]="!portal && check.page.portalPid"
|
||||||
|
|
|
@ -144,8 +144,9 @@ export class PagesComponent implements OnInit {
|
||||||
},
|
},
|
||||||
error => this.handleError('System error retrieving pages', error)));
|
error => this.handleError('System error retrieving pages', error)));
|
||||||
if (this.portal) {
|
if (this.portal) {
|
||||||
this.getPageHelpContentsCounts(this.portal);
|
this.getCountsPerPID(this.portal);
|
||||||
}
|
}
|
||||||
|
this.getPluginTemplatesContentsCounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
@ -429,7 +430,7 @@ export class PagesComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPageHelpContentsCounts(community_pid: string) {
|
getCountsPerPID(community_pid: string) {
|
||||||
this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL, false).subscribe(
|
this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL, false).subscribe(
|
||||||
pageHelpContentsCount => {
|
pageHelpContentsCount => {
|
||||||
this.pageHelpContentsCount = pageHelpContentsCount;
|
this.pageHelpContentsCount = pageHelpContentsCount;
|
||||||
|
@ -451,4 +452,13 @@ export class PagesComponent implements OnInit {
|
||||||
},
|
},
|
||||||
error => this.handleError('System error retrieving page contents', error)));
|
error => this.handleError('System error retrieving page contents', error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPluginTemplatesContentsCounts() {
|
||||||
|
this.subscriptions.push(this._pluginsService.countPluginTemplatePerPageForAllPortals( this.properties.adminToolsAPIURL).subscribe(
|
||||||
|
countPlugins => {
|
||||||
|
this.pagePluginTemplatesCount = countPlugins;
|
||||||
|
},
|
||||||
|
error => this.handleError('System error retrieving page contents', error)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,15 @@
|
||||||
</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">
|
||||||
|
<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>
|
||||||
<div *ngIf="templateView" class="uk-width-expand">
|
<div *ngIf="templateView" class="uk-width-expand">
|
||||||
<a routerLink="../.." class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
|
<a routerLink="../.." class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
|
||||||
|
@ -40,8 +49,8 @@
|
||||||
<h1 *ngIf="template" class="uk-h5 uk-margin-remove">{{template.name}}</h1>
|
<h1 *ngIf="template" class="uk-h5 uk-margin-remove">{{template.name}}</h1>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div search-input [disabled]="showLoading" [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" placeholder="Search plugins" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1">
|
<!--<div search-input [disabled]="showLoading" [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" placeholder="Search plugins" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1">
|
||||||
</div>
|
</div>-->
|
||||||
<!-- <div>
|
<!-- <div>
|
||||||
<button (click)="newPluginSelectTemplate()" [disabled]="showLoading" [class.uk-disabled]="showLoading || this.pluginTemplates.length ==0"
|
<button (click)="newPluginSelectTemplate()" [disabled]="showLoading" [class.uk-disabled]="showLoading || this.pluginTemplates.length ==0"
|
||||||
class="uk-flex uk-flex-middle uk-button uk-button-default" >
|
class="uk-flex uk-flex-middle uk-button uk-button-default" >
|
||||||
|
@ -60,21 +69,25 @@
|
||||||
<loading></loading>
|
<loading></loading>
|
||||||
</div>
|
</div>
|
||||||
<ng-container *ngIf="!showLoading && !editView">
|
<ng-container *ngIf="!showLoading && !editView">
|
||||||
<div *ngIf="checkboxes.length == 0"
|
<div *ngIf="pluginTemplates.length == 0"
|
||||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||||
<div>No plugins found</div>
|
<div>No plugins found</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="checkboxes.length > 0" class="uk-grid uk-child-width-1-1" uk-height-match=".uk-card-body" uk-grid>
|
<ng-container *ngFor="let placement of pluginUtils.placementsOptions">
|
||||||
<div *ngFor="let check of checkboxes; let i=index">
|
|
||||||
|
<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>
|
||||||
|
<div *ngFor="let pluginGroup of pluginsByPlacement.get(placement.value) ; let i=index">
|
||||||
<div class="uk-card uk-card-default">
|
<div class="uk-card uk-card-default">
|
||||||
<div class="uk-card-body uk-flex">
|
<div class="uk-card-body uk-flex">
|
||||||
<div class="uk-width-expand uk-text-small">
|
<div class="uk-width-expand uk-text-small">
|
||||||
<ng-container *ngIf="check.template && !templateView">
|
<ng-container *ngIf="pluginGroup.template && !templateView">
|
||||||
<h6>{{check.template.name}}</h6>
|
<h6>{{pluginGroup.template.name}}</h6>
|
||||||
<div class="uk-margin-small-bottom">
|
<div class="uk-margin-small-bottom">
|
||||||
{{check.template.description}}
|
{{pluginGroup.template.description}}
|
||||||
</div>
|
</div>
|
||||||
<plugin-wrapper [editMode]="false" [wrapperEditMode]="true" [pluginTemplate]="check.template" [plugin]="check.plugin"></plugin-wrapper>
|
<plugin-wrapper [editMode]="false" [wrapperEditMode]="true" [pluginTemplate]="pluginGroup.template" [plugin]="pluginGroup.plugin"></plugin-wrapper>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<!--<ng-container *ngIf="templateView">
|
<!--<ng-container *ngIf="templateView">
|
||||||
<h6>Community: {{check.plugin.pid}}</h6>
|
<h6>Community: {{check.plugin.pid}}</h6>
|
||||||
|
@ -86,7 +99,10 @@
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<!-- </ng-container>-->
|
<!-- </ng-container>-->
|
||||||
<div class="uk-margin-small-bottom">
|
<div class="uk-margin-small-bottom">
|
||||||
<span class="uk-text-meta">Placement: </span>{{check.plugin.placement}}
|
<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>
|
</div>
|
||||||
<!--<div *ngFor="let key of getKeys(check.template.attributes)">
|
<!--<div *ngFor="let key of getKeys(check.template.attributes)">
|
||||||
<div *ngIf="check.template.attributes[key]['type'] =='HTML' ">
|
<div *ngIf="check.template.attributes[key]['type'] =='HTML' ">
|
||||||
|
@ -109,7 +125,8 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(check.plugin, check.template)" [class.uk-disabled]="!check.template">
|
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(pluginGroup.plugin, pluginGroup.template, placement, index)"
|
||||||
|
[class.uk-disabled]="!pluginGroup.template">
|
||||||
<icon name="edit" [flex]="true"></icon>
|
<icon name="edit" [flex]="true"></icon>
|
||||||
<span class="uk-margin-xsmall-left"> Edit</span>
|
<span class="uk-margin-xsmall-left"> Edit</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -125,10 +142,28 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
<mat-slide-toggle [checked]="check.plugin.active"
|
<mat-slide-toggle [checked]="pluginGroup.plugin.active"
|
||||||
(change)="($event.source.checked = check.plugin.active);togglePlugin(!check.plugin.active,check.plugin._id)"
|
(change)="($event.source.checked = pluginGroup.plugin.active);togglePlugin(!pluginGroup.plugin.active,pluginGroup.plugin._id,i, placement.value)"
|
||||||
>
|
>
|
||||||
<span class="uk-text-small">Enable</span>
|
<span class="uk-text-small">Enable</span>
|
||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
|
@ -138,8 +173,10 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ng-container>
|
||||||
|
|
||||||
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="editView">
|
<ng-container *ngIf="editView">
|
||||||
|
|
||||||
|
@ -186,7 +223,7 @@
|
||||||
<ng-container *ngIf="selectedTemplate || selectedPlugin">
|
<ng-container *ngIf="selectedTemplate || selectedPlugin">
|
||||||
<div class="uk-text-large ">{{selectedTemplate.name}}</div>
|
<div class="uk-text-large ">{{selectedTemplate.name}}</div>
|
||||||
<div class="uk-text-meta uk-width-1-1">{{selectedTemplate.description}}</div>
|
<div class="uk-text-meta uk-width-1-1">{{selectedTemplate.description}}</div>
|
||||||
<div input [formInput]="templateForm.get('placement')" placeholder="Placements" [options]="placementsOptions" type="select" class="uk-width-1-2"></div>
|
<!-- <div input [formInput]="templateForm.get('placement')" placeholder="Placements" [options]="placementsOptions" type="select" class="uk-width-1-2"></div>-->
|
||||||
<plugin-wrapper [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="selectedTemplate" [plugin]="this.templateForm.getRawValue()"
|
<plugin-wrapper [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="selectedTemplate" [plugin]="this.templateForm.getRawValue()"
|
||||||
class="uk-width-1-1" (changed)="pluginFieldChanged($event)"></plugin-wrapper>
|
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 *ngIf="attrFormArray.controls.length > 0" class="uk-heading-divider uk-text-small uk-width-1-1 uk-margin-bottom uk-text-meta">
|
||||||
|
@ -222,5 +259,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<modal-alert #deleteModal (alertOutput)="confirmedDelete()" classTitle="uk-background-primary uk-light"></modal-alert>
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
ValidatorFn,
|
ValidatorFn,
|
||||||
Validators
|
Validators
|
||||||
} from "@angular/forms";
|
} from "@angular/forms";
|
||||||
import {CheckPage, Page} from "../../utils/entities/adminTool/page";
|
import {Page} from "../../utils/entities/adminTool/page";
|
||||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
|
@ -25,21 +25,16 @@ import {Plugin} from "../../utils/entities/adminTool/plugin";
|
||||||
import {StringUtils} from "../../utils/string-utils.class";
|
import {StringUtils} from "../../utils/string-utils.class";
|
||||||
import {Portal} from "../../utils/entities/adminTool/portal";
|
import {Portal} from "../../utils/entities/adminTool/portal";
|
||||||
import {PluginTemplate} from "../../utils/entities/adminTool/pluginTemplate";
|
import {PluginTemplate} from "../../utils/entities/adminTool/pluginTemplate";
|
||||||
import template = CKEDITOR.template;
|
|
||||||
import {PluginEditEvent} from "./utils/base-plugin.component";
|
import {PluginEditEvent} from "./utils/base-plugin.component";
|
||||||
|
import {PluginUtils} from "./utils/pluginUtils";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'plugins',
|
selector: 'plugins',
|
||||||
templateUrl: './plugins.component.html',
|
templateUrl: './plugins.component.html',
|
||||||
})
|
})
|
||||||
export class PluginsComponent implements OnInit {
|
export class PluginsComponent implements OnInit {
|
||||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
|
||||||
private selectedId: string;
|
private selectedId: string;
|
||||||
public checkboxes: {
|
public pluginsByPlacement: Map<string,{plugin:Plugin, template:PluginTemplate}[]> = new Map();
|
||||||
plugin: Plugin;
|
|
||||||
checked: boolean;
|
|
||||||
template: PluginTemplate
|
|
||||||
}[] = [];
|
|
||||||
public plugins: Plugin[] = [];
|
public plugins: Plugin[] = [];
|
||||||
public pluginTemplates: PluginTemplate[] = [];
|
public pluginTemplates: PluginTemplate[] = [];
|
||||||
public selectedTemplate: PluginTemplate = null;
|
public selectedTemplate: PluginTemplate = null;
|
||||||
|
@ -54,23 +49,9 @@ export class PluginsComponent implements OnInit {
|
||||||
public properties: EnvProperties = properties;
|
public properties: EnvProperties = properties;
|
||||||
public formPages: Page[] = [];
|
public formPages: Page[] = [];
|
||||||
public showLoading: boolean = true;
|
public showLoading: boolean = true;
|
||||||
public filterForm: UntypedFormGroup;
|
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
public allPages: Option[] = [];
|
public allPages: Option[] = [];
|
||||||
public attrTypeOptions: Option[] = [
|
public pluginUtils = new PluginUtils();
|
||||||
{label: "Text", value: "text"},
|
|
||||||
{label: "HTML", value: "HTML"},
|
|
||||||
{label: "Boolean", value: "boolean"},
|
|
||||||
{label: "URL", value: "URL"},
|
|
||||||
];
|
|
||||||
public placementsOptions: Option[] = [
|
|
||||||
{label: "Top", value: "top"},
|
|
||||||
{label: "Bottom", value: "bottom"},
|
|
||||||
{label: "Top Right", value: "top-right"},
|
|
||||||
{label: "Center", value: "center"},
|
|
||||||
{label: "Right", value: "right"},
|
|
||||||
{label: "Left", value: "left"},
|
|
||||||
];
|
|
||||||
selectedCommunityPid = null;
|
selectedCommunityPid = null;
|
||||||
public portalUtils: PortalUtils = new PortalUtils();
|
public portalUtils: PortalUtils = new PortalUtils();
|
||||||
private index: number;
|
private index: number;
|
||||||
|
@ -80,7 +61,8 @@ export class PluginsComponent implements OnInit {
|
||||||
public page: Page;
|
public page: Page;
|
||||||
public templateView = false;
|
public templateView = false;
|
||||||
public templateCode:string = null;
|
public templateCode:string = null;
|
||||||
public template
|
public template;
|
||||||
|
public selectedPlacementView = "all";
|
||||||
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
|
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
|
||||||
private title: Title, private _helpContentService: HelpContentService,
|
private title: Title, private _helpContentService: HelpContentService,
|
||||||
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
|
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
|
||||||
|
@ -89,26 +71,10 @@ export class PluginsComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.title.setTitle('Administrator Dashboard | Plugins');
|
this.title.setTitle('Administrator Dashboard | Plugins');
|
||||||
this.filterForm = this._fb.group({
|
|
||||||
keyword: [''],
|
|
||||||
type: ['all', Validators.required]
|
|
||||||
});
|
|
||||||
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
|
||||||
this.searchText = new RegExp(value, 'i');
|
|
||||||
this.applyFilters();
|
|
||||||
}));
|
|
||||||
this.subscriptions.push(this.route.params.subscribe(params => {
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
||||||
|
|
||||||
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
|
||||||
// this.templateView = this.route.snapshot.data['templateView']
|
|
||||||
this.selectedCommunityPid = params.community;
|
this.selectedCommunityPid = params.community;
|
||||||
/*this.templateCode = params['templateCode'];
|
|
||||||
if(this.templateView && this.templateCode){
|
|
||||||
this.getTemplateAndPlugins();
|
|
||||||
}
|
|
||||||
if(this.templateView && !this.templateCode){
|
|
||||||
this._router.navigate(['../..'], {relativeTo: this.route});
|
|
||||||
}*/
|
|
||||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||||
HelperFunctions.scroll();
|
HelperFunctions.scroll();
|
||||||
this.selectedPageId = params['pageId'];
|
this.selectedPageId = params['pageId'];
|
||||||
|
@ -133,9 +99,9 @@ export class PluginsComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplateByCode(code) {
|
getTemplateById(id) {
|
||||||
for (let template of this.pluginTemplates) {
|
for (let template of this.pluginTemplates) {
|
||||||
if (template.code == code) {
|
if (template._id == id) {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,13 +131,15 @@ export class PluginsComponent implements OnInit {
|
||||||
this.subscriptions.push(this._pluginsService.getPluginsByPage(this.properties.adminToolsAPIURL, this.selectedCommunityPid, this.selectedPageId).subscribe(
|
this.subscriptions.push(this._pluginsService.getPluginsByPage(this.properties.adminToolsAPIURL, this.selectedCommunityPid, this.selectedPageId).subscribe(
|
||||||
plugins => {
|
plugins => {
|
||||||
this.plugins = plugins;
|
this.plugins = plugins;
|
||||||
this.checkboxes = [];
|
this.pluginsByPlacement = new Map();
|
||||||
|
for(let pos of this.pluginUtils.placementsOptions){
|
||||||
|
this.pluginsByPlacement.set(pos.value,[]);
|
||||||
|
}
|
||||||
let self = this;
|
let self = this;
|
||||||
this.pluginTemplates.forEach(_ => {
|
this.pluginTemplates.forEach(_ => {
|
||||||
let plugin:Plugin = null;
|
let plugin:Plugin = null;
|
||||||
for(let pl of plugins){
|
for(let pl of plugins){
|
||||||
if (pl.code == _.code){
|
if (pl.templateId == _._id){
|
||||||
plugin = pl;
|
plugin = pl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,9 +147,13 @@ export class PluginsComponent implements OnInit {
|
||||||
plugin = new Plugin(this.selectedPageId, this.selectedCommunityPid,_);
|
plugin = new Plugin(this.selectedPageId, this.selectedCommunityPid,_);
|
||||||
this.plugins.push(plugin);
|
this.plugins.push(plugin);
|
||||||
}
|
}
|
||||||
self.checkboxes.push({plugin: plugin, checked: false, template: _});
|
this.pluginsByPlacement.get(plugin.placement).push({plugin: plugin, template: _ });
|
||||||
});
|
});
|
||||||
|
for(let placement of this.pluginUtils.placementsOptions){
|
||||||
|
this.pluginsByPlacement.get(placement.value).sort(function (a, b) {
|
||||||
|
return a.plugin.order - b.plugin.order;
|
||||||
|
})
|
||||||
|
}
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
},
|
},
|
||||||
error => this.handleError('System error retrieving plugins', error)));
|
error => this.handleError('System error retrieving plugins', error)));
|
||||||
|
@ -189,90 +161,22 @@ export class PluginsComponent implements OnInit {
|
||||||
},
|
},
|
||||||
error => this.handleError('System error retrieving templates', error)));
|
error => this.handleError('System error retrieving templates', error)));
|
||||||
}
|
}
|
||||||
// getTemplateAndPlugins(){
|
|
||||||
//
|
|
||||||
// this.showLoading = true;
|
|
||||||
// this.subscriptions.push(this._pluginsService.getPluginTemplate(this.properties.adminToolsAPIURL, this.templateCode).subscribe(
|
|
||||||
// template => {
|
|
||||||
// this.template = template;
|
|
||||||
// this.pluginTemplates = [template]
|
|
||||||
//
|
|
||||||
// this.subscriptions.push(this._pluginsService.getPluginsByTemplatesCode(this.properties.adminToolsAPIURL,"", this.template.code).subscribe(
|
|
||||||
// plugins => {
|
|
||||||
// this.plugins = plugins;
|
|
||||||
// this.checkboxes = [];
|
|
||||||
//
|
|
||||||
// let self = this;
|
|
||||||
// this.plugins.forEach(_ => {
|
|
||||||
// self.checkboxes.push({plugin: _, checked: false, template: this.template});
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// this.showLoading = false;
|
|
||||||
// },
|
|
||||||
// error => this.handleError('System error retrieving plugins', error)));
|
|
||||||
//
|
|
||||||
// },
|
|
||||||
// error => this.handleError('System error retrieving templates', error)));
|
|
||||||
// }
|
|
||||||
public toggleCheckBoxes(event) {
|
|
||||||
this.checkboxes.forEach(_ => _.checked = event.target.checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
public applyCheck(flag: boolean) {
|
public edit(plugin:Plugin, template:PluginTemplate, placement, index) {
|
||||||
this.checkboxes.forEach(_ => _.checked = flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
private deleteFromArray(id: string): void {
|
|
||||||
|
|
||||||
let i = this.plugins.findIndex(_ => _._id == id);
|
|
||||||
this.plugins.splice(i, 1);
|
|
||||||
|
|
||||||
this.applyFilters();
|
|
||||||
}
|
|
||||||
|
|
||||||
public confirmDelete(id: string) {
|
|
||||||
this.selectedId = id;
|
|
||||||
this.confirmModalOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private confirmModalOpen() {
|
|
||||||
this.deleteModal.alertTitle = "Delete Confirmation";
|
|
||||||
this.deleteModal.message = "Are you sure you want to delete the selected template(s)?";
|
|
||||||
this.deleteModal.okButtonText = "Yes";
|
|
||||||
this.deleteModal.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public confirmedDelete() {
|
|
||||||
this.showLoading = true;
|
|
||||||
this.subscriptions.push(this._pluginsService.deletePluginTemplate(this.selectedId, this.properties.adminToolsAPIURL).subscribe(
|
|
||||||
_ => {
|
|
||||||
this.deleteFromArray(this.selectedId);
|
|
||||||
NotificationHandler.rise('Template have been <b>successfully deleted</b>');
|
|
||||||
this.showLoading = false;
|
|
||||||
this._clearCacheService.clearCache("Template id deleted");
|
|
||||||
},
|
|
||||||
error => this.handleUpdateError('System error deleting the selected Template', error)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public edit(plugin:Plugin, template:PluginTemplate) {
|
|
||||||
this.editView = true;
|
this.editView = true;
|
||||||
this.selectedPlugin = plugin;
|
this.selectedPlugin = plugin;
|
||||||
this.selectedTemplate = template;
|
this.selectedTemplate = template;
|
||||||
this.index = this.plugins.findIndex(value => value._id === plugin._id);
|
this.index = index;
|
||||||
// this.formPages = <Page[]>plugin.pages;
|
|
||||||
this.pagesCtrl = this._fb.array([], Validators.required);
|
this.pagesCtrl = this._fb.array([], Validators.required);
|
||||||
this.templateForm = this._fb.group({
|
this.templateForm = this._fb.group({
|
||||||
_id: this._fb.control(plugin._id),
|
_id: this._fb.control(plugin._id),
|
||||||
pid: this._fb.control(this.selectedCommunityPid),
|
pid: this._fb.control(this.selectedCommunityPid),
|
||||||
page: this._fb.control(plugin.page),
|
page: this._fb.control(plugin.page),
|
||||||
code: this._fb.control(plugin.code, Validators.required),
|
templateCode: this._fb.control(plugin.templateCode, Validators.required),
|
||||||
|
templateId: this._fb.control(plugin.templateId, Validators.required),
|
||||||
placement: this._fb.control(plugin.placement),
|
placement: this._fb.control(plugin.placement),
|
||||||
order: this._fb.control(plugin.order),
|
order: this._fb.control(plugin.order),
|
||||||
active: this._fb.control(plugin.active),
|
active: this._fb.control(plugin.active),
|
||||||
isPriorTo: this._fb.control(plugin.priorTo),
|
|
||||||
values: this._fb.array([]),
|
values: this._fb.array([]),
|
||||||
object: this._fb.group(plugin.object?plugin.object:(this.selectedTemplate.object?this.selectedTemplate.object:{}))
|
object: this._fb.group(plugin.object?plugin.object:(this.selectedTemplate.object?this.selectedTemplate.object:{}))
|
||||||
});
|
});
|
||||||
|
@ -305,7 +209,7 @@ export class PluginsComponent implements OnInit {
|
||||||
pid: this._fb.control(this.selectedCommunityPid),
|
pid: this._fb.control(this.selectedCommunityPid),
|
||||||
page: this._fb.control(this.selectedPageId),
|
page: this._fb.control(this.selectedPageId),
|
||||||
code: this._fb.control(this.selectedTemplate.code, Validators.required),
|
code: this._fb.control(this.selectedTemplate.code, Validators.required),
|
||||||
placement: this._fb.control(this.selectedTemplate.placements[0]),
|
placement: this._fb.control(this.selectedTemplate.placement),
|
||||||
order: this._fb.control(""),
|
order: this._fb.control(""),
|
||||||
active: this._fb.control(false),
|
active: this._fb.control(false),
|
||||||
isPriorTo: this._fb.control(false),
|
isPriorTo: this._fb.control(false),
|
||||||
|
@ -326,18 +230,17 @@ export class PluginsComponent implements OnInit {
|
||||||
public saveConfirmed() {
|
public saveConfirmed() {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
let plugin: Plugin = <Plugin>this.templateForm.getRawValue();
|
let plugin: Plugin = <Plugin>this.templateForm.getRawValue();
|
||||||
// template.pages = this.pagesCtrl.getRawValue().map(page => page._id?page._id:page);
|
|
||||||
plugin.settingsValues = new Map<string, string>();
|
plugin.settingsValues = new Map<string, string>();
|
||||||
for (let fields of this.templateForm.getRawValue().values) {
|
for (let fields of this.templateForm.getRawValue().values) {
|
||||||
plugin.settingsValues[fields.key] = fields.value;
|
plugin.settingsValues[fields.key] = fields.value;
|
||||||
}
|
}
|
||||||
let update = (plugin._id ) ? true : false;
|
let update = (plugin._id) ? true : false;
|
||||||
console.log("update:" + update);
|
this.savePlugin(plugin,update, null)
|
||||||
|
}
|
||||||
|
public savePlugin(plugin, update, index){
|
||||||
this.subscriptions.push(this._pluginsService.savePlugin(plugin, this.properties.adminToolsAPIURL).subscribe(
|
this.subscriptions.push(this._pluginsService.savePlugin(plugin, this.properties.adminToolsAPIURL).subscribe(
|
||||||
saved => {
|
saved => {
|
||||||
this.savedSuccessfully(saved, update);
|
this.savedSuccessfully(saved, update, index);
|
||||||
NotificationHandler.rise('Plugin <b>' + this.selectedTemplate.name + '</b> has been <b>successfully' + (update ? ' updated ' : ' created ') + '</b>');
|
|
||||||
this._clearCacheService.clearCache("Plugin id saved");
|
|
||||||
this.editView = false;
|
this.editView = false;
|
||||||
this.selectTemplateView = false;
|
this.selectTemplateView = false;
|
||||||
this.selectedTemplate = null;
|
this.selectedTemplate = null;
|
||||||
|
@ -347,44 +250,21 @@ export class PluginsComponent implements OnInit {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public savedSuccessfully(plugin: Plugin, update: boolean) {
|
public savedSuccessfully(plugin: Plugin, update: boolean, index) {
|
||||||
if (update) {
|
if (update) {
|
||||||
this.plugins[this.index] = plugin;
|
this.pluginsByPlacement.get(plugin.placement)[index].plugin = plugin;
|
||||||
} else {
|
} else {
|
||||||
this.plugins.push(plugin);
|
this.plugins.push(plugin);
|
||||||
}
|
}
|
||||||
this.applyFilters();
|
|
||||||
this.applyCheck(false);
|
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public applyFilters() {
|
|
||||||
/* this.checkboxes = [];
|
|
||||||
this.plugins.filter(item => this.filterByType(item)).forEach(
|
|
||||||
item => this.checkboxes.push({plugin: item, checked: false})
|
|
||||||
);
|
|
||||||
this.checkboxes = this.checkboxes.filter(item => this.filter(item.plugin));*/
|
|
||||||
|
|
||||||
this.checkboxes = [];
|
|
||||||
|
|
||||||
this.plugins.forEach(item => {
|
|
||||||
let template = this.getTemplateByCode(item.code);
|
|
||||||
if (this.filterPlugins(item, template)) {
|
|
||||||
this.checkboxes.push({plugin: item, checked: false, template: template});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public filterPlugins(plugin: Plugin, template: PluginTemplate): boolean {
|
public filterPlugins(plugin: Plugin, template: PluginTemplate): boolean {
|
||||||
let values =[];
|
let values =[];
|
||||||
for(let key of this.getKeys(plugin.settingsValues)){
|
for(let key of this.getKeys(plugin.settingsValues)){
|
||||||
values.push(plugin.settingsValues[key]);
|
values.push(plugin.settingsValues[key]);
|
||||||
}
|
}
|
||||||
return this.searchText.toString() == '' || (plugin.code + ' ' +values.join(' ') + (template?(template.name + ' ' +template.description):'')).match(this.searchText) != null;
|
return this.searchText.toString() == '' || (plugin.templateCode + ' ' +values.join(' ') + (template?(template.name + ' ' +template.description):'')).match(this.searchText) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -460,25 +340,31 @@ export class PluginsComponent implements OnInit {
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
if (this.selectedPlugin) {
|
if (this.selectedPlugin) {
|
||||||
this.edit(this.selectedPlugin, this.selectedTemplate)
|
this.edit(this.selectedPlugin, this.selectedTemplate, this.selectedTemplate.placement, this.index)
|
||||||
} else {
|
} else {
|
||||||
this.newPlugin(this.selectedTemplate)
|
this.newPlugin(this.selectedTemplate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public togglePlugin(status: boolean, id: string) {
|
public togglePlugin(status: boolean, id: string,i, placement) {
|
||||||
this.subscriptions.push(this._pluginsService.togglePages(id, status, this.properties.adminToolsAPIURL).subscribe(
|
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(
|
||||||
|
() => {
|
||||||
|
|
||||||
let i = this.checkboxes.findIndex(_ => _.plugin._id == id);
|
this.pluginsByPlacement.get(placement)[i].plugin.active = status;
|
||||||
this.checkboxes[i].plugin.active = status;
|
this._clearCacheService.clearCache("Plugin's status changed");
|
||||||
this.applyCheck(false);
|
this._clearCacheService.purgeBrowserCache("Plugin's status changed", this.portal);
|
||||||
this._clearCacheService.clearCache("Plugin's status changed");
|
},
|
||||||
this._clearCacheService.purgeBrowserCache("Plugin's status changed", this.portal);
|
error => this.handleUpdateError('System error changing the status of Plugin', error)
|
||||||
},
|
));
|
||||||
error => this.handleUpdateError('System error changing the status of Plugin', error)
|
}else{
|
||||||
));
|
let plugin = this.pluginsByPlacement.get(placement)[i].plugin;
|
||||||
|
plugin.active = status;
|
||||||
|
this.savePlugin(plugin, true, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pluginFieldChanged($event:PluginEditEvent){
|
pluginFieldChanged($event:PluginEditEvent){
|
||||||
let object = this.templateForm.get("object").getRawValue();
|
let object = this.templateForm.get("object").getRawValue();
|
||||||
|
@ -486,4 +372,29 @@ export class PluginsComponent implements OnInit {
|
||||||
this.templateForm.get("object").setValue(object);
|
this.templateForm.get("object").setValue(object);
|
||||||
this.templateForm.markAsDirty();
|
this.templateForm.markAsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public swap(pluginToMoveUp, pluginToMoveDown, placement ){
|
||||||
|
this.showLoading = true;
|
||||||
|
let moveUpGroup = this.pluginsByPlacement.get(placement)[pluginToMoveUp];
|
||||||
|
let moveDownGroup = this.pluginsByPlacement.get(placement)[pluginToMoveDown];
|
||||||
|
this.pluginsByPlacement.get(placement)[pluginToMoveUp] = moveDownGroup;
|
||||||
|
this.pluginsByPlacement.get(placement)[pluginToMoveDown] = moveUpGroup;
|
||||||
|
this.move(moveUpGroup.plugin,true, pluginToMoveDown, placement);
|
||||||
|
this.move(moveDownGroup.plugin,false, pluginToMoveUp, placement);
|
||||||
|
this.showLoading = false;
|
||||||
|
}
|
||||||
|
public move(plugin: Plugin, up:boolean, index, placement) {
|
||||||
|
if(plugin._id) {
|
||||||
|
this.subscriptions.push(this._pluginsService.updatePluginOrder(plugin, this.properties.adminToolsAPIURL, up ? -1 : 1).subscribe(
|
||||||
|
saved => {
|
||||||
|
this.pluginsByPlacement.get(placement)[index].plugin = saved;
|
||||||
|
},
|
||||||
|
error => this.handleUpdateError("System error creating template", error)
|
||||||
|
));
|
||||||
|
}else{
|
||||||
|
|
||||||
|
plugin.order = plugin.order + (up ? -1 : 1)
|
||||||
|
this.savePlugin(plugin, true, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,28 @@
|
||||||
<div page-content>
|
<div page-content>
|
||||||
<div header>
|
<div header>
|
||||||
<admin-tabs tab="template"></admin-tabs>
|
<admin-tabs tab="template"></admin-tabs>
|
||||||
<ul class="uk-subnav uk-subnav-pill uk-margin-medium-top">
|
<div *ngIf="page" class="uk-width-expand">
|
||||||
<li [class.uk-active]="filterForm.get('type').value === 'all'" class="uk-margin-small-bottom"><a
|
<a routerLink="../pages" class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
|
||||||
(click)="filterForm.get('type').setValue('all')"><span
|
<span class="uk-margin-right">
|
||||||
class="title">All portals</span></a></li>
|
<icon name="west" ratio="1.7" [flex]="true"></icon>
|
||||||
<li *ngFor="let type of portalUtils.portalTypes; let i=index"
|
</span>
|
||||||
[class.uk-active]="filterForm.get('type').value === type.value" class="uk-margin-small-bottom"><a
|
<h1 class="uk-h5 uk-margin-remove">{{page.name}}</h1>
|
||||||
(click)="filterForm.get('type').setValue(type.value)"><span
|
</a>
|
||||||
class="title">{{type.label}}</span></a></li>
|
</div>
|
||||||
|
<ul *ngIf="page" class="uk-subnav uk-subnav-pill uk-margin-medium-top">
|
||||||
|
<li [class.uk-active]="filterForm.get('position').value === 'all'" class="uk-margin-small-bottom"><a
|
||||||
|
(click)="filterForm.get('position').setValue('all')"><span
|
||||||
|
class="title">All placements</span></a></li>
|
||||||
|
<li *ngFor="let position of pluginUtils.placementsOptions; let i=index"
|
||||||
|
[class.uk-active]="filterForm.get('position').value === position.value" class="uk-margin-small-bottom"><a
|
||||||
|
(click)="filterForm.get('position').setValue(position.value)"><span
|
||||||
|
class="title">{{position.label}}</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div actions>
|
<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 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>
|
<div>
|
||||||
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="newPlugin()"
|
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="newPlugin()"
|
||||||
[disabled]="showLoading" [class.uk-disabled]="showLoading">
|
[disabled]="showLoading" [class.uk-disabled]="showLoading">
|
||||||
|
@ -31,12 +39,19 @@
|
||||||
<loading></loading>
|
<loading></loading>
|
||||||
</div>
|
</div>
|
||||||
<ng-container *ngIf="!showLoading">
|
<ng-container *ngIf="!showLoading">
|
||||||
<div *ngIf="checkboxes.length == 0"
|
<!--<div *ngIf="checkboxes.length == 0"
|
||||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||||
<div>No templates found</div>
|
<div>No templates found</div>
|
||||||
</div>
|
</div>-->
|
||||||
<div *ngIf="checkboxes.length > 0" class="uk-grid uk-child-width-1-1" uk-height-match=".uk-card-body" uk-grid>
|
<div class="uk-grid uk-child-width-1-1" uk-height-match=".uk-card-body" uk-grid>
|
||||||
<div *ngFor="let check of checkboxes; let i=index">
|
<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>
|
||||||
|
<div *ngFor="let template of templatesByPlacement.get(placement.value) ; let i=index">
|
||||||
|
<!-- <div *ngIf="this.filter(template)">-->
|
||||||
|
<!-- <div *ngFor="let check of checkboxes; let i=index">-->
|
||||||
<div class="uk-card uk-card-default">
|
<div class="uk-card uk-card-default">
|
||||||
<div class="uk-card-body uk-flex">
|
<div class="uk-card-body uk-flex">
|
||||||
<!--<div *ngIf="!portal" class="uk-margin-right">
|
<!--<div *ngIf="!portal" class="uk-margin-right">
|
||||||
|
@ -46,21 +61,21 @@
|
||||||
<div class="uk-width-expand uk-text-small">
|
<div class="uk-width-expand uk-text-small">
|
||||||
<!-- <h6>{{check.template.name}}</h6>-->
|
<!-- <h6>{{check.template.name}}</h6>-->
|
||||||
|
|
||||||
<plugin-wrapper [editMode]="false" [wrapperEditMode]="true" [pluginTemplate]="check.template"></plugin-wrapper>
|
<plugin-wrapper [editMode]="false" [wrapperEditMode]="true" [pluginTemplate]="template"></plugin-wrapper>
|
||||||
<div *ngIf="check.template.pages && check.template.pages.length > 0" class="uk-margin-small-bottom">
|
<div class="uk-margin-small-bottom">
|
||||||
<span class="uk-text-meta">Pages: </span>{{getPagesAsString(check.template.pages)}}
|
<span class="uk-text-meta">Page: </span>{{getPageAsString(template.page)}} -
|
||||||
</div>
|
<span class="uk-text-meta">Placement: </span>{{template.placement}} -
|
||||||
<div *ngIf="check.template.placements && check.template.placements.length > 0" class="uk-margin-small-bottom">
|
<span class="uk-text-meta">Order: </span>{{template.order}}
|
||||||
<span class="uk-text-meta">Placements: </span>{{check.template.placements.join(", ")}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-margin-small-bottom">
|
<div class="uk-margin-small-bottom">
|
||||||
<span class="uk-text-meta">Portal type: </span>{{check.template.portalType}}
|
<span class="uk-text-meta">Portal type: </span>{{template.portalType}}
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-margin-small-bottom">
|
<div class="uk-margin-small-bottom">
|
||||||
<span class="uk-text-meta">Plan: </span>{{check.template.plan}}
|
<span class="uk-text-meta">Plan: </span>{{template.plan}}
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-margin-small-bottom">
|
<div class="uk-margin-small-bottom">
|
||||||
{{check.template.description}}
|
{{template.description}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -68,22 +83,30 @@
|
||||||
<div class="uk-card-footer uk-padding-remove-vertical">
|
<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-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
||||||
|
|
||||||
<!-- <div class="uk-position-bottom-left">-->
|
<ng-container *ngIf="page">
|
||||||
<!-- <div class="uk-padding-small uk-padding-remove-horizontal">-->
|
<div *ngIf="template.order>0">
|
||||||
<!-- <button-->
|
|
||||||
<!-- class="uk-button uk-button-link uk-flex uk-flex-middle" [routerLink]="['./plugins',check.template.code]" >-->
|
|
||||||
<!-- <icon name="edit" [flex]="true"></icon>-->
|
|
||||||
<!-- <span class="uk-margin-xsmall-left"> Manage Plugins-->
|
|
||||||
<!-- <span *ngIf="pluginsCount[check.template.code]">({{pluginsCount[check.template.code]}}-->
|
|
||||||
<!-- )</span>-->
|
|
||||||
<!-- </span>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div>
|
|
||||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(i)">
|
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>
|
<icon name="edit" [flex]="true"></icon>
|
||||||
<span class="uk-margin-xsmall-left"> Edit</span>
|
<span class="uk-margin-xsmall-left"> Edit</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -92,7 +115,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
|
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
|
||||||
(click)="confirmDelete(check.template._id)">
|
(click)="confirmDelete(template)">
|
||||||
<icon name="delete" [flex]="true"></icon>
|
<icon name="delete" [flex]="true"></icon>
|
||||||
<span class="uk-margin-xsmall-left"> Delete</span>
|
<span class="uk-margin-xsmall-left"> Delete</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -101,7 +124,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<!-- </div>-->
|
||||||
|
</div>
|
||||||
|
<!-- </div>-->
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,14 +139,15 @@
|
||||||
[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-child-width-1-2" uk-grid>
|
<form *ngIf="templateForm" [formGroup]="templateForm" class="uk-grid uk-child-width-1-2" uk-grid>
|
||||||
<div input [formInput]="templateForm.get('name')" placeholder="Template Name"></div>
|
<div input [formInput]="templateForm.get('name')" placeholder="Template Name"></div>
|
||||||
<div input [formInput]="templateForm.get('code')" placeholder="Template Code" [options]="availablePluginCodes" type="select"></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 class="uk-width-1-1" input [formInput]="templateForm.get('description')" placeholder="Description" type="textarea"> </div>
|
||||||
<div input [formInput]="templateForm.get('plan')" placeholder="Plan" [options]="plans" type="select"></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('image')" placeholder="Image"></div>
|
||||||
<!-- <div input [formInput]="templateForm.get('portalType')" placeholder="Portal Type" [options]="portalUtils.portalTypes" type="select"></div>-->
|
<div input [formInput]="templateForm.get('portalType')" placeholder="Portal Type" [options]="portalUtils.portalTypes" type="select"></div>
|
||||||
<div input [formInput]="templateForm.get('placements')" placeholder="Placements" [options]="placementsOptions" type="chips"></div>
|
<div input [formInput]="templateForm.get('placement')" placeholder="Placement" [options]="pluginUtils.placementsOptions" type="select"></div>
|
||||||
<div input [formInput]="templateForm.get('pages')" placeholder="Pages" [options]="templateForm.get('portalType').value?getPagesByPortal(templateForm.get('portalType').value):allPages" type="chips"></div>
|
<div *ngIf="!templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page" [options]="allPages" type="select" ></div>
|
||||||
<plugin-wrapper *ngIf="index>= 0 " [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="this.templateForm.getRawValue()"
|
<div *ngIf="templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page" [options]="allPagesByPortal.get(templateForm.get('portalType').value)" type="select" ></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>
|
class="uk-width-1-1" [editTemplate]="true" (changed)="pluginFieldChanged($event)"></plugin-wrapper>
|
||||||
<!--<div *ngIf="pluginEditEvent">
|
<!--<div *ngIf="pluginEditEvent">
|
||||||
<div *ngIf="pluginEditEvent.type == 'text'" input [value]="this.templateForm.getRawValue().object[pluginEditEvent.field]" [placeholder]="pluginEditEvent.field" [type]="pluginEditEvent.type"
|
<div *ngIf="pluginEditEvent.type == 'text'" input [value]="this.templateForm.getRawValue().object[pluginEditEvent.field]" [placeholder]="pluginEditEvent.field" [type]="pluginEditEvent.type"
|
||||||
|
@ -154,7 +183,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div input [formInput]="attrForm.get('key')" placeholder="Key"></div>
|
<div input [formInput]="attrForm.get('key')" placeholder="Key"></div>
|
||||||
<div input [formInput]="attrForm.get('name')" placeholder="Name"></div>
|
<div input [formInput]="attrForm.get('name')" placeholder="Name"></div>
|
||||||
<div input [formInput]="attrForm.get('type')" placeholder="Type" [options]="attrTypeOptions" type="select" (valueChange)="attributeTypeChanged(attrForm)"></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 == '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 == 'URL'" input [formInput]="attrForm.get('value')" placeholder="Default value" [type]="attrForm.get('type').value" [validators]="urlValidator"></div>
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {HelpContentService} from "../../../services/help-content.service";
|
import {HelpContentService} from "../../../services/help-content.service";
|
||||||
import {
|
import {FormArray, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators} from "@angular/forms";
|
||||||
FormArray,
|
|
||||||
UntypedFormArray,
|
|
||||||
UntypedFormBuilder,
|
|
||||||
UntypedFormGroup,
|
|
||||||
ValidatorFn,
|
|
||||||
Validators
|
|
||||||
} from "@angular/forms";
|
|
||||||
import {Page} from "../../../utils/entities/adminTool/page";
|
import {Page} from "../../../utils/entities/adminTool/page";
|
||||||
import {EnvProperties} from '../../../utils/properties/env-properties';
|
import {EnvProperties} from '../../../utils/properties/env-properties';
|
||||||
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
||||||
|
@ -22,10 +15,9 @@ import {ClearCacheService} from "../../../services/clear-cache.service";
|
||||||
import {NotificationHandler} from "../../../utils/notification-handler";
|
import {NotificationHandler} from "../../../utils/notification-handler";
|
||||||
import {PluginsService} from "../../../services/plugins.service";
|
import {PluginsService} from "../../../services/plugins.service";
|
||||||
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
|
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
|
||||||
import {Entity} from "../../../utils/entities/adminTool/entity";
|
|
||||||
import {StringUtils} from "../../../utils/string-utils.class";
|
import {StringUtils} from "../../../utils/string-utils.class";
|
||||||
import {PluginEditEvent} from "../utils/base-plugin.component";
|
import {PluginEditEvent} from "../utils/base-plugin.component";
|
||||||
import {StakeholderEntities} from "../../../monitor/entities/stakeholder";
|
import {PluginUtils} from "../utils/pluginUtils";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'plugin-templates',
|
selector: 'plugin-templates',
|
||||||
|
@ -34,14 +26,12 @@ import {StakeholderEntities} from "../../../monitor/entities/stakeholder";
|
||||||
export class PluginTemplatesComponent implements OnInit {
|
export class PluginTemplatesComponent implements OnInit {
|
||||||
@ViewChild('editModal') editModal: AlertModal;
|
@ViewChild('editModal') editModal: AlertModal;
|
||||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||||
private selectedId: string;
|
/*public checkboxes: {
|
||||||
public checkboxes: {
|
|
||||||
template: PluginTemplate;
|
template: PluginTemplate;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
}[] = [];
|
}[] = [];*/
|
||||||
public templates: PluginTemplate[] = [];
|
public templatesByPlacement: Map<string,PluginTemplate[]> = new Map();
|
||||||
public templateForm: UntypedFormGroup;
|
public templateForm: UntypedFormGroup;
|
||||||
public pagesCtrl: UntypedFormArray;
|
|
||||||
urlValidator: ValidatorFn = StringUtils.urlValidator;
|
urlValidator: ValidatorFn = StringUtils.urlValidator;
|
||||||
private searchText: RegExp = new RegExp('');
|
private searchText: RegExp = new RegExp('');
|
||||||
public keyword: string = "";
|
public keyword: string = "";
|
||||||
|
@ -51,65 +41,51 @@ export class PluginTemplatesComponent implements OnInit {
|
||||||
public filterForm: UntypedFormGroup;
|
public filterForm: UntypedFormGroup;
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
public allPages: Option[] = [];
|
public allPages: Option[] = [];
|
||||||
public attrTypeOptions: Option[] = [
|
public allPagesByPortal: Map<string, Option[]> = new Map();
|
||||||
{label:"Text", value:"text"},
|
public pluginUtils = new PluginUtils();
|
||||||
{label:"HTML", value:"HTML"},
|
|
||||||
{label:"Boolean", value:"boolean"},
|
|
||||||
{label:"URL", value:"URL"},
|
|
||||||
];
|
|
||||||
|
|
||||||
public availablePluginCodes: Option[] = [
|
|
||||||
{label:"Test", value:"test"},
|
|
||||||
{label:"openaire-products", value:"openaire-products"},
|
|
||||||
{label:"results-numbers", value:"results-numbers"},
|
|
||||||
];
|
|
||||||
public placementsOptions: Option[] = [
|
|
||||||
{label:"Top", value:"top"},
|
|
||||||
{label:"Bottom", value:"bottom"},
|
|
||||||
{label:"Top Right", value:"top-right"},
|
|
||||||
{label:"Center", value:"center"},
|
|
||||||
{label:"Right", value:"right"},
|
|
||||||
{label:"Left", value:"left"},
|
|
||||||
];
|
|
||||||
plans: Option[] = [
|
|
||||||
{value: 'starter', label: 'Starter'},
|
|
||||||
{value: 'extended', label: 'Extended'}
|
|
||||||
];
|
|
||||||
selectedCommunityPid = null;
|
|
||||||
public portalUtils: PortalUtils = new PortalUtils();
|
public portalUtils: PortalUtils = new PortalUtils();
|
||||||
private index: number;
|
private selectedTemplate: PluginTemplate;
|
||||||
// pluginObject:any = {};
|
public selectedPageId: string;
|
||||||
pluginsCount = {};
|
public selectedPortalPid: string;
|
||||||
|
public page: Page;
|
||||||
|
|
||||||
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
|
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
|
||||||
private title: Title,private _helpContentService: HelpContentService,
|
private title: Title, private _helpContentService: HelpContentService,
|
||||||
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
|
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
|
||||||
private _clearCacheService: ClearCacheService) {
|
private _clearCacheService: ClearCacheService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.title.setTitle('Administrator Dashboard | Classes');
|
this.title.setTitle('Administrator Dashboard | Classes');
|
||||||
this.filterForm = this._fb.group({
|
this.filterForm = this._fb.group({
|
||||||
keyword: [''],
|
keyword: [''],
|
||||||
type: ['all', Validators.required]
|
position: ['all', Validators.required]
|
||||||
});
|
});
|
||||||
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
||||||
this.searchText = new RegExp(value, 'i');
|
this.searchText = new RegExp(value, 'i');
|
||||||
this.applyFilters();
|
// this.applyFilters();
|
||||||
}));
|
}));
|
||||||
this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
|
this.subscriptions.push(this.filterForm.get('position').valueChanges.subscribe(value => {
|
||||||
this.applyFilters();
|
// this.applyFilters();
|
||||||
}));
|
}));
|
||||||
this.getTemplates();
|
|
||||||
|
|
||||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||||
HelperFunctions.scroll();
|
HelperFunctions.scroll();
|
||||||
this.selectedCommunityPid = params['communityId'];
|
this.selectedPageId = params['pageId'];
|
||||||
this.getPages();
|
this.selectedPortalPid = params['portalPid'];
|
||||||
this.getPluginsCounts();
|
if (this.selectedPageId) {
|
||||||
|
this.getPage(this.selectedPageId);
|
||||||
|
this.getTemplates(this.selectedPageId);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.getPages();
|
||||||
|
this.getTemplates();
|
||||||
|
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.subscriptions.forEach(value => {
|
this.subscriptions.forEach(value => {
|
||||||
if (value instanceof Subscriber) {
|
if (value instanceof Subscriber) {
|
||||||
|
@ -119,62 +95,81 @@ export class PluginTemplatesComponent implements OnInit {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplates() {
|
getPage(pageId: string) {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.subscriptions.push(this._pluginsService.getAllPluginTemplates(this.properties.adminToolsAPIURL).subscribe(
|
this.subscriptions.push(this._helpContentService.getPageById(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||||
|
page => {
|
||||||
|
this.page = page;
|
||||||
|
this.allPages = [];
|
||||||
|
this.allPagesByPortal = new Map();
|
||||||
|
let option = {
|
||||||
|
label: page.name + " [" + page.portalType + "]",
|
||||||
|
value: page
|
||||||
|
};
|
||||||
|
this.allPages.push(option);
|
||||||
|
this.allPagesByPortal.set(page.portalType, [])
|
||||||
|
this.allPagesByPortal.get(page.portalType).push(option)
|
||||||
|
},
|
||||||
|
error => this.handleError('System error retrieving page', error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
getTemplates(pageId = null) {
|
||||||
|
this.showLoading = true;
|
||||||
|
this.subscriptions.push(this._pluginsService.getPluginTemplates(this.properties.adminToolsAPIURL, pageId).subscribe(
|
||||||
templates => {
|
templates => {
|
||||||
this.templates = templates;
|
for(let pos of this.pluginUtils.placementsOptions){
|
||||||
this.checkboxes = [];
|
this.templatesByPlacement.set(pos.value,[]);
|
||||||
|
}
|
||||||
|
for(let template of templates){
|
||||||
|
|
||||||
|
this.templatesByPlacement.get(template.placement).push(template);
|
||||||
|
}
|
||||||
|
// this.checkboxes = [];
|
||||||
let self = this;
|
let self = this;
|
||||||
templates.forEach(_ => {
|
/*templates.forEach(_ => {
|
||||||
self.checkboxes.push( {template: _, checked: false});
|
self.checkboxes.push({template: _, checked: false});
|
||||||
});
|
});*/
|
||||||
|
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
},
|
},
|
||||||
error => this.handleError('System error retrieving classes', error)));
|
error => this.handleError('System error retrieving classes', error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public showModal():void {
|
/*public toggleCheckBoxes(event) {
|
||||||
// this.modal.showModal();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public toggleCheckBoxes(event) {
|
|
||||||
this.checkboxes.forEach(_ => _.checked = event.target.checked);
|
this.checkboxes.forEach(_ => _.checked = event.target.checked);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public applyCheck(flag: boolean) {
|
/*public applyCheck(flag: boolean) {
|
||||||
this.checkboxes.forEach(_ => _.checked = flag);
|
this.checkboxes.forEach(_ => _.checked = flag);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private deleteFromArray(id: string): void {
|
|
||||||
|
|
||||||
let i = this.templates.findIndex(_ => _._id == id);
|
private deleteFromArray(template:PluginTemplate): void {
|
||||||
this.templates.splice(i, 1);
|
|
||||||
|
|
||||||
this.applyFilters();
|
let i = this.templatesByPlacement.get(template.placement).findIndex(_ => _._id == template._id);
|
||||||
|
this.templatesByPlacement.get(template.placement).splice(i, 1);
|
||||||
|
|
||||||
|
// this.applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public confirmDelete(id: string) {
|
public confirmDelete(template:PluginTemplate) {
|
||||||
this.selectedId = id;
|
this.selectedTemplate = template;
|
||||||
this.confirmModalOpen();
|
this.confirmModalOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private confirmModalOpen() {
|
private confirmModalOpen() {
|
||||||
this.deleteModal.alertTitle = "Delete Confirmation";
|
this.deleteModal.alertTitle = "Delete Confirmation";
|
||||||
this.deleteModal.message = "Are you sure you want to delete the selected template(s)?";
|
this.deleteModal.message = "Are you sure you want to delete the selected template(s)?";
|
||||||
this.deleteModal.okButtonText = "Yes";
|
this.deleteModal.okButtonText = "Yes";
|
||||||
this.deleteModal.open();
|
this.deleteModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public confirmedDelete() {
|
public confirmedDelete() {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.subscriptions.push(this._pluginsService.deletePluginTemplate(this.selectedId, this.properties.adminToolsAPIURL).subscribe(
|
this.subscriptions.push(this._pluginsService.deletePluginTemplate(this.selectedTemplate._id, this.properties.adminToolsAPIURL).subscribe(
|
||||||
_ => {
|
_ => {
|
||||||
this.deleteFromArray(this.selectedId);
|
this.deleteFromArray(this.selectedTemplate);
|
||||||
NotificationHandler.rise('Template have been <b>successfully deleted</b>');
|
NotificationHandler.rise('Template have been <b>successfully deleted</b>');
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
this._clearCacheService.clearCache("Template id deleted");
|
this._clearCacheService.clearCache("Template id deleted");
|
||||||
|
@ -182,32 +177,27 @@ export class PluginTemplatesComponent implements OnInit {
|
||||||
error => this.handleUpdateError('System error deleting the selected Template', error)
|
error => this.handleUpdateError('System error deleting the selected Template', error)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public edit(i: number) {
|
public edit(pluginTemplate) {
|
||||||
let pluginTemplate: PluginTemplate = this.checkboxes[i].template;
|
this.selectedTemplate = pluginTemplate;
|
||||||
console.log(pluginTemplate.object)
|
|
||||||
this.index = this.templates.findIndex(value => value._id === pluginTemplate._id);
|
|
||||||
// this.pluginObject = Object.assign(this.templates[this.index].object);
|
// this.pluginObject = Object.assign(this.templates[this.index].object);
|
||||||
// this.formPages = <Page[]>pluginTemplate.pages;
|
// this.formPages = <Page[]>pluginTemplate.pages;
|
||||||
this.pagesCtrl = this._fb.array([], Validators.required);
|
|
||||||
this.templateForm = this._fb.group({
|
this.templateForm = this._fb.group({
|
||||||
_id: this._fb.control(pluginTemplate._id),
|
_id: this._fb.control(pluginTemplate._id),
|
||||||
name: this._fb.control(pluginTemplate.name, Validators.required),
|
name: this._fb.control(pluginTemplate.name),
|
||||||
pages: this.pagesCtrl,
|
page: this._fb.control(this.getPageById(pluginTemplate.page)),
|
||||||
portalType: this._fb.control(pluginTemplate.portalType, Validators.required),
|
portalType: this._fb.control(pluginTemplate.portalType, Validators.required),
|
||||||
|
|
||||||
code: this._fb.control(pluginTemplate.code, Validators.required),
|
code: this._fb.control(pluginTemplate.code, Validators.required),
|
||||||
description: this._fb.control(pluginTemplate.description),
|
description: this._fb.control(pluginTemplate.description),
|
||||||
plan: this._fb.control(pluginTemplate.plan, Validators.required),
|
plan: this._fb.control(pluginTemplate.plan, Validators.required),
|
||||||
placements: this._fb.array(pluginTemplate.placements),
|
placement: this._fb.control(pluginTemplate.placement),
|
||||||
settings:this._fb.array([]),
|
order: this._fb.control(pluginTemplate.order),
|
||||||
object: this._fb.group(pluginTemplate.object?pluginTemplate.object:{})
|
settings: this._fb.array([]),
|
||||||
|
object: this._fb.group(pluginTemplate.object ? pluginTemplate.object : {})
|
||||||
});
|
});
|
||||||
this.templateForm.get('portalType').disable();
|
this.templateForm.get('portalType').disable();
|
||||||
for (let i = 0; i < pluginTemplate.pages.length; i++) {
|
if (pluginTemplate.settings) {
|
||||||
this.pagesCtrl.push(this._fb.control(this.getPageById(pluginTemplate.pages[i])));
|
|
||||||
}
|
|
||||||
if(pluginTemplate.settings) {
|
|
||||||
for (let attrKey of Object.keys(pluginTemplate.settings)) {
|
for (let attrKey of Object.keys(pluginTemplate.settings)) {
|
||||||
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
||||||
key: this._fb.control(attrKey, Validators.required),
|
key: this._fb.control(attrKey, Validators.required),
|
||||||
|
@ -220,110 +210,144 @@ export class PluginTemplatesComponent implements OnInit {
|
||||||
// console.log(this.templateForm.getRawValue(),this.templateForm.get("object").value)
|
// console.log(this.templateForm.getRawValue(),this.templateForm.get("object").value)
|
||||||
this.modalOpen("Edit Template", "Save Changes");
|
this.modalOpen("Edit Template", "Save Changes");
|
||||||
}
|
}
|
||||||
|
|
||||||
public newPlugin() {
|
public newPlugin() {
|
||||||
this.index = -1;
|
this.selectedTemplate = null;
|
||||||
this.pagesCtrl = this._fb.array([], Validators.required);
|
|
||||||
if (this.templateForm) {
|
if (this.templateForm) {
|
||||||
this.templateForm.get('portalType').enable();
|
this.templateForm.get('portalType').enable();
|
||||||
}
|
}
|
||||||
this.templateForm = this._fb.group({
|
this.templateForm = this._fb.group({
|
||||||
_id: this._fb.control(null),
|
_id: this._fb.control(null),
|
||||||
name: this._fb.control('', Validators.required),
|
name: this._fb.control(''),
|
||||||
code: this._fb.control('', Validators.required),
|
code: this._fb.control('', Validators.required),
|
||||||
plan: this._fb.control('starter', Validators.required),
|
plan: this._fb.control('starter', Validators.required),
|
||||||
description: this._fb.control(''),
|
description: this._fb.control(''),
|
||||||
pages: this.pagesCtrl,
|
page: this._fb.control(this.page?this.getPageById(this.page):'', Validators.required),
|
||||||
portalType: this._fb.control('community', Validators.required),
|
portalType: this._fb.control('community', Validators.required),
|
||||||
placements: this._fb.array([]),
|
placement: this._fb.array([]),
|
||||||
settings:this._fb.array([]),
|
order: this._fb.control(''),
|
||||||
|
settings: this._fb.array([]),
|
||||||
object: this._fb.control({})
|
object: this._fb.control({})
|
||||||
});
|
});
|
||||||
// this.addNewAttr();
|
// this.addNewAttr();
|
||||||
this.modalOpen("Create template", "Create");
|
this.modalOpen("Create template", "Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
private modalOpen(title: string, yesBtn: string) {
|
private modalOpen(title: string, yesBtn: string) {
|
||||||
this.editModal.okButtonLeft = false;
|
this.editModal.okButtonLeft = false;
|
||||||
this.editModal.alertTitle = title;
|
this.editModal.alertTitle = title;
|
||||||
this.editModal.okButtonText = yesBtn;
|
this.editModal.okButtonText = yesBtn;
|
||||||
this.editModal.open();
|
this.editModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public swap(templateToMoveUp, templateToMoveDown, placement) {
|
||||||
|
|
||||||
|
this.move(this.templatesByPlacement.get(placement)[templateToMoveUp], true);
|
||||||
|
this.move(this.templatesByPlacement.get(placement)[templateToMoveDown], false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public move(template: PluginTemplate, up: boolean) {
|
||||||
|
this.showLoading = true;
|
||||||
|
this.subscriptions.push(this._pluginsService.updatePluginTemplateOrder(template, this.properties.adminToolsAPIURL, up ? -1 : 1).subscribe(
|
||||||
|
saved => {
|
||||||
|
this.savedSuccessfully(saved, true);
|
||||||
|
|
||||||
|
this._clearCacheService.clearCache("Template updates");
|
||||||
|
},
|
||||||
|
error => this.handleUpdateError("System error creating template", error)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public saveConfirmed(data: any) {
|
public saveConfirmed(data: any) {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
let template:PluginTemplate = <PluginTemplate>this.templateForm.getRawValue();
|
let template: PluginTemplate = <PluginTemplate>this.templateForm.getRawValue();
|
||||||
template.pages = this.pagesCtrl.getRawValue().map(page => page._id?page._id:page);
|
template.page = this.templateForm.getRawValue().page._id
|
||||||
template.settings = new Map<string, {name: string; type: string; value: string}>();
|
template.placement = this.templateForm.getRawValue().placement[0];
|
||||||
|
template.settings = new Map<string, { name: string; type: string; value: string }>();
|
||||||
|
if(!template._id){
|
||||||
|
template.order = this.templatesByPlacement.get(template.placement).length > 0 ? this.templatesByPlacement.get(template.placement).length:0;
|
||||||
|
}
|
||||||
for (let attr of this.templateForm.getRawValue().settings) {
|
for (let attr of this.templateForm.getRawValue().settings) {
|
||||||
template.settings[attr.key]={name: attr.name, type: attr.type, value: attr.value};
|
template.settings[attr.key] = {name: attr.name, type: attr.type, value: attr.value};
|
||||||
}
|
}
|
||||||
let update = template._id?true:false;
|
let update = template._id ? true : false;
|
||||||
this.subscriptions.push(this._pluginsService.savePluginTemplate(template, this.properties.adminToolsAPIURL).subscribe(
|
this.subscriptions.push(this._pluginsService.savePluginTemplate(template, this.properties.adminToolsAPIURL).subscribe(
|
||||||
saved => {
|
saved => {
|
||||||
this.savedSuccessfully(saved, update );
|
this.selectedTemplate = saved;
|
||||||
NotificationHandler.rise('Template <b>' + saved.name + '</b> has been <b>successfully' + (update?' updated ':' created ') + '</b>');
|
this.savedSuccessfully(saved, update);
|
||||||
this._clearCacheService.clearCache("Template id saved");
|
NotificationHandler.rise('Template <b>' + saved.name + '</b> has been <b>successfully' + (update ? ' updated ' : ' created ') + '</b>');
|
||||||
},
|
this._clearCacheService.clearCache("Template id saved");
|
||||||
error => this.handleUpdateError("System error creating template", error)
|
},
|
||||||
));
|
error => this.handleUpdateError("System error creating template", error)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public savedSuccessfully(template: PluginTemplate, update:boolean) {
|
public savedSuccessfully(template: PluginTemplate, update: boolean) {
|
||||||
if(update){
|
if (update) {
|
||||||
this.templates[this.index] = template;
|
let index = this.templatesByPlacement.get(this.selectedTemplate.placement).findIndex(value => value._id === template._id);
|
||||||
}else{
|
this.templatesByPlacement.get(this.selectedTemplate.placement)[index] = template;
|
||||||
this.templates.push(template);
|
// TODO sort
|
||||||
|
// this.templatesByPlacement.get(this.selectedTemplate.placement) = this.templatesByPlacement.get(this.selectedTemplate.placement).sort()
|
||||||
|
} else {
|
||||||
|
this.templatesByPlacement.get(this.selectedTemplate.placement).push(template);
|
||||||
}
|
}
|
||||||
this.applyFilters();
|
|
||||||
this.applyCheck(false);
|
// this.applyFilters();
|
||||||
|
// this.applyCheck(false);
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public applyFilters() {
|
/* public applyFilters() {
|
||||||
this.checkboxes = [];
|
this.checkboxes = [];
|
||||||
this.templates.filter(item => this.filterByType(item)).forEach(
|
this.templates.filter(item => this.filterByPosition(item)).forEach(
|
||||||
item => this.checkboxes.push({template: item, checked: false})
|
item => this.checkboxes.push({template: item, checked: false})
|
||||||
);
|
);
|
||||||
this.checkboxes = this.checkboxes.filter(item => this.filter(item.template));
|
this.checkboxes = this.checkboxes.filter(item => this.filter(item.template));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public filterByType(template: PluginTemplate): boolean {
|
/*public filterByPosition(template: PluginTemplate): boolean {
|
||||||
let type = this.filterForm.get("type").value;
|
let position = this.filterForm.get("position").value;
|
||||||
return type == "all" || (type == template.portalType);
|
return position == "all" || (template.placement == position);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public filter(plugin: PluginTemplate): boolean {
|
public filter(plugin: PluginTemplate): boolean {
|
||||||
return this.searchText.toString() == '' || (plugin.name + ' ' + plugin.portalType).match(this.searchText) != null;
|
return this.searchText.toString() == '' || (plugin.name + ' ' + plugin.portalType).match(this.searchText) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUpdateError(message: string, error = null) {
|
handleUpdateError(message: string, error = null) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('Server responded: ' + error);
|
console.log('Server responded: ' + error);
|
||||||
}
|
}
|
||||||
NotificationHandler.rise(message,'danger');
|
NotificationHandler.rise(message, 'danger');
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleError(message: string, error = null) {
|
handleError(message: string, error = null) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('Server responded: ' + error);
|
console.log('Server responded: ' + error);
|
||||||
}
|
}
|
||||||
NotificationHandler.rise(message,'danger');
|
NotificationHandler.rise(message, 'danger');
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPages() {
|
getPages() {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.subscriptions.push(this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(
|
this.subscriptions.push(this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(
|
||||||
pages => {
|
pages => {
|
||||||
this.allPages = [];
|
this.allPages = [];
|
||||||
|
this.allPagesByPortal = new Map();
|
||||||
pages.forEach(page => {
|
pages.forEach(page => {
|
||||||
this.allPages.push({
|
let option = {
|
||||||
label: page.name + " [" + page.portalType + "]",
|
label: page.name + " [" + page.portalType + "]",
|
||||||
value: page
|
value: page
|
||||||
});
|
};
|
||||||
|
this.allPages.push(option);
|
||||||
|
if (!this.allPagesByPortal.has(page.portalType)) {
|
||||||
|
this.allPagesByPortal.set(page.portalType, [])
|
||||||
|
}
|
||||||
|
this.allPagesByPortal.get(page.portalType).push(option)
|
||||||
});
|
});
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
},
|
},
|
||||||
|
@ -331,65 +355,55 @@ export class PluginTemplatesComponent implements OnInit {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
addNewAttr(){
|
addNewAttr() {
|
||||||
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
||||||
key:this._fb.control("", Validators.required),
|
key: this._fb.control("", Validators.required),
|
||||||
name: this._fb.control("", Validators.required),
|
name: this._fb.control("", Validators.required),
|
||||||
type: this._fb.control("text", Validators.required),
|
type: this._fb.control("text", Validators.required),
|
||||||
value: this._fb.control("")
|
value: this._fb.control("")
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAttr(index){
|
removeAttr(index) {
|
||||||
this.attrFormArray.removeAt(index);
|
this.attrFormArray.removeAt(index);
|
||||||
this.attrFormArray.markAsDirty();
|
this.attrFormArray.markAsDirty();
|
||||||
}
|
}
|
||||||
get attrFormArray(){
|
|
||||||
|
get attrFormArray() {
|
||||||
|
|
||||||
return this.templateForm.get("settings") as FormArray;
|
return this.templateForm.get("settings") as FormArray;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attributeTypeChanged(form){
|
attributeTypeChanged(form) {
|
||||||
let type = form.get("value").get("type");
|
let type = form.get("value").get("type");
|
||||||
form.get("value").setValue("");
|
form.get("value").setValue("");
|
||||||
if(type == "boolean"){
|
if (type == "boolean") {
|
||||||
form.get("value").setValue(false);
|
form.get("value").setValue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public getPagesAsString(pageIds): string {
|
|
||||||
|
|
||||||
let pages = [];
|
public getPageAsString(pageId): string {
|
||||||
for(let id of pageIds) {
|
return this.allPages.filter(option => option.value._id == pageId).map((option => option.value.name + " [" + option.value.portalType + "]")).join(",");
|
||||||
pages.push(this.allPages.filter(option => option.value._id == id).map((option => option.value.name + " [" + option.value.portalType + "]")));
|
|
||||||
|
|
||||||
}
|
|
||||||
return pages.join(", ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPageById(pageId) {
|
public getPageById(pageId) {
|
||||||
for(let option of this.allPages) {
|
for (let option of this.allPages) {
|
||||||
if(option.value._id == pageId){
|
if (option.value._id == pageId) {
|
||||||
return option.value;
|
return option.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pageId;
|
return pageId;
|
||||||
}
|
}
|
||||||
getPluginsCounts() {
|
|
||||||
this.subscriptions.push(this._pluginsService.countPluginPerTemplate( this.properties.adminToolsAPIURL).subscribe(
|
|
||||||
countPlugins => {
|
|
||||||
this.pluginsCount = countPlugins;
|
|
||||||
},
|
|
||||||
error => this.handleError('System error retrieving page contents', error)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pluginFieldChanged($event: PluginEditEvent) {
|
||||||
pluginFieldChanged($event:PluginEditEvent){
|
|
||||||
let object = this.templateForm.get("object").getRawValue();
|
let object = this.templateForm.get("object").getRawValue();
|
||||||
object[$event.field]=$event.value;
|
object[$event.field] = $event.value;
|
||||||
this.templateForm.get("object").setValue(object);
|
this.templateForm.get("object").setValue(object);
|
||||||
this.templateForm.markAsDirty();
|
this.templateForm.markAsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPagesByPortal(portal) {
|
public getPagesByPortal(portal) {
|
||||||
return this.allPages.filter(option => option.value.portalType == portal);
|
return this.allPages.filter(option => option.value.portalType == portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
import {Option} from "../../../sharedComponents/input/input.component";
|
||||||
|
|
||||||
|
export class PluginUtils{
|
||||||
|
public attrTypeOptions: Option[] = [
|
||||||
|
{label:"Text", value:"text"},
|
||||||
|
{label:"HTML", value:"HTML"},
|
||||||
|
{label:"Boolean", value:"boolean"},
|
||||||
|
{label:"URL", value:"URL"},
|
||||||
|
];
|
||||||
|
|
||||||
|
public availablePluginCodes: Option[] = [
|
||||||
|
{label:"Test", value:"test"},
|
||||||
|
{label:"openaire-products", value:"openaire-products"},
|
||||||
|
{label:"results-numbers", value:"results-numbers"},
|
||||||
|
{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"},
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
public placementsOptions: Option[] = [
|
||||||
|
{label:"Top", value:"top"},
|
||||||
|
{label:"Bottom", value:"bottom"},
|
||||||
|
// {label:"Top Right", value:"top-right"},
|
||||||
|
// {label:"Center", value:"center"},
|
||||||
|
{label:"Right", value:"right"},
|
||||||
|
{label:"Left", value:"left"},
|
||||||
|
];
|
||||||
|
public planOptions: Option[] = [
|
||||||
|
{value: 'starter', label: 'Starter'},
|
||||||
|
{value: 'extended', label: 'Extended'}
|
||||||
|
];
|
||||||
|
}
|
|
@ -17,8 +17,8 @@ import {PluginFeaturedDatasetsModule} from '../components/featured-datasets/plug
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, RouterModule, FormsModule, PluginResultsNumbersModule, PluginTestModule, PluginOpenaireProductsModule,
|
CommonModule, RouterModule, FormsModule, PluginResultsNumbersModule, PluginTestModule, PluginOpenaireProductsModule,
|
||||||
PluginDiscoverBySubcommunityModule, PluginGatewayInformationModule, PluginSearchDepositLinkModule, PluginLearnAndConnectModule,
|
PluginDiscoverBySubcommunityModule, /*PluginGatewayInformationModule,*/ PluginSearchDepositLinkModule, PluginLearnAndConnectModule,
|
||||||
PluginHowToUseModule, PluginSuggestedRepositoriesModule, PluginFeaturedDatasetsModule
|
PluginHowToUseModule, PluginSuggestedRepositoriesModule, PluginFeaturedDatasetsModule, PluginGatewayInformationModule
|
||||||
],
|
],
|
||||||
declarations: [PluginWrapperComponent],
|
declarations: [PluginWrapperComponent],
|
||||||
exports: [PluginWrapperComponent]
|
exports: [PluginWrapperComponent]
|
||||||
|
|
|
@ -280,7 +280,10 @@ export class HelpContentService {
|
||||||
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
|
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
|
||||||
.pipe(catchError(this.handleError));
|
.pipe(catchError(this.handleError));
|
||||||
}
|
}
|
||||||
|
getPageById(pageId:string, helpContentUrl:string) {
|
||||||
|
return this.http.get<Page>(helpContentUrl + 'page/' + pageId)
|
||||||
|
.pipe(catchError(this.handleError));
|
||||||
|
}
|
||||||
getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) {
|
getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) {
|
||||||
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
|
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
|
||||||
.pipe(catchError(this.handleError));
|
.pipe(catchError(this.handleError));
|
||||||
|
|
|
@ -16,12 +16,8 @@ export class PluginsService {
|
||||||
return this.http.get<PluginTemplate>(api + 'pluginTemplates/' + code)
|
return this.http.get<PluginTemplate>(api + 'pluginTemplates/' + code)
|
||||||
|
|
||||||
}
|
}
|
||||||
getAllPluginTemplates(api:string) {
|
getPluginTemplates(api:string,pageId) {
|
||||||
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates')
|
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates' + (pageId?'/page/'+pageId:''))
|
||||||
|
|
||||||
}
|
|
||||||
getAllPlugins(api:string) {
|
|
||||||
return this.http.get<Array<Plugin>>(api + 'plugins')
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +25,12 @@ export class PluginsService {
|
||||||
// console.log(pluginTemplate, pluginTemplate.toJsonObj())
|
// 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());
|
||||||
|
}
|
||||||
|
updatePluginOrder(plugin:Plugin, api:string, position) {
|
||||||
|
return this.http.post<Plugin>(api + 'plugin/save/order/'+position, plugin, CustomOptions.getAuthOptionsWithBody());
|
||||||
|
}
|
||||||
savePlugin(plugin, api:string) {
|
savePlugin(plugin, api:string) {
|
||||||
return this.http.post<Plugin>(api + 'plugin/save', JSON.stringify(plugin), CustomOptions.getAuthOptionsWithBody());
|
return this.http.post<Plugin>(api + 'plugin/save', JSON.stringify(plugin), CustomOptions.getAuthOptionsWithBody());
|
||||||
}
|
}
|
||||||
|
@ -44,6 +46,9 @@ export class PluginsService {
|
||||||
countPluginTemplatePerPage( api:string, pid:string){
|
countPluginTemplatePerPage( api:string, pid:string){
|
||||||
return this.http.get(api + properties.adminToolsPortalType + '/' +pid+'/pluginTemplate/page/count');
|
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){
|
countPluginPerTemplate( api:string){
|
||||||
return this.http.get(api + '/plugin/template/count');
|
return this.http.get(api + '/plugin/template/count');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ import {PluginTemplate} from "./pluginTemplate";
|
||||||
|
|
||||||
export class Plugin {
|
export class Plugin {
|
||||||
_id: string;
|
_id: string;
|
||||||
code: string;
|
templateCode: string;
|
||||||
|
templateId: string;
|
||||||
page: string;
|
page: string;
|
||||||
pid:string;
|
pid:string;
|
||||||
placement: string;
|
placement: string;
|
||||||
order: string;
|
order: number;
|
||||||
active:boolean;
|
active:boolean;
|
||||||
priorTo:boolean;
|
|
||||||
object:any;
|
object:any;
|
||||||
settingsValues:Map<string,string> = new Map<string, string>();
|
settingsValues:Map<string,string> = new Map<string, string>();
|
||||||
|
|
||||||
|
@ -16,10 +16,12 @@ export class Plugin {
|
||||||
console.log(template)
|
console.log(template)
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.pid = pid;
|
this.pid = pid;
|
||||||
this.code = template.code;
|
this.templateCode = template.code;
|
||||||
this.placement = template.placements ? template.placements[0] : null;
|
this.templateId = template._id;
|
||||||
|
this.placement = template.placement;
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.object = template.object ? Object.assign(template.object) : null;
|
this.object = template.object && Object.keys(template.object).length > 0 ? Object.assign(template.object) : null;
|
||||||
|
this.order = template.order;
|
||||||
if (template.settings) {
|
if (template.settings) {
|
||||||
for (let attr of Object.keys(template.settings)) {
|
for (let attr of Object.keys(template.settings)) {
|
||||||
this.settingsValues.set(attr, template.settings[attr].value)
|
this.settingsValues.set(attr, template.settings[attr].value)
|
||||||
|
|
|
@ -6,9 +6,10 @@ export class PluginTemplate{
|
||||||
code: string;
|
code: string;
|
||||||
description: string;
|
description: string;
|
||||||
image: string;
|
image: string;
|
||||||
pages: string[];
|
page: string;
|
||||||
plan: "starter" | "extended";
|
plan: "starter" | "extended";
|
||||||
placements: string[];
|
order:number;
|
||||||
|
placement: string;
|
||||||
portalType: string;
|
portalType: string;
|
||||||
settings: {};
|
settings: {};
|
||||||
object:any;
|
object:any;
|
||||||
|
|
Loading…
Reference in New Issue