mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 14:09:31 +02:00
refactor: init
This commit is contained in:
141
.idea/workspace.xml
generated
141
.idea/workspace.xml
generated
@@ -5,32 +5,25 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="chore: compress video icon">
|
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="chore: compress video icon">
|
||||||
<change afterPath="$PROJECT_DIR$/@types/theme.d.ts" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/sphereArea.ts" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/public/assets/background-dark.png" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/sphereVolume.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/App.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/App.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/home/daniel/Projects/omni-tools/src/pages/tools/index.ts" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/Hero.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/Hero.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/home/daniel/Projects/omni-tools/src/pages/tools/number/calculators/index.ts" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/Navbar/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/Navbar/index.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/home/daniel/Projects/omni-tools/src/pages/tools/number/index.ts" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/ToolHeader.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolHeader.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/components/ToolContent.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolContent.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/ToolLayout.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolLayout.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/components/ToolInputAndResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolInputAndResult.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/allTools/ToolCard.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/allTools/ToolCard.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/components/input/NumericInputWithUnit.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/input/NumericInputWithUnit.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/examples/ExampleCard.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/examples/ExampleCard.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/datatables/data/index.ts" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/input/BaseFileInput.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/input/BaseFileInput.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/datatables/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/datatables/index.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/input/ToolFileInput.tsx" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/datatables/types.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/datatables/types.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/input/ToolTextInput.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/input/ToolTextInput.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/area_volume.ts" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/options/ColorSelector.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/options/ColorSelector.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/index.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/options/TextFieldWithDesc.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/options/TextFieldWithDesc.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/ohms_law.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/ohms_law.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/options/ToolOptions.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/options/ToolOptions.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/types.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/types.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/wire_voltage_drop.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/data/wire_voltage_drop.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/result/ToolTextResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolTextResult.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/index.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/config/muiConfig.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/config/muiConfig.ts" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/number/generic-calc/service.ts" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/home/Categories.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/home/Categories.tsx" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/home/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/home/index.tsx" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/tools-by-category/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools-by-category/index.tsx" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/tools/video/compress/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/video/compress/service.ts" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/pages/tools/video/gif/change-speed/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/video/gif/change-speed/index.tsx" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/tsconfig.json" beforeDir="false" afterPath="$PROJECT_DIR$/tsconfig.json" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -47,7 +40,7 @@
|
|||||||
<option name="PUSH_AUTO_UPDATE" value="true" />
|
<option name="PUSH_AUTO_UPDATE" value="true" />
|
||||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
<map>
|
<map>
|
||||||
<entry key="$PROJECT_DIR$" value="main" />
|
<entry key="$PROJECT_DIR$" value="chesterkxng" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
@@ -66,87 +59,87 @@
|
|||||||
"state": "OPEN"
|
"state": "OPEN"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
<component name="GitHubPullRequestState"><![CDATA[{
|
<component name="GitHubPullRequestState">{
|
||||||
"prStates": [
|
"prStates": [
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts51PkS9",
|
"id": "PR_kwDOMJIfts51PkS9",
|
||||||
"number": 22
|
"number": 22
|
||||||
},
|
},
|
||||||
"lastSeen": 1741207144695
|
"lastSeen": 1741207144695
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6NiNYl",
|
"id": "PR_kwDOMJIfts6NiNYl",
|
||||||
"number": 32
|
"number": 32
|
||||||
},
|
},
|
||||||
"lastSeen": 1741209723869
|
"lastSeen": 1741209723869
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6Nheyd",
|
"id": "PR_kwDOMJIfts6Nheyd",
|
||||||
"number": 31
|
"number": 31
|
||||||
},
|
},
|
||||||
"lastSeen": 1741213371410
|
"lastSeen": 1741213371410
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6NmRBs",
|
"id": "PR_kwDOMJIfts6NmRBs",
|
||||||
"number": 33
|
"number": 33
|
||||||
},
|
},
|
||||||
"lastSeen": 1741282429036
|
"lastSeen": 1741282429036
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts5zyFTs",
|
"id": "PR_kwDOMJIfts5zyFTs",
|
||||||
"number": 15
|
"number": 15
|
||||||
},
|
},
|
||||||
"lastSeen": 1741535540953
|
"lastSeen": 1741535540953
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QQB3c",
|
"id": "PR_kwDOMJIfts6QQB3c",
|
||||||
"number": 59
|
"number": 59
|
||||||
},
|
},
|
||||||
"lastSeen": 1743018960900
|
"lastSeen": 1743018960900
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QMPEg",
|
"id": "PR_kwDOMJIfts6QMPEg",
|
||||||
"number": 58
|
"number": 58
|
||||||
},
|
},
|
||||||
"lastSeen": 1743019452983
|
"lastSeen": 1743019452983
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QZvRI",
|
"id": "PR_kwDOMJIfts6QZvRI",
|
||||||
"number": 61
|
"number": 61
|
||||||
},
|
},
|
||||||
"lastSeen": 1743103196866
|
"lastSeen": 1743103196866
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QqPrQ",
|
"id": "PR_kwDOMJIfts6QqPrQ",
|
||||||
"number": 73
|
"number": 73
|
||||||
},
|
},
|
||||||
"lastSeen": 1743265865001
|
"lastSeen": 1743265865001
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6Qp5nI",
|
"id": "PR_kwDOMJIfts6Qp5nI",
|
||||||
"number": 72
|
"number": 72
|
||||||
},
|
},
|
||||||
"lastSeen": 1743338472110
|
"lastSeen": 1743338472110
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": {
|
"id": {
|
||||||
"id": "PR_kwDOMJIfts6QsjlS",
|
"id": "PR_kwDOMJIfts6QsjlS",
|
||||||
"number": 76
|
"number": 76
|
||||||
},
|
},
|
||||||
"lastSeen": 1743352150953
|
"lastSeen": 1743352150953
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="GithubPullRequestsUISettings">{
|
<component name="GithubPullRequestsUISettings">{
|
||||||
"selectedUrlAndAccountId": {
|
"selectedUrlAndAccountId": {
|
||||||
"url": "https://github.com/iib0011/omni-tools.git",
|
"url": "https://github.com/iib0011/omni-tools.git",
|
||||||
@@ -199,7 +192,7 @@
|
|||||||
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
|
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
|
||||||
"Vitest.replaceText function.executor": "Run",
|
"Vitest.replaceText function.executor": "Run",
|
||||||
"Vitest.timeBetweenDates.executor": "Run",
|
"Vitest.timeBetweenDates.executor": "Run",
|
||||||
"git-widget-placeholder": "dark-mode",
|
"git-widget-placeholder": "#89 on generic-calc",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/@types",
|
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/@types",
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
export const toolsTools = [];
|
|
@@ -1 +0,0 @@
|
|||||||
export const calculatorsTools = [];
|
|
@@ -1 +0,0 @@
|
|||||||
export const numberTools = [];
|
|
@@ -40,7 +40,7 @@ const FormikListenerComponent = <T,>({
|
|||||||
|
|
||||||
interface ToolContentProps<T, I> extends ToolComponentProps {
|
interface ToolContentProps<T, I> extends ToolComponentProps {
|
||||||
inputComponent?: ReactNode;
|
inputComponent?: ReactNode;
|
||||||
resultComponent: ReactNode;
|
resultComponent?: ReactNode;
|
||||||
renderCustomInput?: (
|
renderCustomInput?: (
|
||||||
values: T,
|
values: T,
|
||||||
setFieldValue: (fieldName: string, value: any) => void
|
setFieldValue: (fieldName: string, value: any) => void
|
||||||
|
@@ -6,8 +6,9 @@ export default function ToolInputAndResult({
|
|||||||
result
|
result
|
||||||
}: {
|
}: {
|
||||||
input?: ReactNode;
|
input?: ReactNode;
|
||||||
result: ReactNode;
|
result?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
|
if (input || result) {
|
||||||
return (
|
return (
|
||||||
<Grid id="tool" container spacing={2}>
|
<Grid id="tool" container spacing={2}>
|
||||||
{input && (
|
{input && (
|
||||||
@@ -21,3 +22,4 @@ export default function ToolInputAndResult({
|
|||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -20,7 +20,7 @@ export default function NumericInputWithUnit(props: {
|
|||||||
value: { value: number; unit: string };
|
value: { value: number; unit: string };
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
disableChangingUnit?: boolean;
|
disableChangingUnit?: boolean;
|
||||||
onOwnChange: (value: { value: number; unit: string }) => void;
|
onOwnChange?: (value: { value: number; unit: string }) => void;
|
||||||
defaultPrefix?: string;
|
defaultPrefix?: string;
|
||||||
}) {
|
}) {
|
||||||
const [inputValue, setInputValue] = useState(props.value.value);
|
const [inputValue, setInputValue] = useState(props.value.value);
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
import type { DataTable } from '../types';
|
|
||||||
import wiregauge from './wire_gauge';
|
|
||||||
import material_electrical_properties from './material_electrical_properties';
|
|
||||||
|
|
||||||
const allDataTables: { [key: string]: DataTable } = {
|
|
||||||
'wire-gauge': wiregauge,
|
|
||||||
'material-electrical-properties': material_electrical_properties
|
|
||||||
};
|
|
||||||
|
|
||||||
export default allDataTables;
|
|
@@ -1,18 +1,8 @@
|
|||||||
import type { DataTable } from './types.ts';
|
import type { DataTable } from './types.ts';
|
||||||
|
|
||||||
export async function getDataTable(name: string): Promise<DataTable> {
|
|
||||||
const allDataTables = (await import('./data/index')).default;
|
|
||||||
return allDataTables[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Used in case later we want any kind of computed extra data */
|
/* Used in case later we want any kind of computed extra data */
|
||||||
export function dataTableLookup(table: DataTable, key: string): any {
|
export function dataTableLookup(table: DataTable, key: string): any {
|
||||||
return table.data[key];
|
return table.data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listDataTables(): Promise<{ [name: string]: DataTable }> {
|
|
||||||
const allDataTables = (await import('./data/index')).default;
|
|
||||||
return allDataTables;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { DataTable };
|
export { DataTable };
|
||||||
|
@@ -7,7 +7,7 @@ export interface DataTable {
|
|||||||
title: string;
|
title: string;
|
||||||
/* A JSON schema properties */
|
/* A JSON schema properties */
|
||||||
columns: {
|
columns: {
|
||||||
[key: string]: any;
|
[key: string]: { title: string; type: string; unit: string };
|
||||||
};
|
};
|
||||||
data: {
|
data: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import ohmslaw from './ohms_law';
|
import ohmslaw from './ohmsLaw';
|
||||||
import voltagedropinwire from './wire_voltage_drop';
|
import voltageDropInWire from './voltageDropInWire';
|
||||||
import { areaSphere, volumeSphere } from './area_volume';
|
import sphereArea from './sphereArea';
|
||||||
|
import sphereVolume from './sphereVolume';
|
||||||
|
|
||||||
export default [ohmslaw, voltagedropinwire, areaSphere, volumeSphere];
|
export default [ohmslaw, voltageDropInWire, sphereArea, sphereVolume];
|
||||||
|
@@ -5,7 +5,7 @@ const ohmsLawCalc: GenericCalcType = {
|
|||||||
name: 'ohms-law',
|
name: 'ohms-law',
|
||||||
description: 'Calculates voltage, current and resistance',
|
description: 'Calculates voltage, current and resistance',
|
||||||
formula: 'V = I * R',
|
formula: 'V = I * R',
|
||||||
selections: [],
|
presets: [],
|
||||||
variables: [
|
variables: [
|
||||||
{
|
{
|
||||||
name: 'V',
|
name: 'V',
|
25
src/pages/tools/number/generic-calc/data/sphereArea.ts
Normal file
25
src/pages/tools/number/generic-calc/data/sphereArea.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import type { GenericCalcType } from './types';
|
||||||
|
|
||||||
|
const areaSphere: GenericCalcType = {
|
||||||
|
title: 'Area of a Sphere',
|
||||||
|
name: 'area-sphere',
|
||||||
|
description: 'Area of a Sphere',
|
||||||
|
formula: 'A = 4 * pi * r**2',
|
||||||
|
presets: [],
|
||||||
|
variables: [
|
||||||
|
{
|
||||||
|
name: 'A',
|
||||||
|
title: 'Area',
|
||||||
|
unit: 'mm2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'r',
|
||||||
|
title: 'Radius',
|
||||||
|
formula: 'r = sqrt(A/pi) / 2',
|
||||||
|
unit: 'mm',
|
||||||
|
default: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default areaSphere;
|
@@ -1,33 +1,11 @@
|
|||||||
import type { GenericCalcType } from './types';
|
import type { GenericCalcType } from './types';
|
||||||
|
|
||||||
export const areaSphere: GenericCalcType = {
|
const volumeSphere: GenericCalcType = {
|
||||||
title: 'Area of a Sphere',
|
|
||||||
name: 'area-sphere',
|
|
||||||
description: 'Area of a Sphere',
|
|
||||||
formula: 'A = 4 * pi * r**2',
|
|
||||||
selections: [],
|
|
||||||
variables: [
|
|
||||||
{
|
|
||||||
name: 'A',
|
|
||||||
title: 'Area',
|
|
||||||
unit: 'mm2'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'r',
|
|
||||||
title: 'Radius',
|
|
||||||
formula: 'r = sqrt(A/pi) / 2',
|
|
||||||
unit: 'mm',
|
|
||||||
default: 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
export const volumeSphere: GenericCalcType = {
|
|
||||||
title: 'Volume of a Sphere',
|
title: 'Volume of a Sphere',
|
||||||
name: 'volume-sphere',
|
name: 'volume-sphere',
|
||||||
description: 'Volume of a Sphere',
|
description: 'Volume of a Sphere',
|
||||||
formula: 'v = (4/3) * pi * r**3',
|
formula: 'v = (4/3) * pi * r**3',
|
||||||
selections: [],
|
presets: [],
|
||||||
variables: [
|
variables: [
|
||||||
{
|
{
|
||||||
name: 'v',
|
name: 'v',
|
||||||
@@ -49,3 +27,5 @@ export const volumeSphere: GenericCalcType = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default volumeSphere;
|
@@ -1,9 +1,12 @@
|
|||||||
|
import { DataTable } from '../../../../../datatables';
|
||||||
|
|
||||||
export interface AlternativeVarInfo {
|
export interface AlternativeVarInfo {
|
||||||
title: string;
|
title: string;
|
||||||
unit: string;
|
unit: string;
|
||||||
defaultPrefix?: string;
|
defaultPrefix?: string;
|
||||||
formula: string;
|
formula: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GenericCalcType {
|
export interface GenericCalcType {
|
||||||
title: string;
|
title: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -17,9 +20,9 @@ export interface GenericCalcType {
|
|||||||
// Si prefix default
|
// Si prefix default
|
||||||
defaultPrefix?: string;
|
defaultPrefix?: string;
|
||||||
}[];
|
}[];
|
||||||
selections?: {
|
presets?: {
|
||||||
title: string;
|
title: string;
|
||||||
source: string;
|
source: DataTable;
|
||||||
default: string;
|
default: string;
|
||||||
bind: {
|
bind: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
import type { GenericCalcType } from './types';
|
import type { GenericCalcType } from './types';
|
||||||
const voltagedropinwire: GenericCalcType = {
|
import material_electrical_properties from '../../../../../datatables/data/material_electrical_properties';
|
||||||
|
import wire_gauge from '../../../../../datatables/data/wire_gauge';
|
||||||
|
|
||||||
|
const voltageDropInWire: GenericCalcType = {
|
||||||
title: 'Round trip voltage drop in cable',
|
title: 'Round trip voltage drop in cable',
|
||||||
name: 'cable-voltage-drop',
|
name: 'cable-voltage-drop',
|
||||||
formula: 'x = (((p * L) / (A/10**6) ) *2) * I',
|
formula: 'x = (((p * L) / (A/10**6) ) *2) * I',
|
||||||
description:
|
description:
|
||||||
'Calculates round trip voltage and power loss in a 2 conductor cable',
|
'Calculates round trip voltage and power loss in a 2 conductor cable',
|
||||||
selections: [
|
presets: [
|
||||||
{
|
{
|
||||||
title: 'Material',
|
title: 'Material',
|
||||||
source: 'material-electrical-properties',
|
source: material_electrical_properties,
|
||||||
default: 'Copper',
|
default: 'Copper',
|
||||||
bind: {
|
bind: {
|
||||||
p: 'resistivity_20c'
|
p: 'resistivity_20c'
|
||||||
@@ -17,7 +20,7 @@ const voltagedropinwire: GenericCalcType = {
|
|||||||
|
|
||||||
{
|
{
|
||||||
title: 'Wire Gauge',
|
title: 'Wire Gauge',
|
||||||
source: 'wire-gauge',
|
source: wire_gauge,
|
||||||
default: '24 AWG',
|
default: '24 AWG',
|
||||||
bind: {
|
bind: {
|
||||||
A: 'area'
|
A: 'area'
|
||||||
@@ -72,4 +75,4 @@ const voltagedropinwire: GenericCalcType = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export default voltagedropinwire;
|
export default voltageDropInWire;
|
@@ -1,31 +1,29 @@
|
|||||||
import {
|
import {
|
||||||
Box,
|
|
||||||
Autocomplete,
|
Autocomplete,
|
||||||
TextField,
|
Box,
|
||||||
Radio,
|
Radio,
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
TableCell,
|
TableCell,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableRow
|
TableRow,
|
||||||
|
TextField
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import React, { useState } from 'react';
|
import React, { useContext, useState } from 'react';
|
||||||
import ToolContent from '@components/ToolContent';
|
import ToolContent from '@components/ToolContent';
|
||||||
import { ToolComponentProps } from '@tools/defineTool';
|
import { ToolComponentProps } from '@tools/defineTool';
|
||||||
import ToolTextResult from '@components/result/ToolTextResult';
|
|
||||||
import NumericInputWithUnit from '@components/input/NumericInputWithUnit';
|
import NumericInputWithUnit from '@components/input/NumericInputWithUnit';
|
||||||
import { UpdateField } from '@components/options/ToolOptions';
|
import { UpdateField } from '@components/options/ToolOptions';
|
||||||
import { InitialValuesType } from './types';
|
import { InitialValuesType } from './types';
|
||||||
import type { AlternativeVarInfo, GenericCalcType } from './data/types';
|
import type { AlternativeVarInfo, GenericCalcType } from './data/types';
|
||||||
import type { DataTable } from 'datatables';
|
import { dataTableLookup } from 'datatables';
|
||||||
import { getDataTable, dataTableLookup } from 'datatables';
|
|
||||||
|
|
||||||
import nerdamer from 'nerdamer-prime';
|
import nerdamer from 'nerdamer-prime';
|
||||||
import 'nerdamer-prime/Algebra';
|
import 'nerdamer-prime/Algebra';
|
||||||
import 'nerdamer-prime/Solve';
|
import 'nerdamer-prime/Solve';
|
||||||
import 'nerdamer-prime/Calculus';
|
import 'nerdamer-prime/Calculus';
|
||||||
import Qty from 'js-quantities';
|
import Qty from 'js-quantities';
|
||||||
import { error } from 'console';
|
import { CustomSnackBarContext } from 'contexts/CustomSnackBarContext';
|
||||||
|
|
||||||
function numericSolveEquationFor(
|
function numericSolveEquationFor(
|
||||||
equation: string,
|
equation: string,
|
||||||
@@ -59,15 +57,8 @@ export default async function makeTool(
|
|||||||
presets: {}
|
presets: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataTables: { [key: string]: DataTable } = {};
|
|
||||||
|
|
||||||
for (const selection of calcData.selections || []) {
|
|
||||||
dataTables[selection.source] = await getDataTable(selection.source);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function GenericCalc({ title }: ToolComponentProps) {
|
return function GenericCalc({ title }: ToolComponentProps) {
|
||||||
const [result, setResult] = useState<string>('');
|
const { showSnackBar } = useContext(CustomSnackBarContext);
|
||||||
|
|
||||||
const [alternatesByVariable, setAlternatesByVariable] = useState<{
|
const [alternatesByVariable, setAlternatesByVariable] = useState<{
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
value: {
|
value: {
|
||||||
@@ -126,7 +117,7 @@ export default async function makeTool(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectionData = calcData.selections?.find(
|
const selectionData = calcData.presets?.find(
|
||||||
(sel) => sel.title === selection
|
(sel) => sel.title === selection
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -142,12 +133,11 @@ export default async function makeTool(
|
|||||||
updateVarField(
|
updateVarField(
|
||||||
key,
|
key,
|
||||||
|
|
||||||
dataTableLookup(dataTables[selectionData.source], preset)[
|
dataTableLookup(selectionData.source, preset)[
|
||||||
selectionData.bind[key]
|
selectionData.bind[key]
|
||||||
],
|
],
|
||||||
|
|
||||||
dataTables[selectionData.source].columns[selectionData.bind[key]]
|
selectionData.source.columns[selectionData.bind[key]]?.unit || '',
|
||||||
?.unit || '',
|
|
||||||
currentValues,
|
currentValues,
|
||||||
updateFieldFunc
|
updateFieldFunc
|
||||||
);
|
);
|
||||||
@@ -178,19 +168,16 @@ export default async function makeTool(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
calcData.selections?.forEach((selection) => {
|
calcData.presets?.forEach((selection) => {
|
||||||
initialValues.presets[selection.title] = selection.default;
|
initialValues.presets[selection.title] = selection.default;
|
||||||
if (selection.default == '<custom>') return;
|
if (selection.default == '<custom>') return;
|
||||||
for (const key in selection.bind) {
|
for (const key in selection.bind) {
|
||||||
initialValues.vars[key] = {
|
initialValues.vars[key] = {
|
||||||
value: dataTableLookup(
|
value: dataTableLookup(selection.source, selection.default)[
|
||||||
dataTables[selection.source],
|
selection.bind[key]
|
||||||
selection.default
|
],
|
||||||
)[selection.bind[key]],
|
|
||||||
|
|
||||||
unit:
|
unit: selection.source.columns[selection.bind[key]]?.unit || ''
|
||||||
dataTables[selection.source].columns[selection.bind[key]]?.unit ||
|
|
||||||
''
|
|
||||||
};
|
};
|
||||||
valsBoundToPreset[key] = selection.title;
|
valsBoundToPreset[key] = selection.title;
|
||||||
}
|
}
|
||||||
@@ -264,6 +251,8 @@ export default async function makeTool(
|
|||||||
calcData.formula
|
calcData.formula
|
||||||
}}
|
}}
|
||||||
getGroups={({ values, updateField }) => [
|
getGroups={({ values, updateField }) => [
|
||||||
|
...(calcData.presets?.length
|
||||||
|
? [
|
||||||
{
|
{
|
||||||
title: 'Presets',
|
title: 'Presets',
|
||||||
component: (
|
component: (
|
||||||
@@ -276,7 +265,7 @@ export default async function makeTool(
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{calcData.selections?.map((preset) => (
|
{calcData.presets?.map((preset) => (
|
||||||
<TableRow key={preset.title}>
|
<TableRow key={preset.title}>
|
||||||
<TableCell>{preset.title}</TableCell>
|
<TableCell>{preset.title}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
@@ -286,9 +275,7 @@ export default async function makeTool(
|
|||||||
value={values.presets[preset.title]}
|
value={values.presets[preset.title]}
|
||||||
options={[
|
options={[
|
||||||
'<custom>',
|
'<custom>',
|
||||||
...Object.keys(
|
...Object.keys(preset.source.data).sort()
|
||||||
dataTables[preset.source].data
|
|
||||||
).sort()
|
|
||||||
]}
|
]}
|
||||||
sx={{ width: 300 }}
|
sx={{ width: 300 }}
|
||||||
onChange={(event, newValue) => {
|
onChange={(event, newValue) => {
|
||||||
@@ -310,7 +297,9 @@ export default async function makeTool(
|
|||||||
</Table>
|
</Table>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
title: 'Variables',
|
title: 'Variables',
|
||||||
component: (
|
component: (
|
||||||
@@ -330,9 +319,6 @@ export default async function makeTool(
|
|||||||
<TableCell>{variable.title}</TableCell>
|
<TableCell>{variable.title}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<NumericInputWithUnit
|
<NumericInputWithUnit
|
||||||
description={
|
|
||||||
valsBoundToPreset[variable.name] || ''
|
|
||||||
}
|
|
||||||
defaultPrefix={variable.defaultPrefix}
|
defaultPrefix={variable.defaultPrefix}
|
||||||
value={values.vars[variable.name]}
|
value={values.vars[variable.name]}
|
||||||
disabled={
|
disabled={
|
||||||
@@ -351,7 +337,6 @@ export default async function makeTool(
|
|||||||
updateField
|
updateField
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
type="number"
|
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -362,9 +347,6 @@ export default async function makeTool(
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<NumericInputWithUnit
|
<NumericInputWithUnit
|
||||||
key={alt.title}
|
key={alt.title}
|
||||||
description={
|
|
||||||
valsBoundToPreset[alt.title] || ''
|
|
||||||
}
|
|
||||||
defaultPrefix={alt.defaultPrefix || ''}
|
defaultPrefix={alt.defaultPrefix || ''}
|
||||||
value={{
|
value={{
|
||||||
value:
|
value:
|
||||||
@@ -442,7 +424,7 @@ export default async function makeTool(
|
|||||||
]}
|
]}
|
||||||
compute={(values) => {
|
compute={(values) => {
|
||||||
if (values.outputVariable === '') {
|
if (values.outputVariable === '') {
|
||||||
setResult('Please select a solve for variable');
|
showSnackBar('Please select a solve for variable', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let expr: nerdamer.Expression | null = null;
|
let expr: nerdamer.Expression | null = null;
|
||||||
@@ -491,8 +473,6 @@ export default async function makeTool(
|
|||||||
result = (result as unknown as nerdamer.Expression[])[0];
|
result = (result as unknown as nerdamer.Expression[])[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
setResult(result.toString());
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
if (values.vars[values.outputVariable] != undefined) {
|
if (values.vars[values.outputVariable] != undefined) {
|
||||||
values.vars[values.outputVariable].value = parseFloat(
|
values.vars[values.outputVariable].value = parseFloat(
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import { InitialValuesType } from './types';
|
|
||||||
|
|
||||||
export function main(input: string, options: InitialValuesType): string {
|
|
||||||
return input + 'pp';
|
|
||||||
}
|
|
Reference in New Issue
Block a user