Skip to content

Commit

Permalink
removing errors, building first prerelease for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronleopold committed Dec 23, 2020
1 parent b222271 commit 31fbbb4
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 80 deletions.
20 changes: 13 additions & 7 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import url from 'url';
import { app, BrowserWindow, Menu, Event } from 'electron';
import is from 'electron-is';
import { autoUpdater } from 'electron-updater';
import installExtension, {
REACT_DEVELOPER_TOOLS,
} from 'electron-devtools-installer';

import './server/server';

console.log(process.env.ELECTRON_WEBPACK_APP_SECRET_KEY);
// console.log(process.env.ELECTRON_WEBPACK_APP_SECRET_KEY);

app.commandLine.appendSwitch('ignore-certificate-errors');

Expand All @@ -19,9 +17,17 @@ console.log(path.resolve(__dirname, 'flmnhLogo.png'));
export let win: BrowserWindow | null = null;

app.on('ready', () => {
installExtension(REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err));
if (is.dev()) {
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
} = require('electron-devtools-installer');
installExtension(REACT_DEVELOPER_TOOLS)
.then((name: any) => console.log(`Added Extension: ${name}`))
.catch((err: any) =>
console.log('Failed to install React Developer Tools: ', err)
);
}

const customMenu: any = Menu.getApplicationMenu()?.items.map((item: any) => {
if (item.role === 'filemenu') {
Expand Down
2 changes: 0 additions & 2 deletions src/main/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ import { queriablesStats } from './endpoints/sql/utils/queriablesStats';
import getTableLogs from './endpoints/sql/admin/getTableLogs';
import logUpdate from './endpoints/sql/utils/logUpdate';
import logDelete from './endpoints/sql/utils/logDelete';
import { sendStatusToWindow } from '..';
// import { win } from '..';

require('dotenv').config();

Expand Down
10 changes: 5 additions & 5 deletions src/renderer/components/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Chart as GChart } from 'react-google-charts';
import { useStore } from '../../stores';
import Spinner from './ui/Spinner';

function ChartError(props: any) {
console.log(props);
// function ChartError(props: any) {
// console.log(props);

return <div>fff</div>;
}
// return <div>fff</div>;
// }

export default function Chart() {
const allData = useStore((state) => state.queryData.data);
// const allData = useStore((state) => state.queryData.data);

const { chartType, options } = useStore((state) => state.chartConfig);

Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/TableCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { TableStats } from '../types';
import CreateDeleteTableModal from './modals/CreateDeleteTableModal';
import CreateEditTableModal from './modals/CreateEditTableModal';
import Button from './ui/Button';
import Heading from './ui/Heading';

import numeral from 'numeral';
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/forms/ChartConfigForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ type ChartConfigProps = {
keys: string[];
};

function validateStringConstraint(value: any) {
function validateStringConstraint(_value: any) {
return true;
}

function validateNumberConstraint(value: any) {}
// function validateNumberConstraint(_value: any) {}

type AggregateProps = {
fields: SelectOption[];
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/forms/ConditionalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '../utils/constants';
import numberParser from 'number-to-words';
import Text from '../ui/Text';
import { values } from 'lodash';
import Label from '../ui/Label';

type ConditionalFormProps = {
Expand Down
86 changes: 43 additions & 43 deletions src/renderer/components/modals/CreateAdminLogModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,48 @@ import Modal from '../ui/Modal';
import Tabs from '../ui/Tabs';
import useKeyboard from '../utils/useKeyboard';
import useToggle from '../utils/useToggle';
import { Logs } from '../../../stores/index';
import CopyButton from '../buttons/CopyButton';
import clsx from 'clsx';
import { Logs } from '../../../stores/table';

// TODO: make this ADMIN SPECIFIC

type LogProps = {
errors?: Logs;
};

function Log({ errors }: LogProps) {
const disabled = !errors || !errors.insert || !errors.insert.length;
// const clearErrors = useStore((state) => state.clearErrors);

return (
<div className="-mb-6">
<div className="mt-4 h-56 bg-gray-100 rounded-md overflow-scroll">
<div
className={clsx(
disabled && 'h-full',
'p-2 flex flex-col items-center justify-center'
)}
>
{/* {renderLog()} */}
<p>No errors exist in the log</p>
</div>
</div>

<div className="mt-3 flex space-x-2 items-center justify-end">
<Button
disabled={disabled}
variant="warning"
// onClick={() => clearErrors('')}
>
Clear
</Button>
<CopyButton
disabled={disabled}
value={JSON.stringify(errors?.insert, null, 2) ?? ''}
/>
</div>
</div>
);
}
// type LogProps = {
// errors?: Logs;
// };

// function Log({ errors }: LogProps) {
// const disabled = !errors || !errors.insert || !errors.insert.length;
// // const clearErrors = useStore((state) => state.clearErrors);

// return (
// <div className="-mb-6">
// <div className="mt-4 h-56 bg-gray-100 rounded-md overflow-scroll">
// <div
// className={clsx(
// disabled && 'h-full',
// 'p-2 flex flex-col items-center justify-center'
// )}
// >
// {/* {renderLog()} */}
// <p>No errors exist in the log</p>
// </div>
// </div>

// <div className="mt-3 flex space-x-2 items-center justify-end">
// <Button
// disabled={disabled}
// variant="warning"
// // onClick={() => clearErrors('')}
// >
// Clear
// </Button>
// <CopyButton
// disabled={disabled}
// value={JSON.stringify(errors?.insert, null, 2) ?? ''}
// />
// </div>
// </div>
// );
// }

type Props = {
initialTab?: number;
Expand Down Expand Up @@ -84,10 +82,12 @@ export default function CreateAdminLogModal({
switch (tab) {
// User Operations
case 0:
return <Log errors={errors} />;
// return <Log errors={errors} />;
return <div>TODO</div>;
// table operations
case 1:
return <Log errors={errors} />;
// return <Log errors={errors} />;
return <div>TODO</div>;

default:
return null;
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/modals/CreateDeleteTableModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default function CreateDeleteTableModal({ table }: Props) {

const { deleteTable } = useQuery();

function handleDelete() {}
console.log(table, deleteTable);

// function handleDelete() {}

return (
<React.Fragment>
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/modals/CreateEditTableModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export default function CreateEditTableModal({ table }: Props) {

const { updateTable } = useQuery();

function handleEdit(values: Values) {}
function handleEdit(_values: Values) {}

console.log(updateTable, handleEdit);

return (
<React.Fragment>
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/modals/CreateSelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default function CreateSelectModal({ open, onClose }: Props) {
value: values[`conditionalValue_${current}`],
};

const { field, operator, value } = conditional;
// value can be destructed too
const { field, operator } = conditional;

/**
* 'IS NOT NULL',
Expand Down
9 changes: 4 additions & 5 deletions src/renderer/components/modals/CreateSingleInsertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import Steps from '../ui/Steps';
import useKeyboard from '../utils/useKeyboard';
import CreateHelpModal from './CreateHelpModal';
import CreateLogModal from './CreateLogModal';
import axios from 'axios';
import useQuery from '../utils/useQuery';

type Props = {
open: boolean;
onClose(): void;
};

// TODO: will need this to be paginated, multistep form
export default function CreateSingleInsertModal({ open, onClose }: Props) {
const { insert } = useQuery();
const [page, changePage] = useState(0);

console.log(insert);

useKeyboard('Escape', () => {
onClose();
});
Expand All @@ -30,13 +30,14 @@ export default function CreateSingleInsertModal({ open, onClose }: Props) {
console.log(values);

const { databaseTable } = values;
console.log(databaseTable);

delete values.databaseTable;

const correctedArrays = arrayFieldsToString(values as Specimen);
const correctedNulls = getSpecimenDefaults(correctedArrays);

console.log(correctedNulls);
console.log(correctedNulls, 'TODO UNCOMMENT');

// await insert(databaseTable, correctedNulls);
}
Expand Down Expand Up @@ -104,8 +105,6 @@ export default function CreateSingleInsertModal({ open, onClose }: Props) {
</div>
</Modal.Footer>
</Modal>

{/* <Dropdown.Item text="Select" onClick={on} /> */}
</React.Fragment>
);
}
7 changes: 1 addition & 6 deletions src/renderer/components/ui/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AutoSizer,
Column,
Table as VTable,
TableRowProps,
TableProps as VTableProps,
} from 'react-virtualized';
import useWindowDimensions from '../utils/useWindowDimensions';
Expand Down Expand Up @@ -43,7 +42,7 @@ function VirtualTable({
...props
}: TableProps) {
const { width } = useWindowDimensions();
const [sortingDirection, setSortingDirection] = useState<SortingConfig>();
const [sortingDirection] = useState<SortingConfig>();

// TODO: this implementation won't hold after sorting
function getRowStyle({ index }: { index: number }) {
Expand Down Expand Up @@ -183,13 +182,9 @@ function VirtualTable({

function BasicTable({
data,
activeIndex,
headerClassName,
headers,
loading,
sortable,
containerClassname,
...props
}: TableProps) {
function getHeaders() {
return Array.from(headers).map((header) => {
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { GoogleChartType } from '../../types';
import { countries } from '../../assets/countries';
import { SelectOption } from '../ui/Select';

Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/utils/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import useExpiredSession from './useExpiredSession';
import axios from 'axios';
import { CountQueryReturn } from '../modals/CreateCountModal';
import { User } from '../UsersTable';
import insert from '../../../main/server/endpoints/sql/insert';
// import { queriablesStats } from '../../../main/server/endpoints/sql/utils/queriablesStats';

export default function useQuery() {
Expand Down Expand Up @@ -431,7 +430,7 @@ export default function useQuery() {
return undefined;
}
},
async updateTable(table: string, updates: any) {},
async updateTable(_table: string, _updates: any) {},
}),
[query, selectedSpecimen]
);
Expand Down
1 change: 0 additions & 1 deletion src/renderer/functions/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Specimen } from '../types';
import Qty from 'js-quantities'; //https://github.com/gentooboontoo/js-quantities
import { validUnits } from '../components/utils/constants';

export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
Expand Down
1 change: 0 additions & 1 deletion src/renderer/pages/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Heading from '../components/ui/Heading';
import TableCard from '../components/TableCard';
import { TableStats } from '../types';
import useQuery from '../components/utils/useQuery';
import Badge from '../components/ui/Badge';
import CreateCreateTableModal from '../components/modals/CreateCreateTableModal';

function AdminHeader({ username }: { username?: string }) {
Expand Down

0 comments on commit 31fbbb4

Please sign in to comment.