Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 18f5f58

Browse files
author
haad
committed
Refactor bits of UI, fix loading db from url, clean ups
1 parent df709c9 commit 18f5f58

File tree

13 files changed

+234
-105
lines changed

13 files changed

+234
-105
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> UI for managing [OrbitDB](https://github.com/orbitdb/orbit-db) databases.
44
5-
**Run the [Control Center](https://ipfs.io/ipfs/QmbUP5MPCYnFcouSmB5oRj91jNSHYGGbyqvbPUvNoxFomo) in your browser.**
5+
**Run the [Control Center](https://ipfs.io/ipfs/Qme9bwgUYgdLTA9ZpZnHqNHRXGfJ5QHw4BCzgrFQMB59T8) in your browser.**
66

77
<img width="80%" src="https://raw.githubusercontent.com/haadcode/orbit-db-control-center/master/screenshot1.png"/>
88

screenshot1.png

-58.4 KB
Loading

screenshot2.png

-12 KB
Loading

src/components/CounterStoreControls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function KeyValueStoreControls () {
5151
defaultValue={1}
5252
placeholder='amount'
5353
height={24}
54-
width='5%'
54+
width='10%'
5555
></TextInput>
5656
<Button
5757
iconBefore='plus'

src/components/DatabaseList.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import React from 'react'
2+
3+
import {
4+
majorScale,
5+
minorScale,
6+
Icon,
7+
IconButton,
8+
Table
9+
} from 'evergreen-ui'
10+
11+
import { useHistory } from 'react-router-dom'
12+
import { formatDistanceToNow } from 'date-fns'
13+
14+
const colors = {
15+
eventlog: '#47B881',
16+
feed: '#14B5D0',
17+
keyvalue: '#1070CA',
18+
docstore: '#D9822B',
19+
counter: '#735DD0'
20+
}
21+
22+
function ProgramList ({ programs, onRemove }) {
23+
const history = useHistory()
24+
25+
function handleSelect (program) {
26+
history.push(program.address)
27+
}
28+
29+
return (
30+
<Table>
31+
<Table.Head padding='0'>
32+
<Table.TextHeaderCell
33+
flex='1 1 2%'
34+
textAlign='center'
35+
padding={minorScale(2)}
36+
alignItems='baseline'
37+
>
38+
<Icon size={majorScale(2)} icon='eye-open'/>
39+
</Table.TextHeaderCell>
40+
<Table.TextHeaderCell flex='1 1 10%' paddingX={0}>Name</Table.TextHeaderCell>
41+
<Table.TextHeaderCell flex='1 1 5%' paddingX={minorScale(1)}>Type</Table.TextHeaderCell>
42+
<Table.TextHeaderCell flex='1 1 40%' paddingX={0}>Address</Table.TextHeaderCell>
43+
<Table.TextHeaderCell flex='1 1 10%' paddingX={0}>Added</Table.TextHeaderCell>
44+
<Table.TextHeaderCell
45+
flex='1 1 2%'
46+
textAlign='center'
47+
padding={minorScale(2)}
48+
alignItems='baseline'
49+
>
50+
<Icon size={12} icon='trash'/>
51+
</Table.TextHeaderCell>
52+
</Table.Head>
53+
<Table.Body>
54+
{programs.map(e => {
55+
const program = e.payload.value
56+
return (
57+
<Table.Row key={`program-id-${program.address}`}>
58+
<Table.Cell
59+
flex='1 1 2%'
60+
display='flex'
61+
flexDirection='row'
62+
justifyContent='center'
63+
padding={minorScale(2)}
64+
>
65+
<IconButton
66+
appearance='minimal'
67+
icon='database'
68+
margin={0}
69+
padding={0}
70+
onClick={() => handleSelect(program)}
71+
/>
72+
</Table.Cell>
73+
<Table.TextCell flex='1 1 10%' paddingX={0}>{program.name}</Table.TextCell>
74+
<Table.TextCell flex='1 1 5%' paddingX={minorScale(1)} textProps={{ color: colors[program.type]}}>
75+
{program.type}
76+
</Table.TextCell>
77+
<Table.TextCell flex='1 1 40%' paddingX={0}>{program.address.toString() ? program.address.toString() : program.address}</Table.TextCell>
78+
<Table.TextCell flex='1 1 10%' paddingX={0}>{program.added ? formatDistanceToNow(program.added) + ' ago': 'Unknown'}</Table.TextCell>
79+
<Table.Cell
80+
flex='1 1 2%'
81+
display='flex'
82+
flexDirection='row'
83+
justifyContent='center'
84+
padding={minorScale(2)}
85+
>
86+
<IconButton
87+
appearance='minimal'
88+
icon='cross'
89+
intent='danger'
90+
margin={0}
91+
padding={0}
92+
onClick={() => onRemove(e.hash, program)}
93+
/>
94+
</Table.Cell>
95+
</Table.Row>
96+
)})}
97+
</Table.Body>
98+
</Table>
99+
)
100+
}
101+
102+
export default ProgramList

src/components/Header.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ function Header () {
1818

1919
return (
2020
<Pane background='white' elevation={1}>
21-
<Pane display='flex' flexDirection='row'>
21+
<Pane
22+
className='row-wrap'
23+
display='flex'
24+
borderBottom='default'
25+
>
2226
<Pane
27+
className='align title'
2328
display='flex'
2429
flex='1 1 60%'
25-
paddingLeft={majorScale(6)}
26-
paddingY={majorScale(1)}
27-
borderBottom='default'
2830
>
2931
<Link
3032
href='#/'
@@ -33,22 +35,24 @@ function Header () {
3335
flexDirection='row'
3436
alignItems='center'
3537
>
36-
<img src='Orbit_round-02.png' width={majorScale(4)}/>
37-
<Heading size={800} fontFamily='Titillium Web' marginX={majorScale(2)}>CONTROL CENTER</Heading>
38+
<img src='Orbit_round-02.png' width={majorScale(5)}/>
39+
<Heading size={800} fontFamily='Titillium Web' marginX={majorScale(2)}>
40+
CONTROL CENTER
41+
</Heading>
3842
</Link>
3943
</Pane>
4044
<Pane
45+
className='align search'
4146
display='flex'
42-
flex='1 1 40%'
4347
alignItems='center'
4448
justifyContent='center'
45-
paddingRight={majorScale(6)}
4649
>
47-
<SearchInput
48-
placeholder='Search...'
50+
<SearchInput
51+
width='100%'
52+
flex='1 1 100%'
53+
placeholder='Search...'
4954
height={24}
50-
width='100%'
51-
onKeyUp={handleKeyUp}
55+
onKeyUp={handleKeyUp}
5256
/>
5357
</Pane>
5458
</Pane>

src/components/ProgramList.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/components/Systems.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Systems () {
3131
})
3232
}, [dispatch])
3333

34-
const statusIconSize = 8
34+
const statusIconSize = 6
3535

3636
return (
3737
<Pane background='white' elevation={1}>

src/database/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ export const getAllDatabases = async () => {
3434
}
3535

3636
export const getDB = async (address) => {
37-
const db = await orbitdb.open(address)
38-
await db.load()
37+
let db
38+
if (orbitdb) {
39+
db = await orbitdb.open(address)
40+
await db.load()
41+
}
3942
return db
4043
}
4144

src/index.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,58 @@ body {
1515
code {
1616
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
1717
}
18+
19+
@media screen and (max-width: 720px) {
20+
.row-wrap {
21+
flex-direction: column;
22+
align-items: flex-start;
23+
}
24+
25+
.align {
26+
flex: 1 1 80%;
27+
margin-left: 16px;
28+
}
29+
30+
.title {
31+
padding-top: 16px;
32+
padding-bottom: 8px;
33+
padding-left: 32px;
34+
padding-right: 32px;
35+
}
36+
37+
.search {
38+
padding-top: 8px;
39+
padding-bottom: 16px;
40+
padding-left: 32px;
41+
padding-right: 32px;
42+
width: 95%;
43+
}
44+
45+
.search input {
46+
width: 100%;
47+
}
48+
}
49+
50+
@media screen and (min-width: 720px) {
51+
.row-wrap {
52+
flex-direction: row;
53+
justify-content: center;
54+
}
55+
56+
.align {
57+
flex: 1 1 40%;
58+
padding-top: 8px;
59+
padding-bottom: 8px;
60+
margin-left: 0px;
61+
}
62+
63+
.title {
64+
padding-left: 48px;
65+
padding-right: 0px;
66+
}
67+
68+
.search {
69+
padding-left: 48px;
70+
padding-right: 48px;
71+
}
72+
}

0 commit comments

Comments
 (0)