From c100c11a2f864db1b76b44562f8ad7b795f0c8c0 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Tue, 12 Nov 2019 15:04:32 +0000 Subject: [PATCH] fix: rebase issues and code style --- migrations/001-initial.js | 8 -- .../1572524820075-server-support-logs.js | 15 +++- new-lamassu-admin/src/components/Uptime.js | 2 +- .../components/fake-table/EditableTable.js | 60 --------------- .../src/components/fake-table/Table.js | 2 +- .../src/components/fake-table/Table.styles.js | 36 --------- .../src/components/inputs/Checkbox.js | 43 ----------- .../src/components/inputs/Radio.js | 14 ---- .../src/components/inputs/Switch.js | 73 ------------------- .../src/components/inputs/TextInput.js | 51 ------------- .../autocomplete/AutocompleteMultiple.js | 2 +- .../src/components/inputs/base/Checkbox.js | 2 +- .../components/inputs/{ => base}/Select.js | 0 .../inputs/{ => base}/Select.styles.js | 6 +- .../src/components/inputs/index.js | 10 +-- .../src/components/table/Table.js | 2 - .../src/pages/Funding.module.scss | 60 --------------- new-lamassu-admin/src/pages/Logs.module.scss | 52 ------------- new-lamassu-admin/src/pages/Logs.styles.js | 6 +- new-lamassu-admin/src/pages/ServerLogs.js | 3 +- 20 files changed, 28 insertions(+), 419 deletions(-) delete mode 100644 new-lamassu-admin/src/components/fake-table/EditableTable.js delete mode 100644 new-lamassu-admin/src/components/fake-table/Table.styles.js delete mode 100644 new-lamassu-admin/src/components/inputs/Checkbox.js delete mode 100644 new-lamassu-admin/src/components/inputs/Radio.js delete mode 100644 new-lamassu-admin/src/components/inputs/Switch.js delete mode 100644 new-lamassu-admin/src/components/inputs/TextInput.js rename new-lamassu-admin/src/components/inputs/{ => base}/Select.js (100%) rename new-lamassu-admin/src/components/inputs/{ => base}/Select.styles.js (88%) delete mode 100644 new-lamassu-admin/src/pages/Funding.module.scss delete mode 100644 new-lamassu-admin/src/pages/Logs.module.scss diff --git a/migrations/001-initial.js b/migrations/001-initial.js index f49b331b..c4ac59ce 100644 --- a/migrations/001-initial.js +++ b/migrations/001-initial.js @@ -2,14 +2,6 @@ const db = require('./db') exports.up = function (next) { var sqls = [ - 'create table server_logs ( ' + - 'id uuid PRIMARY KEY, ' + - 'device_id text, ' + - 'log_level text, ' + - 'timestamp timestamptz DEFAULT now(), ' + - 'message text, ' + - 'meta json)', - 'CREATE TABLE IF NOT EXISTS user_config ( ' + 'id serial PRIMARY KEY, ' + 'type text NOT NULL, ' + diff --git a/migrations/1572524820075-server-support-logs.js b/migrations/1572524820075-server-support-logs.js index 6edaadff..f34ffcc0 100644 --- a/migrations/1572524820075-server-support-logs.js +++ b/migrations/1572524820075-server-support-logs.js @@ -2,9 +2,18 @@ var db = require('./db') exports.up = function (next) { const sql = - [`create table server_support_logs ( - id uuid PRIMARY KEY, - timestamp timestamptz not null default now() )` + [ + 'create table server_logs ( ' + + 'id uuid PRIMARY KEY, ' + + 'device_id text, ' + + 'log_level text, ' + + 'timestamp timestamptz DEFAULT now(), ' + + 'message text, ' + + 'meta json)', + + `create table server_support_logs ( + id uuid PRIMARY KEY, + timestamp timestamptz not null default now() )` ] db.multi(sql, next) diff --git a/new-lamassu-admin/src/components/Uptime.js b/new-lamassu-admin/src/components/Uptime.js index aaa23f8f..957e746a 100644 --- a/new-lamassu-admin/src/components/Uptime.js +++ b/new-lamassu-admin/src/components/Uptime.js @@ -3,7 +3,7 @@ import { floor, lowerCase, startCase } from 'lodash/fp' import { makeStyles } from '@material-ui/core' import classnames from 'classnames' -import { spring3, spring2, mistyRose, tomato, zircon, comet, white, fontSecondary } from '../styling/variables' +import { spring3, spring2, mistyRose, tomato, comet } from '../styling/variables' import typographyStyles from './typography/styles' const { label } = typographyStyles diff --git a/new-lamassu-admin/src/components/fake-table/EditableTable.js b/new-lamassu-admin/src/components/fake-table/EditableTable.js deleted file mode 100644 index 6b38d3d1..00000000 --- a/new-lamassu-admin/src/components/fake-table/EditableTable.js +++ /dev/null @@ -1,60 +0,0 @@ -import React, { useState } from 'react' - -import { - Td, - Tr, - THead, - TBody, - Table -} from './Table' - -import { Link } from '../../components/buttons' - -const EditableRow = ({ elements, cancel, save }) => { - const [editing, setEditing] = useState(false) - const innerCancel = () => { - setEditing(false) - cancel() - } - - return ( - - {elements.map(({ size, edit, view }, idx) => ( - {editing ? edit : view} - ))} - - {editing ? ( - <> - - Cancel - - - Save - - - ) : ( - setEditing(true)}> - Edit - - )} - - - ) -} - -const EditableTable = ({ elements = [], data = [], cancel, save }) => { - return ( - - - {elements.map(({ size, header }, idx) => ( - - ))} - - - {data.map((it, idx) => )} - -
{header}
- ) -} - -export default EditableTable diff --git a/new-lamassu-admin/src/components/fake-table/Table.js b/new-lamassu-admin/src/components/fake-table/Table.js index 94123696..a12678ea 100644 --- a/new-lamassu-admin/src/components/fake-table/Table.js +++ b/new-lamassu-admin/src/components/fake-table/Table.js @@ -16,7 +16,7 @@ import { import typographyStyles from '../typography/styles' -const { label2, p, info2 } = typographyStyles +const { label2, p } = typographyStyles const useStyles = makeStyles({ body: { diff --git a/new-lamassu-admin/src/components/fake-table/Table.styles.js b/new-lamassu-admin/src/components/fake-table/Table.styles.js deleted file mode 100644 index dc26d465..00000000 --- a/new-lamassu-admin/src/components/fake-table/Table.styles.js +++ /dev/null @@ -1,36 +0,0 @@ -import { - tableHeaderColor, - tableHeaderHeight, - spacer, - white -} from '../styling/variables' - -import typographyStyles from './typography/styles' - -const { label2 } = typographyStyles - -export default { - tableBody: { - borderSpacing: '0 4px' - }, - header: { - extend: label2, - backgroundColor: tableHeaderColor, - height: tableHeaderHeight, - textAlign: 'left', - color: white, - // display: 'flex' - display: 'table-row' - }, - td: { - padding: `0 ${spacer * 3}px` - }, - tdHeader: { - verticalAlign: 'middle', - display: 'table-cell', - padding: `0 ${spacer * 3}px` - }, - summary: { - cursor: 'auto' - } -} diff --git a/new-lamassu-admin/src/components/inputs/Checkbox.js b/new-lamassu-admin/src/components/inputs/Checkbox.js deleted file mode 100644 index 1fe9e747..00000000 --- a/new-lamassu-admin/src/components/inputs/Checkbox.js +++ /dev/null @@ -1,43 +0,0 @@ -import React, { memo } from 'react' -import { makeStyles } from '@material-ui/core/styles' -import Checkbox from '@material-ui/core/Checkbox' -import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank' -import CheckBoxIcon from '@material-ui/icons/CheckBox' - -import { secondaryColor } from '../../styling/variables' - -const useStyles = makeStyles({ - root: { - color: secondaryColor, - '&$checked': { - color: secondaryColor - } - }, - checked: {} -}) - -const CheckboxInput = memo(({ label, ...props }) => { - const classes = useStyles() - - const { name, onChange, value } = props.field - const { values, touched, errors } = props.form - - return ( - } - checkedIcon={} - disableRipple - {...props} - /> - ) -}) - -export default CheckboxInput diff --git a/new-lamassu-admin/src/components/inputs/Radio.js b/new-lamassu-admin/src/components/inputs/Radio.js deleted file mode 100644 index 39b1c2be..00000000 --- a/new-lamassu-admin/src/components/inputs/Radio.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' - -function Radio ({ label, ...props }) { - return ( - <> - - - ) -} - -export default Radio diff --git a/new-lamassu-admin/src/components/inputs/Switch.js b/new-lamassu-admin/src/components/inputs/Switch.js deleted file mode 100644 index 0ff25bfc..00000000 --- a/new-lamassu-admin/src/components/inputs/Switch.js +++ /dev/null @@ -1,73 +0,0 @@ -import React, { memo } from 'react' -import { makeStyles } from '@material-ui/core/styles' -import Switch from '@material-ui/core/Switch' - -import { secondaryColor, offColor, disabledColor, disabledColor2 } from '../../styling/variables' - -const useStyles = makeStyles(theme => ({ - root: { - width: 32, - height: 20, - padding: 0, - margin: theme.spacing(1) - }, - switchBase: { - padding: 2, - '&$disabled': { - color: disabledColor2, - '& + $track': { - backgroundColor: disabledColor, - opacity: 1 - } - }, - '&$checked': { - color: theme.palette.common.white, - '& + $track': { - backgroundColor: secondaryColor, - opacity: 1, - border: 'none' - } - }, - '&$focusVisible $thumb': { - border: '6px solid #fff' - } - }, - thumb: { - width: 16, - height: 16 - }, - track: { - borderRadius: 17, - border: 'none', - backgroundColor: offColor, - opacity: 1, - transition: theme.transitions.create(['background-color', 'border']) - }, - disabled: { - }, - checked: { - }, - focusVisible: { - } -})) - -const SwitchInput = memo(({ ...props }) => { - const classes = useStyles() - return ( - - ) -}) - -export default SwitchInput diff --git a/new-lamassu-admin/src/components/inputs/TextInput.js b/new-lamassu-admin/src/components/inputs/TextInput.js deleted file mode 100644 index 2e5c5310..00000000 --- a/new-lamassu-admin/src/components/inputs/TextInput.js +++ /dev/null @@ -1,51 +0,0 @@ -import React, { memo } from 'react' -import TextField from '@material-ui/core/TextField' -import InputAdornment from '@material-ui/core/InputAdornment' -import { makeStyles } from '@material-ui/core/styles' - -import { fontColor, inputFontSize, inputFontSizeLg, inputFontWeight } from '../../styling/variables' - -const useStyles = makeStyles({ - inputRoot: { - fontSize: inputFontSize, - color: fontColor, - fontWeight: inputFontWeight - }, - inputRootLg: { - fontSize: inputFontSizeLg, - color: fontColor, - fontWeight: inputFontWeight - }, - labelRoot: { - color: fontColor - } -}) - -const TextInput = memo(({ suffix, large, ...props }) => { - const { name, onChange, onBlur, value } = props.field - const { touched, errors } = props.form - const classes = useStyles() - - return ( - - {suffix} - - ) : null - }} - InputLabelProps={{ className: classes.labelRoot }} - {...props} - /> - ) -}) - -export default TextInput diff --git a/new-lamassu-admin/src/components/inputs/autocomplete/AutocompleteMultiple.js b/new-lamassu-admin/src/components/inputs/autocomplete/AutocompleteMultiple.js index 9c37c530..08a6c7aa 100644 --- a/new-lamassu-admin/src/components/inputs/autocomplete/AutocompleteMultiple.js +++ b/new-lamassu-admin/src/components/inputs/autocomplete/AutocompleteMultiple.js @@ -16,7 +16,7 @@ const AutocompleteMultiple = memo( const [popperNode, setPopperNode] = useState(null) const onDelete = item => { - let selectedItem = (value || []).slice() + const selectedItem = (value || []).slice() const index = selectedItem.indexOf(item) if (index === -1) return diff --git a/new-lamassu-admin/src/components/inputs/base/Checkbox.js b/new-lamassu-admin/src/components/inputs/base/Checkbox.js index 9db8056b..032eb676 100644 --- a/new-lamassu-admin/src/components/inputs/base/Checkbox.js +++ b/new-lamassu-admin/src/components/inputs/base/Checkbox.js @@ -1,4 +1,4 @@ -import React, { memo } from 'react' +import React from 'react' import { makeStyles } from '@material-ui/core/styles' import Checkbox from '@material-ui/core/Checkbox' import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank' diff --git a/new-lamassu-admin/src/components/inputs/Select.js b/new-lamassu-admin/src/components/inputs/base/Select.js similarity index 100% rename from new-lamassu-admin/src/components/inputs/Select.js rename to new-lamassu-admin/src/components/inputs/base/Select.js diff --git a/new-lamassu-admin/src/components/inputs/Select.styles.js b/new-lamassu-admin/src/components/inputs/base/Select.styles.js similarity index 88% rename from new-lamassu-admin/src/components/inputs/Select.styles.js rename to new-lamassu-admin/src/components/inputs/base/Select.styles.js index 2b8f28e4..d70d7c26 100644 --- a/new-lamassu-admin/src/components/inputs/Select.styles.js +++ b/new-lamassu-admin/src/components/inputs/base/Select.styles.js @@ -1,7 +1,7 @@ -import { zircon, comet, white, fontSecondary } from '../../styling/variables' -import typographyStyles from '../typography/styles' +import { zircon, comet, white } from '../../../styling/variables' +import typographyStyles from '../../typography/styles' -const { select, regularLabel, label, label2 } = typographyStyles +const { select, regularLabel } = typographyStyles const WIDTH = 152 diff --git a/new-lamassu-admin/src/components/inputs/index.js b/new-lamassu-admin/src/components/inputs/index.js index 6bae3bda..c7af2a30 100644 --- a/new-lamassu-admin/src/components/inputs/index.js +++ b/new-lamassu-admin/src/components/inputs/index.js @@ -1,9 +1,9 @@ import Autocomplete from './autocomplete/Autocomplete' import AutocompleteMultiple from './autocomplete/AutocompleteMultiple' -import Checkbox from './Checkbox' -import Radio from './Radio' -import TextInput from './TextInput' -import Switch from './Switch' -import Select from './Select' +import Checkbox from './base/Checkbox' +import Radio from './base/Radio' +import TextInput from './base/TextInput' +import Switch from './base/Switch' +import Select from './base/Select' export { Autocomplete, AutocompleteMultiple, TextInput, Radio, Checkbox, Switch, Select } diff --git a/new-lamassu-admin/src/components/table/Table.js b/new-lamassu-admin/src/components/table/Table.js index 934e691a..77abc0b3 100644 --- a/new-lamassu-admin/src/components/table/Table.js +++ b/new-lamassu-admin/src/components/table/Table.js @@ -2,8 +2,6 @@ import React, { memo } from 'react' import classnames from 'classnames' import { makeStyles } from '@material-ui/core/styles' -import { tableHeaderColor } from '../../styling/variables' - const useStyles = makeStyles({ table: { // backgroundColor: tableHeaderColor, diff --git a/new-lamassu-admin/src/pages/Funding.module.scss b/new-lamassu-admin/src/pages/Funding.module.scss deleted file mode 100644 index a64f686f..00000000 --- a/new-lamassu-admin/src/pages/Funding.module.scss +++ /dev/null @@ -1,60 +0,0 @@ -$spacer: 8; -$subheader-color: white; -$placeholder-color: white; - -.wrapper { - display: flex; - flex-direction: row; - height: 100%; -} - -.main { - display: flex; - flex: 1; -} - -.firstSide { - margin: 0 ($spacer * 8px) 0 ($spacer * 6px); -} - -.secondSide { - margin-top: -49px; -} - -.coinTotal { - margin: ($spacer * 1.5px) 0; -} - -.noMargin { - margin: 0px; -} - -.leftSpacer { - margin-left: $spacer * 1px; -} - -.topSpacer { - margin-top: $spacer * 5px; -} - -.addressWrapper { - display: flex; - flex-direction: column; - flex: 1; - background-color: $subheader-color; -} - -.address { - width: 375px; - margin: ($spacer * 1.5px) ($spacer * 3px); -} - -.total { - margin-top: auto; - text-align: right; - margin-right: 20px; -} - -.totalTitle { - color: $placeholder-color; -} diff --git a/new-lamassu-admin/src/pages/Logs.module.scss b/new-lamassu-admin/src/pages/Logs.module.scss deleted file mode 100644 index c134602e..00000000 --- a/new-lamassu-admin/src/pages/Logs.module.scss +++ /dev/null @@ -1,52 +0,0 @@ -.titleWrapper { - display: flex; - justify-content: space-between; - align-items: center; - flex-direction: row; -} - -.wrapper { - display: flex; - flex-direction: row; - height: 100%; -} - -.tableWrapper { - flex: 1; - margin-left: 40px; - display: block; - overflow-x: auto; - width: 100%; - max-width: 78%; - max-height: 70vh; -} - -.table { - white-space: nowrap; - display: block; - & th { - position: sticky; - top: 0; - } -} - -.dateColumn { - min-width: 160px; -} - -.levelColumn { - min-width: 100px; -} - -.fillColumn { - width: 100%; -} - -.button { - margin: 8px; -} - -.buttonsWrapper { - display: flex; - align-items: center; -} diff --git a/new-lamassu-admin/src/pages/Logs.styles.js b/new-lamassu-admin/src/pages/Logs.styles.js index 9432029d..e0596f09 100644 --- a/new-lamassu-admin/src/pages/Logs.styles.js +++ b/new-lamassu-admin/src/pages/Logs.styles.js @@ -3,7 +3,7 @@ export default { display: 'flex', justifyContent: 'space-between', alignItems: 'center', - flexDirection: 'row', + flexDirection: 'row' }, wrapper: { display: 'flex', @@ -28,10 +28,10 @@ export default { } }, dateColumn: { - minWidth: 160, + minWidth: 160 }, levelColumn: { - minWidth: 100, + minWidth: 100 }, fillColumn: { width: '100%' diff --git a/new-lamassu-admin/src/pages/ServerLogs.js b/new-lamassu-admin/src/pages/ServerLogs.js index 968c275c..65e47d2c 100644 --- a/new-lamassu-admin/src/pages/ServerLogs.js +++ b/new-lamassu-admin/src/pages/ServerLogs.js @@ -14,13 +14,12 @@ import { ReactComponent as Download } from '../styling/icons/button/download/zod import { ReactComponent as DownloadActive } from '../styling/icons/button/download/white.svg' import { makeStyles } from '@material-ui/core' -import typographyStyles from '../components/typography/styles' +import { regularLabel } from '../components/typography/styles' import { comet } from '../styling/variables' import styles from './Logs.styles' import logPageHeaderStyles from './LogPageHeader.styles' -const { regularLabel } = typographyStyles const { tableWrapper } = styles const { titleAndButtonsContainer, buttonsWrapper } = logPageHeaderStyles