Skip to content

Commit

Permalink
fixed more styling issues and added dotenv for production
Browse files Browse the repository at this point in the history
  • Loading branch information
peace317 committed Aug 17, 2024
1 parent 652edce commit 8e86036
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
REACT_APP_ALLOW_CONTEXT_MENU=false
UPDATE_PORT_LIST_INTERVAL=5000
UPDATE_PORT_LIST_INTERVAL=5000
DEBUG_PROD=false
50 changes: 50 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"@electron/fuses": "^1.8.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/dotenv-webpack": "^7.0.7",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"@typescript-eslint/parser": "^8.0.1",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"css-loader": "^6.0.0",
"dotenv-webpack": "^8.1.0",
"electron": "^31.3.1",
"eslint": "^8.0.1",
"eslint-import-resolver-typescript": "^3.6.1",
Expand Down
1 change: 1 addition & 0 deletions src/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import z from "zod";
const environmentVariables = z.object({
REACT_APP_ALLOW_CONTEXT_MENU: z.string().default("true"),
UPDATE_PORT_LIST_INTERVAL: z.coerce.number().default(5000),
DEBUG_PROD: z.string().optional()
});

const parsedResults = environmentVariables.safeParse(process.env);
Expand Down
14 changes: 8 additions & 6 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import Store from "electron-store";
import defaults from "./defaultSettings";
import log from "electron-log";
import MenuBuilder from "./menu";
import SerialPortListener from '@/main/serialportListener';
import SerialPortListener from "@/main/serialportListener";

// Before doing anything, make sure logger is assigned to track everything in the ongoing initialization
Object.assign(console, log.functions);
log.initialize({ spyRendererConsole: true });

import "dotenv/config";
import "@/lib/env"
import "@/lib/env";

// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
// whether you're running in development or production).
Expand Down Expand Up @@ -166,10 +172,6 @@ ipcMain.on(IPCChannelType.IS_DEVELOPMENT, async (event) => {
event.returnValue = isDevelopment;
});

ipcMain.on(IPCChannelType.GET_ENV, async (event, arg) => {
event.returnValue = process.env[arg];
});

ipcMain.on(IPCChannelType.CHANGE_THEME, async (event, args) => {
nativeTheme.themeSource = args[0];
});
5 changes: 3 additions & 2 deletions src/renderer/components/output/OutputDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { useContext } from '@/renderer/context';
import { IDefaultProps, IPCChannelType } from '@minterm/types';
import OutputDataTableCore from './OutputDataTableCore';
import clsx from 'clsx';

