This repository has been archived by the owner on Jun 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#14): fetching data and creating db list
- Loading branch information
Showing
22 changed files
with
239 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,44 @@ | ||
const { r } = require('rebirthdb-ts') | ||
const driver = require('../driver') | ||
const { SYSTEM_DB } = require('../../helpers/constants') | ||
|
||
const tableList = () => { | ||
const connection = () => driver.getConnection() | ||
|
||
const tablesByDb = () => { | ||
return r | ||
.db('rethinkdb') | ||
.table('table_config') | ||
.coerceTo('array') | ||
.db(SYSTEM_DB) | ||
.table('db_config') | ||
.filter(db => db('name').ne(SYSTEM_DB)) | ||
.map(db => ({ | ||
name: db('name'), | ||
id: db('id'), | ||
tables: r | ||
.db(SYSTEM_DB) | ||
.table('table_status') | ||
.orderBy(table => table('name')) | ||
.filter({ db: db('name') }) | ||
.merge(table => ({ | ||
shards: table('shards') | ||
.count() | ||
.default(0), | ||
replicas: table('shards') | ||
.default([]) | ||
.map(shard => shard('replicas').count()) | ||
.sum(), | ||
replicasReady: table('shards') | ||
.default([]) | ||
.map(shard => | ||
shard('replicas') | ||
.filter(replica => replica('state').eq('ready')) | ||
.count() | ||
) | ||
.sum(), | ||
status: table('status'), | ||
id: table('id') | ||
})) | ||
})).run(connection()) | ||
} | ||
|
||
module.exports = { | ||
tableList | ||
} | ||
tablesByDb | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const table = require('./models/table') | ||
|
||
const queries = { | ||
'tablesByDb': table.tablesByDb | ||
} | ||
const queryResolver = (query='query', args) => { | ||
if (!queries[query]) { | ||
throw new Error(`Could not resolve query "${query}"`) | ||
} | ||
return queries[query](args) | ||
} | ||
|
||
module.exports = queryResolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { StyledActionsBar } from './styles.js' | ||
|
||
const ActionsBar = ({ title, children }) => { | ||
return ( | ||
<StyledActionsBar> | ||
<h3>{title}</h3> | ||
{children} | ||
</StyledActionsBar> | ||
) | ||
} | ||
|
||
export default ActionsBar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import styled from 'react-emotion' | ||
import theme from '@/style/common' | ||
|
||
export const StyledActionsBar = styled('header')(props => ({ | ||
|
||
width: '100%', | ||
backgroundColor: theme.contrastColor, | ||
borderBottom: `1px solid ${theme.mainBorderColor}`, | ||
height: '50px', | ||
padding: '15px', | ||
'h3': { | ||
fontWeight: 500 | ||
} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react' | ||
import { StyledDatabaseItem, DBLabel} from './styles' | ||
|
||
const DatabaseItem = props => { | ||
const { name } = props.item | ||
return ( | ||
<StyledDatabaseItem> | ||
<header> | ||
<DBLabel>Database</DBLabel> | ||
<span className="db-name">{name}</span> | ||
</header> | ||
<section>tables list</section> | ||
</StyledDatabaseItem> | ||
) | ||
} | ||
|
||
export default DatabaseItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
import { StyledDatabaseList} from './styles' | ||
import DatabaseItem from './DatabaseItem' | ||
|
||
const DatabaseList = props => { | ||
const { list } = props | ||
return ( | ||
<StyledDatabaseList> | ||
{list.map(db => ( | ||
<DatabaseItem key={db.id} item={db} /> | ||
))} | ||
</StyledDatabaseList> | ||
) | ||
} | ||
|
||
export default DatabaseList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import styled from 'react-emotion' | ||
import theme from '@/style/common' | ||
|
||
export const StyledDatabaseList = styled('ul')({ | ||
padding: '15px', | ||
listStyle: 'none' | ||
}) | ||
|
||
export const StyledDatabaseItem = styled('li')({ | ||
border: `1px solid ${theme.mainBorderColor}`, | ||
marginBottom: '10px', | ||
'header': { | ||
background: theme.contrastColor, | ||
padding: '8px', | ||
borderBottom: `1px solid ${theme.mainBorderColor}`, | ||
'.db-name': { | ||
paddingLeft: '20px', | ||
fontWeight: 500, | ||
fontSize: '16px' | ||
} | ||
}, | ||
'section': { | ||
padding: '8px', | ||
background: '#fff' | ||
} | ||
}) | ||
|
||
export const DBLabel = styled('span')({ | ||
display: 'inline-block', | ||
padding: '0 7px', | ||
height: '22px', | ||
lineHeight: '20px', | ||
textAlign: 'center', | ||
color: '#eb2f96', | ||
background: '#fff0f6', | ||
border: '1px solid #ffadd2', | ||
fontSize: '12px' | ||
|
||
}) |
Empty file.
Oops, something went wrong.