feat: Implement Polish translation for UI elements and properties in ObjectFlowDesigner
This commit is contained in:
524
script.js
524
script.js
@@ -1,3 +1,273 @@
|
|||||||
|
// Polish translation system
|
||||||
|
const translations = {
|
||||||
|
en: {
|
||||||
|
// UI Elements
|
||||||
|
"Power System Designer": "Power System Designer",
|
||||||
|
"Calculate Voltage Drops": "Calculate Voltage Drops",
|
||||||
|
"Clear All": "Clear All",
|
||||||
|
"Export Data": "Export Data",
|
||||||
|
"Import Data": "Import Data",
|
||||||
|
"Objects": "Objects",
|
||||||
|
"Transformer": "Transformer",
|
||||||
|
"Cable Box": "Cable Box",
|
||||||
|
"Pole": "Pole",
|
||||||
|
"End Connection": "End Connection",
|
||||||
|
"Cables": "Cables",
|
||||||
|
"Underground Cable": "Underground Cable",
|
||||||
|
"Overhead Cable": "Overhead Cable",
|
||||||
|
"Tools": "Tools",
|
||||||
|
"Select Mode": "Select Mode",
|
||||||
|
"Delete Mode": "Delete Mode",
|
||||||
|
"Auto Arrange - One Click to Make Everything Look Nice and Tidy": "Auto Arrange - One Click to Make Everything Look Nice and Tidy",
|
||||||
|
"Properties": "Properties",
|
||||||
|
"No object selected": "No object selected",
|
||||||
|
|
||||||
|
// Object Properties
|
||||||
|
"Transformer Properties": "Transformer Properties",
|
||||||
|
"Number:": "Number:",
|
||||||
|
"Name:": "Name:",
|
||||||
|
"Upper Voltage (V):": "Upper Voltage (V):",
|
||||||
|
"Bottom Voltage (V):": "Bottom Voltage (V):",
|
||||||
|
"Power (kVA):": "Power (kVA):",
|
||||||
|
"Description:": "Description:",
|
||||||
|
"Transformer Info": "Transformer Info",
|
||||||
|
"Type:": "Type:",
|
||||||
|
"ID:": "ID:",
|
||||||
|
"Position:": "Position:",
|
||||||
|
"Ratio:": "Ratio:",
|
||||||
|
"Outputs:": "Outputs:",
|
||||||
|
"Actions": "Actions",
|
||||||
|
"Delete Transformer": "Delete Transformer",
|
||||||
|
|
||||||
|
// Node Properties
|
||||||
|
"Node Properties": "Node Properties",
|
||||||
|
"Box": "Box",
|
||||||
|
"End": "End",
|
||||||
|
"Enter type description": "Enter type description",
|
||||||
|
"3-Phase Consumers (7kW each):": "3-Phase Consumers (7kW each):",
|
||||||
|
"1-Phase Consumers (3kW each):": "1-Phase Consumers (3kW each):",
|
||||||
|
"Custom Power (kW):": "Custom Power (kW):",
|
||||||
|
"Node Info": "Node Info",
|
||||||
|
"Total Power:": "Total Power:",
|
||||||
|
"3-Phase:": "3-Phase:",
|
||||||
|
"consumers": "consumers",
|
||||||
|
"1-Phase:": "1-Phase:",
|
||||||
|
"Custom:": "Custom:",
|
||||||
|
"Inputs:": "Inputs:",
|
||||||
|
"Delete Node": "Delete Node",
|
||||||
|
|
||||||
|
// Cable Properties
|
||||||
|
"Power Cable Properties": "Power Cable Properties",
|
||||||
|
"Label:": "Label:",
|
||||||
|
"Cable Type:": "Cable Type:",
|
||||||
|
"YAKY (Ground Cable)": "YAKY (Ground Cable)",
|
||||||
|
"NA2XY-J (Ground Cable)": "NA2XY-J (Ground Cable)",
|
||||||
|
"AL (Overhead Cable)": "AL (Overhead Cable)",
|
||||||
|
"AsXSn (Overhead Cable)": "AsXSn (Overhead Cable)",
|
||||||
|
"Cross Section (mm²):": "Cross Section (mm²):",
|
||||||
|
"Length (m):": "Length (m):",
|
||||||
|
"Cable Info": "Cable Info",
|
||||||
|
"From:": "From:",
|
||||||
|
"To:": "To:",
|
||||||
|
"Specifications:": "Specifications:",
|
||||||
|
"Section Resistance:": "Section Resistance:",
|
||||||
|
"Section Current:": "Section Current:",
|
||||||
|
"Voltage Drop:": "Voltage Drop:",
|
||||||
|
"Total Consumers:": "Total Consumers:",
|
||||||
|
"Diversity Factor:": "Diversity Factor:",
|
||||||
|
"⚠️ Overhead cables can only connect to poles or end connections!": "⚠️ Overhead cables can only connect to poles or end connections!",
|
||||||
|
"Delete Cable": "Delete Cable",
|
||||||
|
|
||||||
|
// Error Messages
|
||||||
|
"Cannot connect object to itself!": "Cannot connect object to itself!",
|
||||||
|
"Connection already exists!": "Connection already exists!",
|
||||||
|
"Transformer can only have one outgoing connection!": "Transformer can only have one outgoing connection!",
|
||||||
|
"Node can only have one incoming connection!": "Node can only have one incoming connection!",
|
||||||
|
"End connections cannot have outgoing connections!": "End connections cannot have outgoing connections!",
|
||||||
|
"Cannot connect from end connections!": "Cannot connect from end connections!",
|
||||||
|
"Cannot connect from node to transformer!": "Cannot connect from node to transformer!",
|
||||||
|
"Failed to import file: Invalid format": "Failed to import file: Invalid format",
|
||||||
|
"Need at least 2 objects to align": "Need at least 2 objects to align",
|
||||||
|
"Select at least 2 objects to align": "Select at least 2 objects to align",
|
||||||
|
"Need at least 3 objects to distribute": "Need at least 3 objects to distribute",
|
||||||
|
"No transformer found for auto-arrangement": "No transformer found for auto-arrangement",
|
||||||
|
|
||||||
|
// Confirmation Messages
|
||||||
|
"Are you sure you want to clear all objects and connections?": "Are you sure you want to clear all objects and connections?",
|
||||||
|
|
||||||
|
// Cable Names
|
||||||
|
"Cable": "Cable",
|
||||||
|
|
||||||
|
// Node Types Display
|
||||||
|
"Ground": "Ground",
|
||||||
|
"Overhead": "Overhead",
|
||||||
|
"Node": "Node"
|
||||||
|
},
|
||||||
|
pl: {
|
||||||
|
// UI Elements
|
||||||
|
"Power System Designer": "Analiza sieci nN",
|
||||||
|
"Calculate Voltage Drops": "Oblicz Spadki Napięcia",
|
||||||
|
"Clear All": "Wyczyść Wszystko",
|
||||||
|
"Export Data": "Eksportuj Dane",
|
||||||
|
"Import Data": "Importuj Dane",
|
||||||
|
"Objects": "Obiekty",
|
||||||
|
"Transformer": "Transformator",
|
||||||
|
"Cable Box": "Złącze Kablowe",
|
||||||
|
"Pole": "Słup",
|
||||||
|
"End Connection": "Odbiorca (napowietrzny)",
|
||||||
|
"Cables": "Kable",
|
||||||
|
"Underground Cable": "Kabel Ziemny",
|
||||||
|
"Overhead Cable": "Kabel Napowietrzny",
|
||||||
|
"Tools": "Narzędzia",
|
||||||
|
"Select Mode": "Tryb Wyboru",
|
||||||
|
"Delete Mode": "Tryb Usuwania",
|
||||||
|
"Auto Arrange - One Click to Make Everything Look Nice and Tidy": "Auto Rozmieszczenie",
|
||||||
|
"Properties": "Właściwości",
|
||||||
|
"No object selected": "Nie wybrano obiektu",
|
||||||
|
|
||||||
|
// Object Properties
|
||||||
|
"Transformer Properties": "Właściwości Transformatora",
|
||||||
|
"Number:": "Numer:",
|
||||||
|
"Name:": "Nazwa:",
|
||||||
|
"Upper Voltage (V):": "Napięcie Górne (V):",
|
||||||
|
"Bottom Voltage (V):": "Napięcie Dolne (V):",
|
||||||
|
"Power (kVA):": "Moc (kVA):",
|
||||||
|
"Description:": "Opis:",
|
||||||
|
"Transformer Info": "Informacje o Transformatorze",
|
||||||
|
"Type:": "Typ:",
|
||||||
|
"ID:": "ID:",
|
||||||
|
"Position:": "Pozycja:",
|
||||||
|
"Ratio:": "Przekładnia:",
|
||||||
|
"Outputs:": "Wyjścia:",
|
||||||
|
"Actions": "Akcje",
|
||||||
|
"Delete Transformer": "Usuń Transformator",
|
||||||
|
|
||||||
|
// Node Properties
|
||||||
|
"Node Properties": "Właściwości Węzła",
|
||||||
|
"Box": "Złącze Kablowe",
|
||||||
|
"End": "Koniec",
|
||||||
|
"Enter type description": "Wprowadź opis typu",
|
||||||
|
"3-Phase Consumers (7kW each):": "Odbiorcy 3-fazowi (7kW każdy):",
|
||||||
|
"1-Phase Consumers (3kW each):": "Odbiorcy 1-fazowi (3kW każdy):",
|
||||||
|
"Custom Power (kW):": "Niestandardowa Moc (kW):",
|
||||||
|
"Node Info": "Informacje o Węźle",
|
||||||
|
"Total Power:": "Moc Całkowita:",
|
||||||
|
"3-Phase:": "3-fazowe:",
|
||||||
|
"consumers": "odbiorców",
|
||||||
|
"1-Phase:": "1-fazowe:",
|
||||||
|
"Custom:": "Niestandardowe:",
|
||||||
|
"Inputs:": "Wejścia:",
|
||||||
|
"Delete Node": "Usuń Węzeł",
|
||||||
|
|
||||||
|
// Cable Properties
|
||||||
|
"Power Cable Properties": "Właściwości Kabla Zasilającego",
|
||||||
|
"Label:": "Etykieta:",
|
||||||
|
"Cable Type:": "Typ Kabla:",
|
||||||
|
"YAKY (Ground Cable)": "YAKY",
|
||||||
|
"NA2XY-J (Ground Cable)": "NA2XY-J",
|
||||||
|
"AL (Overhead Cable)": "AL",
|
||||||
|
"AsXSn (Overhead Cable)": "AsXSn",
|
||||||
|
"Cross Section (mm²):": "Przekrój (mm²):",
|
||||||
|
"Length (m):": "Długość (m):",
|
||||||
|
"Cable Info": "Informacje o Kablu",
|
||||||
|
"From:": "Od:",
|
||||||
|
"To:": "Do:",
|
||||||
|
"Specifications:": "Specyfikacje:",
|
||||||
|
"Section Resistance:": "Rezystancja Odcinka:",
|
||||||
|
"Section Current:": "Prąd Odcinka:",
|
||||||
|
"Voltage Drop:": "Spadek Napięcia:",
|
||||||
|
"Total Consumers:": "Łączna Liczba Odbiorców:",
|
||||||
|
"Diversity Factor:": "Współczynnik Jednoczesności:",
|
||||||
|
"⚠️ Overhead cables can only connect to poles or end connections!": "Kable napowietrzne mogą łączyć się tylko ze słupami lub końcowymi połączeniami!",
|
||||||
|
"Delete Cable": "Usuń Kabel",
|
||||||
|
|
||||||
|
// Error Messages
|
||||||
|
"Cannot connect object to itself!": "Nie można połączyć obiektu z samym sobą!",
|
||||||
|
"Connection already exists!": "Połączenie już istnieje!",
|
||||||
|
"Transformer can only have one outgoing connection!": "Transformator może mieć tylko jedno połączenie wychodzące!",
|
||||||
|
"Node can only have one incoming connection!": "Węzeł może mieć tylko jedno połączenie przychodzące!",
|
||||||
|
"End connections cannot have outgoing connections!": "Końcowe połączenia nie mogą mieć połączeń wychodzących!",
|
||||||
|
"Cannot connect from end connections!": "Nie można łączyć z końcowych połączeń!",
|
||||||
|
"Cannot connect from node to transformer!": "Nie można łączyć z węzła do transformatora!",
|
||||||
|
"Failed to import file: Invalid format": "Błąd importu pliku: Nieprawidłowy format",
|
||||||
|
"Need at least 2 objects to align": "Potrzeba co najmniej 2 obiektów do wyrównania",
|
||||||
|
"Select at least 2 objects to align": "Wybierz co najmniej 2 obiekty do wyrównania",
|
||||||
|
"Need at least 3 objects to distribute": "Potrzeba co najmniej 3 obiektów do rozłożenia",
|
||||||
|
"No transformer found for auto-arrangement": "Nie znaleziono transformatora do automatycznego rozmieszczenia",
|
||||||
|
|
||||||
|
// Confirmation Messages
|
||||||
|
"Are you sure you want to clear all objects and connections?": "Czy na pewno chcesz wyczyścić wszystkie obiekty i połączenia?",
|
||||||
|
|
||||||
|
// Cable Names
|
||||||
|
"Cable": "Kabel",
|
||||||
|
|
||||||
|
// Node Types Display
|
||||||
|
"Ground": "Podziemny",
|
||||||
|
"Overhead": "Napowietrzny",
|
||||||
|
"Node": "Węzeł"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Current language setting
|
||||||
|
let currentLanguage = 'pl'; // Default to Polish
|
||||||
|
|
||||||
|
// Translation function
|
||||||
|
function t(key) {
|
||||||
|
return translations[currentLanguage][key] || translations.en[key] || key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate static HTML UI elements
|
||||||
|
function translateStaticUI() {
|
||||||
|
// Header and buttons
|
||||||
|
const header = document.querySelector(".header h1");
|
||||||
|
if (header) header.textContent = t("Power System Designer");
|
||||||
|
|
||||||
|
const calculateBtn = document.getElementById("calculateBtn");
|
||||||
|
if (calculateBtn) calculateBtn.textContent = t("Calculate Voltage Drops");
|
||||||
|
|
||||||
|
const clearBtn = document.getElementById("clearBtn");
|
||||||
|
if (clearBtn) clearBtn.textContent = t("Clear All");
|
||||||
|
|
||||||
|
const exportBtn = document.getElementById("exportBtn");
|
||||||
|
if (exportBtn) exportBtn.textContent = t("Export Data");
|
||||||
|
|
||||||
|
const importBtn = document.getElementById("importBtn");
|
||||||
|
if (importBtn) importBtn.textContent = t("Import Data");
|
||||||
|
|
||||||
|
// Toolbar labels
|
||||||
|
document.querySelectorAll(".toolbar-label").forEach((el) => {
|
||||||
|
if (el.textContent.trim() === "Objects") el.textContent = t("Objects");
|
||||||
|
if (el.textContent.trim() === "Cables") el.textContent = t("Cables");
|
||||||
|
if (el.textContent.trim() === "Tools") el.textContent = t("Tools");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Icon tooltips
|
||||||
|
document.querySelectorAll(".icon-btn[data-type]").forEach((btn) => {
|
||||||
|
const type = btn.getAttribute("data-type");
|
||||||
|
if (type === "triangle") btn.title = t("Transformer");
|
||||||
|
if (type === "box") btn.title = t("Cable Box");
|
||||||
|
if (type === "pole") btn.title = t("Pole");
|
||||||
|
if (type === "end") btn.title = t("End Connection");
|
||||||
|
if (type === "underground") btn.title = t("Underground Cable");
|
||||||
|
if (type === "overhead") btn.title = t("Overhead Cable");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tool buttons tooltips
|
||||||
|
const selectBtn = document.getElementById("selectBtn");
|
||||||
|
if (selectBtn) selectBtn.title = t("Select Mode");
|
||||||
|
const deleteBtn = document.getElementById("deleteBtn");
|
||||||
|
if (deleteBtn) deleteBtn.title = t("Delete Mode");
|
||||||
|
const autoArrangeBtn = document.getElementById("autoArrangeBtn");
|
||||||
|
if (autoArrangeBtn) autoArrangeBtn.title = t("Auto Arrange - One Click to Make Everything Look Nice and Tidy");
|
||||||
|
|
||||||
|
// Properties panel
|
||||||
|
const propertiesPanel = document.querySelector(".properties-panel h3");
|
||||||
|
if (propertiesPanel) propertiesPanel.textContent = t("Properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call translation on DOMContentLoaded
|
||||||
|
window.addEventListener("DOMContentLoaded", translateStaticUI);
|
||||||
|
|
||||||
class ObjectFlowDesigner {
|
class ObjectFlowDesigner {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.canvas = document.getElementById("canvas");
|
this.canvas = document.getElementById("canvas");
|
||||||
@@ -1069,7 +1339,7 @@ class ObjectFlowDesigner {
|
|||||||
} else if (this.selectedConnection) {
|
} else if (this.selectedConnection) {
|
||||||
this.updateConnectionProperties(panel);
|
this.updateConnectionProperties(panel);
|
||||||
} else {
|
} else {
|
||||||
panel.innerHTML = '<p class="no-selection">No object selected</p>';
|
panel.innerHTML = `<p class="no-selection">${t("No object selected")}</p>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,37 +1350,31 @@ class ObjectFlowDesigner {
|
|||||||
// Transformer properties
|
// Transformer properties
|
||||||
panel.innerHTML = `
|
panel.innerHTML = `
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Transformer Properties</h4>
|
<h4>${t("Transformer Properties")}</h4>
|
||||||
<label>Number:</label>
|
<label>${t("Number:")}</label>
|
||||||
<input type="text" id="objNumber" value="${obj.data.number}">
|
<input type="text" id="objNumber" value="${obj.data.number}">
|
||||||
<label>Name:</label>
|
<label>${t("Name:")}</label>
|
||||||
<input type="text" id="objName" value="${obj.data.name}">
|
<input type="text" id="objName" value="${obj.data.name}">
|
||||||
<label>Upper Voltage (V):</label>
|
<label>${t("Upper Voltage (V):")}</label>
|
||||||
<input type="number" id="objUpperVoltage" value="${obj.data.upperVoltage}">
|
<input type="number" id="objUpperVoltage" value="${obj.data.upperVoltage}">
|
||||||
<label>Bottom Voltage (V):</label>
|
<label>${t("Bottom Voltage (V):")}</label>
|
||||||
<input type="number" id="objBottomVoltage" value="${obj.data.bottomVoltage}">
|
<input type="number" id="objBottomVoltage" value="${obj.data.bottomVoltage}">
|
||||||
<label>Power (kVA):</label>
|
<label>${t("Power (kVA):")}</label>
|
||||||
<input type="number" id="objPowerKVA" value="${obj.data.powerKVA}">
|
<input type="number" id="objPowerKVA" value="${obj.data.powerKVA}">
|
||||||
<label>Description:</label>
|
<label>${t("Description:")}</label>
|
||||||
<textarea id="objDescription">${obj.data.description}</textarea>
|
<textarea id="objDescription">${obj.data.description}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Transformer Info</h4>
|
<h4>${t("Transformer Info")}</h4>
|
||||||
<p><strong>Type:</strong> Transformer</p>
|
<p><strong>${t("Type:")}</strong> ${t("Transformer")}</p>
|
||||||
<p><strong>ID:</strong> ${obj.id}</p>
|
<p><strong>${t("ID:")}</strong> ${obj.id}</p>
|
||||||
<p><strong>Position:</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
|
<p><strong>${t("Position:")}</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
|
||||||
<p><strong>Ratio:</strong> ${obj.data.upperVoltage}V / ${
|
<p><strong>${t("Ratio:")}</strong> ${obj.data.upperVoltage}V / ${obj.data.bottomVoltage}V</p>
|
||||||
obj.data.bottomVoltage
|
<p><strong>${t("Outputs:")}</strong> ${obj.connections.outputs.length}/1</p>
|
||||||
}V</p>
|
|
||||||
<p><strong>Outputs:</strong> ${obj.connections.outputs.length}/1</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Actions</h4>
|
<h4>${t("Actions")}</h4>
|
||||||
<button class="btn btn-danger" onclick="designer.deleteObject(${
|
<button class="btn btn-danger" onclick="designer.deleteObject(${obj.id})">${t("Delete Transformer")}</button>
|
||||||
obj.id
|
|
||||||
})">Delete Transformer</button>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -1143,94 +1407,50 @@ class ObjectFlowDesigner {
|
|||||||
// Square (Node) properties
|
// Square (Node) properties
|
||||||
panel.innerHTML = `
|
panel.innerHTML = `
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Node Properties</h4>
|
<h4>${t("Node Properties")}</h4>
|
||||||
|
|
||||||
<!-- Node Type Icons -->
|
<!-- Node Type Icons -->
|
||||||
<div class="node-type-selector">
|
<div class="node-type-selector">
|
||||||
<button type="button" class="node-type-btn ${
|
<button type="button" class="node-type-btn ${obj.data.nodeType === "cable_box" ? "active" : ""}" data-type="cable_box" title="${t("Cable Box")}">
|
||||||
obj.data.nodeType === "cable_box" ? "active" : ""
|
|
||||||
}"
|
|
||||||
data-type="cable_box" title="Cable Box">
|
|
||||||
<span class="node-icon">⬛</span>
|
<span class="node-icon">⬛</span>
|
||||||
<span class="node-label">Box</span>
|
<span class="node-label">${t("Box")}</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="node-type-btn ${
|
<button type="button" class="node-type-btn ${obj.data.nodeType === "pole" ? "active" : ""}" data-type="pole" title="${t("Pole")}">
|
||||||
obj.data.nodeType === "pole" ? "active" : ""
|
|
||||||
}"
|
|
||||||
data-type="pole" title="Pole">
|
|
||||||
<span class="node-icon">⬆</span>
|
<span class="node-icon">⬆</span>
|
||||||
<span class="node-label">Pole</span>
|
<span class="node-label">${t("Pole")}</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="node-type-btn ${
|
<button type="button" class="node-type-btn ${obj.data.nodeType === "end_connection" ? "active" : ""}" data-type="end_connection" title="${t("End Connection")}">
|
||||||
obj.data.nodeType === "end_connection" ? "active" : ""
|
|
||||||
}"
|
|
||||||
data-type="end_connection" title="End Connection">
|
|
||||||
<span class="node-icon">⬤</span>
|
<span class="node-icon">⬤</span>
|
||||||
<span class="node-label">End</span>
|
<span class="node-label">${t("End")}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<label>${t("Number:")}</label>
|
||||||
<!-- Number -->
|
|
||||||
<label>Number:</label>
|
|
||||||
<input type="text" id="objNumber" value="${obj.data.number}">
|
<input type="text" id="objNumber" value="${obj.data.number}">
|
||||||
|
<label>${t("Type:")}</label>
|
||||||
<!-- Type Description -->
|
<input type="text" id="objBoxPoleType" value="${obj.data.boxPoleType}" placeholder="${t("Enter type description")}">
|
||||||
<label>Type:</label>
|
<label>${t("3-Phase Consumers (7kW each):")}</label>
|
||||||
<input type="text" id="objBoxPoleType" value="${
|
<input type="number" id="objConsumers3Phase" value="${obj.data.consumers3Phase || 0}" min="0">
|
||||||
obj.data.boxPoleType
|
<label>${t("1-Phase Consumers (3kW each):")}</label>
|
||||||
}" placeholder="Enter type description">
|
<input type="number" id="objConsumers1Phase" value="${obj.data.consumers1Phase || 0}" min="0">
|
||||||
|
<label>${t("Custom Power (kW):")}</label>
|
||||||
<!-- Power Settings -->
|
<input type="number" id="objCustomPowerKW" value="${obj.data.customPowerKW || 0}" step="0.1" min="0">
|
||||||
<label>3-Phase Consumers (7kW each):</label>
|
<label>${t("Description:")}</label>
|
||||||
<input type="number" id="objConsumers3Phase" value="${
|
|
||||||
obj.data.consumers3Phase || 0
|
|
||||||
}" min="0">
|
|
||||||
<label>1-Phase Consumers (3kW each):</label>
|
|
||||||
<input type="number" id="objConsumers1Phase" value="${
|
|
||||||
obj.data.consumers1Phase || 0
|
|
||||||
}" min="0">
|
|
||||||
<label>Custom Power (kW):</label>
|
|
||||||
<input type="number" id="objCustomPowerKW" value="${
|
|
||||||
obj.data.customPowerKW || 0
|
|
||||||
}" step="0.1" min="0">
|
|
||||||
|
|
||||||
<!-- Description -->
|
|
||||||
<label>Description:</label>
|
|
||||||
<textarea id="objDescription">${obj.data.description}</textarea>
|
<textarea id="objDescription">${obj.data.description}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Node Info</h4>
|
<h4>${t("Node Info")}</h4>
|
||||||
<p><strong>Type:</strong> ${
|
<p><strong>${t("Type:")}</strong> ${obj.data.nodeType === "cable_box" ? t("Cable Box") : obj.data.nodeType === "pole" ? t("Pole") : t("End Connection")}</p>
|
||||||
obj.data.nodeType === "cable_box"
|
<p><strong>${t("ID:")}</strong> ${obj.id}</p>
|
||||||
? "Cable Box"
|
<p><strong>${t("Position:")}</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
|
||||||
: obj.data.nodeType === "pole"
|
<p><strong>${t("Total Power:")}</strong> ${this.calculateNodeTotalPower(obj)} kW</p>
|
||||||
? "Pole"
|
<p><strong>${t("3-Phase:")}</strong> ${obj.data.consumers3Phase || 0} ${t("consumers")} (${(obj.data.consumers3Phase || 0) * 7}kW)</p>
|
||||||
: "End Connection"
|
<p><strong>${t("1-Phase:")}</strong> ${obj.data.consumers1Phase || 0} ${t("consumers")} (${(obj.data.consumers1Phase || 0) * 3}kW)</p>
|
||||||
}</p>
|
<p><strong>${t("Custom:")}</strong> ${obj.data.customPowerKW || 0} kW</p>
|
||||||
<p><strong>ID:</strong> ${obj.id}</p>
|
<p><strong>${t("Inputs:")}</strong> ${obj.connections.inputs.length}${obj.data.nodeType === "end_connection" ? "" : "/1"}</p>
|
||||||
<p><strong>Position:</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
|
<p><strong>${t("Outputs:")}</strong> ${obj.connections.outputs.length}${obj.data.nodeType === "end_connection" ? "/0" : ""}</p>
|
||||||
<p><strong>Total Power:</strong> ${this.calculateNodeTotalPower(obj)} kW</p>
|
|
||||||
<p><strong>3-Phase:</strong> ${obj.data.consumers3Phase || 0} consumers (${
|
|
||||||
(obj.data.consumers3Phase || 0) * 7
|
|
||||||
}kW)</p>
|
|
||||||
<p><strong>1-Phase:</strong> ${obj.data.consumers1Phase || 0} consumers (${
|
|
||||||
(obj.data.consumers1Phase || 0) * 3
|
|
||||||
}kW)</p>
|
|
||||||
<p><strong>Custom:</strong> ${obj.data.customPowerKW || 0} kW</p>
|
|
||||||
<p><strong>Inputs:</strong> ${obj.connections.inputs.length}${
|
|
||||||
obj.data.nodeType === "end_connection" ? "" : "/1"
|
|
||||||
}</p>
|
|
||||||
<p><strong>Outputs:</strong> ${obj.connections.outputs.length}${
|
|
||||||
obj.data.nodeType === "end_connection" ? "/0" : ""
|
|
||||||
}</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Actions</h4>
|
<h4>${t("Actions")}</h4>
|
||||||
<button class="btn btn-danger" onclick="designer.deleteObject(${
|
<button class="btn btn-danger" onclick="designer.deleteObject(${obj.id})">${t("Delete Node")}</button>
|
||||||
obj.id
|
|
||||||
})">Delete Node</button>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -1302,97 +1522,41 @@ class ObjectFlowDesigner {
|
|||||||
|
|
||||||
updateConnectionProperties(panel) {
|
updateConnectionProperties(panel) {
|
||||||
const conn = this.selectedConnection;
|
const conn = this.selectedConnection;
|
||||||
const isOverheadCable =
|
const isOverheadCable = conn.data.cableType === "AL" || conn.data.cableType === "AsXSn";
|
||||||
conn.data.cableType === "AL" || conn.data.cableType === "AsXSn";
|
const hasElectricalData = conn.data.sectionCurrent !== null && conn.data.sectionCurrent !== undefined;
|
||||||
|
|
||||||
// Calculate electrical properties for display
|
|
||||||
const hasElectricalData =
|
|
||||||
conn.data.sectionCurrent !== null &&
|
|
||||||
conn.data.sectionCurrent !== undefined;
|
|
||||||
|
|
||||||
panel.innerHTML = `
|
panel.innerHTML = `
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Power Cable Properties</h4>
|
<h4>${t("Power Cable Properties")}</h4>
|
||||||
<label>Label:</label>
|
<label>${t("Label:")}</label>
|
||||||
<input type="text" id="connLabel" value="${conn.data.label}">
|
<input type="text" id="connLabel" value="${conn.data.label}">
|
||||||
<label>Cable Type:</label>
|
<label>${t("Cable Type:")}</label>
|
||||||
<select id="connCableType">
|
<select id="connCableType">
|
||||||
<option value="YAKY" ${
|
<option value="YAKY" ${conn.data.cableType === "YAKY" ? "selected" : ""}>${t("YAKY (Ground Cable)")}</option>
|
||||||
conn.data.cableType === "YAKY" ? "selected" : ""
|
<option value="NA2XY-J" ${conn.data.cableType === "NA2XY-J" ? "selected" : ""}>${t("NA2XY-J (Ground Cable)")}</option>
|
||||||
}>YAKY (Ground Cable)</option>
|
<option value="AL" ${conn.data.cableType === "AL" ? "selected" : ""}>${t("AL (Overhead Cable)")}</option>
|
||||||
<option value="NA2XY-J" ${
|
<option value="AsXSn" ${conn.data.cableType === "AsXSn" ? "selected" : ""}>${t("AsXSn (Overhead Cable)")}</option>
|
||||||
conn.data.cableType === "NA2XY-J" ? "selected" : ""
|
|
||||||
}>NA2XY-J (Ground Cable)</option>
|
|
||||||
<option value="AL" ${
|
|
||||||
conn.data.cableType === "AL" ? "selected" : ""
|
|
||||||
}>AL (Overhead Cable)</option>
|
|
||||||
<option value="AsXSn" ${
|
|
||||||
conn.data.cableType === "AsXSn" ? "selected" : ""
|
|
||||||
}>AsXSn (Overhead Cable)</option>
|
|
||||||
</select>
|
</select>
|
||||||
<label>Cross Section (mm²):</label>
|
<label>${t("Cross Section (mm²):")}</label>
|
||||||
<input type="number" id="connCrossSection" value="${
|
<input type="number" id="connCrossSection" value="${conn.data.crossSection}" min="1">
|
||||||
conn.data.crossSection
|
<label>${t("Length (m):")}</label>
|
||||||
}" min="1">
|
<input type="number" id="connLength" value="${conn.data.length}" min="0.1" step="0.1">
|
||||||
<label>Length (m):</label>
|
<label>${t("Description:")}</label>
|
||||||
<input type="number" id="connLength" value="${
|
|
||||||
conn.data.length
|
|
||||||
}" min="0.1" step="0.1">
|
|
||||||
<label>Description:</label>
|
|
||||||
<textarea id="connDescription">${conn.data.description}</textarea>
|
<textarea id="connDescription">${conn.data.description}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Cable Info</h4>
|
<h4>${t("Cable Info")}</h4>
|
||||||
<p><strong>ID:</strong> ${conn.id}</p>
|
<p><strong>${t("ID:")}</strong> ${conn.id}</p>
|
||||||
<p><strong>Type:</strong> ${conn.data.cableType} ${
|
<p><strong>${t("Type:")}</strong> ${conn.data.cableType} ${isOverheadCable ? `(${t("Overhead")})` : `(${t("Ground")})`}</p>
|
||||||
isOverheadCable ? "(Overhead)" : "(Ground)"
|
<p><strong>${t("From:")}</strong> ${conn.from.data.number || conn.from.data.name} (${conn.from.type === "triangle" ? t("Transformer") : this.getNodeDisplayType(conn.from.data.nodeType)})</p>
|
||||||
}</p>
|
<p><strong>${t("To:")}</strong> ${conn.to.data.number || conn.to.data.name} (${conn.to.type === "triangle" ? t("Transformer") : this.getNodeDisplayType(conn.to.data.nodeType)})</p>
|
||||||
<p><strong>From:</strong> ${conn.from.data.number || conn.from.data.name} (${
|
<p><strong>${t("Specifications:")}</strong> ${conn.data.crossSection}mm² × ${conn.data.length}m</p>
|
||||||
conn.from.type === "triangle"
|
${hasElectricalData ? `<p><strong>${t("Section Resistance:")}</strong> ${Math.round(conn.data.sectionResistance * 1000) / 1000} Ω</p><p><strong>${t("Section Current:")}</strong> ${Math.round(conn.data.sectionCurrent * 10) / 10} A (per phase)</p><p><strong>${t("Voltage Drop:")}</strong> ${Math.round(conn.data.voltageDrop * 1000) / 1000} V</p><p><strong>${t("Total Consumers:")}</strong> ${this.getTotalConsumers(conn.to)}</p><p><strong>${t("Diversity Factor:")}</strong> ${(this.getDiversityFactor(this.getTotalConsumers(conn.to)) * 100).toFixed(0)}%</p>` : ""}
|
||||||
? "Transformer"
|
${isOverheadCable ? `<p class="warning"><strong>${t("⚠️ Overhead cables can only connect to poles or end connections!")}</strong></p>` : ""}
|
||||||
: this.getNodeDisplayType(conn.from.data.nodeType)
|
|
||||||
})</p>
|
|
||||||
<p><strong>To:</strong> ${conn.to.data.number || conn.to.data.name} (${
|
|
||||||
conn.to.type === "triangle"
|
|
||||||
? "Transformer"
|
|
||||||
: this.getNodeDisplayType(conn.to.data.nodeType)
|
|
||||||
})</p>
|
|
||||||
<p><strong>Specifications:</strong> ${conn.data.crossSection}mm² × ${
|
|
||||||
conn.data.length
|
|
||||||
}m</p>
|
|
||||||
${
|
|
||||||
hasElectricalData
|
|
||||||
? `
|
|
||||||
<p><strong>Section Resistance:</strong> ${
|
|
||||||
Math.round(conn.data.sectionResistance * 1000) / 1000
|
|
||||||
} Ω</p>
|
|
||||||
<p><strong>Section Current:</strong> ${
|
|
||||||
Math.round(conn.data.sectionCurrent * 10) / 10
|
|
||||||
} A (per phase)</p>
|
|
||||||
<p><strong>Voltage Drop:</strong> ${
|
|
||||||
Math.round(conn.data.voltageDrop * 1000) / 1000
|
|
||||||
} V</p>
|
|
||||||
<p><strong>Total Consumers:</strong> ${this.getTotalConsumers(conn.to)}</p>
|
|
||||||
<p><strong>Diversity Factor:</strong> ${(
|
|
||||||
this.getDiversityFactor(this.getTotalConsumers(conn.to)) * 100
|
|
||||||
).toFixed(0)}%</p>
|
|
||||||
`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
${
|
|
||||||
isOverheadCable
|
|
||||||
? '<p class="warning"><strong>⚠️ Overhead cables can only connect to poles or end connections!</strong></p>'
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="property-group">
|
<div class="property-group">
|
||||||
<h4>Actions</h4>
|
<h4>${t("Actions")}</h4>
|
||||||
<button class="btn btn-primary" onclick="designer.updateCalculations()">Calculate Voltage Drops</button>
|
<button class="btn btn-primary" onclick="designer.updateCalculations()">${t("Calculate Voltage Drops")}</button>
|
||||||
<button class="btn btn-danger" onclick="designer.deleteConnection(${
|
<button class="btn btn-danger" onclick="designer.deleteConnection(${conn.id})">${t("Delete Cable")}</button>
|
||||||
conn.id
|
|
||||||
})">Delete Cable</button>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -1573,18 +1737,15 @@ class ObjectFlowDesigner {
|
|||||||
z-index: 10000;
|
z-index: 10000;
|
||||||
animation: slideIn 0.3s ease;
|
animation: slideIn 0.3s ease;
|
||||||
`;
|
`;
|
||||||
error.textContent = message;
|
error.textContent = t(message);
|
||||||
document.body.appendChild(error);
|
document.body.appendChild(error);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
error.remove();
|
error.remove();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAll() {
|
clearAll() {
|
||||||
if (
|
if (confirm(t("Are you sure you want to clear all objects and connections?"))) {
|
||||||
confirm("Are you sure you want to clear all objects and connections?")
|
|
||||||
) {
|
|
||||||
this.objects = [];
|
this.objects = [];
|
||||||
this.connections = [];
|
this.connections = [];
|
||||||
this.selectedObject = null;
|
this.selectedObject = null;
|
||||||
@@ -1690,6 +1851,7 @@ class ObjectFlowDesigner {
|
|||||||
return "Pole";
|
return "Pole";
|
||||||
case "end_connection":
|
case "end_connection":
|
||||||
return "End Connection";
|
return "End Connection";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "Node";
|
return "Node";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user