Add more types to the charging stations theme, better merge if translations already exist
This commit is contained in:
parent
e18eb06f14
commit
204b431df0
6 changed files with 851 additions and 38 deletions
|
@ -258,7 +258,7 @@ export class InitUiElements {
|
||||||
|
|
||||||
new Combine([
|
new Combine([
|
||||||
"Error: could not parse the custom layout:",
|
"Error: could not parse the custom layout:",
|
||||||
e,
|
new FixedUiElement(""+e).SetClass("alert"),
|
||||||
new SubtleButton("./assets/svg/mapcomplete_logo.svg",
|
new SubtleButton("./assets/svg/mapcomplete_logo.svg",
|
||||||
"Go back to the theme overview",
|
"Go back to the theme overview",
|
||||||
{url: window.location.protocol+"//"+ window.location.hostname+"/index.html", newTab: false})
|
{url: window.location.protocol+"//"+ window.location.hostname+"/index.html", newTab: false})
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
||||||
|
|
||||||
export default class Constants {
|
export default class Constants {
|
||||||
|
|
||||||
public static vNumber = "0.9.12";
|
public static vNumber = "0.9.13";
|
||||||
|
|
||||||
// The user journey states thresholds when a new feature gets unlocked
|
// The user journey states thresholds when a new feature gets unlocked
|
||||||
public static userJourney = {
|
public static userJourney = {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -93,8 +93,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "Who is allowed to use this charging station?",
|
"#": "access",
|
||||||
"render": "Access is {access}",
|
"question": {
|
||||||
|
"en": "Who is allowed to use this charging station?"
|
||||||
|
},
|
||||||
|
"render": {
|
||||||
|
"en": "Access is {access}"
|
||||||
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "access",
|
"key": "access",
|
||||||
"addExtraTags": [
|
"addExtraTags": [
|
||||||
|
@ -141,7 +146,7 @@
|
||||||
"type": "pnat"
|
"type": "pnat"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
$$$
|
{"#": "$$$"},
|
||||||
{
|
{
|
||||||
"#": "Authentication",
|
"#": "Authentication",
|
||||||
"question": {
|
"question": {
|
||||||
|
@ -311,6 +316,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"#": "payment-options",
|
||||||
"builtin": "payment-options",
|
"builtin": "payment-options",
|
||||||
"override": {
|
"override": {
|
||||||
"condition": {
|
"condition": {
|
||||||
|
@ -395,8 +401,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"#": "Operator",
|
"#": "Operator",
|
||||||
"question": "Who is the operator of this charging station?",
|
"question": {
|
||||||
"render": "This charging station is operated by {operator}",
|
"en": "Who is the operator of this charging station?"
|
||||||
|
},
|
||||||
|
"render": {
|
||||||
|
"en": "This charging station is operated by {operator}"
|
||||||
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "operator"
|
"key": "operator"
|
||||||
},
|
},
|
||||||
|
@ -407,7 +417,9 @@
|
||||||
"network:={operator}"
|
"network:={operator}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"then": "Actually, {operator} is the network",
|
"then": {
|
||||||
|
"en": "Actually, {operator} is the network"
|
||||||
|
},
|
||||||
"addExtraTags": [
|
"addExtraTags": [
|
||||||
"operator="
|
"operator="
|
||||||
],
|
],
|
||||||
|
@ -460,7 +472,9 @@
|
||||||
"question": {
|
"question": {
|
||||||
"en": "What is the reference number of this charging station?"
|
"en": "What is the reference number of this charging station?"
|
||||||
},
|
},
|
||||||
"render": "Reference number is <b>{ref}</b>",
|
"render": {
|
||||||
|
"en": "Reference number is <b>{ref}</b>"
|
||||||
|
},
|
||||||
"freeform": {
|
"freeform": {
|
||||||
"key": "ref"
|
"key": "ref"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {readFileSync, writeFileSync} from "fs";
|
||||||
import {Utils} from "../../../Utils";
|
import {Utils} from "../../../Utils";
|
||||||
import {TagRenderingConfigJson} from "../../../Models/ThemeConfig/Json/TagRenderingConfigJson";
|
import {TagRenderingConfigJson} from "../../../Models/ThemeConfig/Json/TagRenderingConfigJson";
|
||||||
import ScriptUtils from "../../../scripts/ScriptUtils";
|
import ScriptUtils from "../../../scripts/ScriptUtils";
|
||||||
|
import {LayerConfigJson} from "../../../Models/ThemeConfig/Json/LayerConfigJson";
|
||||||
|
|
||||||
|
|
||||||
function colonSplit(value: string): string[] {
|
function colonSplit(value: string): string[] {
|
||||||
|
@ -13,6 +14,7 @@ function loadCsv(file): {
|
||||||
image: string,
|
image: string,
|
||||||
description: Map<string, string>,
|
description: Map<string, string>,
|
||||||
countryWhiteList?: string[],
|
countryWhiteList?: string[],
|
||||||
|
countryBlackList?: string[],
|
||||||
commonVoltages?: number[],
|
commonVoltages?: number[],
|
||||||
commonCurrents?: number[],
|
commonCurrents?: number[],
|
||||||
commonOutputs?: string[]
|
commonOutputs?: string[]
|
||||||
|
@ -27,7 +29,7 @@ function loadCsv(file): {
|
||||||
}
|
}
|
||||||
|
|
||||||
const v = {}
|
const v = {}
|
||||||
const colonSeperated = ["commonVoltages", "commonOutputs", "commonCurrents", "countryWhiteList"]
|
const colonSeperated = ["commonVoltages", "commonOutputs", "commonCurrents", "countryWhiteList","countryBlackList"]
|
||||||
const descriptionTranslations = new Map<string, string>()
|
const descriptionTranslations = new Map<string, string>()
|
||||||
for (let j = 0; j < header.length; j++) {
|
for (let j = 0; j < header.length; j++) {
|
||||||
const key = header[j];
|
const key = header[j];
|
||||||
|
@ -51,7 +53,7 @@ function loadCsv(file): {
|
||||||
function run(file, protojson) {
|
function run(file, protojson) {
|
||||||
|
|
||||||
const overview_question_answers = []
|
const overview_question_answers = []
|
||||||
const questions: TagRenderingConfigJson[] = []
|
const questions: (TagRenderingConfigJson & {"#": string})[] = []
|
||||||
const filterOptions: { question: any, osmTags?: string } [] = [
|
const filterOptions: { question: any, osmTags?: string } [] = [
|
||||||
{
|
{
|
||||||
question: {
|
question: {
|
||||||
|
@ -62,7 +64,8 @@ function run(file, protojson) {
|
||||||
]
|
]
|
||||||
|
|
||||||
const entries = loadCsv(file)
|
const entries = loadCsv(file)
|
||||||
for (const e of entries) {
|
for (let i = 0; i < entries.length; i++){
|
||||||
|
const e = entries[i];
|
||||||
const txt = {
|
const txt = {
|
||||||
en: `<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${e.image}'/> ${e.description.get("en")}`,
|
en: `<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${e.image}'/> ${e.description.get("en")}`,
|
||||||
nl: `<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${e.image}'/> ${e.description.get("nl")}`
|
nl: `<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${e.image}'/> ${e.description.get("nl")}`
|
||||||
|
@ -73,9 +76,15 @@ function run(file, protojson) {
|
||||||
then: txt,
|
then: txt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.countryWhiteList !== undefined && e.countryWhiteList.length > 0) {
|
if(e.countryWhiteList.length > 0 && e.countryBlackList.length > 0){
|
||||||
|
throw "Error for type "+e.key+": don't defined both a whitelist and a blacklist"
|
||||||
|
}
|
||||||
|
if (e.countryWhiteList.length > 0) {
|
||||||
const countries = e.countryWhiteList.map(country => "_country!=" + country) //HideInAnswer if it is in the wrong country
|
const countries = e.countryWhiteList.map(country => "_country!=" + country) //HideInAnswer if it is in the wrong country
|
||||||
json["hideInAnswer"] = {or: countries}
|
json["hideInAnswer"] = {or: countries}
|
||||||
|
}else if (e.countryBlackList .length > 0) {
|
||||||
|
const countries = e.countryBlackList.map(country => "_country=" + country) //HideInAnswer if it is in the wrong country
|
||||||
|
json["hideInAnswer"] = {or: countries}
|
||||||
}
|
}
|
||||||
|
|
||||||
overview_question_answers.push(json)
|
overview_question_answers.push(json)
|
||||||
|
@ -94,6 +103,7 @@ function run(file, protojson) {
|
||||||
const descrWithImage_nl = `<b>${e.description.get("nl")}</b> <img style='width:1rem;' src='./assets/layers/charging_station/${e.image}'/>`
|
const descrWithImage_nl = `<b>${e.description.get("nl")}</b> <img style='width:1rem;' src='./assets/layers/charging_station/${e.image}'/>`
|
||||||
|
|
||||||
questions.push({
|
questions.push({
|
||||||
|
"#":"plugs-"+i,
|
||||||
question: {
|
question: {
|
||||||
en: `How much plugs of type ${descrWithImage_en} are available here?`,
|
en: `How much plugs of type ${descrWithImage_en} are available here?`,
|
||||||
nl: `Hoeveel stekkers van type ${descrWithImage_nl} heeft dit oplaadpunt?`,
|
nl: `Hoeveel stekkers van type ${descrWithImage_nl} heeft dit oplaadpunt?`,
|
||||||
|
@ -112,6 +122,7 @@ function run(file, protojson) {
|
||||||
})
|
})
|
||||||
|
|
||||||
questions.push({
|
questions.push({
|
||||||
|
"#":"voltage-"+i,
|
||||||
question: {
|
question: {
|
||||||
en: `What voltage do the plugs with ${descrWithImage_en} offer?`,
|
en: `What voltage do the plugs with ${descrWithImage_en} offer?`,
|
||||||
nl: `Welke spanning levert de stekker van type ${descrWithImage_nl}`
|
nl: `Welke spanning levert de stekker van type ${descrWithImage_nl}`
|
||||||
|
@ -140,6 +151,7 @@ function run(file, protojson) {
|
||||||
|
|
||||||
|
|
||||||
questions.push({
|
questions.push({
|
||||||
|
"#":"current-"+i,
|
||||||
question: {
|
question: {
|
||||||
en: `What current do the plugs with ${descrWithImage_en} offer?`,
|
en: `What current do the plugs with ${descrWithImage_en} offer?`,
|
||||||
nl: `Welke stroom levert de stekker van type ${descrWithImage_nl}?`,
|
nl: `Welke stroom levert de stekker van type ${descrWithImage_nl}?`,
|
||||||
|
@ -168,6 +180,7 @@ function run(file, protojson) {
|
||||||
|
|
||||||
|
|
||||||
questions.push({
|
questions.push({
|
||||||
|
"#":"power-output-"+i,
|
||||||
question: {
|
question: {
|
||||||
en: `What power output does a single plug of type ${descrWithImage_en} offer?`,
|
en: `What power output does a single plug of type ${descrWithImage_en} offer?`,
|
||||||
nl: `Welk vermogen levert een enkele stekker van type ${descrWithImage_nl}?`,
|
nl: `Welk vermogen levert een enkele stekker van type ${descrWithImage_nl}?`,
|
||||||
|
@ -204,6 +217,7 @@ function run(file, protojson) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggles = {
|
const toggles = {
|
||||||
|
"#":"Available_charging_stations (generated)",
|
||||||
"question": {
|
"question": {
|
||||||
"en": "Which charging stations are available here?"
|
"en": "Which charging stations are available here?"
|
||||||
},
|
},
|
||||||
|
@ -213,9 +227,20 @@ function run(file, protojson) {
|
||||||
questions.unshift(toggles)
|
questions.unshift(toggles)
|
||||||
|
|
||||||
const stringified = questions.map(q => JSON.stringify(q, null, " "))
|
const stringified = questions.map(q => JSON.stringify(q, null, " "))
|
||||||
let proto = readFileSync(protojson, "utf8")
|
let protoString = readFileSync(protojson, "utf8")
|
||||||
proto = proto.replace("$$$", stringified.join(",\n") + ",")
|
|
||||||
proto = JSON.parse(proto)
|
protoString = protoString.replace("{\"#\": \"$$$\"}", stringified.join(",\n"))
|
||||||
|
const proto = <LayerConfigJson> JSON.parse(protoString)
|
||||||
|
proto.tagRenderings.forEach(tr => {
|
||||||
|
if(typeof tr === "string"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(tr["#"] === undefined || typeof tr["#"] !== "string"){
|
||||||
|
console.error(tr)
|
||||||
|
throw "Every tagrendering should have an id, acting as comment"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
proto["filter"].push({
|
proto["filter"].push({
|
||||||
options: filterOptions
|
options: filterOptions
|
||||||
})
|
})
|
||||||
|
@ -274,7 +299,8 @@ function run(file, protojson) {
|
||||||
}
|
}
|
||||||
proto["units"].push(...extraUnits)
|
proto["units"].push(...extraUnits)
|
||||||
|
|
||||||
writeFileSync("charging_station.json", JSON.stringify(proto, undefined, " "))
|
mergeTranslations("charging_station.json",proto)
|
||||||
|
writeFileSync("charging_station.json", JSON.stringify(proto, undefined, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,22 +328,51 @@ async function queryTagInfo(file, type, clean: ((s: string) => string)) {
|
||||||
}
|
}
|
||||||
const countsArray = Array.from(counts.keys())
|
const countsArray = Array.from(counts.keys())
|
||||||
countsArray.sort()
|
countsArray.sort()
|
||||||
// console.log(`${e.key}:${type} = ${countsArray.join(";")}`)
|
console.log(`${e.key}:${type} = ${countsArray.join(";")}`)
|
||||||
console.log(`${countsArray.join(";")}`)
|
// console.log(`${countsArray.join(";")}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the translations into the 'newConfig' object
|
||||||
|
* @param origPath
|
||||||
|
* @param newConfig
|
||||||
|
*/
|
||||||
|
function mergeTranslations(origPath, newConfig: LayerConfigJson){
|
||||||
|
const oldFile = <LayerConfigJson> JSON.parse(readFileSync(origPath, "utf-8"))
|
||||||
|
const newFile =<LayerConfigJson> newConfig
|
||||||
|
const renderingsOld = oldFile.tagRenderings
|
||||||
|
delete oldFile.tagRenderings
|
||||||
|
const newRenderings = newFile.tagRenderings
|
||||||
|
Utils.Merge(oldFile, newFile)
|
||||||
|
|
||||||
|
for (const oldRendering of renderingsOld) {
|
||||||
|
|
||||||
|
const oldRenderingName = oldRendering["#"]
|
||||||
|
if(oldRenderingName === undefined){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const applicable = newRenderings.filter(r => r["#"] === oldRenderingName)[0]
|
||||||
|
if(applicable === undefined){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Utils.Merge(oldRendering, applicable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
run("types.csv", "charging_station.protojson")
|
run("types.csv", "charging_station.protojson")
|
||||||
// queryTagInfo("types.csv","voltage", true)
|
/*/
|
||||||
// queryTagInfo("types.csv", "current", true)
|
queryTagInfo("types.csv","voltage", s => s.trim())
|
||||||
/* queryTagInfo("types.csv", "output", s => {
|
queryTagInfo("types.csv", "current", s => s.trim())
|
||||||
|
queryTagInfo("types.csv", "output", s => {
|
||||||
if(s.endsWith("kW")){
|
if(s.endsWith("kW")){
|
||||||
s = s.substring(0, s.length - 2)
|
s = s.substring(0, s.length - 2)
|
||||||
}
|
}
|
||||||
s = s.trim()
|
s = s.trim()
|
||||||
return s + " kW"
|
return s + " kW"
|
||||||
})*/
|
})
|
||||||
|
//*/
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
key,image,description:en,countryWhitelist,commonVoltages,commonCurrents,commonOutputs,description:nl
|
key,image,description:en,countryWhiteList,countryBlackList,commonVoltages,commonCurrents,commonOutputs,description:nl
|
||||||
socket:schuko,CEE7_4F.svg,<b>Schuko wall plug</b> without ground pin (CEE7/4 type F),be;fr;ma;tn;pl;cs;sk;mo,230,16,3.6 kW,<b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)
|
socket:schuko,CEE7_4F.svg,<b>Schuko wall plug</b> without ground pin (CEE7/4 type F),be;fr;ma;tn;pl;cs;sk;mo,,230,16,3.6 kW,<b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)
|
||||||
socket:typee,TypeE.svg,<b>European wall plug</b> with ground pin (CEE7/4 type E),,230,16,3 kW;22 kW;,<b>Europese stekker</b> met aardingspin (CEE7/4 type E)
|
socket:typee,TypeE.svg,<b>European wall plug</b> with ground pin (CEE7/4 type E),,,230,16,3 kW;22 kW;,<b>Europese stekker</b> met aardingspin (CEE7/4 type E)
|
||||||
socket:chademo,Chademo_type4.svg,<b>Chademo</b>,,500,120,50 kW,
|
socket:chademo,Chademo_type4.svg,<b>Chademo</b>,,,500,120,50 kW,
|
||||||
socket:type1_cable,Type1_J1772.svg,<b>Type 1 with cable</b> (J1772),,200;240,32,3.7 kW;7 kW,<b>Type 1 met kabel</b> (J1772)
|
socket:type1_cable,Type1_J1772.svg,<b>Type 1 with cable</b> (J1772),,,200;240,32,3.7 kW;7 kW,<b>Type 1 met kabel</b> (J1772)
|
||||||
socket:type1,Type1_J1772.svg,<b>Type 1 <i>without</i> cable</b> (J1772),,200;240,32,3.7 kW;6.6 kW;7 kW;7.2 kW,<b>Type 1 <i>zonder</i> kabel</b> (J1772)
|
socket:type1,Type1_J1772.svg,<b>Type 1 <i>without</i> cable</b> (J1772),,,200;240,32,3.7 kW;6.6 kW;7 kW;7.2 kW,<b>Type 1 <i>zonder</i> kabel</b> (J1772)
|
||||||
socket:type1_combo,Type1-ccs.svg,<b>Type 1 CCS</b> (aka Type 1 Combo),,400;1000,50;125,50 kW;62.5 kW;150 kW;350 kW;,
|
socket:type1_combo,Type1-ccs.svg,<b>Type 1 CCS</b> (aka Type 1 Combo),,,400;1000,50;125,50 kW;62.5 kW;150 kW;350 kW;,
|
||||||
socket:tesla_supercharger,Tesla-hpwc-model-s.svg,<b>Tesla Supercharger</b>,,480,125;350,120 kW;150 kW;250 kW,
|
socket:tesla_supercharger,Tesla-hpwc-model-s.svg,<b>Tesla Supercharger</b>,,,480,125;350,120 kW;150 kW;250 kW,
|
||||||
socket:type2,Type2_socket.svg,<b>Type 2</b> (mennekes),,230;400,16;32,11 kW;22 kW,
|
socket:type2,Type2_socket.svg,<b>Type 2</b> (mennekes),,,230;400,16;32,11 kW;22 kW,
|
||||||
socket:type2_combo,Type2_CCS.svg,<b>Type 2 CCS</b> (mennekes),,500;920,125;350,50 kW,
|
socket:type2_combo,Type2_CCS.svg,<b>Type 2 CCS</b> (mennekes),,,500;920,125;350,50 kW,
|
||||||
|
socket:type2_cable,Type2_tethered.svg,<b>Type 2 with cable</b> (mennekes),,,230;400,16;32,11 kW;22 kW,<b>Type 2 met kabel</b> (J1772)
|
||||||
|
socket:tesla_supercharger_ccs,Type2_CCS.svg,<b>Tesla Supercharger CCS</b> (a branded type2_css),,,500;920,125;350,50 kW,
|
||||||
|
socket:tesla_destination,Tesla-hpwc-model-s.svg,<b>Tesla Supercharger (destination)</b>,us,,480,125;350,120 kW;150 kW;250 kW,
|
||||||
|
socket:tesla_destination,Type2_tethered.svg,<b>Tesla supercharger (destination</b> (A Type 2 with cable branded as tesla),,us,230;400,16;32,11 kW;22 kW,
|
||||||
|
|
|
Loading…
Reference in a new issue