106 lines
4.4 KiB
TypeScript
106 lines
4.4 KiB
TypeScript
import {Option} from "../../../sharedComponents/input/input.component";
|
|
import {PluginOpenAIREProducts} from "../components/openaireProducts/plugin-openaire-products.component";
|
|
import {PluginDiscoverBySubcommunity} from "../components/discover-by-subcommunity/plugin-discover-by-subcommunity.component";
|
|
import {PluginBaseInfo} from "./base-plugin.component";
|
|
import {PluginGatewayInformation} from "../components/gateway-information/plugin-gateway-information.component";
|
|
import {PluginLearnAndConnect} from "../components/learn-and-connect/plugin-learn-and-connect.component";
|
|
import {PluginFeaturedDatasets} from "../components/featured-datasets/plugin-featured-datasets.component";
|
|
import {PluginHowToUse} from "../components/how-to-use/plugin-how-to-use.component";
|
|
import {PluginSearchDepositLink} from "../components/search-deposit-link/plugin-search-deposit-link.component";
|
|
import {PluginOrganizations} from "../components/organizations/plugin-organizations.component";
|
|
import {PluginSuggestedRepositories} from "../components/suggested-repositories/plugin-suggested-repositories.component";
|
|
import {PluginGraphInfo} from "../components/graph-info/plugin-graph-info.component";
|
|
import {PluginStats} from "../components/stats/plugin-stats.component";
|
|
|
|
export class PluginUtils{
|
|
public attrTypeOptions: Option[] = [
|
|
{label:"Text", value:"text"},
|
|
{label:"HTML", value:"HTML"},
|
|
{label:"Boolean", value:"boolean"},
|
|
{label:"URL", value:"URL"},
|
|
];
|
|
|
|
public availablePluginCodesOptions: Option[] = [
|
|
{label:"OpenAIRE products", value:"openaire-products"},
|
|
{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"},
|
|
{label:"Organizations", value:"organizations"},
|
|
{label:"Graph info", value:"graph-info"},
|
|
{label:"Statistics", value:"stats"},
|
|
];
|
|
public availablePluginCodes: string[] = ["openaire-products", "discover-by-subcommunity", "gateway-information", "search-deposit-link", "learn-and-connect", "how-to-use", "suggested-repositories", "featured-datasets", "organizations", "graph-info", "organizations", "stats"
|
|
];
|
|
public placementsOptions: Option[] = [
|
|
{label:"Right", value:"right"},
|
|
{label:"Top", value:"top"},
|
|
// {label:"Top Right", value:"top-right"},
|
|
// {label:"Center", value:"center"},
|
|
{label:"Bottom", value:"bottom"},
|
|
{label:"Left", value:"left"},
|
|
];
|
|
public planOptions: Option[] = [
|
|
{value: 'starter', label: 'Starter'},
|
|
{value: 'extended', label: 'Extended'}
|
|
];
|
|
|
|
|
|
public static initializeObjectAndCompare(code, oldObject = null){
|
|
switch(code) {
|
|
case 'openaire-products': {
|
|
return (new PluginOpenAIREProducts()).compare(oldObject);
|
|
}
|
|
case 'discover-by-subcommunity': {
|
|
return (new PluginDiscoverBySubcommunity()).compare(oldObject);
|
|
}
|
|
case 'gateway-information': {
|
|
return (new PluginGatewayInformation()).compare(oldObject);
|
|
}
|
|
case 'search-deposit-link': {
|
|
return (new PluginSearchDepositLink()).compare(oldObject);
|
|
}
|
|
case 'learn-and-connect': {
|
|
return (new PluginLearnAndConnect()).compare(oldObject);
|
|
}
|
|
case 'how-to-use': {
|
|
return (new PluginHowToUse()).compare(oldObject);
|
|
}
|
|
case 'suggested-repositories': {
|
|
return (new PluginSuggestedRepositories()).compare(oldObject);
|
|
}
|
|
case 'featured-datasets': {
|
|
return (new PluginFeaturedDatasets()).compare(oldObject);
|
|
}
|
|
case 'organizations': {
|
|
return (new PluginOrganizations()).compare(oldObject);
|
|
}
|
|
case 'graph-info': {
|
|
return (new PluginGraphInfo()).compare(oldObject);
|
|
}
|
|
case 'stats': {
|
|
return (new PluginStats()).compare(oldObject);
|
|
}
|
|
default: {
|
|
return (new PluginBaseInfo()).compare(oldObject);
|
|
}
|
|
}
|
|
}
|
|
//
|
|
public static updateExistingObject(oldObject, object ){
|
|
if(!oldObject) {
|
|
oldObject = Object.assign(object)
|
|
}else{
|
|
for (let attrKey of Object.keys(object)) {
|
|
if (!oldObject[attrKey] && oldObject[attrKey] != false) {
|
|
oldObject[attrKey] = Object.assign(object[attrKey])
|
|
}
|
|
}
|
|
}
|
|
return oldObject;
|
|
}
|
|
}
|