+
+ Manage Twin World: {twinworld.name || "No Twin World Selected"}
+
+
+
+
- {#if twinworld.households.length > 0}
- {#each twinworld.households as household, hIndex}
-
-
-
+ {#if twinworld.households.length > 0}
+ {#each twinworld.households as household, hIndex}
+
+
+
+
+
+
+ handleHouseholdChange(
+ hIndex,
+ "name",
+ (e.target as HTMLInputElement).value
+ )}
+ class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none" />
+ {#if errors.households[household.id]?.name}
+
+ {errors.households[household.id].name}
+
+ {/if}
+
+
-
-
- handleHouseholdChange(hIndex, "name", (e.target as HTMLInputElement).value)}
- class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none" />
- {#if errors.households[household.id]?.name}
-
{errors.households[household.id].name}
- {/if}
-
-
-
-
-
- {#if !foldedHouseholds[hIndex]}
-
-
-
-
- handleHouseholdChange(
- hIndex,
- "size",
- Number((e.target as HTMLInputElement).value)
- )}
- class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
- placeholder="Enter number of members" />
- {#if errors.households[household.id]?.size}
-
{errors.households[household.id].size}
- {/if}
-
-
-
-
{
- const value = Number((e.target as HTMLInputElement).value);
- household.solarPanels = value >= 0 ? value : 0;
- handleHouseholdChange(hIndex, "solarPanels", household.solarPanels);
- }}
- class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
- placeholder="Enter number of solar panels" />
- {#if errors.households[household.id]?.solarPanels}
-
- {errors.households[household.id].solarPanels}
-
- {/if}
-
-
-
-
- {#if errors.households[household.id]?.solarPanelType}
-
- {errors.households[household.id].solarPanelType}
-
- {/if}
-
-
-
-
Appliances
-
+ {#if !foldedHouseholds[hIndex]}
+
+
+
+
+ handleHouseholdChange(
+ hIndex,
+ "size",
+ Number((e.target as HTMLInputElement).value)
+ )}
+ class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
+ placeholder="Enter number of members" />
+ {#if errors.households[household.id]?.size}
+
+ {errors.households[household.id].size}
+
+ {/if}
+
+
+
+
{
+ const value = Number((e.target as HTMLInputElement).value);
+ household.solarPanels = value >= 0 ? value : 0;
+ handleHouseholdChange(hIndex, "solarPanels", household.solarPanels);
+ }}
+ class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
+ placeholder="Enter number of solar panels" />
+ {#if errors.households[household.id]?.solarPanels}
+
+ {errors.households[household.id].solarPanels}
+
+ {/if}
+
+
+
+
+ {#if errors.households[household.id]?.solarPanelType}
+
+ {errors.households[household.id].solarPanelType}
+
+ {/if}
+
- {#each household.appliances! as appliance, aIndex}
-
-
-
-
-
-
- {#if errors.appliances[household.id]?.[appliance.id]?.name}
-
- {errors.appliances[household.id][appliance.id].name}
-
- {/if}
-
-
-
-
- {#if !foldedAppliances[hIndex][aIndex]}
-
-
-
-
- handleApplianceChange(
- hIndex,
- aIndex,
- "power",
- Number((e.target as HTMLInputElement).value)
- )}
- class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
- placeholder="Enter power in watts" />
- {#if errors.appliances[household.id]?.[appliance.id]?.power}
-
- {errors.appliances[household.id][appliance.id].power}
-
- {/if}
-
-
-
-
- handleApplianceChange(
- hIndex,
- aIndex,
- "duration",
- Number((e.target as HTMLInputElement).value)
- )}
- class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
- placeholder="Enter duration in hours" />
- {#if errors.appliances[household.id]?.[appliance.id]?.duration}
-
- {errors.appliances[household.id][appliance.id].duration}
-
+
+
+
Appliances
+
+
+ {#each household.appliances! as appliance, aIndex}
+
+
+
-
-
-
+
+
+
+ {#if errors.appliances[household.id]?.[appliance.id]?.name}
- {errors.appliances[household.id][appliance.id].dailyUsage}
+ {errors.appliances[household.id][appliance.id].name}
{/if}
+
+
-
- {#each appliance.timeDaily.slice(0, 7) as time}
-
-
- {/each}
-
- {/if}
-
- {/each}
- {/if}
+
+
+ Duration (hours)
+
+
+ handleApplianceChange(
+ hIndex,
+ aIndex,
+ "duration",
+ Number((e.target as HTMLInputElement).value)
+ )}
+ class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
+ placeholder="Enter duration in hours" />
+ {#if errors.appliances[household.id]?.[appliance.id]?.duration}
+
+ {errors.appliances[household.id][appliance.id].duration}
+
+ {/if}
+
+
+
+ Daily Usage (times)
+
+
+ handleApplianceChange(
+ hIndex,
+ aIndex,
+ "dailyUsage",
+ Number((e.target as HTMLInputElement).value)
+ )}
+ class="w-full rounded-lg border-2 border-gray-300 p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
+ placeholder="Enter daily usage times" />
+ {#if errors.appliances[household.id]?.[appliance.id]?.dailyUsage}
+
+ {errors.appliances[household.id][appliance.id].dailyUsage}
+
+ {/if}
+
+
+
+ {#each appliance.timeDaily.slice(0, 7) as time}
+
+
+ {daysOfWeek[time.day - 1]}
+
+
+ {#each Array(24) as _, hour}
+
+ {
+ const target = e.target as HTMLInputElement;
+ handleTimeDailyChange(
+ hIndex,
+ aIndex,
+ time.day,
+ hour,
+ target.checked
+ );
+ }}
+ class="rounded text-blue-600 focus:ring-blue-500" />
+ {hour}:00
+
+ {/each}
+
+
+ {/each}
+
+ {/if}
+
+ {/each}
+
+ {/if}
+
+ {/each}
+ {/if}
+
-
+ {/if}
{/snippet}
diff --git a/src/excel.svelte.ts b/src/excel.svelte.ts
index 71dc24c..5249bf2 100644
--- a/src/excel.svelte.ts
+++ b/src/excel.svelte.ts
@@ -111,19 +111,25 @@ export function downloadExcel(name?: string): void {
}
function processGraphDataAndAddToWorkbook(graphData: GraphData, workbook: XLSX.WorkBook): void {
+ const graphTabNames: Record
= {
+ graph1: "Internal Energy Price",
+ graph2: "Individual Solar Energy",
+ graph3: "Total Solar Energy",
+ graph4: "Total Money Saved",
+ };
+
Object.keys(graphData).forEach((graphKey) => {
- const graphPoints: GraphPoint[] = graphData[graphKey as keyof GraphData].map(
- (point: string) => {
- const [xPart, yPart] = point.split(",");
- return {
- X: xPart.split(":")[1].trim(),
- Y: yPart.split(":")[1].trim(),
- };
- }
- );
+ const key = graphKey as keyof GraphData;
+ const graphPoints: GraphPoint[] = graphData[key].map((point: string) => {
+ const [xPart, yPart] = point.split(",");
+ return {
+ X: xPart.split(":")[1].trim(),
+ Y: yPart.split(":")[1].trim(),
+ };
+ });
const worksheet = XLSX.utils.json_to_sheet(graphPoints);
- XLSX.utils.book_append_sheet(workbook, worksheet, graphKey);
+ XLSX.utils.book_append_sheet(workbook, worksheet, graphTabNames[key]);
});
}
@@ -142,15 +148,17 @@ export function downloadExcel(name?: string): void {
const timeDailiesSheet = XLSX.utils.json_to_sheet(timeDailies);
XLSX.utils.book_append_sheet(workbook, timeDailiesSheet, "Time Dailies");
+
processGraphDataAndAddToWorkbook(graphData, workbook);
const dashboardSheet = XLSX.utils.json_to_sheet(dashboardData);
XLSX.utils.book_append_sheet(workbook, dashboardSheet, "Dashboard Data");
+
const wbout = XLSX.write(workbook, { bookType: "xlsx", type: "binary" });
const blob = new Blob([s2ab(wbout)], { type: "application/octet-stream" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
- a.download = name + ".xlsx" || "session-data.xlsx";
+ a.download = name ? name + ".xlsx" : "session-data.xlsx";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
diff --git a/src/formdata.svelte.ts b/src/formdata.svelte.ts
index c228a08..9734967 100644
--- a/src/formdata.svelte.ts
+++ b/src/formdata.svelte.ts
@@ -132,8 +132,8 @@ export async function loadFormData() {
},
],
twinWorlds: {
- "1": createTwinWorld("Twin World Small", 25, 5),
- "2": createTwinWorld("Twin World Large", 75, 5),
+ "1": createTwinWorld("Twin World Small", 25, 2),
+ "2": createTwinWorld("Twin World Large", 75, 2),
},
},
{
From 1f72cf9062b71aec4368f8fdaa8eb04803430cbe Mon Sep 17 00:00:00 2001
From: xlc-dev <119954023+xlc-dev@users.noreply.github.com>
Date: Wed, 15 Jan 2025 18:57:56 +0100
Subject: [PATCH 2/2] last bug
---
src/Stepper.svelte | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/Stepper.svelte b/src/Stepper.svelte
index 8b450e9..afdf444 100644
--- a/src/Stepper.svelte
+++ b/src/Stepper.svelte
@@ -1424,7 +1424,11 @@
Appliances