[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}"
|
||||
routerLink="../plugins">
|
||||
Manage plugins
|
||||
<span *ngIf="pagePluginsCount[check.page._id]">({{pagePluginsCount[check.page._id]}}
|
||||
)</span>
|
||||
<span *ngIf="pagePluginTemplatesCount[check.page._id]">({{pagePluginTemplatesCount[check.page._id]}})</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -105,8 +104,7 @@
|
|||
[queryParams]="{pageId: check.page._id}"
|
||||
routerLink="../helptexts">
|
||||
Manage page help texts
|
||||
<span *ngIf="pageHelpContentsCount[check.page._id]">({{pageHelpContentsCount[check.page._id]}}
|
||||
)</span>
|
||||
<span *ngIf="pageHelpContentsCount[check.page._id]">({{pageHelpContentsCount[check.page._id]}})</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -116,8 +114,7 @@
|
|||
[queryParams]="{ pageId: check.page._id}"
|
||||
routerLink="../classContents">Manage class help texts
|
||||
<span
|
||||
*ngIf="pageClassContentsCount[check.page._id]">({{pageClassContentsCount[check.page._id]}}
|
||||
)</span>
|
||||
*ngIf="pageClassContentsCount[check.page._id]">({{pageClassContentsCount[check.page._id]}})</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -133,6 +130,16 @@
|
|||
</ng-container>
|
||||
<ng-container
|
||||
*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 class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button [disabled]="!portal && check.page.portalPid"
|
||||
|
|
|
@ -144,8 +144,9 @@ export class PagesComponent implements OnInit {
|
|||
},
|
||||
error => this.handleError('System error retrieving pages', error)));
|
||||
if (this.portal) {
|
||||
this.getPageHelpContentsCounts(this.portal);
|
||||
this.getCountsPerPID(this.portal);
|
||||
}
|
||||
this.getPluginTemplatesContentsCounts()
|
||||
}
|
||||
|
||||
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(
|
||||
pageHelpContentsCount => {
|
||||
this.pageHelpContentsCount = pageHelpContentsCount;
|
||||
|
@ -451,4 +452,13 @@ export class PagesComponent implements OnInit {
|
|||
},
|
||||
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>
|
||||
<h1 *ngIf="page" class="uk-h5 uk-margin-remove">{{page.name}}</h1>
|
||||
</a>
|
||||
<ul class="uk-subnav uk-subnav-pill uk-margin-medium-top">
|
||||
<li [class.uk-active]="selectedPlacementView === 'all'" class="uk-margin-small-bottom"><a
|
||||
(click)="selectedPlacementView = 'all'"><span
|
||||
class="title">All placements</span></a></li>
|
||||
<li *ngFor="let position of pluginUtils.placementsOptions; let i=index"
|
||||
[class.uk-active]="selectedPlacementView === position.value" class="uk-margin-small-bottom"><a
|
||||
(click)="selectedPlacementView = position.value"><span
|
||||
class="title">{{position.label}}</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div *ngIf="templateView" class="uk-width-expand">
|
||||
<a routerLink="../.." class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
|
||||
|
@ -40,8 +49,8 @@
|
|||
<h1 *ngIf="template" class="uk-h5 uk-margin-remove">{{template.name}}</h1>
|
||||
</a>
|
||||
</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>
|
||||
<!--<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>
|
||||
<button (click)="newPluginSelectTemplate()" [disabled]="showLoading" [class.uk-disabled]="showLoading || this.pluginTemplates.length ==0"
|
||||
class="uk-flex uk-flex-middle uk-button uk-button-default" >
|
||||
|
@ -60,21 +69,25 @@
|
|||
<loading></loading>
|
||||
</div>
|
||||
<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">
|
||||
<div>No plugins found</div>
|
||||
</div>
|
||||
<div *ngIf="checkboxes.length > 0" 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="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-body uk-flex">
|
||||
<div class="uk-width-expand uk-text-small">
|
||||
<ng-container *ngIf="check.template && !templateView">
|
||||
<h6>{{check.template.name}}</h6>
|
||||
<ng-container *ngIf="pluginGroup.template && !templateView">
|
||||
<h6>{{pluginGroup.template.name}}</h6>
|
||||
<div class="uk-margin-small-bottom">
|
||||
{{check.template.description}}
|
||||
{{pluginGroup.template.description}}
|
||||
</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 *ngIf="templateView">
|
||||
<h6>Community: {{check.plugin.pid}}</h6>
|
||||
|
@ -86,7 +99,10 @@
|
|||
<!-- </div>-->
|
||||
<!-- </ng-container>-->
|
||||
<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 *ngFor="let key of getKeys(check.template.attributes)">
|
||||
<div *ngIf="check.template.attributes[key]['type'] =='HTML' ">
|
||||
|
@ -109,7 +125,8 @@
|
|||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<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>
|
||||
<span class="uk-margin-xsmall-left"> Edit</span>
|
||||
</button>
|
||||
|
@ -125,10 +142,28 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>-->
|
||||
<div *ngIf="pluginGroup.plugin.order>0">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i, i-1, placement.value)">
|
||||
<!-- <icon name="" [flex]="true"></icon>-->
|
||||
<span class="uk-margin-xsmall-left"> Up</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="pluginGroup.plugin.order < pluginsByPlacement.get(placement.value).length -1 ">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i+1, i, placement.value)">
|
||||
<!-- <icon name="" [flex]="true"></icon>-->
|
||||
<span class="uk-margin-xsmall-left"> Down</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<mat-slide-toggle [checked]="check.plugin.active"
|
||||
(change)="($event.source.checked = check.plugin.active);togglePlugin(!check.plugin.active,check.plugin._id)"
|
||||
<mat-slide-toggle [checked]="pluginGroup.plugin.active"
|
||||
(change)="($event.source.checked = pluginGroup.plugin.active);togglePlugin(!pluginGroup.plugin.active,pluginGroup.plugin._id,i, placement.value)"
|
||||
>
|
||||
<span class="uk-text-small">Enable</span>
|
||||
</mat-slide-toggle>
|
||||
|
@ -139,7 +174,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="editView">
|
||||
|
||||
|
@ -186,7 +223,7 @@
|
|||
<ng-container *ngIf="selectedTemplate || selectedPlugin">
|
||||
<div class="uk-text-large ">{{selectedTemplate.name}}</div>
|
||||
<div class="uk-text-meta uk-width-1-1">{{selectedTemplate.description}}</div>
|
||||
<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()"
|
||||
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">
|
||||
|
@ -222,5 +259,3 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<modal-alert #deleteModal (alertOutput)="confirmedDelete()" classTitle="uk-background-primary uk-light"></modal-alert>
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
ValidatorFn,
|
||||
Validators
|
||||
} 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 {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||
import {Subscriber} from "rxjs";
|
||||
|
@ -25,21 +25,16 @@ import {Plugin} from "../../utils/entities/adminTool/plugin";
|
|||
import {StringUtils} from "../../utils/string-utils.class";
|
||||
import {Portal} from "../../utils/entities/adminTool/portal";
|
||||
import {PluginTemplate} from "../../utils/entities/adminTool/pluginTemplate";
|
||||
import template = CKEDITOR.template;
|
||||
import {PluginEditEvent} from "./utils/base-plugin.component";
|
||||
import {PluginUtils} from "./utils/pluginUtils";
|
||||
|
||||
@Component({
|
||||
selector: 'plugins',
|
||||
templateUrl: './plugins.component.html',
|
||||
})
|
||||
export class PluginsComponent implements OnInit {
|
||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||
private selectedId: string;
|
||||
public checkboxes: {
|
||||
plugin: Plugin;
|
||||
checked: boolean;
|
||||
template: PluginTemplate
|
||||
}[] = [];
|
||||
public pluginsByPlacement: Map<string,{plugin:Plugin, template:PluginTemplate}[]> = new Map();
|
||||
public plugins: Plugin[] = [];
|
||||
public pluginTemplates: PluginTemplate[] = [];
|
||||
public selectedTemplate: PluginTemplate = null;
|
||||
|
@ -54,23 +49,9 @@ export class PluginsComponent implements OnInit {
|
|||
public properties: EnvProperties = properties;
|
||||
public formPages: Page[] = [];
|
||||
public showLoading: boolean = true;
|
||||
public filterForm: UntypedFormGroup;
|
||||
private subscriptions: any[] = [];
|
||||
public allPages: Option[] = [];
|
||||
public attrTypeOptions: Option[] = [
|
||||
{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"},
|
||||
];
|
||||
public pluginUtils = new PluginUtils();
|
||||
selectedCommunityPid = null;
|
||||
public portalUtils: PortalUtils = new PortalUtils();
|
||||
private index: number;
|
||||
|
@ -80,7 +61,8 @@ export class PluginsComponent implements OnInit {
|
|||
public page: Page;
|
||||
public templateView = false;
|
||||
public templateCode:string = null;
|
||||
public template
|
||||
public template;
|
||||
public selectedPlacementView = "all";
|
||||
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
|
||||
private title: Title, private _helpContentService: HelpContentService,
|
||||
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
|
||||
|
@ -89,26 +71,10 @@ export class PluginsComponent implements OnInit {
|
|||
|
||||
ngOnInit() {
|
||||
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.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.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 => {
|
||||
HelperFunctions.scroll();
|
||||
this.selectedPageId = params['pageId'];
|
||||
|
@ -133,9 +99,9 @@ export class PluginsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
getTemplateByCode(code) {
|
||||
getTemplateById(id) {
|
||||
for (let template of this.pluginTemplates) {
|
||||
if (template.code == code) {
|
||||
if (template._id == id) {
|
||||
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(
|
||||
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;
|
||||
this.pluginTemplates.forEach(_ => {
|
||||
let plugin:Plugin = null;
|
||||
for(let pl of plugins){
|
||||
if (pl.code == _.code){
|
||||
if (pl.templateId == _._id){
|
||||
plugin = pl;
|
||||
}
|
||||
}
|
||||
|
@ -179,9 +147,13 @@ export class PluginsComponent implements OnInit {
|
|||
plugin = new Plugin(this.selectedPageId, this.selectedCommunityPid,_);
|
||||
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;
|
||||
},
|
||||
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)));
|
||||
}
|
||||
// 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) {
|
||||
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) {
|
||||
public edit(plugin:Plugin, template:PluginTemplate, placement, index) {
|
||||
this.editView = true;
|
||||
this.selectedPlugin = plugin;
|
||||
this.selectedTemplate = template;
|
||||
this.index = this.plugins.findIndex(value => value._id === plugin._id);
|
||||
// this.formPages = <Page[]>plugin.pages;
|
||||
this.index = index;
|
||||
this.pagesCtrl = this._fb.array([], Validators.required);
|
||||
this.templateForm = this._fb.group({
|
||||
_id: this._fb.control(plugin._id),
|
||||
pid: this._fb.control(this.selectedCommunityPid),
|
||||
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),
|
||||
order: this._fb.control(plugin.order),
|
||||
active: this._fb.control(plugin.active),
|
||||
isPriorTo: this._fb.control(plugin.priorTo),
|
||||
values: this._fb.array([]),
|
||||
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),
|
||||
page: this._fb.control(this.selectedPageId),
|
||||
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(""),
|
||||
active: this._fb.control(false),
|
||||
isPriorTo: this._fb.control(false),
|
||||
|
@ -326,18 +230,17 @@ export class PluginsComponent implements OnInit {
|
|||
public saveConfirmed() {
|
||||
this.showLoading = true;
|
||||
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>();
|
||||
for (let fields of this.templateForm.getRawValue().values) {
|
||||
plugin.settingsValues[fields.key] = fields.value;
|
||||
}
|
||||
let update = (plugin._id ) ? true : false;
|
||||
console.log("update:" + update);
|
||||
let update = (plugin._id) ? true : false;
|
||||
this.savePlugin(plugin,update, null)
|
||||
}
|
||||
public savePlugin(plugin, update, index){
|
||||
this.subscriptions.push(this._pluginsService.savePlugin(plugin, this.properties.adminToolsAPIURL).subscribe(
|
||||
saved => {
|
||||
this.savedSuccessfully(saved, update);
|
||||
NotificationHandler.rise('Plugin <b>' + this.selectedTemplate.name + '</b> has been <b>successfully' + (update ? ' updated ' : ' created ') + '</b>');
|
||||
this._clearCacheService.clearCache("Plugin id saved");
|
||||
this.savedSuccessfully(saved, update, index);
|
||||
this.editView = false;
|
||||
this.selectTemplateView = false;
|
||||
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) {
|
||||
this.plugins[this.index] = plugin;
|
||||
this.pluginsByPlacement.get(plugin.placement)[index].plugin = plugin;
|
||||
} else {
|
||||
this.plugins.push(plugin);
|
||||
}
|
||||
this.applyFilters();
|
||||
this.applyCheck(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 {
|
||||
let values =[];
|
||||
for(let key of this.getKeys(plugin.settingsValues)){
|
||||
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() {
|
||||
if (this.selectedPlugin) {
|
||||
this.edit(this.selectedPlugin, this.selectedTemplate)
|
||||
this.edit(this.selectedPlugin, this.selectedTemplate, this.selectedTemplate.placement, this.index)
|
||||
} else {
|
||||
this.newPlugin(this.selectedTemplate)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public togglePlugin(status: boolean, id: string) {
|
||||
public togglePlugin(status: boolean, id: string,i, placement) {
|
||||
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.checkboxes[i].plugin.active = status;
|
||||
this.applyCheck(false);
|
||||
this.pluginsByPlacement.get(placement)[i].plugin.active = status;
|
||||
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)
|
||||
));
|
||||
}else{
|
||||
let plugin = this.pluginsByPlacement.get(placement)[i].plugin;
|
||||
plugin.active = status;
|
||||
this.savePlugin(plugin, true, i);
|
||||
}
|
||||
}
|
||||
pluginFieldChanged($event:PluginEditEvent){
|
||||
let object = this.templateForm.get("object").getRawValue();
|
||||
|
@ -486,4 +372,29 @@ export class PluginsComponent implements OnInit {
|
|||
this.templateForm.get("object").setValue(object);
|
||||
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 header>
|
||||
<admin-tabs tab="template"></admin-tabs>
|
||||
<ul class="uk-subnav uk-subnav-pill uk-margin-medium-top">
|
||||
<li [class.uk-active]="filterForm.get('type').value === 'all'" class="uk-margin-small-bottom"><a
|
||||
(click)="filterForm.get('type').setValue('all')"><span
|
||||
class="title">All portals</span></a></li>
|
||||
<li *ngFor="let type of portalUtils.portalTypes; let i=index"
|
||||
[class.uk-active]="filterForm.get('type').value === type.value" class="uk-margin-small-bottom"><a
|
||||
(click)="filterForm.get('type').setValue(type.value)"><span
|
||||
class="title">{{type.label}}</span></a></li>
|
||||
<div *ngIf="page" class="uk-width-expand">
|
||||
<a routerLink="../pages" class="uk-flex uk-flex-middle uk-h5 uk-link-reset">
|
||||
<span class="uk-margin-right">
|
||||
<icon name="west" ratio="1.7" [flex]="true"></icon>
|
||||
</span>
|
||||
<h1 class="uk-h5 uk-margin-remove">{{page.name}}</h1>
|
||||
</a>
|
||||
</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>
|
||||
</div>
|
||||
<div actions>
|
||||
<div class="uk-section-xsmall">
|
||||
<div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
|
||||
<div search-input [disabled]="showLoading" [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" placeholder="Search class" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
|
||||
<!-- <div search-input [disabled]="showLoading" [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" placeholder="Search class" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>-->
|
||||
<div>
|
||||
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="newPlugin()"
|
||||
[disabled]="showLoading" [class.uk-disabled]="showLoading">
|
||||
|
@ -31,12 +39,19 @@
|
|||
<loading></loading>
|
||||
</div>
|
||||
<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">
|
||||
<div>No templates found</div>
|
||||
</div>
|
||||
<div *ngIf="checkboxes.length > 0" 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">
|
||||
</div>-->
|
||||
<div class="uk-grid uk-child-width-1-1" uk-height-match=".uk-card-body" uk-grid>
|
||||
<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-body uk-flex">
|
||||
<!--<div *ngIf="!portal" class="uk-margin-right">
|
||||
|
@ -46,21 +61,21 @@
|
|||
<div class="uk-width-expand uk-text-small">
|
||||
<!-- <h6>{{check.template.name}}</h6>-->
|
||||
|
||||
<plugin-wrapper [editMode]="false" [wrapperEditMode]="true" [pluginTemplate]="check.template"></plugin-wrapper>
|
||||
<div *ngIf="check.template.pages && check.template.pages.length > 0" class="uk-margin-small-bottom">
|
||||
<span class="uk-text-meta">Pages: </span>{{getPagesAsString(check.template.pages)}}
|
||||
</div>
|
||||
<div *ngIf="check.template.placements && check.template.placements.length > 0" class="uk-margin-small-bottom">
|
||||
<span class="uk-text-meta">Placements: </span>{{check.template.placements.join(", ")}}
|
||||
<plugin-wrapper [editMode]="false" [wrapperEditMode]="true" [pluginTemplate]="template"></plugin-wrapper>
|
||||
<div class="uk-margin-small-bottom">
|
||||
<span class="uk-text-meta">Page: </span>{{getPageAsString(template.page)}} -
|
||||
<span class="uk-text-meta">Placement: </span>{{template.placement}} -
|
||||
<span class="uk-text-meta">Order: </span>{{template.order}}
|
||||
|
||||
</div>
|
||||
<div class="uk-margin-small-bottom">
|
||||
<span class="uk-text-meta">Portal type: </span>{{check.template.portalType}}
|
||||
<span class="uk-text-meta">Portal type: </span>{{template.portalType}}
|
||||
</div>
|
||||
<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 class="uk-margin-small-bottom">
|
||||
{{check.template.description}}
|
||||
{{template.description}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -68,22 +83,30 @@
|
|||
<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-position-bottom-left">-->
|
||||
<!-- <div class="uk-padding-small uk-padding-remove-horizontal">-->
|
||||
<!-- <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>-->
|
||||
<ng-container *ngIf="page">
|
||||
<div *ngIf="template.order>0">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i, i-1, template.placement)">
|
||||
<!-- <icon name="" [flex]="true"></icon>-->
|
||||
<span class="uk-margin-xsmall-left"> Up</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="template.order < templatesByPlacement.get(placement.value).length -1 ">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="swap(i+1, i, template.placement)">
|
||||
<!-- <icon name="" [flex]="true"></icon>-->
|
||||
<span class="uk-margin-xsmall-left"> Down</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(i)">
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(template)">
|
||||
<icon name="edit" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left"> Edit</span>
|
||||
</button>
|
||||
|
@ -92,7 +115,7 @@
|
|||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
|
||||
(click)="confirmDelete(check.template._id)">
|
||||
(click)="confirmDelete(template)">
|
||||
<icon name="delete" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left"> Delete</span>
|
||||
</button>
|
||||
|
@ -101,7 +124,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
<!-- </div>-->
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
@ -111,14 +139,15 @@
|
|||
[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>
|
||||
<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 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('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('pages')" placeholder="Pages" [options]="templateForm.get('portalType').value?getPagesByPortal(templateForm.get('portalType').value):allPages" type="chips"></div>
|
||||
<plugin-wrapper *ngIf="index>= 0 " [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="this.templateForm.getRawValue()"
|
||||
<div input [formInput]="templateForm.get('portalType')" placeholder="Portal Type" [options]="portalUtils.portalTypes" type="select"></div>
|
||||
<div input [formInput]="templateForm.get('placement')" placeholder="Placement" [options]="pluginUtils.placementsOptions" type="select"></div>
|
||||
<div *ngIf="!templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page" [options]="allPages" type="select" ></div>
|
||||
<div *ngIf="templateForm.get('portalType').value" input [formInput]="templateForm.get('page')" placeholder="Page" [options]="allPagesByPortal.get(templateForm.get('portalType').value)" type="select" ></div>
|
||||
<plugin-wrapper *ngIf="selectedTemplate " [editMode]="true" [wrapperEditMode]="false" [pluginTemplate]="this.templateForm.getRawValue()"
|
||||
class="uk-width-1-1" [editTemplate]="true" (changed)="pluginFieldChanged($event)"></plugin-wrapper>
|
||||
<!--<div *ngIf="pluginEditEvent">
|
||||
<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 input [formInput]="attrForm.get('key')" placeholder="Key"></div>
|
||||
<div input [formInput]="attrForm.get('name')" placeholder="Name"></div>
|
||||
<div input [formInput]="attrForm.get('type')" placeholder="Type" [options]="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 == '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 {ActivatedRoute, Router} from "@angular/router";
|
||||
import {HelpContentService} from "../../../services/help-content.service";
|
||||
import {
|
||||
FormArray,
|
||||
UntypedFormArray,
|
||||
UntypedFormBuilder,
|
||||
UntypedFormGroup,
|
||||
ValidatorFn,
|
||||
Validators
|
||||
} from "@angular/forms";
|
||||
import {FormArray, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators} from "@angular/forms";
|
||||
import {Page} from "../../../utils/entities/adminTool/page";
|
||||
import {EnvProperties} from '../../../utils/properties/env-properties';
|
||||
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
||||
|
@ -22,10 +15,9 @@ import {ClearCacheService} from "../../../services/clear-cache.service";
|
|||
import {NotificationHandler} from "../../../utils/notification-handler";
|
||||
import {PluginsService} from "../../../services/plugins.service";
|
||||
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
|
||||
import {Entity} from "../../../utils/entities/adminTool/entity";
|
||||
import {StringUtils} from "../../../utils/string-utils.class";
|
||||
import {PluginEditEvent} from "../utils/base-plugin.component";
|
||||
import {StakeholderEntities} from "../../../monitor/entities/stakeholder";
|
||||
import {PluginUtils} from "../utils/pluginUtils";
|
||||
|
||||
@Component({
|
||||
selector: 'plugin-templates',
|
||||
|
@ -34,14 +26,12 @@ import {StakeholderEntities} from "../../../monitor/entities/stakeholder";
|
|||
export class PluginTemplatesComponent implements OnInit {
|
||||
@ViewChild('editModal') editModal: AlertModal;
|
||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||
private selectedId: string;
|
||||
public checkboxes: {
|
||||
/*public checkboxes: {
|
||||
template: PluginTemplate;
|
||||
checked: boolean;
|
||||
}[] = [];
|
||||
public templates: PluginTemplate[] = [];
|
||||
}[] = [];*/
|
||||
public templatesByPlacement: Map<string,PluginTemplate[]> = new Map();
|
||||
public templateForm: UntypedFormGroup;
|
||||
public pagesCtrl: UntypedFormArray;
|
||||
urlValidator: ValidatorFn = StringUtils.urlValidator;
|
||||
private searchText: RegExp = new RegExp('');
|
||||
public keyword: string = "";
|
||||
|
@ -51,37 +41,16 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
public filterForm: UntypedFormGroup;
|
||||
private subscriptions: any[] = [];
|
||||
public allPages: Option[] = [];
|
||||
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"},
|
||||
];
|
||||
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 allPagesByPortal: Map<string, Option[]> = new Map();
|
||||
public pluginUtils = new PluginUtils();
|
||||
public portalUtils: PortalUtils = new PortalUtils();
|
||||
private index: number;
|
||||
// pluginObject:any = {};
|
||||
pluginsCount = {};
|
||||
private selectedTemplate: PluginTemplate;
|
||||
public selectedPageId: string;
|
||||
public selectedPortalPid: string;
|
||||
public page: Page;
|
||||
|
||||
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 _clearCacheService: ClearCacheService) {
|
||||
}
|
||||
|
@ -90,22 +59,29 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
this.title.setTitle('Administrator Dashboard | Classes');
|
||||
this.filterForm = this._fb.group({
|
||||
keyword: [''],
|
||||
type: ['all', Validators.required]
|
||||
position: ['all', Validators.required]
|
||||
});
|
||||
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
||||
this.searchText = new RegExp(value, 'i');
|
||||
this.applyFilters();
|
||||
// this.applyFilters();
|
||||
}));
|
||||
this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
|
||||
this.applyFilters();
|
||||
this.subscriptions.push(this.filterForm.get('position').valueChanges.subscribe(value => {
|
||||
// this.applyFilters();
|
||||
}));
|
||||
this.getTemplates();
|
||||
|
||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||
HelperFunctions.scroll();
|
||||
this.selectedCommunityPid = params['communityId'];
|
||||
this.selectedPageId = params['pageId'];
|
||||
this.selectedPortalPid = params['portalPid'];
|
||||
if (this.selectedPageId) {
|
||||
this.getPage(this.selectedPageId);
|
||||
this.getTemplates(this.selectedPageId);
|
||||
|
||||
} else {
|
||||
this.getPages();
|
||||
this.getPluginsCounts();
|
||||
this.getTemplates();
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
@ -120,45 +96,64 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
getTemplates() {
|
||||
getPage(pageId: string) {
|
||||
this.showLoading = true;
|
||||
this.subscriptions.push(this._pluginsService.getAllPluginTemplates(this.properties.adminToolsAPIURL).subscribe(
|
||||
templates => {
|
||||
this.templates = templates;
|
||||
this.checkboxes = [];
|
||||
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 => {
|
||||
for(let pos of this.pluginUtils.placementsOptions){
|
||||
this.templatesByPlacement.set(pos.value,[]);
|
||||
}
|
||||
for(let template of templates){
|
||||
|
||||
this.templatesByPlacement.get(template.placement).push(template);
|
||||
}
|
||||
// this.checkboxes = [];
|
||||
let self = this;
|
||||
templates.forEach(_ => {
|
||||
self.checkboxes.push( {template: _, checked: false});
|
||||
});
|
||||
/*templates.forEach(_ => {
|
||||
self.checkboxes.push({template: _, checked: false});
|
||||
});*/
|
||||
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving classes', error)));
|
||||
}
|
||||
|
||||
// public showModal():void {
|
||||
// this.modal.showModal();
|
||||
// }
|
||||
|
||||
public toggleCheckBoxes(event) {
|
||||
/*public toggleCheckBoxes(event) {
|
||||
this.checkboxes.forEach(_ => _.checked = event.target.checked);
|
||||
}
|
||||
}*/
|
||||
|
||||
public applyCheck(flag: boolean) {
|
||||
/*public applyCheck(flag: boolean) {
|
||||
this.checkboxes.forEach(_ => _.checked = flag);
|
||||
}*/
|
||||
|
||||
private deleteFromArray(template:PluginTemplate): void {
|
||||
|
||||
let i = this.templatesByPlacement.get(template.placement).findIndex(_ => _._id == template._id);
|
||||
this.templatesByPlacement.get(template.placement).splice(i, 1);
|
||||
|
||||
// this.applyFilters();
|
||||
}
|
||||
|
||||
private deleteFromArray(id: string): void {
|
||||
|
||||
let i = this.templates.findIndex(_ => _._id == id);
|
||||
this.templates.splice(i, 1);
|
||||
|
||||
this.applyFilters();
|
||||
}
|
||||
|
||||
public confirmDelete(id: string) {
|
||||
this.selectedId = id;
|
||||
public confirmDelete(template:PluginTemplate) {
|
||||
this.selectedTemplate = template;
|
||||
this.confirmModalOpen();
|
||||
}
|
||||
|
||||
|
@ -172,9 +167,9 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
|
||||
public confirmedDelete() {
|
||||
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>');
|
||||
this.showLoading = false;
|
||||
this._clearCacheService.clearCache("Template id deleted");
|
||||
|
@ -183,31 +178,26 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
));
|
||||
}
|
||||
|
||||
public edit(i: number) {
|
||||
let pluginTemplate: PluginTemplate = this.checkboxes[i].template;
|
||||
console.log(pluginTemplate.object)
|
||||
this.index = this.templates.findIndex(value => value._id === pluginTemplate._id);
|
||||
public edit(pluginTemplate) {
|
||||
this.selectedTemplate = pluginTemplate;
|
||||
// this.pluginObject = Object.assign(this.templates[this.index].object);
|
||||
// this.formPages = <Page[]>pluginTemplate.pages;
|
||||
this.pagesCtrl = this._fb.array([], Validators.required);
|
||||
this.templateForm = this._fb.group({
|
||||
_id: this._fb.control(pluginTemplate._id),
|
||||
name: this._fb.control(pluginTemplate.name, Validators.required),
|
||||
pages: this.pagesCtrl,
|
||||
name: this._fb.control(pluginTemplate.name),
|
||||
page: this._fb.control(this.getPageById(pluginTemplate.page)),
|
||||
portalType: this._fb.control(pluginTemplate.portalType, Validators.required),
|
||||
|
||||
code: this._fb.control(pluginTemplate.code, Validators.required),
|
||||
description: this._fb.control(pluginTemplate.description),
|
||||
plan: this._fb.control(pluginTemplate.plan, Validators.required),
|
||||
placements: this._fb.array(pluginTemplate.placements),
|
||||
settings:this._fb.array([]),
|
||||
object: this._fb.group(pluginTemplate.object?pluginTemplate.object:{})
|
||||
placement: this._fb.control(pluginTemplate.placement),
|
||||
order: this._fb.control(pluginTemplate.order),
|
||||
settings: this._fb.array([]),
|
||||
object: this._fb.group(pluginTemplate.object ? pluginTemplate.object : {})
|
||||
});
|
||||
this.templateForm.get('portalType').disable();
|
||||
for (let i = 0; i < pluginTemplate.pages.length; i++) {
|
||||
this.pagesCtrl.push(this._fb.control(this.getPageById(pluginTemplate.pages[i])));
|
||||
}
|
||||
if(pluginTemplate.settings) {
|
||||
if (pluginTemplate.settings) {
|
||||
for (let attrKey of Object.keys(pluginTemplate.settings)) {
|
||||
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
||||
key: this._fb.control(attrKey, Validators.required),
|
||||
|
@ -222,21 +212,21 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
}
|
||||
|
||||
public newPlugin() {
|
||||
this.index = -1;
|
||||
this.pagesCtrl = this._fb.array([], Validators.required);
|
||||
this.selectedTemplate = null;
|
||||
if (this.templateForm) {
|
||||
this.templateForm.get('portalType').enable();
|
||||
}
|
||||
this.templateForm = this._fb.group({
|
||||
_id: this._fb.control(null),
|
||||
name: this._fb.control('', Validators.required),
|
||||
name: this._fb.control(''),
|
||||
code: this._fb.control('', Validators.required),
|
||||
plan: this._fb.control('starter', Validators.required),
|
||||
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),
|
||||
placements: this._fb.array([]),
|
||||
settings:this._fb.array([]),
|
||||
placement: this._fb.array([]),
|
||||
order: this._fb.control(''),
|
||||
settings: this._fb.array([]),
|
||||
object: this._fb.control({})
|
||||
});
|
||||
// this.addNewAttr();
|
||||
|
@ -250,49 +240,77 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
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) {
|
||||
this.showLoading = true;
|
||||
let template:PluginTemplate = <PluginTemplate>this.templateForm.getRawValue();
|
||||
template.pages = this.pagesCtrl.getRawValue().map(page => page._id?page._id:page);
|
||||
template.settings = new Map<string, {name: string; type: string; value: string}>();
|
||||
for (let attr of this.templateForm.getRawValue().settings) {
|
||||
template.settings[attr.key]={name: attr.name, type: attr.type, value: attr.value};
|
||||
let template: PluginTemplate = <PluginTemplate>this.templateForm.getRawValue();
|
||||
template.page = this.templateForm.getRawValue().page._id
|
||||
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;
|
||||
}
|
||||
let update = template._id?true:false;
|
||||
for (let attr of this.templateForm.getRawValue().settings) {
|
||||
template.settings[attr.key] = {name: attr.name, type: attr.type, value: attr.value};
|
||||
}
|
||||
let update = template._id ? true : false;
|
||||
this.subscriptions.push(this._pluginsService.savePluginTemplate(template, this.properties.adminToolsAPIURL).subscribe(
|
||||
saved => {
|
||||
this.savedSuccessfully(saved, update );
|
||||
NotificationHandler.rise('Template <b>' + saved.name + '</b> has been <b>successfully' + (update?' updated ':' created ') + '</b>');
|
||||
this.selectedTemplate = saved;
|
||||
this.savedSuccessfully(saved, update);
|
||||
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)
|
||||
));
|
||||
}
|
||||
|
||||
public savedSuccessfully(template: PluginTemplate, update:boolean) {
|
||||
if(update){
|
||||
this.templates[this.index] = template;
|
||||
}else{
|
||||
this.templates.push(template);
|
||||
public savedSuccessfully(template: PluginTemplate, update: boolean) {
|
||||
if (update) {
|
||||
let index = this.templatesByPlacement.get(this.selectedTemplate.placement).findIndex(value => value._id === template._id);
|
||||
this.templatesByPlacement.get(this.selectedTemplate.placement)[index] = 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;
|
||||
}
|
||||
|
||||
|
||||
public applyFilters() {
|
||||
/* public applyFilters() {
|
||||
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})
|
||||
);
|
||||
this.checkboxes = this.checkboxes.filter(item => this.filter(item.template));
|
||||
}
|
||||
}*/
|
||||
|
||||
public filterByType(template: PluginTemplate): boolean {
|
||||
let type = this.filterForm.get("type").value;
|
||||
return type == "all" || (type == template.portalType);
|
||||
}
|
||||
/*public filterByPosition(template: PluginTemplate): boolean {
|
||||
let position = this.filterForm.get("position").value;
|
||||
return position == "all" || (template.placement == position);
|
||||
}*/
|
||||
|
||||
public filter(plugin: PluginTemplate): boolean {
|
||||
return this.searchText.toString() == '' || (plugin.name + ' ' + plugin.portalType).match(this.searchText) != null;
|
||||
|
@ -302,7 +320,7 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
if (error) {
|
||||
console.log('Server responded: ' + error);
|
||||
}
|
||||
NotificationHandler.rise(message,'danger');
|
||||
NotificationHandler.rise(message, 'danger');
|
||||
this.showLoading = false;
|
||||
}
|
||||
|
||||
|
@ -310,7 +328,7 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
if (error) {
|
||||
console.log('Server responded: ' + error);
|
||||
}
|
||||
NotificationHandler.rise(message,'danger');
|
||||
NotificationHandler.rise(message, 'danger');
|
||||
this.showLoading = false;
|
||||
}
|
||||
|
||||
|
@ -319,11 +337,17 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
this.subscriptions.push(this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(
|
||||
pages => {
|
||||
this.allPages = [];
|
||||
this.allPagesByPortal = new Map();
|
||||
pages.forEach(page => {
|
||||
this.allPages.push({
|
||||
let option = {
|
||||
label: page.name + " [" + page.portalType + "]",
|
||||
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;
|
||||
},
|
||||
|
@ -331,64 +355,54 @@ export class PluginTemplatesComponent implements OnInit {
|
|||
));
|
||||
}
|
||||
|
||||
addNewAttr(){
|
||||
addNewAttr() {
|
||||
(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),
|
||||
type: this._fb.control("text", Validators.required),
|
||||
value: this._fb.control("")
|
||||
}));
|
||||
}
|
||||
|
||||
removeAttr(index){
|
||||
removeAttr(index) {
|
||||
this.attrFormArray.removeAt(index);
|
||||
this.attrFormArray.markAsDirty();
|
||||
}
|
||||
get attrFormArray(){
|
||||
|
||||
get attrFormArray() {
|
||||
|
||||
return this.templateForm.get("settings") as FormArray;
|
||||
|
||||
}
|
||||
|
||||
attributeTypeChanged(form){
|
||||
attributeTypeChanged(form) {
|
||||
let type = form.get("value").get("type");
|
||||
form.get("value").setValue("");
|
||||
if(type == "boolean"){
|
||||
if (type == "boolean") {
|
||||
form.get("value").setValue(false);
|
||||
}
|
||||
}
|
||||
public getPagesAsString(pageIds): string {
|
||||
|
||||
let pages = [];
|
||||
for(let id of pageIds) {
|
||||
pages.push(this.allPages.filter(option => option.value._id == id).map((option => option.value.name + " [" + option.value.portalType + "]")));
|
||||
public getPageAsString(pageId): string {
|
||||
return this.allPages.filter(option => option.value._id == pageId).map((option => option.value.name + " [" + option.value.portalType + "]")).join(",");
|
||||
}
|
||||
|
||||
}
|
||||
return pages.join(", ");
|
||||
}
|
||||
public getPageById(pageId) {
|
||||
for(let option of this.allPages) {
|
||||
if(option.value._id == pageId){
|
||||
for (let option of this.allPages) {
|
||||
if (option.value._id == pageId) {
|
||||
return option.value;
|
||||
}
|
||||
}
|
||||
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();
|
||||
object[$event.field]=$event.value;
|
||||
object[$event.field] = $event.value;
|
||||
this.templateForm.get("object").setValue(object);
|
||||
this.templateForm.markAsDirty();
|
||||
}
|
||||
|
||||
public getPagesByPortal(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({
|
||||
imports: [
|
||||
CommonModule, RouterModule, FormsModule, PluginResultsNumbersModule, PluginTestModule, PluginOpenaireProductsModule,
|
||||
PluginDiscoverBySubcommunityModule, PluginGatewayInformationModule, PluginSearchDepositLinkModule, PluginLearnAndConnectModule,
|
||||
PluginHowToUseModule, PluginSuggestedRepositoriesModule, PluginFeaturedDatasetsModule
|
||||
PluginDiscoverBySubcommunityModule, /*PluginGatewayInformationModule,*/ PluginSearchDepositLinkModule, PluginLearnAndConnectModule,
|
||||
PluginHowToUseModule, PluginSuggestedRepositoriesModule, PluginFeaturedDatasetsModule, PluginGatewayInformationModule
|
||||
],
|
||||
declarations: [PluginWrapperComponent],
|
||||
exports: [PluginWrapperComponent]
|
||||
|
|
|
@ -280,7 +280,10 @@ export class HelpContentService {
|
|||
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
|
||||
.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) {
|
||||
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
|
||||
.pipe(catchError(this.handleError));
|
||||
|
|
|
@ -16,12 +16,8 @@ export class PluginsService {
|
|||
return this.http.get<PluginTemplate>(api + 'pluginTemplates/' + code)
|
||||
|
||||
}
|
||||
getAllPluginTemplates(api:string) {
|
||||
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates')
|
||||
|
||||
}
|
||||
getAllPlugins(api:string) {
|
||||
return this.http.get<Array<Plugin>>(api + 'plugins')
|
||||
getPluginTemplates(api:string,pageId) {
|
||||
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates' + (pageId?'/page/'+pageId:''))
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,6 +25,12 @@ export class PluginsService {
|
|||
// console.log(pluginTemplate, pluginTemplate.toJsonObj())
|
||||
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());
|
||||
}
|
||||
|
@ -44,6 +46,9 @@ export class PluginsService {
|
|||
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');
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ import {PluginTemplate} from "./pluginTemplate";
|
|||
|
||||
export class Plugin {
|
||||
_id: string;
|
||||
code: string;
|
||||
templateCode: string;
|
||||
templateId: string;
|
||||
page: string;
|
||||
pid:string;
|
||||
placement: string;
|
||||
order: string;
|
||||
order: number;
|
||||
active:boolean;
|
||||
priorTo:boolean;
|
||||
object:any;
|
||||
settingsValues:Map<string,string> = new Map<string, string>();
|
||||
|
||||
|
@ -16,10 +16,12 @@ export class Plugin {
|
|||
console.log(template)
|
||||
this.page = page;
|
||||
this.pid = pid;
|
||||
this.code = template.code;
|
||||
this.placement = template.placements ? template.placements[0] : null;
|
||||
this.templateCode = template.code;
|
||||
this.templateId = template._id;
|
||||
this.placement = template.placement;
|
||||
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) {
|
||||
for (let attr of Object.keys(template.settings)) {
|
||||
this.settingsValues.set(attr, template.settings[attr].value)
|
||||
|
|
|
@ -6,9 +6,10 @@ export class PluginTemplate{
|
|||
code: string;
|
||||
description: string;
|
||||
image: string;
|
||||
pages: string[];
|
||||
page: string;
|
||||
plan: "starter" | "extended";
|
||||
placements: string[];
|
||||
order:number;
|
||||
placement: string;
|
||||
portalType: string;
|
||||
settings: {};
|
||||
object:any;
|
||||
|
|
Loading…
Reference in New Issue