Skip to content
This repository was archived by the owner on Aug 24, 2019. It is now read-only.

Commit f5cd1a3

Browse files
committed
add products and fix readme
1 parent a69723e commit f5cd1a3

File tree

14 files changed

+182
-22
lines changed

14 files changed

+182
-22
lines changed

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016-present tablee <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

LICENSE.txt

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

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1-
## CodePush Web
1+
# CodePush Web [source](https://github.com/lisong/code-push-web)
2+
3+
CodePush Web is a [CodePush Server](https://github.com/lisong/code-push-server)'s web client. it's will more friendly then [code-push-cli](https://github.com/Microsoft/code-push)
4+
5+
## INSTALL
6+
7+
```shell
8+
$ cd /path/to/code-push-web
9+
$ npm install
10+
```
11+
12+
## CONFIGURE
13+
14+
``` shell
15+
$ vim ./src/config #change URL to production
16+
```
17+
18+
## RUN DEV
19+
20+
```shell
21+
$ npm start
22+
```
23+
24+
## BUILD AND RUN IN PRODUCTION
25+
26+
```shell
27+
$ cd /path/to/code-push-web
28+
$ npm run build -- --release
29+
$ cd ./build
30+
$ npm install
31+
$ node ./server.js
32+
```
33+
34+
## BASE ON [React Starter Kit](https://github.com/kriasoft/react-starter-kit)
35+
36+
## License
37+
MIT License [read](https://github.com/lisong/code-push-web/blob/master/LICENSE)

src/actions/actionTypes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ export const GO_BACK_HISTORY = 'GO_BACK_HISTORY';
3030
export const SHOW_HOME = 'SHOW_HOME';
3131
export const SHOW_LOGIN = 'SHOW_LOGIN';
3232
/*========= end routesActions ===========*/
33+
34+
/*========= begin productsActions ===========*/
35+
export const REQUEST_PRODUCTS = 'REQUEST_PRODUCTS';
36+
export const RECEIVE_PRODUCTS = 'RECEIVE_PRODUCTS';
37+
38+
/*========= end productsActions ===========*/

src/actions/productsActions.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import _ from 'lodash';
2+
3+
import * as types from './actionTypes';
4+
import restApi from '../network/RestApi';
5+
6+
export function requestProducts() {
7+
return {
8+
type: types.REQUEST_PRODUCTS,
9+
}
10+
}
11+
12+
export function receiveProducts(data) {
13+
return {
14+
type: types.RECEIVE_PRODUCTS,
15+
payload: data
16+
}
17+
}
18+
19+
export function getProducts() {
20+
return (dispatch) => {
21+
dispatch(requestProducts());
22+
return restApi.getProducts()
23+
.then(data => {
24+
dispatch(receiveProducts(data));
25+
});
26+
};
27+
}

src/components/ProductList/ProductList.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,15 @@ th,td {
3535
th {
3636
background-color: #EEEFFF;
3737
}
38+
39+
li {
40+
list-style: none;
41+
}
42+
43+
.permission {
44+
padding-right: 10px;
45+
}
46+
47+
.permission em {
48+
color: green;
49+
}

src/components/ProductList/ProductList.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import s from './ProductList.css';
55
import _ from 'lodash';
66

77
class ProductList extends Component {
8+
static propTypes = {
9+
isFetching: PropTypes.bool,
10+
rs: PropTypes.array,
11+
};
12+
13+
static defaultProps = {
14+
isFetching: true,
15+
rs: [],
16+
};
17+
818
constructor() {
919
super();
1020
this.renderRow = this.renderRow.bind(this);
@@ -13,11 +23,17 @@ class ProductList extends Component {
1323
renderRow(rowData, index) {
1424
return (
1525
<tr key={index}>
16-
<td>111</td>
17-
<td>111</td>
18-
<td>111</td>
19-
<td>1111</td>
20-
<td>111</td>
26+
<td>{_.get(rowData, 'name')}</td>
27+
<td>
28+
<ul>
29+
{
30+
_.map(_.get(rowData, 'collaborators'), function (item, email) {
31+
return <li><span className={s.permission}>(<em>{_.get(item, 'permission')}</em>)</span>{email}</li>
32+
})
33+
}
34+
</ul>
35+
</td>
36+
<td></td>
2137
</tr>
2238
);
2339
}
@@ -33,19 +49,17 @@ class ProductList extends Component {
3349
<tbody>
3450
<tr>
3551
<th>产品名</th>
36-
<th>拥有者</th>
37-
<th>类型</th>
38-
<th>创建时间</th>
52+
<th>成员</th>
3953
<th>操作</th>
4054
</tr>
4155
{
42-
[1,2].length > 0 ?
43-
_.map([1,2,2], function (item, index) {
56+
this.props.rs.length > 0 ?
57+
_.map(this.props.rs, function (item, index) {
4458
return self.renderRow(item, index);
4559
})
4660
:
4761
<tr>
48-
<td colSpan="5" >{tipText}</td>
62+
<td colSpan="3" >{tipText}</td>
4963
</tr>
5064
}
5165
</tbody>

src/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const analytics = {
1313

1414
export const common = {
1515
api: {
16-
URL: `http://localhost:3000`,
17-
devURL: `http://localhost:3000`
16+
URL: `http://localhost:3000`, //production code-push-server address
17+
devURL: `http://localhost:3000` //development code-push-server address
1818
}
1919
};

src/containers/ProductListContainer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ class ProductListContainer extends Component {
2222
}
2323
}
2424
render() {
25-
const {html, actions } = this.props;
25+
const {products, actions } = this.props;
2626
return (
2727
<div>
2828
<HeaderContainer/>
29-
<ProductList/>
29+
<ProductList
30+
isFetching={_.get(products, 'isFetching')}
31+
rs={_.get(products, 'rs')}
32+
/>
3033
<Footer/>
3134
</div>
3235
);
3336
}
3437
}
3538

3639
function mapStateToProps(state, ownProps) {
37-
return {'auth': _.get(state, 'auth', {})};
40+
return {
41+
'auth': _.get(state, 'auth', {}),
42+
'products': _.get(state, 'products', {})
43+
};
3844
}
3945

4046
function mapDispatchToProps(dispatch, ownProps) {

src/network/RestApi.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class RestApi {
2727
this.aQQGuid = aQQGuid;
2828
}
2929

30+
getProducts() {
31+
return this.get('/apps');
32+
}
33+
3034
login(account, password) {
3135
return this.post('/auth/login', {account: account, password: password, minutes:43200});
3236
}
@@ -65,7 +69,6 @@ class RestApi {
6569
console.log(response.url);
6670
console.log(text);
6771
}
68-
console.log(text);
6972
return JSON.parse(text);
7073
} catch (e) {
7174
if (__DEV__) {

0 commit comments

Comments
 (0)