Skip to content

Commit 6ab5e7f

Browse files
authored
Merge pull request #2 from CovenantSQL/dev
Dev
2 parents eeaa6d7 + 2e3245d commit 6ab5e7f

13 files changed

Lines changed: 85 additions & 193 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description": "CovenantSQL Database as a Service (DBaaS) platform",
77
"icons": [
88
{
9-
"src": "logo.svg",
9+
"src": "favicon.ico",
1010
"sizes": "72x72 96x96 128x128 144x144 152x152 192x192 384x384 512x512"
1111
}
1212
]

src/models/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const {
1616
queryAccount,
1717
queryRouteList,
1818
logoutUser,
19-
queryUserInfo,
19+
// queryUserInfo,
2020
queryCQLUserInfo,
2121
queryProject,
2222
} = api

src/pages/dashboard/components/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import GetPTC from './getPTC'
22
import TaskList from './taskList'
33
import CreateProject from './createProject'
44
import Projects from './Projects'
5+
import User from './user'
56

6-
export { GetPTC, TaskList, CreateProject, Projects }
7+
export { GetPTC, TaskList, CreateProject, Projects, User }
File renamed without changes.

src/pages/dashboard/components_bck/user.js renamed to src/pages/dashboard/components/user.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Button, Avatar } from 'antd'
44
import CountUp from 'react-countup'
5-
import { Color } from 'utils'
5+
import Link from 'umi/link'
6+
import { Color, toPTC } from 'utils'
67
import styles from './user.less'
78

