Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Commit

Permalink
feat(#14): standard fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oferitz committed Jul 1, 2018
1 parent 3909ca1 commit 8bb21a5
Show file tree
Hide file tree
Showing 45 changed files with 145 additions and 177 deletions.
6 changes: 3 additions & 3 deletions app/main/db/driver.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { r } = require('rebirthdb-ts')
//const { getServers, getTables } = require('./queries/stats')
// const { getServers, getTables } = require('./queries/stats')
// const r = require('rethinkdb')

let connection
Expand All @@ -8,7 +8,7 @@ const driver = {

getConnection: () => connection,

connect: async function(config = {}) {
connect: async function (config = {}) {
if (connection) {
console.info('there is an active connection - closing current connection')
await driver.disconnect()
Expand All @@ -19,7 +19,7 @@ const driver = {
console.info('connected')
return connection
},
async disconnect() {
async disconnect () {
if (connection && connection.close) {
return connection.close()
}
Expand Down
2 changes: 1 addition & 1 deletion app/main/db/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ module.exports = {
server,
table,
stats
}
}
6 changes: 3 additions & 3 deletions app/main/db/models/server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { serverList } = require('../queries/server')

const server = {
getServers() {
getServers () {
return serverList()
},

getServer(matchers = {}) {
getServer (matchers = {}) {

}
}

module.exports = server
module.exports = server
4 changes: 2 additions & 2 deletions app/main/db/models/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { STATS_CHANNEL_NAME } = require('../../../shared/channels')
let statsInterval = null

const stats = {
async onTick() {
async onTick () {
try {
const servers = await getServerStats()
const tables = await getTableStats()
Expand All @@ -28,7 +28,7 @@ const stats = {
console.warn('startLiveStats failed: ', e)
}
},
async startLiveStats() {
async startLiveStats () {
if (statsInterval) {
console.info('clearing stats interval...')
clearInterval(statsInterval)
Expand Down
6 changes: 3 additions & 3 deletions app/main/db/models/table.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { tablesByDb, deleteTables } = require('../queries/table')

const table = {
tablesByDb() {
tablesByDb () {
return tablesByDb()
},
deleteTables(tables) {
deleteTables (tables) {
return deleteTables(tables)
}
}

module.exports = table
module.exports = table
2 changes: 1 addition & 1 deletion app/main/db/queries/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ const serverList = () => {

module.exports = {
serverList
}
}
6 changes: 3 additions & 3 deletions app/main/db/resolvers/actionResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const table = require('../models/table')
const actions = {
'deleteTables': table.deleteTables
}
const actionResolver = ({name='action', payload={}}) => {
const actionResolver = ({name = 'action', payload = {}}) => {
if (!actions[name]) {
throw new Error(`Could not resolve action "${action}"`)
throw new Error(`Could not resolve action "${name}"`)
}
return actions[name](payload)
}

module.exports = actionResolver
module.exports = actionResolver
2 changes: 1 addition & 1 deletion app/main/db/resolvers/queryResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const table = require('../models/table')
const queries = {
'tablesByDb': table.tablesByDb
}
const queryResolver = ({name='query', payload={}}) => {
const queryResolver = ({name = 'query', payload = {}}) => {
if (!queries[name]) {
throw new Error(`Could not resolve query "${name}"`)
}
Expand Down
2 changes: 1 addition & 1 deletion app/main/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ const SYSTEM_DB = 'rethinkdb'

module.exports = {
SYSTEM_DB
}
}
2 changes: 1 addition & 1 deletion app/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('./db')

function init() {
function init () {
console.log('registering IPC handlers...')
}

Expand Down
2 changes: 1 addition & 1 deletion app/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import './style/app.js'
const history = createHashHistory()

class App extends Component {
render() {
render () {
return (
<StatsProvider>
<Router history={history}>
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/ActionsBar/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export const StyledActionsBar = styled('header')(props => ({
'h3': {
fontWeight: 500
}
}))
}))
4 changes: 2 additions & 2 deletions app/renderer/components/Alert/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { StyledAlert } from './styles.js'

const Alert = ({ type='basic', children }) => {
const Alert = ({ type = 'basic', children }) => {
return (
<StyledAlert type={type}>
{children}
</StyledAlert>
)
}

export default Alert
export default Alert
3 changes: 1 addition & 2 deletions app/renderer/components/Alert/styles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled, {css} from 'react-emotion'
import theme from '@/style/common'

const success = css`
color: #52c41a;
Expand Down Expand Up @@ -40,4 +39,4 @@ const alertStyle = props =>

export const StyledAlert = styled('p')`
${alertStyle};
`
`
2 changes: 1 addition & 1 deletion app/renderer/components/Error/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const toTitle = (error, componentStack) => {

const ErrorBoundaryFallbackComponent = ({ componentStack, error }) => (
<ErrorBoundryMessage>
<Icon className="error-icon" type="error" size={52} color="#29d829" />
<Icon className='error-icon' type='error' size={52} color='#29d829' />
<h2>Something went wrong...</h2>
<pre>{toTitle(error, componentStack)}</pre>
</ErrorBoundryMessage>
Expand Down
10 changes: 5 additions & 5 deletions app/renderer/components/Page/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@ const Logo = styled(Link)`

const Header = () => (
<Container>
<Logo to="/newConnection">
<Logo to='/newConnection'>
Rebirth<span>DB</span>
</Logo>
<nav>
<ul>
<li>
<NavLink to="/dashboard" activeClassName="active">
<NavLink to='/dashboard' activeClassName='active'>
Dashboard
</NavLink>
</li>
<li>
<NavLink to="/tables" activeClassName="active">
<NavLink to='/tables' activeClassName='active'>
Tables
</NavLink>
</li>
<li>
<NavLink to="/explorer" activeClassName="active">
<NavLink to='/explorer' activeClassName='active'>
Data Explorer
</NavLink>
</li>
<li>
<NavLink to="/logs" activeClassName="active">
<NavLink to='/logs' activeClassName='active'>
Logs
</NavLink>
</li>
Expand Down
31 changes: 15 additions & 16 deletions app/renderer/components/Page/Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const Item = styled.li`
text-align: center;
`


const DD = styled.div`
display: inline-block;
padding: 0.5rem;
Expand Down Expand Up @@ -47,18 +46,18 @@ const Info = () => (
<List>
<Item>
<DD>
<Icon type="connections" size={30} color={theme.mainColorLight} />
<Icon type='connections' size={30} color={theme.mainColorLight} />
</DD>
<FF>
<KK>Connected to</KK>
{/*<ServersConsumer>*/}
{/*{servers => <JJ>{servers[0] ? JSON.stringify(servers[0].server) : ''}</JJ>}*/}
{/*</ServersConsumer>*/}
{/* <ServersConsumer> */}
{/* {servers => <JJ>{servers[0] ? JSON.stringify(servers[0].server) : ''}</JJ>} */}
{/* </ServersConsumer> */}
</FF>
</Item>
<Item>
<DD>
<Icon type="danger" size={30} color={theme.mainColorLight} />
<Icon type='danger' size={30} color={theme.mainColorLight} />
</DD>
<FF>
<KK>Issues</KK>
Expand All @@ -67,26 +66,26 @@ const Info = () => (
</Item>
<Item>
<DD>
<Icon type="servers" size={30} color={theme.mainColorLight} />
<Icon type='servers' size={30} color={theme.mainColorLight} />
</DD>
<FF>
<kk>Servers</kk>
{/*<ServersConsumer>{servers => <JJ>{servers.length} Connected</JJ>}</ServersConsumer>*/}
{/* <ServersConsumer>{servers => <JJ>{servers.length} Connected</JJ>}</ServersConsumer> */}
</FF>
</Item>
<Item>
<DD>
<Icon type="table" size={30} color={theme.mainColorLight} />
<Icon type='table' size={30} color={theme.mainColorLight} />
</DD>
<FF>
<KK>Tables</KK>
{/*<TablesConsumer>*/}
{/*{tables => (*/}
{/*<JJ>*/}
{/*{tables.length}/{tables.length} ready*/}
{/*</JJ>*/}
{/*)}*/}
{/*</TablesConsumer>*/}
{/* <TablesConsumer> */}
{/* {tables => ( */}
{/* <JJ> */}
{/* {tables.length}/{tables.length} ready */}
{/* </JJ> */}
{/* )} */}
{/* </TablesConsumer> */}
</FF>
</Item>
</List>
Expand Down
10 changes: 2 additions & 8 deletions app/renderer/contexts/StatsContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class StatsProvider extends Component {
this.setState({ stats: statsData })
}

componentDidMount() {
componentDidMount () {
liveStats(this.onLiveStats)
}

render() {
render () {
const { stats } = this.state
const { children } = this.props
return (
Expand All @@ -28,10 +28,4 @@ class StatsProvider extends Component {
}
}


export default StatsProvider





16 changes: 8 additions & 8 deletions app/renderer/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ class Routes extends Component {
// return <NewConnection onConnected={this.props.onConnected} />
// }

render() {
render () {
return (
<ErrorBoundary FallbackComponent={Error}>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/newConnection" component={NewConnection} />
<Route exact path="/editConnection/:id" component={EditConnection} />
<Route exact path="/dashboard" component={Dashboard} />
<Route exact path="/tables" component={Tables} />
<Route exact path="/explorer" component={Explorer} />
<Route exact path="/logs" component={Logs} />
<Route exact path='/' component={Home} />
<Route exact path='/newConnection' component={NewConnection} />
<Route exact path='/editConnection/:id' component={EditConnection} />
<Route exact path='/dashboard' component={Dashboard} />
<Route exact path='/tables' component={Tables} />
<Route exact path='/explorer' component={Explorer} />
<Route exact path='/logs' component={Logs} />
</Switch>
</ErrorBoundary>
)
Expand Down
10 changes: 5 additions & 5 deletions app/renderer/service/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../helpers/connectionStore'

const connection = {
async create({ name, address }) {
async create ({ name, address }) {
try {
const result = await connect({ name, address })
if (result.socket.isOpen) {
Expand All @@ -22,16 +22,16 @@ const connection = {
return { error: e }
}
},
update(id, values) {
update (id, values) {
updateConnection(id, values)
},
deleteConnection(id) {
deleteConnection (id) {
removeConnection(id)
},
getConnectionById(id) {
getConnectionById (id) {
return getConnection(id)
},
getConnections() {
getConnections () {
return getConnectionList()
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/service/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export const connect = ({ name, address }) => {
return ipc.callMain(CONNECT_CHANNEL_NAME, { name, address })
}

export const query = (query='', args={}) => {
export const query = (query = '', args = {}) => {
return ipc.callMain(QUERIES_CHANNEL_NAME, query, args)
}

export const action = (action='', args={}) => {
export const action = (action = '', args = {}) => {
return ipc.callMain(ACTIONS_CHANNEL_NAME, action, args)
}

Expand Down
2 changes: 1 addition & 1 deletion app/renderer/style/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export default {
grayTextColor: '#8f8e9b',
// elements dimensions
appHeaderHeight: '38px',
sideBarWidth: '180px',
sideBarWidth: '180px'

}
Loading

0 comments on commit 8bb21a5

Please sign in to comment.