Skip to content

Commit

Permalink
Merge pull request #78 from pitzzahh/feat/exports
Browse files Browse the repository at this point in the history
[Feat]: Add requested changes
  • Loading branch information
pitzzahh authored Dec 30, 2024
2 parents 6282e00 + 4b7a1a8 commit 9f312b6
Show file tree
Hide file tree
Showing 63 changed files with 377 additions and 272 deletions.
20 changes: 20 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://"0.0.9"keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.27] - 2024-12-30

### Add

- Toast notification when performing export to excel.
- Add ErrorCell component and integrate error handling for conduit and conductor sizes in table columns.
- Updated app logo.

### Fix

- Remove adding load in crkt no. cell in load schedule.
- Update column headers and improve rendering logic in base columns for better clarity and functionality.
- Adjust ampacity range condition and add error handling for conduit size in computations.
- Enhance error handling in sidebar header by adding a description field for improved clarity on export failures.
- Improve export error handling in sidebar header by adding descriptive messages for missing project and highest unit.
- Swap voltage and apparent power values in sidebar header for correct data representation.
- Adjust calculation placement for l(t) in sidebar header to correct row positioning.
- Fix alignment and value assignment for l(t) calculation in sidebar header.
- Update load schedule handling for 1P and 3P phases in sidebar header.

## [0.3.26] - 2024-12-30