89
const countUpProps = {
@@ -13,7 +14,7 @@ const countUpProps = {
1314
separator: ',',
1415
}
1516

16-
function User({ avatar, username, sales = 0, sold = 0 }) {
17+
function User({ avatar, username, projectNum = 0, ptc = 0 }) {
1718
return (
1819
<div className={styles.user}>
1920
<div className={styles.header}>
@@ -24,22 +25,29 @@ function User({ avatar, username, sales = 0, sold = 0 }) {
2425
</div>
2526
<div className={styles.number}>
2627
<div className={styles.item}>
27-
<p>EARNING SALES</p>
28+
<p># Projects</p>
2829
<p style={{ color: Color.green }}>
29-
<CountUp end={sales} prefix="$" {...countUpProps} />
30+
<CountUp end={projectNum} prefix="" {...countUpProps} />
3031
</p>
3132
</div>
3233
<div className={styles.item}>
33-
<p>ITEM SOLD</p>
34+
<p>Current Wallet PTC</p>
3435
<p style={{ color: Color.blue }}>
35-
<CountUp end={sold} {...countUpProps} />
36+
<CountUp
37+
end={toPTC(ptc)}
38+
suffix=" PTC"
39+
{...countUpProps}
40+
decimals={2}
41+
/>
3642
</p>
3743
</div>
3844
</div>
3945
<div className={styles.footer}>
40-
<Button type="ghost" size="large">
41-
View Profile
42-
</Button>
46+
<Link to="/wallets">
47+
<Button type="ghost" size="large">
48+
Change Wallet
49+
</Button>
50+
</Link>
4351
</div>
4452
</div>
4553
)
File renamed without changes.

src/pages/dashboard/components_bck/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Comments from './comments'
77
import Completed from './completed'
88
import Browser from './browser'
99
import Cpu from './cpu'
10-
import User from './user'
1110

1211
export {
1312
NumberCard,
@@ -19,5 +18,4 @@ export {
1918
Completed,
2019
Browser,
2120
Cpu,
22-
User,
2321
}

src/pages/dashboard/components_bck/numberCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function NumberCard({ icon, color, title, number, countUp }) {
2222
useEasing
2323
useGrouping
2424
separator=","
25-
{...countUp || {}}
25+
{...(countUp || {})}
2626
/>
2727
</p>
2828
</div>

src/pages/dashboard/index.js

Lines changed: 13 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,7 @@ import { Trans, withI18n } from '@lingui/react'
66
import { Color } from 'utils'
77
import { Page, ScrollBar } from 'components'
88
import ScanSVG from './components/covenantscan.svg'
9-
import {
10-
// NumberCard,
11-
Quote,
12-
// Sales,
13-
Weather,
14-
RecentSales,
15-
Comments,
16-
Completed,
17-
Browser,
18-
Cpu,
19-
User,
20-
} from './components_bck'
21-
import { GetPTC, CreateProject, TaskList, Projects } from './components'
9+
import { User, GetPTC, CreateProject, TaskList, Projects } from './components'
2210
import styles from './index.less'
2311

2412
const bodyStyle = {
@@ -29,35 +17,16 @@ const bodyStyle = {
2917
}
3018

3119
@connect(({ app, dashboard, loading }) => ({
32-
avatar: app.user.avatar,
33-
username: app.user.username,
20+
user: app.user,
3421
projects: app.projects,
22+
mainwallet: app.mainwallet,
3523
dashboard,
3624
loading,
3725
}))
3826
class Dashboard extends PureComponent {
39-
state = {
40-
show: false,
41-
}
4227
render() {
43-
const { avatar, username, dashboard, loading } = this.props
44-
const {
45-
tasks,
46-
weather,
47-
sales,
48-
quote,
49-
numbers,
50-
recentSales,
51-
comments,
52-
completed,
53-
browser,
54-
cpu,
55-
user,
56-
} = dashboard
57-
58-
const numberCards = numbers.map((item, key) => (
59-
<Col key={key} lg={6} md={12} />
60-
))
28+
const { user, dashboard, loading } = this.props
29+
const { tasks } = dashboard
6130

6231
return (
6332
<Page className={styles.dashboard}>
@@ -67,10 +36,7 @@ class Dashboard extends PureComponent {
6736
<Trans>Utilities</Trans>
6837
</div>
6938
<Col lg={6} md={6}>
70-
<GetPTC
71-
{...weather}
72-
loading={loading.effects['dashboard/queryWeather']}
73-
/>
39+
<GetPTC />
7440
</Col>
7541
<Col lg={6} md={6}>
7642
<Card
@@ -114,6 +80,7 @@ class Dashboard extends PureComponent {
11480
<div className={styles.sectionTitle}>
11581
<Trans>Tasks</Trans>
11682
</div>
83+
11784
<Col lg={16} md={16} sm={24}>
11885
<Card
11986
title="All Tasks"
@@ -125,81 +92,20 @@ class Dashboard extends PureComponent {
12592
<TaskList data={tasks} />
12693
</Card>
12794
</Col>
128-
</Row>
129-
130-
<div style={{ float: 'right' }}>
131-
备用
132-
<Switch
133-
size="small"
134-
onChange={checked => {
135-
this.setState({ show: checked })
136-
}}
137-
/>
138-
</div>
13995

140-
<div style={{ display: this.state.show ? 'inherit' : 'none' }}>
141-
<Col lg={6} md={24}>
142-
<Row gutter={24}>
143-
<Col lg={24} md={12}>
144-
<Card
145-
bordered={false}
146-
className={styles.quote}
147-
bodyStyle={{
148-
padding: 0,
149-
height: 204,
150-
background: Color.peach,
151-
}}
152-
>
153-
<ScrollBar>
154-
<Quote {...quote} />
155-
</ScrollBar>
156-
</Card>
157-
</Col>
158-
</Row>
159-
</Col>
160-
<Col lg={12} md={24}>
161-
<Card bordered={false} {...bodyStyle}>
162-
<RecentSales data={recentSales} />
163-
</Card>
164-
</Col>
165-
<Col lg={12} md={24}>
166-
<Card bordered={false} {...bodyStyle}>
167-
<ScrollBar>
168-
<Comments data={comments} />
169-
</ScrollBar>
170-
</Card>
171-
</Col>
172-
<Col lg={24} md={24}>
173-
<Card
174-
bordered={false}
175-
bodyStyle={{
176-
padding: '24px 36px 24px 0',
177-
}}
178-
>
179-
<Completed data={completed} />
180-
</Card>
181-
</Col>
182-
<Col lg={8} md={24}>
183-
<Card bordered={false} {...bodyStyle}>
184-
<Browser data={browser} />
185-
</Card>
186-
</Col>
187-
<Col lg={8} md={24}>
188-
<Card bordered={false} {...bodyStyle}>
189-
<ScrollBar>
190-
<Cpu {...cpu} />
191-
</ScrollBar>
192-
</Card>
193-
</Col>
19496
<Col lg={8} md={24}>
19597
<Card
19698
bordered={false}
19799
bodyStyle={{ ...bodyStyle.bodyStyle, padding: 0 }}
198100
>
199-
<User {...user} avatar={avatar} username={username} />
101+
<User
102+
{...user}
103+
projectNum={this.props.projects.length}
104+
ptc={this.props.mainwallet.balance}
105+
/>
200106
</Card>
201107
</Col>
202-
</div>
108+
</Row>
203109
</Row>
204110
</Page>
205111
)

src/pages/dashboard/model.js

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { pathMatchRegexp } from 'utils'
55
import { model } from 'utils/model'
66

77
const {
8-
queryDashboard,
9-
queryWeather,
8+
// queryDashboard,
9+
// queryWeather,
1010
getPTC,
1111
queryTasks,
1212
queryTask,
@@ -19,27 +19,6 @@ export default modelExtend(model, {
1919
namespace: 'dashboard',
2020
state: {
2121
tasks: [],
22-
weather: {
23-
city: '深圳',
24-
temperature: '30',
25-
name: '晴',
26-
icon: '//s5.sencdn.com/web/icons/3d_50/2.png',
27-
},
28-
sales: [],
29-
quote: {
30-
avatar:
31-
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
32-
},
33-
numbers: [],
34-
recentSales: [],
35-
comments: [],
36-
completed: [],
37-
browser: [],
38-
cpu: {},
39-
user: {
40-
avatar:
41-
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
42-
},
4322
},
4423
subscriptions: {
4524
setup({ dispatch, history }) {
@@ -55,41 +34,41 @@ export default modelExtend(model, {
5534

5635
dispatch({ type: 'app/getProjectList' })
5736
// query dashboard related
58-
dispatch({ type: 'query' })
37+
// dispatch({ type: 'query' })
5938
// dispatch({ type: 'queryWeather' })
6039
dispatch({ type: 'getTaskList', payload: { all: true } })
6140
}
6241
})
6342
},
6443
},
6544
effects: {
66-
*query({ payload }, { call, put }) {
67-
const data = yield call(queryDashboard, parse(payload))
68-
yield put({
69-
type: 'updateState',
70-
payload: data,
71-
})
72-
},
73-
*queryWeather({ payload = {} }, { call, put }) {
74-
payload.location = 'shenzhen'
75-
const result = yield call(queryWeather, payload)
76-
const { success } = result
77-
if (success) {
78-
const data = result.results[0]
79-
const weather = {
80-
city: data.location.name,
81-
temperature: data.now.temperature,
82-
name: data.now.text,
83-
icon: `//s5.sencdn.com/web/icons/3d_50/${data.now.code}.png`,
84-
}
85-
yield put({
86-
type: 'updateState',
87-
payload: {
88-
weather,
89-
},
90-
})
91-
}
92-
},
45+
// *query({ payload }, { call, put }) {
46+
// const data = yield call(queryDashboard, parse(payload))
47+
// yield put({
48+
// type: 'updateState',
49+
// payload: data,
50+
// })
51+
// },
52+
// *queryWeather({ payload = {} }, { call, put }) {
53+
// payload.location = 'shenzhen'
54+
// const result = yield call(queryWeather, payload)
55+
// const { success } = result
56+
// if (success) {
57+
// const data = result.results[0]
58+
// const weather = {
59+
// city: data.location.name,
60+
// temperature: data.now.temperature,
61+
// name: data.now.text,
62+
// icon: `//s5.sencdn.com/web/icons/3d_50/${data.now.code}.png`,
63+
// }
64+
// yield put({
65+
// type: 'updateState',
66+
// payload: {
67+
// weather,
68+
// },
69+
// })
70+
// }
71+
// },
9372
*getPTC({ payload }, { call, put }) {
9473
const { data, success } = yield call(getPTC)
9574
yield put({ type: 'app/checkMainWallet' })

0 commit comments

Comments
 (0)