From f92c4cbf524ed1126fc71af256b07e3cb8708a66 Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 22 Feb 2024 11:09:20 +0200 Subject: [PATCH] [plugins-functionality | WIP] add more plugins, update forms... --- connect/community/communityInfo.ts | 3 +- .../components/curators/curators.module.ts | 2 +- ...in-discover-by-subcommunity.component.html | 19 +- ...ugin-discover-by-subcommunity.component.ts | 28 ++- ...discover-by-subcommunity.form.component.ts | 25 ++ .../plugin-featured-datasets.component.html | 29 ++- .../plugin-featured-datasets.component.ts | 28 ++- ...plugin-featured-datasets.form.component.ts | 31 +++ .../plugin-featured-datasets.module.ts | 4 +- .../plugin-gateway-information.component.html | 86 ++++++- .../plugin-gateway-information.component.ts | 51 ++++- ...ugin-gateway-information.form.component.ts | 103 +++++++++ .../plugin-how-to-use.component.html | 76 ++----- .../how-to-use/plugin-how-to-use.component.ts | 13 +- .../plugin-learn-and-connect.component.html | 59 ++--- .../plugin-learn-and-connect.component.ts | 14 +- ...plugin-learn-and-connect.form.component.ts | 115 ++++++++++ .../plugin-openaire-products.component.ts | 68 +----- ...plugin-openaire-products.form.component.ts | 62 +++++ .../plugin-results-numbers.component.ts | 94 -------- .../plugin-results-numbers.module.ts | 24 -- .../plugin-search-deposit-link.component.html | 61 ++++- .../plugin-search-deposit-link.component.ts | 10 +- .../plugin-search-deposit-link.module.ts | 3 +- ...plugin-suggested-repositories.component.ts | 7 +- .../components/test/plugin-test.component.ts | 71 ------ .../components/test/plugin-test.module.ts | 25 -- dashboard/plugins/plugins.component.html | 214 ++++++++++-------- dashboard/plugins/plugins.component.ts | 40 +++- dashboard/plugins/plugins.module.ts | 7 +- .../templates/pluginTemplates.component.html | 82 ++++--- .../templates/pluginTemplates.component.ts | 61 ++--- .../templates/pluginTemplates.module.ts | 4 +- .../plugins/utils/base-plugin.component.ts | 53 ++++- .../utils/plugin-field-edit.component.ts | 11 +- dashboard/plugins/utils/pluginUtils.ts | 53 ++++- .../wrapper/plugin-edit-wrapper.component.ts | 51 +++++ .../wrapper/plugin-edit-wrapper.module.ts | 24 ++ .../wrapper/plugin-wrapper.component.ts | 38 ++-- .../plugins/wrapper/plugin-wrapper.module.ts | 6 +- utils/entities/adminTool/plugin.ts | 3 +- utils/entities/adminTool/pluginTemplate.ts | 2 + .../fetchResearchResults.class.ts | 2 +- 43 files changed, 1121 insertions(+), 641 deletions(-) create mode 100644 dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.form.component.ts create mode 100644 dashboard/plugins/components/featured-datasets/plugin-featured-datasets.form.component.ts create mode 100644 dashboard/plugins/components/gateway-information/plugin-gateway-information.form.component.ts create mode 100644 dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.form.component.ts create mode 100644 dashboard/plugins/components/openaireProducts/plugin-openaire-products.form.component.ts delete mode 100644 dashboard/plugins/components/results-numbers/plugin-results-numbers.component.ts delete mode 100644 dashboard/plugins/components/results-numbers/plugin-results-numbers.module.ts delete mode 100644 dashboard/plugins/components/test/plugin-test.component.ts delete mode 100644 dashboard/plugins/components/test/plugin-test.module.ts create mode 100644 dashboard/plugins/wrapper/plugin-edit-wrapper.component.ts create mode 100644 dashboard/plugins/wrapper/plugin-edit-wrapper.module.ts diff --git a/connect/community/communityInfo.ts b/connect/community/communityInfo.ts index 8a8469ce..f17b257c 100644 --- a/connect/community/communityInfo.ts +++ b/connect/community/communityInfo.ts @@ -24,7 +24,8 @@ export class CommunityInfo { fos: string[] = []; sdg: string[] = [] selectionCriteria: SelectionCriteria; - + plan: "starter" | "extended"; + public static checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] { if (Array.isArray(response)) { response.forEach(value => { diff --git a/connect/components/curators/curators.module.ts b/connect/components/curators/curators.module.ts index dc5f4530..81afd62b 100644 --- a/connect/components/curators/curators.module.ts +++ b/connect/components/curators/curators.module.ts @@ -6,7 +6,7 @@ import { RouterModule } from '@angular/router'; import {CuratorsComponent} from './curators.component'; import {CuratorService} from "../../curators/curator.service"; import {CuratorsRoutingModule} from "./curators-routing.module"; -import {AffiliationsModule} from "../../../../affiliations/affiliations.module"; +import {AffiliationsModule} from "../../../../pages/affiliations/affiliations.module"; import {HelperModule} from "../../../utils/helper/helper.module"; import {Schema2jsonldModule} from "../../../sharedComponents/schema2jsonld/schema2jsonld.module"; import {SEOServiceModule} from "../../../sharedComponents/SEO/SEOService.module"; diff --git a/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.html b/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.html index 33b05dd4..2a535a27 100644 --- a/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.html +++ b/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.html @@ -1,13 +1,18 @@ -
plugin-discover-by-subcommunity

- Discover content by sub-community + {{pluginObject.title}}

-
\ No newline at end of file +
+ No subcommunities available +
+
+ No community info available +
+ diff --git a/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.ts b/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.ts index f89bf05f..6081dc89 100644 --- a/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.ts +++ b/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.component.ts @@ -1,12 +1,32 @@ import {Component} from '@angular/core'; -import {PluginBaseComponent} from "../../utils/base-plugin.component"; - +import {PluginBaseComponent, PluginBaseInfo} from "../../utils/base-plugin.component"; +import {HttpClient} from "@angular/common/http"; +import {CommunityService} from "../../../../connect/community/community.service"; +export class PluginDiscoverBySubcommunity extends PluginBaseInfo{ + title:string ="Discover content by sub-community"; +} @Component({ selector: 'plugin-discover-by-subcommunity', templateUrl: 'plugin-discover-by-subcommunity.component.html' }) -export class PluginDiscoverBySubcommunityComponent extends PluginBaseComponent{ - constructor() { +export class PluginDiscoverBySubcommunityComponent extends PluginBaseComponent{ + default = new PluginDiscoverBySubcommunity(); + subcommunities = null; + community; + constructor(http:HttpClient, private communityService: CommunityService) { super() + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe( + community => { + this.community = community; + if(community) { + this.subscriptions.push(http.get(this.properties.communityAPI + community.communityId + + "/subcommunities?all=false").subscribe(res => { + console.log(res) + this.subcommunities = res ? res : [] /* = res.splice(0,15)*/; + + })); + } + })); + } } diff --git a/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.form.component.ts b/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.form.component.ts new file mode 100644 index 00000000..7d193040 --- /dev/null +++ b/dashboard/plugins/components/discover-by-subcommunity/plugin-discover-by-subcommunity.form.component.ts @@ -0,0 +1,25 @@ +import {Component} from '@angular/core'; +import {PluginBaseComponent} from "../../utils/base-plugin.component"; +import {HttpClient} from "@angular/common/http"; +import {PluginDiscoverBySubcommunity} from "./plugin-discover-by-subcommunity.component"; + +@Component({ + selector: 'plugin-discover-by-subcommunity-form', + template: ` +
+ +
+ + `, + + +}) +export class PluginDiscoverBySubcommunityFormComponent extends PluginBaseComponent { + default = new PluginDiscoverBySubcommunity(); + selectedIndex = null; + constructor(http:HttpClient) { + super() + + } +} diff --git a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.html b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.html index 0c383a37..21db4b5d 100644 --- a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.html +++ b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.html @@ -1,15 +1,26 @@ -
plugin-featured-datasets
diff --git a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.ts b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.ts index 27e3e061..0c274d78 100644 --- a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.ts +++ b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.component.ts @@ -1,12 +1,36 @@ import {Component} from '@angular/core'; import {PluginBaseComponent} from "../../utils/base-plugin.component"; +import {FetchResearchResults} from "../../../../utils/fetchEntitiesClasses/fetchResearchResults.class"; +import {SearchResearchResultsService} from "../../../../services/searchResearchResults.service"; + +export class PluginFeaturedDatasets { + title: string = "Featured datasets"; + textLine1: string = "Here are listed some of the most important energy datasets as selected by energy experts."; + textLine2: string = "Check them if you want to easily explore and visualize the European energy landscape, using only well-known datasets which you can trust."; + +} @Component({ selector: 'plugin-featured-datasets', templateUrl: 'plugin-featured-datasets.component.html' }) -export class PluginFeaturedDatasetsComponent extends PluginBaseComponent{ - constructor() { + +export class PluginFeaturedDatasetsComponent extends PluginBaseComponent { + default = new PluginFeaturedDatasets(); + public fetchFeaturedDatasets: FetchResearchResults; + page = 1; + size = 3; + + constructor(private _searchResearchResultsService: SearchResearchResultsService) { super() + this.fetchFeaturedDatasets = new FetchResearchResults(this._searchResearchResultsService); + this.fetchFeaturedDatasets.searchUtils.size = this.size; + this.fetchFeaturedDatasets.getAllResultsForCommunity("dataset", "enermaps", 1, 100, this.properties, "enermaps::selection"); + } + + public updatePage(event) { + this.page = event.value; + this.fetchFeaturedDatasets.searchUtils.page = event.value; + this.fetchFeaturedDatasets.results = this.fetchFeaturedDatasets.allResults.slice((this.page - 1) * this.size, this.page * this.size); } } diff --git a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.form.component.ts b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.form.component.ts new file mode 100644 index 00000000..1b61c890 --- /dev/null +++ b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.form.component.ts @@ -0,0 +1,31 @@ +import {Component} from '@angular/core'; +import {PluginBaseComponent} from "../../utils/base-plugin.component"; +import {HttpClient} from "@angular/common/http"; +import {OpenaireEntities} from "../../../../utils/properties/searchFields"; +import {PluginFeaturedDatasets} from "./plugin-featured-datasets.component"; + +@Component({ + selector: 'plugin-featured-datasets-form', + template: ` +
+ + + +
+ `, + + +}) +export class PluginFeaturedDatasetsFormComponent extends PluginBaseComponent { + default = new PluginFeaturedDatasets(); + selectedIndex = null; + openaireEntities= OpenaireEntities; + constructor(http: HttpClient) { + super() + + } + +} diff --git a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.module.ts b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.module.ts index e34b810d..f203a0b3 100644 --- a/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.module.ts +++ b/dashboard/plugins/components/featured-datasets/plugin-featured-datasets.module.ts @@ -9,10 +9,12 @@ import {IconsService} from "../../../../utils/icons/icons.service"; import {SearchResearchResultsServiceModule} from "../../../../services/searchResearchResultsService.module"; import {PluginFieldEditModule} from "../../utils/plugin-field-edit.module"; import {PluginFeaturedDatasetsComponent} from './plugin-featured-datasets.component'; +import {NoLoadPaging} from "../../../../searchPages/searchUtils/no-load-paging.module"; +import {SearchResultsModule} from "../../../../searchPages/searchUtils/searchResults.module"; @NgModule({ imports: [ - CommonModule, RouterModule, FormsModule, IconsModule, NumberRoundModule, SearchResearchResultsServiceModule, PluginFieldEditModule + CommonModule, RouterModule, FormsModule, IconsModule, NumberRoundModule, SearchResearchResultsServiceModule, PluginFieldEditModule, NoLoadPaging, SearchResultsModule ], providers:[PluginsService], declarations: [PluginFeaturedDatasetsComponent], diff --git a/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.html b/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.html index 808e964f..5070f685 100644 --- a/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.html +++ b/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.html @@ -1,19 +1,22 @@ -
plugin-gateway-information
- Gateway Information + {{ pluginObject.title}}
-
+
+ No community info available available +
+
- + diff --git a/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.ts b/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.ts index 8647f53a..4c0d9761 100644 --- a/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.ts +++ b/dashboard/plugins/components/gateway-information/plugin-gateway-information.component.ts @@ -7,13 +7,31 @@ import {SearchCommunityDataprovidersService} from '../../../../../openaireLibrar import {ZenodoCommunitiesService} from '../../../../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; import {ConnectHelper} from '../../../../../openaireLibrary/connect/connectHelper'; import {User} from '../../../../../openaireLibrary/login/utils/helper.class'; +import {RouterHelper} from "../../../../utils/routerHelper.class"; +import {OpenaireEntities} from "../../../../utils/properties/searchFields"; +import {HttpClient} from "@angular/common/http"; +export class PluginGatewayInformation{ + title:string ="Gateway Information"; + curators:boolean = true; + date:boolean = true; + communities:boolean = true; + projects:boolean = true; + organizations:boolean = true; + datasources:boolean = true; + subjects:boolean = true; + publications:boolean = true; + datasets:boolean = true; + software:boolean = true; + other:boolean = true; +} @Component({ selector: 'plugin-gateway-information', templateUrl: 'plugin-gateway-information.component.html', styleUrls: ['plugin-gateway-information.component.less'] }) -export class PluginGatewayInformationComponent extends PluginBaseComponent{ +export class PluginGatewayInformationComponent extends PluginBaseComponent{ + default = new PluginGatewayInformation(); community = null; portal = null; params: any = {}; @@ -33,25 +51,26 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent{ displayedSubjects = []; displayedSdg = []; displayedFos = []; - + resultCounts = null; private user: User; - - constructor(private config: ConfigurationService, + searchLinkToResults: string = null; + public routerHelper: RouterHelper = new RouterHelper(); + openaireEntities= OpenaireEntities; + constructor(private http:HttpClient, + private config: ConfigurationService, private communityService: CommunityService, private searchCommunityProjectsService: SearchCommunityProjectsService, private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, private zenodoCommunitiesService: ZenodoCommunitiesService) { - super() - } - - ngOnInit() { + super(); +// console.log(this.default, this.pluginObject, this.pluginDefaultObject) + this.searchLinkToResults = this.properties.searchLinkToResults; this.searchLinkToProjects = this.properties.searchLinkToProjects; this.searchLinkToDataProviders = this.properties.searchLinkToDataProviders; this.shareInZenodoPage = this.properties.shareInZenodoPage; this.subscriptions.push(this.config.portalAsObservable.subscribe( res => { - console.log(res); this.portal = res; }, error => { @@ -60,7 +79,6 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent{ )); this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe( community => { - console.log(community); this.community = community; if(community && !ConnectHelper.isPrivate(community, this.user)) { this.displayedSubjects = community.subjects; @@ -79,7 +97,7 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent{ this.params = {communityId: community.communityId}; } if (this.community.zenodoCommunity) { - this.subscriptions.push(this.zenodoCommunitiesService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity).subscribe( + this.subscriptions.push(this.zenodoCommunitiesService.getZenodoCommunityById(this.properties, this.community.zenodoCommunity).subscribe( res => { this.masterZenodoCommunity = res; }, @@ -116,8 +134,12 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent{ this.contentProvidersCalculated = true; } )); + this.subscriptions.push(this.http.get(this.properties.utilsService + "/portals/countResults?field=communityid&value=" + this.community.communityId).subscribe(res => { + this.resultCounts = res; + })); } + isEntityEnabled(entity: string) { return this.portal.entities.some(x => x['pid'] == entity && x['isEnabled'] === true); } @@ -161,4 +183,11 @@ export class PluginGatewayInformationComponent extends PluginBaseComponent{ return tooltipContent; } + public getParamsForSearchLink(type: string = "") { + if (type) { + return this.routerHelper.createQueryParams(['type', 'qf', 'sortBy'], [type, 'false', 'resultdateofacceptance,descending']); + } else { + return {}; + } + } } diff --git a/dashboard/plugins/components/gateway-information/plugin-gateway-information.form.component.ts b/dashboard/plugins/components/gateway-information/plugin-gateway-information.form.component.ts new file mode 100644 index 00000000..77f54c1f --- /dev/null +++ b/dashboard/plugins/components/gateway-information/plugin-gateway-information.form.component.ts @@ -0,0 +1,103 @@ +import {Component} from '@angular/core'; +import {PluginBaseComponent} from "../../utils/base-plugin.component"; +import {PluginGatewayInformation} from "./plugin-gateway-information.component"; +import {OpenaireEntities} from "../../../../utils/properties/searchFields"; + +@Component({ + selector: 'plugin-gateway-information-form', + template: ` +
+ +
+ Show or hide the following information: +
+
+
+ Curated by: + + + +
+
+ Created: + + +
+
+ {{openaireEntities.PROJECTS}}: + + +
+
+ Linked Zenodo communities: + + +
+
+ {{openaireEntities.DATASOURCES}} + + + +
+
+ Subjects: + + +
+
+ {{openaireEntities.PUBLICATIONS}}: + + +
+
+ {{openaireEntities.DATASETS}}: + + +
+
+ {{openaireEntities.SOFTWARE}}: + + +
+
+ {{openaireEntities.OTHER}}: + + +
+
+
+ `, + + +}) +export class PluginGatewayInformationFormComponent extends PluginBaseComponent { + default = new PluginGatewayInformation(); + selectedIndex = null; + openaireEntities= OpenaireEntities; + constructor() { + super() + + } + +} diff --git a/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.html b/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.html index e69947e3..acecd751 100644 --- a/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.html +++ b/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.html @@ -1,58 +1,30 @@ -
plugin-how-to-use

- How to use the gateway? + {{pluginObject.title}}

-
- -
-
- -
-
- Tutorials -
-
- The mini-video tutorials can help you find quick answers on specific gateway functionalities. -
- - View all - -
- -
-
- -
-
- Guides -
-
- Textual guides to all gateway functionalities. -
- - Guide for the users - - - Guide for the managers - -
- -
-
- -
-
- Webinars -
-
- Recordings and slides of webinars on OpenAIRE CONNECT and your gateway. -
- - View all - -
+
+ + +
+
+ +
+
+ {{card.title}} +
+
+ {{card.description}} +
+ + {{url.linkText}} + +
+
+
-
\ No newline at end of file +
diff --git a/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.ts b/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.ts index 31fa75b4..39638e20 100644 --- a/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.ts +++ b/dashboard/plugins/components/how-to-use/plugin-how-to-use.component.ts @@ -1,11 +1,18 @@ import {Component} from '@angular/core'; -import {PluginBaseComponent} from "../../utils/base-plugin.component"; - +import {PluginBaseComponent, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component"; +export class PluginHowToUse{ + title:string ="How to use the gateway?"; + cardInfoArray: PluginInfoCards[] = [ + {title: "Tutorials", description: "The mini-video tutorials can help you find quick answers on specific gateway functionalities.", urls:[ new PluginURL("","View all")], show:true}, + {title: "Guides", description: "Textual guides to all gateway functionalities.", urls:[ new PluginURL("","Guide for the users"), new PluginURL("","Guide for the managers")], show:true}, + {title: "Webinars", description: "Recordings and slides of webinars on different aspects of Open Science.", urls:[ new PluginURL("","View all")], show:true} + ]; +} @Component({ selector: 'plugin-how-to-use', templateUrl: 'plugin-how-to-use.component.html' }) -export class PluginHowToUseComponent extends PluginBaseComponent{ +export class PluginHowToUseComponent extends PluginBaseComponent{ constructor() { super() } diff --git a/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.html b/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.html index 8613e3bc..2bdd3632 100644 --- a/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.html +++ b/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.html @@ -1,57 +1,32 @@ -
plugin-learn-and-connect

- Learn & Connect with Open Science + {{pluginObject.title}}

-
- -
+
+ + +
- OS Practices + {{card.title}}
- Open Science best practices for your community, policies and mandates. + {{card.description}}
- - Learn more - -
- -
-
- -
-
- OS Guides for beginners -
-
- New to Open Science? Learn the basics! -
- -
- -
-
- -
-
- Webinars -
-
- Recordings and slides of webinars on different aspects of Open Science. -
- - Learn more + + {{url.linkText}}
+
+
+ + +
-
\ No newline at end of file +
diff --git a/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.ts b/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.ts index 0661e263..37327d2d 100644 --- a/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.ts +++ b/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.component.ts @@ -1,11 +1,19 @@ import {Component} from '@angular/core'; -import {PluginBaseComponent} from "../../utils/base-plugin.component"; - +import {PluginBaseComponent, PluginInfoCards, PluginURL} from "../../utils/base-plugin.component"; +export class PluginLearnAndConnect{ + title:string ="Learn & Connect with Open Science"; + cardInfoArray:PluginInfoCards[] = [ + {title: "OS Practices", description: "Open Science best practices for your community, policies and mandates.", + urls:[ new PluginURL("","Learn more")], show:true}, + {title: "OS Guides for beginners", description: "New to Open Science? Learn the basics!",urls:[ new PluginURL("","Learn more")], show:true}, + {title: "Webinars", description: "Recordings and slides of webinars on different aspects of Open Science.",urls:[ new PluginURL("","Learn more")], show:true} + ]; +} @Component({ selector: 'plugin-learn-and-connect', templateUrl: 'plugin-learn-and-connect.component.html' }) -export class PluginLearnAndConnectComponent extends PluginBaseComponent{ +export class PluginLearnAndConnectComponent extends PluginBaseComponent{ constructor() { super() } diff --git a/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.form.component.ts b/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.form.component.ts new file mode 100644 index 00000000..5d33e06d --- /dev/null +++ b/dashboard/plugins/components/learn-and-connect/plugin-learn-and-connect.form.component.ts @@ -0,0 +1,115 @@ +import {Component, EventEmitter, OnChanges, Output, SimpleChanges} from '@angular/core'; +import {PluginBaseComponent, PluginEditEvent} from "../../utils/base-plugin.component"; +import {HttpClient} from "@angular/common/http"; +import {PluginLearnAndConnect} from "./plugin-learn-and-connect.component"; +import {PluginOpenAIREProducts} from "../openaireProducts/plugin-openaire-products.component"; + +@Component({ + selector: 'plugin-learn-and-connect-form', + template: ` +
+ + +
+ Cards: +
+ + +
+
{{card.title}}
+
+ +
+
+ + + +
+
+ edit + hide +
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+ + +
+
+ + `, + + +}) +export class PluginLearnAndConnectFormComponent extends PluginBaseComponent /*implements OnChanges*/{ + selectedIndex = null; + default = new PluginLearnAndConnect(); + constructor(http:HttpClient) { + super() + // this.default = new PluginLearnAndConnect(); + } + /*ngOnInit(): void { + if(this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title)){ + this.pluginTemplate.object = new PluginLearnAndConnect(); + } + }*/ + + /*ngOnChanges(changes: SimpleChanges) { + console.log("changes") + if(changes.plugin){ + console.log("changes plugin", changes.plugin) + }else if (changes.pluginTemplate){ + console.log("changes pluginTemplate", changes.pluginTemplate) + } + } + +*/ + cardShowChanged(i,$event:PluginEditEvent){ + if(this.editTemplate){ + this.pluginTemplate.object.cardInfoArray[i].show=$event.value; + $event.value =this.pluginTemplate.object.cardInfoArray; + }else{ + this.plugin.object.cardInfoArray[i].show=$event.value; + $event.value =this.plugin.object.cardInfoArray; + } + + this.valuesChanged.emit({field:$event.field, value: $event.value, type: 'parent'}) + } + + cardValueChanged(i,$event:PluginEditEvent){ + if(this.editTemplate){ + this.pluginTemplate.object.cardInfoArray[i][$event.field]=$event.value; + $event.value =this.pluginTemplate.object.cardInfoArray; + }else{ + this.plugin.object.cardInfoArray[i][$event.field]=$event.value; + $event.value =this.plugin.object.cardInfoArray; + } + + this.valuesChanged.emit({field:"cardInfoArray", value: $event.value, type: 'parent'}) + } + + edit(i){ + this.selectedIndex = i; + } + +} diff --git a/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts b/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts index a8c5601b..2597fa5e 100644 --- a/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts +++ b/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts @@ -1,33 +1,21 @@ import {Component} from '@angular/core'; -import {PluginBaseComponent, PluginEditEvent} from "../../utils/base-plugin.component"; +import {PluginBaseComponent, PluginBaseInfo, PluginEditEvent} from "../../utils/base-plugin.component"; import {HttpClient} from "@angular/common/http"; -export class PluginOpenAIREProducts{ +export class PluginOpenAIREProducts extends PluginBaseInfo{ title:string ="OpenAIRE services for your community"; - serviceIds = {"zenodo":true,"graph":true,"explore":true}; - constructor() { - } + serviceIdsArray = ["zenodo","graph","explore"]; + } @Component({ selector: 'plugin-openaire-products', template: ` -
-
- - - - +

- {{pluginObject && pluginObject.title?pluginObject.title:pluginDefaultObject.title}}

-
-
+ {{pluginObject.title}}
- - -
+
@@ -38,40 +26,24 @@ export class PluginOpenAIREProducts{
{{service.tagline}}
Read more - -
- - -
-
-
-
-
`, }) -export class PluginOpenaireProductsComponent extends PluginBaseComponent{ +export class PluginOpenaireProductsComponent extends PluginBaseComponent{ services = []; excludedServiceIds = ["openaire_login","research_community_dashboard"] - get pluginObject():PluginOpenAIREProducts{ - return this.plugin?this.plugin.object:null; - } - get pluginDefaultObject():PluginOpenAIREProducts{ - return this.pluginTemplate?this.pluginTemplate.object:null; - } + default = new PluginOpenAIREProducts(); constructor(http:HttpClient) { super() this.subscriptions.push(http.get("https://explore.openaire.eu/cache/get?url="+ encodeURIComponent("https://catalogue.openaire.eu/api/catalogue-resources?from=0&quantity=100&order=asc&orderField=name")).subscribe(res =>{ - console.log(res) this.services = res["results"].map( x=> { x.id = x.id.split("openaire.")[1] return x; @@ -80,26 +52,4 @@ export class PluginOpenaireProductsComponent extends PluginBaseComponent{ })) } - ngOnInit(): void { - if(this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title)){ - this.pluginTemplate.object = new PluginOpenAIREProducts(); - } - } - - - serviceChanged(id,$event:PluginEditEvent){ - if(this.editTemplate){ - this.pluginTemplate.object.serviceIds[id]=$event.value; - $event.value =this.pluginTemplate.object.serviceIds; - }else{ - if(!this.plugin.object){ - this.plugin.object =this.pluginDefaultObject? Object.assign(this.pluginDefaultObject): new PluginOpenAIREProducts(); - } - console.log(this.plugin.object,this.plugin.object.serviceIds) - this.plugin.object.serviceIds[id]=$event.value; - $event.value =this.plugin.object.serviceIds; - } - - this.valuesChanged.emit($event) - } } diff --git a/dashboard/plugins/components/openaireProducts/plugin-openaire-products.form.component.ts b/dashboard/plugins/components/openaireProducts/plugin-openaire-products.form.component.ts new file mode 100644 index 00000000..58f1e513 --- /dev/null +++ b/dashboard/plugins/components/openaireProducts/plugin-openaire-products.form.component.ts @@ -0,0 +1,62 @@ +import {Component, EventEmitter, Output} from '@angular/core'; +import {PluginBaseComponent, PluginEditEvent} from "../../utils/base-plugin.component"; +import {HttpClient} from "@angular/common/http"; +import {PluginOpenAIREProducts} from "./plugin-openaire-products.component"; + +@Component({ + selector: 'plugin-openaire-products-form', + template: ` +
+ + +
+ Select services: +
+ + +
+
{{service.name}}
+
+ + +
+
+
+ +
+ + `, + + +}) +export class PluginOpenaireProductsFormComponent extends PluginBaseComponent{ + default = new PluginOpenAIREProducts(); + services = []; + excludedServiceIds = ["openaire_login","research_community_dashboard"] + constructor(http:HttpClient) { + super() + this.subscriptions.push(http.get("https://explore.openaire.eu/cache/get?url="+ encodeURIComponent("https://catalogue.openaire.eu/api/catalogue-resources?from=0&quantity=100&order=asc&orderField=name")).subscribe(res =>{ + this.services = res["results"].map( x=> { + x.id = x.id.split("openaire.")[1] + return x; + }); + this.services = this.services.filter(x=> this.excludedServiceIds.indexOf(x.id) ==-1); + })) + + } + + serviceChanged(id,$event:PluginEditEvent){ + let index = this.pluginObject.serviceIdsArray.indexOf(id); + if(index !=-1){ + this.pluginObject.serviceIdsArray.splice(index,1); + }else{ + this.pluginObject.serviceIdsArray.push(id); + } + $event.value =this.pluginObject.serviceIdsArray; + + this.valuesChanged.emit({field:$event.field, value: $event.value, type: 'parent'}) + } + +} diff --git a/dashboard/plugins/components/results-numbers/plugin-results-numbers.component.ts b/dashboard/plugins/components/results-numbers/plugin-results-numbers.component.ts deleted file mode 100644 index 56310258..00000000 --- a/dashboard/plugins/components/results-numbers/plugin-results-numbers.component.ts +++ /dev/null @@ -1,94 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {Plugin} from "../../../../utils/entities/adminTool/plugin"; -import {PluginTemplate} from "../../../../utils/entities/adminTool/pluginTemplate"; -import {SearchResearchResultsService} from "../../../../services/searchResearchResults.service"; -import {FetchResearchResults} from "../../../../utils/fetchEntitiesClasses/fetchResearchResults.class"; -import {EnvProperties} from "../../../../utils/properties/env-properties"; -import { properties } from 'src/environments/environment'; -import {RouterHelper} from "../../../../utils/routerHelper.class"; -import {OpenaireEntities} from "../../../../utils/properties/searchFields"; -import {PluginBaseComponent} from "../../utils/base-plugin.component"; -export class PluginResultsNumbers{ - publicationsOnOff:boolean; - datasetsOnOff:boolean; - softwareOnOff:boolean; - otherOnOff:boolean; -} -@Component({ - selector: 'plugin-results-numbers', - template: ` - - - ` -}) -export class PluginResultsNumbersComponent extends PluginBaseComponent{ - get pluginObject():PluginResultsNumbers{ - return this.plugin.object; - } - get pluginDefaultObject():PluginResultsNumbers{ - return this.pluginTemplate.object; - } - // Variables for publications, research data, projects, content providers, related content providers tabs - public fetchPublications: FetchResearchResults; - public fetchDatasets: FetchResearchResults; - public fetchSoftware: FetchResearchResults; - public fetchOrps: FetchResearchResults; - public fetchFeaturedDatasets: FetchResearchResults; - searchLinkToResults: string = null; - properties: EnvProperties = properties; - public routerHelper: RouterHelper = new RouterHelper(); - openaireEntities= OpenaireEntities; - - constructor(private _searchResearchResultsService: SearchResearchResultsService,) { - super(); - this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService); - this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService); - this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService); - this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService); - this.fetchFeaturedDatasets = new FetchResearchResults(this._searchResearchResultsService); - } - ngOnInit(): void { - this.searchLinkToResults = this.properties.searchLinkToResults; - - } - - public getParamsForSearchLink(type: string = "") { - if (type) { - return this.routerHelper.createQueryParams(['type', 'qf', 'sortBy'], [type, 'false', 'resultdateofacceptance,descending']); - } else { - return {}; - } - } -} diff --git a/dashboard/plugins/components/results-numbers/plugin-results-numbers.module.ts b/dashboard/plugins/components/results-numbers/plugin-results-numbers.module.ts deleted file mode 100644 index e59df0cf..00000000 --- a/dashboard/plugins/components/results-numbers/plugin-results-numbers.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; -import {PluginsService} from "../../../../services/plugins.service"; -import {PluginResultsNumbersComponent} from "./plugin-results-numbers.component"; -import {IconsModule} from "../../../../utils/icons/icons.module"; -import {NumberRoundModule} from "../../../../utils/pipes/number-round.module"; -import {IconsService} from "../../../../utils/icons/icons.service"; -import {SearchResearchResultsServiceModule} from "../../../../services/searchResearchResultsService.module"; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, IconsModule, NumberRoundModule, SearchResearchResultsServiceModule - ], - providers:[PluginsService], - declarations: [PluginResultsNumbersComponent], - exports: [PluginResultsNumbersComponent] -}) -export class PluginResultsNumbersModule { - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([]) - } -} diff --git a/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.html b/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.html index 4819e6be..12d14855 100644 --- a/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.html +++ b/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.html @@ -1,2 +1,61 @@
plugin-search-deposit-link
- \ No newline at end of file + +
+
+
+ +

+ Find the best for your community. +

+
+ + + + ipad + + + ipad + + + ipad + + + ipad + + + ipad + + + + +
+ Find a repository + to deposit your {{entities.RESULT | lowercase}} + . +
+
+ +
+ Link your {{entities.RESULT | lowercase}} + with your community, funding, and other {{entities.RESULTS | lowercase}} + . +
+
+ +
+ View community's + overview at a glance. +
+
+ +
+ Search & browse + your community's {{entities.RESULTS | lowercase}} + . +
+
+
+
+
+
diff --git a/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.ts b/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.ts index 5c2272f0..6af442b7 100644 --- a/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.ts +++ b/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.component.ts @@ -1,11 +1,17 @@ import {Component} from '@angular/core'; import {PluginBaseComponent} from "../../utils/base-plugin.component"; - +import {OpenaireEntities} from "../../../../utils/properties/searchFields"; +export class PluginSearchDepositLink{ + title:string ="Search, link and deposit your research in one place."; + description: string = "Lorem ipsum"; +} @Component({ selector: 'plugin-search-deposit-link', templateUrl: 'plugin-search-deposit-link.component.html' }) -export class PluginSearchDepositLinkComponent extends PluginBaseComponent{ +export class PluginSearchDepositLinkComponent extends PluginBaseComponent{ + entities= OpenaireEntities; + constructor() { super() } diff --git a/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.module.ts b/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.module.ts index 54269f97..a3923f36 100644 --- a/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.module.ts +++ b/dashboard/plugins/components/search-deposit-link/plugin-search-deposit-link.module.ts @@ -9,10 +9,11 @@ import {IconsService} from "../../../../utils/icons/icons.service"; import {SearchResearchResultsServiceModule} from "../../../../services/searchResearchResultsService.module"; import {PluginFieldEditModule} from "../../utils/plugin-field-edit.module"; import {PluginSearchDepositLinkComponent} from './plugin-search-deposit-link.component'; +import {SliderUtilsModule} from "../../../../sharedComponents/slider-utils/slider-utils.module"; @NgModule({ imports: [ - CommonModule, RouterModule, FormsModule, IconsModule, NumberRoundModule, SearchResearchResultsServiceModule, PluginFieldEditModule + CommonModule, RouterModule, FormsModule, IconsModule, NumberRoundModule, SearchResearchResultsServiceModule, PluginFieldEditModule, SliderUtilsModule ], providers:[PluginsService], declarations: [PluginSearchDepositLinkComponent], diff --git a/dashboard/plugins/components/suggested-repositories/plugin-suggested-repositories.component.ts b/dashboard/plugins/components/suggested-repositories/plugin-suggested-repositories.component.ts index 04e13e93..3bacaf66 100644 --- a/dashboard/plugins/components/suggested-repositories/plugin-suggested-repositories.component.ts +++ b/dashboard/plugins/components/suggested-repositories/plugin-suggested-repositories.component.ts @@ -1,11 +1,14 @@ import {Component} from '@angular/core'; import {PluginBaseComponent} from "../../utils/base-plugin.component"; - +export class PluginSuggestedRepositories{ + title:string ="Lorem ipsum"; + description: string = "Lorem ipsum"; +} @Component({ selector: 'plugin-suggested-repositories', templateUrl: 'plugin-suggested-repositories.component.html' }) -export class PluginSuggestedRepositoriesComponent extends PluginBaseComponent{ +export class PluginSuggestedRepositoriesComponent extends PluginBaseComponent{ constructor() { super() } diff --git a/dashboard/plugins/components/test/plugin-test.component.ts b/dashboard/plugins/components/test/plugin-test.component.ts deleted file mode 100644 index 46c3c757..00000000 --- a/dashboard/plugins/components/test/plugin-test.component.ts +++ /dev/null @@ -1,71 +0,0 @@ -import {Component} from '@angular/core'; -import {PluginBaseComponent} from "../../utils/base-plugin.component"; - -export class PluginTest{ - title:string ="Test Plugin"; - description: string = "Lorem ipsum"; - numberOn:boolean = true; - constructor() { - console.log(this) - } -} -@Component({ - selector: 'plugin-test', - template: ` - -
-
- - - - -

- {{pluginObject && pluginObject.title?pluginObject.title:pluginDefaultObject.title}}

- - -
-
- - - - -

- {{pluginObject && pluginObject.description?pluginObject.description:pluginDefaultObject.description}}

-
-
- - - - -

58K

-
- -
- - `, - - -}) -export class PluginTestComponent extends PluginBaseComponent{ - - get pluginObject():PluginTest{ - return this.plugin?this.plugin.object:null; - } - get pluginDefaultObject():PluginTest{ - return this.pluginTemplate?this.pluginTemplate.object:null; - } - constructor() { - super() - - } - ngOnInit(): void { - if(this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title)){ - this.pluginTemplate.object = new PluginTest(); - } - } - -} diff --git a/dashboard/plugins/components/test/plugin-test.module.ts b/dashboard/plugins/components/test/plugin-test.module.ts deleted file mode 100644 index ee15806f..00000000 --- a/dashboard/plugins/components/test/plugin-test.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; -import {PluginsService} from "../../../../services/plugins.service"; -import {IconsModule} from "../../../../utils/icons/icons.module"; -import {NumberRoundModule} from "../../../../utils/pipes/number-round.module"; -import {IconsService} from "../../../../utils/icons/icons.service"; -import {SearchResearchResultsServiceModule} from "../../../../services/searchResearchResultsService.module"; -import {PluginTestComponent} from "./plugin-test.component"; -import {PluginFieldEditModule} from "../../utils/plugin-field-edit.module"; - -@NgModule({ - imports: [ - CommonModule, RouterModule, FormsModule, IconsModule, NumberRoundModule, SearchResearchResultsServiceModule, PluginFieldEditModule - ], - providers:[PluginsService], - declarations: [PluginTestComponent], - exports: [PluginTestComponent] -}) -export class PluginTestModule { - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([]) - } -} diff --git a/dashboard/plugins/plugins.component.html b/dashboard/plugins/plugins.component.html index 66869f6f..d6a15258 100644 --- a/dashboard/plugins/plugins.component.html +++ b/dashboard/plugins/plugins.component.html @@ -1,30 +1,73 @@ -
+
+ + +
-
+
@@ -78,8 +113,10 @@
{{placement.value}}
-
-
+ + +
@@ -87,33 +124,22 @@
{{pluginGroup.template.description}}
- +
- - - - - - -
Placement: {{pluginGroup.plugin.placement}}
Order: {{pluginGroup.plugin.order}}
- + +
@@ -125,7 +151,7 @@
-
+ + @@ -217,45 +244,48 @@
--> -
+ - -
{{selectedTemplate.name}}
-
{{selectedTemplate.description}}
- - -
-
-
Plugin settings
-
-
-
-
-
-
-
- - - -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
-
+ + +
+
diff --git a/dashboard/plugins/plugins.component.ts b/dashboard/plugins/plugins.component.ts index 7ae71a28..c3c33d92 100644 --- a/dashboard/plugins/plugins.component.ts +++ b/dashboard/plugins/plugins.component.ts @@ -2,7 +2,7 @@ import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from "@angular/router"; import {HelpContentService} from "../../services/help-content.service"; import { - FormArray, + FormArray, FormGroup, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, @@ -27,6 +27,8 @@ import {Portal} from "../../utils/entities/adminTool/portal"; import {PluginTemplate} from "../../utils/entities/adminTool/pluginTemplate"; import {PluginEditEvent} from "./utils/base-plugin.component"; import {PluginUtils} from "./utils/pluginUtils"; +import {CommunityService} from "../../connect/community/community.service"; +import {CommunityInfo} from "../../connect/community/communityInfo"; @Component({ selector: 'plugins', @@ -63,7 +65,9 @@ export class PluginsComponent implements OnInit { public templateCode:string = null; public template; public selectedPlacementView = "all"; + communityInfo:CommunityInfo = null; constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, + private communityService: CommunityService, private title: Title, private _helpContentService: HelpContentService, private _pluginsService: PluginsService, private _fb: UntypedFormBuilder, private _clearCacheService: ClearCacheService) { @@ -71,10 +75,15 @@ export class PluginsComponent implements OnInit { ngOnInit() { this.title.setTitle('Administrator Dashboard | Plugins'); + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe( + community => { + this.communityInfo = community; + })); 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.selectedCommunityPid = params.community; + this.subscriptions.push(this.route.queryParams.subscribe(params => { HelperFunctions.scroll(); this.selectedPageId = params['pageId']; @@ -147,6 +156,8 @@ export class PluginsComponent implements OnInit { plugin = new Plugin(this.selectedPageId, this.selectedCommunityPid,_); this.plugins.push(plugin); } + let defaultObj = PluginUtils.initializeObject(_.code); + plugin.object = PluginUtils.updateExistingObject(plugin.object, PluginUtils.updateExistingObject(_.object, defaultObj)) this.pluginsByPlacement.get(plugin.placement).push({plugin: plugin, template: _ }); }); for(let placement of this.pluginUtils.placementsOptions){ @@ -178,8 +189,16 @@ export class PluginsComponent implements OnInit { order: this._fb.control(plugin.order), active: this._fb.control(plugin.active), values: this._fb.array([]), - object: this._fb.group(plugin.object?plugin.object:(this.selectedTemplate.object?this.selectedTemplate.object:{})) + object: this._fb.group({}) }); + for (let attrKey of Object.keys(plugin.object)) { + if(attrKey.indexOf("Array")==-1) { + (this.templateForm.get("object") as FormGroup).addControl(attrKey, this._fb.control(plugin.object[attrKey])); + }else{ + (this.templateForm.get("object") as FormGroup).addControl(attrKey,this._fb.array(plugin.object[attrKey])); + } + } + if (template.settings) { for (let attrKey of Object.keys(template.settings)) { (this.templateForm.get("values") as FormArray).push(this._fb.group({ @@ -189,6 +208,7 @@ export class PluginsComponent implements OnInit { )); } } + console.log("aaa", this.templateForm.getRawValue()) } public newPluginSelectTemplate() { @@ -227,7 +247,7 @@ export class PluginsComponent implements OnInit { } - public saveConfirmed() { + public saveConfirmed(index) { this.showLoading = true; let plugin: Plugin = this.templateForm.getRawValue(); plugin.settingsValues = new Map(); @@ -235,7 +255,7 @@ export class PluginsComponent implements OnInit { plugin.settingsValues[fields.key] = fields.value; } let update = (plugin._id) ? true : false; - this.savePlugin(plugin,update, null) + this.savePlugin(plugin,update, this.index) } public savePlugin(plugin, update, index){ this.subscriptions.push(this._pluginsService.savePlugin(plugin, this.properties.adminToolsAPIURL).subscribe( @@ -251,6 +271,7 @@ export class PluginsComponent implements OnInit { } public savedSuccessfully(plugin: Plugin, update: boolean, index) { + console.log(plugin.placement, index, update) if (update) { this.pluginsByPlacement.get(plugin.placement)[index].plugin = plugin; } else { @@ -369,7 +390,16 @@ export class PluginsComponent implements OnInit { pluginFieldChanged($event:PluginEditEvent){ let object = this.templateForm.get("object").getRawValue(); object[$event.field]=$event.value; - this.templateForm.get("object").setValue(object); + if($event.field.indexOf("Array") == -1) { + this.templateForm.get("object").get($event.field).setValue($event.value); + }else{ + ((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).clear(); + $event.value.forEach(id => { + ((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).push(this._fb.control(id)) + }); + console.log(((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).getRawValue()); + + } this.templateForm.markAsDirty(); } diff --git a/dashboard/plugins/plugins.module.ts b/dashboard/plugins/plugins.module.ts index 2b181240..ca4fa834 100644 --- a/dashboard/plugins/plugins.module.ts +++ b/dashboard/plugins/plugins.module.ts @@ -24,16 +24,19 @@ import {PluginsService} from "../../services/plugins.service"; import {CKEditorModule} from "ng2-ckeditor"; import {MatSlideToggleModule} from "@angular/material/slide-toggle"; import {PluginWrapperModule} from "./wrapper/plugin-wrapper.module"; +import {SideBarModule} from "../sharedComponents/sidebar/sideBar.module"; +import {PluginEditWrapperModule} from "./wrapper/plugin-edit-wrapper.module"; + @NgModule({ imports: [ CommonModule, RouterModule, FormsModule, AlertModalModule, ReactiveFormsModule, AdminToolServiceModule, InputModule, MatAutocompleteModule, MatFormFieldModule, MatChipsModule, MatCheckboxModule, AdminTabsModule, PageContentModule, PluginsRoutingModule, SearchInputModule, IconsModule, LoadingModule, CKEditorModule, - MatSlideToggleModule, PluginWrapperModule + MatSlideToggleModule, PluginWrapperModule, SideBarModule, PluginEditWrapperModule ], providers:[PluginsService], - declarations: [PluginsComponent], + declarations: [PluginsComponent], exports: [PluginsComponent] }) export class PluginsModule {} diff --git a/dashboard/plugins/templates/pluginTemplates.component.html b/dashboard/plugins/templates/pluginTemplates.component.html index 02bafb62..a6fc90c7 100644 --- a/dashboard/plugins/templates/pluginTemplates.component.html +++ b/dashboard/plugins/templates/pluginTemplates.component.html @@ -43,41 +43,41 @@ class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
No templates found
--> -
+
{{placement.value}}
- - -
+
-
- - - +
{{template.name}}
- Page: {{getPageAsString(template.page)}} - - Placement: {{template.placement}} - - Order: {{template.order}} - -
-
- Portal type: {{template.portalType}} -
-
- Plan: {{template.plan}} + Plan: {{template.plan}} + Communities: {{template.portalSpecific.join(', ')}} + Default status: Active
{{template.description}}
- +
+ Page: {{getPageAsString(template.page)}} - + Placement: {{template.placement}} - + Order: {{template.order}} +
+
+ Portal type: {{template.portalType}} +
+
-
+ +
+
Plugin options
+ +
+
@@ -147,27 +153,12 @@
+
+
+
Default Status
-
@@ -206,6 +197,13 @@ +
+
+
Plugin preview
+ + +
+
diff --git a/dashboard/plugins/templates/pluginTemplates.component.ts b/dashboard/plugins/templates/pluginTemplates.component.ts index 9b6573e4..cb22a91d 100644 --- a/dashboard/plugins/templates/pluginTemplates.component.ts +++ b/dashboard/plugins/templates/pluginTemplates.component.ts @@ -1,7 +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, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators} from "@angular/forms"; +import {FormArray, FormGroup, 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"; @@ -26,10 +26,6 @@ import {PluginUtils} from "../utils/pluginUtils"; export class PluginTemplatesComponent implements OnInit { @ViewChild('editModal') editModal: AlertModal; @ViewChild('deleteModal') deleteModal: AlertModal; - /*public checkboxes: { - template: PluginTemplate; - checked: boolean; - }[] = [];*/ public templatesByPlacement: Map = new Map(); public templateForm: UntypedFormGroup; urlValidator: ValidatorFn = StringUtils.urlValidator; @@ -122,7 +118,8 @@ export class PluginTemplatesComponent implements OnInit { this.templatesByPlacement.set(pos.value,[]); } for(let template of templates){ - + let defaultObj = PluginUtils.initializeObject(template.code); + template.object = PluginUtils.updateExistingObject(template.object, defaultObj) this.templatesByPlacement.get(template.placement).push(template); } // this.checkboxes = []; @@ -136,20 +133,11 @@ export class PluginTemplatesComponent implements OnInit { error => this.handleError('System error retrieving classes', error))); } - /*public toggleCheckBoxes(event) { - this.checkboxes.forEach(_ => _.checked = event.target.checked); - }*/ - - /*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(); } public confirmDelete(template:PluginTemplate) { @@ -180,8 +168,6 @@ export class PluginTemplatesComponent implements OnInit { public edit(pluginTemplate) { this.selectedTemplate = pluginTemplate; - // this.pluginObject = Object.assign(this.templates[this.index].object); - // this.formPages = pluginTemplate.pages; this.templateForm = this._fb.group({ _id: this._fb.control(pluginTemplate._id), name: this._fb.control(pluginTemplate.name), @@ -191,11 +177,20 @@ export class PluginTemplatesComponent implements OnInit { code: this._fb.control(pluginTemplate.code, Validators.required), description: this._fb.control(pluginTemplate.description), plan: this._fb.control(pluginTemplate.plan, Validators.required), - placement: this._fb.control(pluginTemplate.placement), + placement: this._fb.control(pluginTemplate.placement, Validators.required), order: this._fb.control(pluginTemplate.order), + portalSpecific: this._fb.control(pluginTemplate.portalSpecific?pluginTemplate.portalSpecific.join(','):''), + defaultIsActive: this._fb.control(pluginTemplate.defaultIsActive), settings: this._fb.array([]), - object: this._fb.group(pluginTemplate.object ? pluginTemplate.object : {}) + object: this._fb.group({}) }); + for (let attrKey of Object.keys(pluginTemplate.object)) { + if(attrKey.indexOf("Array")==-1) { + (this.templateForm.get("object") as FormGroup).addControl(attrKey, this._fb.control(pluginTemplate.object[attrKey])); + }else{ + (this.templateForm.get("object") as FormGroup).addControl(attrKey,this._fb.array(pluginTemplate.object[attrKey])); + } + } this.templateForm.get('portalType').disable(); if (pluginTemplate.settings) { for (let attrKey of Object.keys(pluginTemplate.settings)) { @@ -224,8 +219,10 @@ export class PluginTemplatesComponent implements OnInit { description: this._fb.control(''), page: this._fb.control(this.page?this.getPageById(this.page):'', Validators.required), portalType: this._fb.control('community', Validators.required), - placement: this._fb.array([]), + placement: this._fb.control('', Validators.required), order: this._fb.control(''), + portalSpecific: this._fb.control(''), + defaultIsActive: this._fb.control(false), settings: this._fb.array([]), object: this._fb.control({}) }); @@ -263,7 +260,7 @@ export class PluginTemplatesComponent implements OnInit { this.showLoading = true; let template: PluginTemplate = this.templateForm.getRawValue(); template.page = this.templateForm.getRawValue().page._id - template.placement = this.templateForm.getRawValue().placement[0]; + template.portalSpecific = this.templateForm.getRawValue().portalSpecific.length > 0? this.templateForm.getRawValue().portalSpecific.split(','):[]; template.settings = new Map(); if(!template._id){ template.order = this.templatesByPlacement.get(template.placement).length > 0 ? this.templatesByPlacement.get(template.placement).length:0; @@ -290,6 +287,8 @@ export class PluginTemplatesComponent implements OnInit { // TODO sort // this.templatesByPlacement.get(this.selectedTemplate.placement) = this.templatesByPlacement.get(this.selectedTemplate.placement).sort() } else { + let defaultObj = PluginUtils.initializeObject(template.code); + template.object = PluginUtils.updateExistingObject(template.object, defaultObj) this.templatesByPlacement.get(this.selectedTemplate.placement).push(template); } @@ -396,13 +395,23 @@ export class PluginTemplatesComponent implements OnInit { return pageId; } - pluginFieldChanged($event: PluginEditEvent) { - let object = this.templateForm.get("object").getRawValue(); - object[$event.field] = $event.value; - this.templateForm.get("object").setValue(object); + + pluginFieldChanged($event:PluginEditEvent){ + console.log($event) + // let object = this.templateForm.get("object").getRawValue(); + // object[$event.field]=$event.value; + if($event.field.indexOf("Array") == -1) { + this.templateForm.get("object").get($event.field).setValue($event.value); + }else{ + ((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).clear(); + $event.value.forEach(id => { + ((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).push(this._fb.control(id)) + }); + console.log(((this.templateForm.get("object") as FormGroup).get($event.field) as FormArray).getRawValue()); + + } this.templateForm.markAsDirty(); } - public getPagesByPortal(portal) { return this.allPages.filter(option => option.value.portalType == portal); } diff --git a/dashboard/plugins/templates/pluginTemplates.module.ts b/dashboard/plugins/templates/pluginTemplates.module.ts index 4ef8ddb2..4790450a 100644 --- a/dashboard/plugins/templates/pluginTemplates.module.ts +++ b/dashboard/plugins/templates/pluginTemplates.module.ts @@ -23,12 +23,14 @@ import {LoadingModule} from "../../../utils/loading/loading.module"; import {PluginsService} from "../../../services/plugins.service"; import {CKEditorModule} from "ng2-ckeditor"; import {PluginWrapperModule} from "../wrapper/plugin-wrapper.module"; +import {PluginEditWrapperModule} from "../wrapper/plugin-edit-wrapper.module"; +import {MatSlideToggleModule} from "@angular/material/slide-toggle"; @NgModule({ imports: [ CommonModule, RouterModule, FormsModule, AlertModalModule, ReactiveFormsModule, AdminToolServiceModule, InputModule, MatAutocompleteModule, MatFormFieldModule, MatChipsModule, - MatCheckboxModule, AdminTabsModule, PageContentModule, PluginTemplatesRoutingModule, SearchInputModule, IconsModule, LoadingModule, CKEditorModule, PluginWrapperModule + MatCheckboxModule, AdminTabsModule, PageContentModule, PluginTemplatesRoutingModule, SearchInputModule, IconsModule, LoadingModule, CKEditorModule, PluginWrapperModule, PluginEditWrapperModule, MatSlideToggleModule ], providers:[PluginsService], declarations: [PluginTemplatesComponent], diff --git a/dashboard/plugins/utils/base-plugin.component.ts b/dashboard/plugins/utils/base-plugin.component.ts index e607fba2..b4675816 100644 --- a/dashboard/plugins/utils/base-plugin.component.ts +++ b/dashboard/plugins/utils/base-plugin.component.ts @@ -7,27 +7,58 @@ import {Subscriber} from "rxjs"; export class PluginEditEvent { field:string; - type:"text" | "HTML" | "boolean"; + type:"text" | "HTML" | "boolean" | 'parent'; value?:any; } + +export class PluginBaseInfo { + title: string = "Lorem ipsum"; + constructor() { + } +} +export class PluginURL { + url:string; + linkText:string; + target:string; + constructor(url,linkText, target = "_blank") { + this.url = url; + this.linkText = linkText; + this.target = target; + } + +} + +export class PluginInfoCards{ + title:string; + description:string; + urls:PluginURL[]; + image?:string; + show:boolean; +} @Directive() - export abstract class PluginBaseComponent implements OnDestroy { + export abstract class PluginBaseComponent implements OnDestroy { public properties: EnvProperties = properties; @Input() editMode =false; @Input() plugin:Plugin; @Input() pluginTemplate:PluginTemplate; @Input() editTemplate:boolean = false; + @Input() pluginObject:T; @Output() valuesChanged:EventEmitter = new EventEmitter(); subscriptions = []; pluginEditEvent:PluginEditEvent; + /*default:T;*/ constructor() { } ngOnInit(): void { + // console.log(this.default) + /*if (this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title) && this.default) { + this.pluginTemplate.object = Object.assign(this.default); + }*/ } - ngOnDestroy() { + ngOnDestroy() { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { subscription.unsubscribe() @@ -43,18 +74,22 @@ export class PluginEditEvent { valueChanged($event:PluginEditEvent){ if(this.editTemplate){ this.pluginTemplate.object[$event.field]=$event.value; + this.pluginObject[$event.field]=$event.value; }else{ this.plugin.object[$event.field]=$event.value; } this.valuesChanged.emit($event) } - showOnOffBlock(field){ - return (this.editTemplate /* edit template*/ - || (this.editMode && !this.editTemplate) /* edit plugin*/ - || (this.plugin && this.plugin.object && this.plugin.object[field] == true) /* is on anyway */ - || (!this.plugin)) /* is not plugin view */ + isVisible(field){ + return (this.plugin && this.plugin.object && this.plugin.object[field] == true) /* plugin is on anyway */ + || (!this.plugin && this.pluginTemplate && this.pluginTemplate.object && this.pluginTemplate.object[field] == true) /* template is on */ } - + /*get pluginObject():T{ + return this.plugin?this.plugin.object:null; + } + get pluginDefaultObject():T{ + return this.pluginTemplate?this.pluginTemplate.object:null; + }*/ } diff --git a/dashboard/plugins/utils/plugin-field-edit.component.ts b/dashboard/plugins/utils/plugin-field-edit.component.ts index dc91d72d..65dd9eb2 100644 --- a/dashboard/plugins/utils/plugin-field-edit.component.ts +++ b/dashboard/plugins/utils/plugin-field-edit.component.ts @@ -6,16 +6,15 @@ import {PluginEditEvent} from "./base-plugin.component"; selector: 'plugin-field-edit', template: ` - {{value}} - Edit + - close -
-
+ + +