interface IOutputDataTableProps extends IDefaultProps {
selectedCells: Array<any>;
Expand Down Expand Up @@ -39,9 +40,9 @@ const OutputDataTable: React.FC<IOutputDataTableProps> = ({
}, []);

return (
<div id={`${id}:container`} className={`${className} h-full`}>
<div id={`${id}:container`} className={clsx(className, "h-full")}>
<OutputDataTableCore
id={`${id}:outputTable`}
id={`${id}:outputTableCore`}
data={receivedData}
setData={setReceivedData}
clearButtonToolTip={t('CLEAR_RECEIVED')}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/output/OutputDataTableCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useResizeDetector } from 'react-resize-detector';
import { ConversionType, DataPointType } from '@minterm/types';
import ActionBar, { ActionBarProps } from './ActionBar';
import clsx from 'clsx';

interface IOutputDataTableCoreProps extends ActionBarProps {
data: Array<DataPointType>;
Expand Down Expand Up @@ -213,8 +214,7 @@ const OutputDataTableCore: React.FC<IOutputDataTableCoreProps> = ({
<div
id={`${id}:container`}
ref={ref}
className={`${className} h-full`}
style={{ paddingBottom: '50px' }}
className={clsx(className, "flex-column")}
>
<ActionBar
id={`${id}:outputActionBar`}
Expand All @@ -231,7 +231,7 @@ const OutputDataTableCore: React.FC<IOutputDataTableCoreProps> = ({
/>
<div className="h-full datatable">
<DataTable
id={id}
id={`${id}:dataTable`}
value={tableData}
responsiveLayout="scroll"
scrollable
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/output/OutputLineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const OutputLineChart: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
const opacity = isDataNumeric ? "1" : "0.5";
return (
<Chart
id={id}
id={id + ":chart"}
ref={chartRef}
type="line"
className="w-full"
Expand All @@ -246,7 +246,7 @@ const OutputLineChart: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
};

return (
<div id={id + ":container"} className={clsx(className, " h-full flex flex-column")}>
<div id={id + ":container"} className={clsx(className, "flex-column")}>
<ActionBar
id={id + ":outputActionBar"}
data={receivedData}
Expand Down
13 changes: 4 additions & 9 deletions src/renderer/components/output/OutputTabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TabPanel, TabView } from 'primereact/tabview';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useContext } from '@/renderer/context';
import { IDefaultProps, IPCChannelType } from '@minterm/types';
import { IDefaultProps } from '@minterm/types';
import ContextMenuOutput from './ContextMenuOutput';
import OutputDataTable from './OutputDataTable';
import OutputTextArea from './OutputTextArea';
Expand All @@ -18,11 +18,7 @@ const OutputTabView: React.FC<IDefaultProps> = ({ id, className }) => {
);

const isContextEnabled = () => {
const env = window.electron?.ipcRenderer.fetch(
IPCChannelType.GET_ENV,
'REACT_APP_ALLOW_CONTEXT_MENU'
);
return env !== 'false';
return process.env.REACT_APP_ALLOW_CONTEXT_MENU !== 'false';
};

return (
Expand All @@ -45,7 +41,7 @@ const OutputTabView: React.FC<IDefaultProps> = ({ id, className }) => {
className="h-full"
>
<OutputDataTable
id="outDataTable"
id="outputDataTable"
selectedCells={selectedCellsInTable}
setSelectedCells={setSelectedCellsInTable}
/>
Expand All @@ -56,8 +52,7 @@ const OutputTabView: React.FC<IDefaultProps> = ({ id, className }) => {
className="h-full"
>
<OutputTextArea
id="lineChart"
className="pb-5"
id={`${id}:outputTextArea`}
data={receivedData.map((i) => i.value).join('')}
setData={setReceivedData}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/output/OutputTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const OutputTextArea: React.FC<IOutputTextAreaProps> = ({


return (
<div id={`${id}:container`} className={clsx(className, "card h-full")}>
<div hidden={actionBarHidden}>
<div id={`${id}:container`} className={clsx(className, "flex-column")}>
<div id={`${id}:outputActionBarWrapper`} hidden={actionBarHidden}>
<ActionBar
id={`${id}:outputActionBar`}
data={data}
Expand All @@ -84,15 +84,15 @@ const OutputTextArea: React.FC<IOutputTextAreaProps> = ({
clearButtonToolTip={t('CLEAR_RECEIVED')}
/>
</div>
<div className="h-full">
<div id={`${id}:outputTextWrapper`} className="h-full">
<Button
onClick={goDown}
visible={downScrollable}
className="scrollDown p-button-text"
icon="pi pi-angle-down"
/>
<InputTextarea
id={id}
id={`${id}:outputText`}
value={data}
readOnly
ref={ref}
Expand Down
14 changes: 4 additions & 10 deletions src/renderer/components/output/TransmitDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,28 @@ const TransmitDataTable: React.FC<IDefaultProps> = ({ id, className }) => {
const [selectedCells, setSelectedCells] = useState<Array<any>>([]);

const isContextEnabled = () => {
const env = window.electron?.ipcRenderer.fetch(
IPCChannelType.GET_ENV,
'REACT_APP_ALLOW_CONTEXT_MENU'
);
return env !== 'false';
return process.env.REACT_APP_ALLOW_CONTEXT_MENU !== 'false';
};

return (
<div id={`${id}:container`} className={clsx(className, 'w-full h-full')}>
<div id={`${id}:container`} className={clsx(className, 'flex-column w-full pt-2')} style={{padding: "1.25rem"}}>
{isContextEnabled() && (
<ContextMenuOutput
data={transmittedData}
selectedCells={selectedCells}
onContextMenu={contextEvent}
/>
)}
<SequenceInput id="sequenceInput" className="w-full mt-2 pr-3" />
<SequenceInput id={`${id}:sequenceInput`} className='mb-2' />
<div
className="h-full"
style={{ padding: '0.5rem 1rem 3rem' }}
onContextMenu={setContextEvent}
>
<OutputDataTableCore
id="outputTable"
id={`${id}:outputDataTableCore`}
data={transmittedData}
setData={setTransmittedData}
clearButtonToolTip={t('CLEAR_TRANSMITTED')}
className="pb-3"
dataCountLabel="Tx"
selectedCells={selectedCells}
setSelectedCells={setSelectedCells}
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/resources/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ body {
margin: 0;
}

.flex-column {
display: flex;
flex-direction: column;
height: 100%; /* Optional: Kann verwendet werden, um den Container auf die volle Höhe zu strecken */
}

.pi {
font-size: 1rem !important;
}
Expand Down
2 changes: 2 additions & 0 deletions webpack.plugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import Dotenv from 'dotenv-webpack';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
Expand All @@ -7,4 +8,5 @@ export const plugins = [
new ForkTsCheckerWebpackPlugin({
logger: 'webpack-infrastructure',
}),
new Dotenv()
];

0 comments on commit 8e86036

Please sign in to comment.