### Test
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "heda",
"version": "0.3.26",
"version": "0.3.27",
"type": "module",
"private": true,
"author": {
Expand Down
Binary file modified src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square107x107Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square142x142Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square284x284Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square310x310Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square71x71Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square89x89Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/icon.icns
Binary file not shown.
Binary file modified src-tauri/icons/icon.ico
Binary file not shown.
Binary file modified src-tauri/icons/icon.png
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
Binary file added src-tauri/icons/ios/[email protected]
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Hierarchical Electrical Design Analyzer",
"version": "0.3.26",
"version": "0.3.27",
"identifier": "me.araopj.heda",
"build": {
"frontendDist": "../build",
Expand All @@ -13,7 +13,7 @@
"windows": [
{
"center": true,
"title": "Hierarchical Electrical Design Analyzer v0.3.26",
"title": "Hierarchical Electrical Design Analyzer v0.3.27",
"width": 950,
"height": 650,
"minWidth": 950,
Expand Down
53 changes: 36 additions & 17 deletions src/lib/components/custom/settings-dialog.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import { Tween } from 'svelte/motion';
import { cubicOut } from 'svelte/easing';
import * as Tooltip from '@/components/ui/tooltip';
import * as Alert from '$lib/components/ui/alert/index.js';
import * as Select from '@/components/ui/select';
Expand Down Expand Up @@ -31,17 +33,18 @@
const settingsState = getSettingsState();
const selectedFont = $derived(settingsState.font);
const tween = new Tween(0, { duration: 500, easing: cubicOut });
let open = $state(false);
let app_update: Update | null = $state(null);
let update_state: 'stale' | 'available' | 'no_updates' | 'processing' | 'error' | 'downloading' =
$state('stale');
let download_progress = $state(0);
let is_adjustment_factor_constant = $state(
project?.settings.is_adjustment_factor_constant || false
let is_adjustment_factor_dynamic = $state(
project?.settings.is_adjustment_factor_dynamic || false
);
let has_changes = $derived(
project && project.settings.is_adjustment_factor_constant !== is_adjustment_factor_constant
project && project.settings.is_adjustment_factor_dynamic !== is_adjustment_factor_dynamic
);
function handleChangeThemeColor(themeColor: Settings['color']) {
Expand All @@ -53,7 +56,7 @@
async function handleSaveChanges() {
if (!project) return;
await updateProjectSettings(project.id, { is_adjustment_factor_constant });
await updateProjectSettings(project.id, { is_adjustment_factor_dynamic });
invalidate('app:workspace').then(() => invalidate('app:workspace/load-schedule'));
toast.success('Adjustment Factor applied');
}
Expand All @@ -62,7 +65,7 @@
if (open) return;
// reset all the fields if not open
if (!open) {
is_adjustment_factor_constant = project?.settings.is_adjustment_factor_constant || false;
is_adjustment_factor_dynamic = project?.settings.is_adjustment_factor_dynamic || false;
update_state = 'stale';
app_update = null;
}
Expand Down Expand Up @@ -91,7 +94,7 @@
<Switch
disabled={!!!project}
id="adjustment_factor"
bind:checked={is_adjustment_factor_constant}
bind:checked={is_adjustment_factor_dynamic}
/>

{#if has_changes}
Expand All @@ -100,9 +103,9 @@
</div>

<p class="text-xs text-muted-foreground">
{is_adjustment_factor_constant
? 'The adjustment factor for all loads will be set to 100%.'
: 'The adjustment factor for each load may vary between 100%, 80%, 70%, 50%, 45%, 40%, and 35%, depending on the total number of conductors.'}
{is_adjustment_factor_dynamic
? 'The adjustment factor for each load may vary between 100%, 80%, 70%, 50%, 45%, 40%, and 35%, depending on the total number of conductors.'
: 'The adjustment factor for all loads will be set to 100%.'}
</p>
</div>
</div>
Expand Down Expand Up @@ -167,19 +170,16 @@
<svelte:boundary>
<Button
variant={update_state === 'available' ? 'default' : 'outline'}
style={download_progress > 0
? `background: linear-gradient(to right, var(--primary) ${download_progress}%, transparent ${download_progress}%)`
: ''}
class={cn({
class={cn('button-background', {
'!cursor-not-allowed opacity-50':
update_state === 'processing' || update_state === 'no_updates'
})}
onclick={async () => {
if (update_state === 'available' && app_update) {
download_progress = 0;
tween.target = 0;
update_state = 'downloading';
return installUpdate(app_update, true, (progress) => {
download_progress = progress;
tween.target = Math.round(progress);
});
}
if (update_state === 'processing' || update_state === 'no_updates') return;
Expand Down Expand Up @@ -212,7 +212,7 @@
{:else if update_state === 'no_updates'}
No updates available
{:else if update_state === 'downloading'}
{Math.round(download_progress)}%
{tween.target}%
{:else if update_state === 'error'}
Something went wrong while checking for updates
{:else}
Expand All @@ -232,3 +232,22 @@
<Tooltip.Content>Settings</Tooltip.Content>
</Tooltip.Root>
</Tooltip.Provider>

<style>
.button-background {
position: relative;
overflow: hidden;
}
.button-background::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: var(--progress, 0%);
height: 100%;
background-color: var(--primary); /* Highlight color */
pointer-events: none;
transition: width 0.1s ease; /* Smooth transition */
}
</style>
29 changes: 23 additions & 6 deletions src/lib/components/custom/sidebar/sidebar-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
const settingsState = getSettingsState();
type ButtonState = 'idle' | 'loading';
let button_states = $state({
export_to_excel: 'idle' as ButtonState
});
function handleSave() {
// TODO: Implement save functionality
toast.warning('This feature is not yet implemented');
Expand All @@ -41,12 +47,18 @@
description: 'This is a system error and should not be here, the error has been logged.'
});
}
const file_name = project?.project_name ?? 'Exported Panelboard Schedule';
button_states.export_to_excel = 'loading';
toast.loading(`Exporting to Excel... ${file_name}.xlsx`, {
description: 'Please wait, this should last very long.',
position: 'bottom-center'
});
const workbook = new ExcelJS.Workbook();
workbook.title = 'Exported Panelboard Schedule';
workbook.creator = 'HEDA(Desktop App)';
async function processNodeChildren(
async function processOnePhaseExcelPanelBoardSchedule(
nodeId: string,
parent?: Node,
depth: number = 1,
Expand Down Expand Up @@ -75,7 +87,7 @@
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (child.node_type === 'root') {
await processNodeChildren(child.id, child, depth + 1);
await processOnePhaseExcelPanelBoardSchedule(child.id, child, depth + 1);
} else if (child.node_type === 'panel') {
const panel_name = child.panel_data?.name ?? 'Unknown Panel';
const panel_level = getOrdinalSuffix(depth + 1);
Expand Down Expand Up @@ -388,7 +400,7 @@
{ column: 'N', value: node_data_summary.egc_size.toString() },
{ column: 'O', value: node_data_summary.egc_insulation ?? 'N/A' },
{ column: 'P', value: node_data_summary.conduit_size.toString() },
{ column: 'Q', value: ' ' }
{ column: 'Q', value: node_data_summary.conduit_type ?? 'N/A' }
];
main_columns.forEach(({ column, value }) => set_main_cell(column, value));
Expand All @@ -403,7 +415,7 @@
// last_total_cell.alignment = centerAlignment;
end_row += last_row + 3;
await processNodeChildren(child.id, child, depth + 1, last_row);
await processOnePhaseExcelPanelBoardSchedule(child.id, child, depth + 1, last_row);
}
const node_type = parent?.node_type;
dev &&
Expand All @@ -421,7 +433,7 @@
workbook.subject = '1P Load Schedule';
workbook.category = ['1P', 'Load Schedule', 'Export'].join(',');
workbook.description = 'Load schedule for 1 phase load schedule';
const process_result = await processNodeChildren(root_node.id);
const process_result = await processOnePhaseExcelPanelBoardSchedule(root_node.id);
if (!process_result.valid) {
toast.warning(process_result.message ?? 'Something went wrong while exporting', {
description: process_result?.is_system_error
Expand Down Expand Up @@ -457,13 +469,17 @@
// Create a link and download the file
const link = document.createElement('a');
link.href = url;
link.download = `${project?.project_name ?? 'Exported Data'}.xlsx`;
link.download = `${file_name}.xlsx`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Free resources
URL.revokeObjectURL(url);
toast.success('Export finished successfully.', {
description: 'The file has been downloaded successfully'
});
button_states.export_to_excel = 'idle';
}
</script>

Expand Down Expand Up @@ -507,6 +523,7 @@
<Tooltip.Provider>
<Tooltip.Root>
<Tooltip.Trigger
disabled={button_states.export_to_excel === 'loading'}
class={buttonVariants({ variant: 'outline', size: 'sm' })}
onclick={exportToExcel}
>
Expand Down
23 changes: 23 additions & 0 deletions src/lib/components/custom/table/(components)/error-cell.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts">
import { InfoIcon } from 'lucide-svelte';
import * as Tooltip from '@/components/ui/tooltip';
let { trigger_value, tooltip_content }: { tooltip_content: string; trigger_value: string } =
$props();
</script>

<div class="grid w-full place-content-center">
<Tooltip.Provider delayDuration={100}>
<Tooltip.Root>
<Tooltip.Trigger>
<p class="flex items-center gap-[7px] text-center text-red-500">
{trigger_value}
<InfoIcon class="size-[14px]" />
</p>
</Tooltip.Trigger>
<Tooltip.Content class="bg-red-500 text-white">
{tooltip_content}
</Tooltip.Content>
</Tooltip.Root>
</Tooltip.Provider>
</div>
Loading

0 comments on commit 9f312b6

Please sign in to comment.