Skip to content

Commit

Permalink
fixes, refactoring, improvements all pages. Not finidhed, before fork
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Domrachev authored and Pavel Domrachev committed Mar 11, 2017
1 parent b7c92e5 commit 4ee9aec
Show file tree
Hide file tree
Showing 32 changed files with 450 additions and 235 deletions.
17 changes: 0 additions & 17 deletions src/components/common/flags.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/modals/IssueLHModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class IssueLHModal extends Component {
const issueAmount = +values.get('issueAmount');
let issued = oldIssued + issueAmount;
let account = localStorage.getItem('chronoBankAccount');
let address = values.get('address');
this.props.updateLOC({issued, account, address});
issueLH({account, issueAmount});
let locAddress = values.get('address');
this.props.updateLOC({issued, account, locAddress});
issueLH({account, issueAmount, locAddress});
this.props.hideModal();
};

Expand Down
6 changes: 3 additions & 3 deletions src/components/modals/LOCModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class LOCModal extends Component {

handleSubmit = (values) => {
let account = localStorage.getItem('chronoBankAccount');
let address = values.get('address');
let locAddress = values.get('address');
let jsValues = values.toJS();
jsValues = {...jsValues, expDate: new BigNumber(jsValues.expDate.getTime()), issueLimit: new BigNumber(jsValues.issueLimit)}
if (!address) {
if (!locAddress) {
proposeLOC({...jsValues, account});
} else {
let changedProps = {};
Expand All @@ -41,7 +41,7 @@ class LOCModal extends Component {
changedProps[key] = jsValues[key];
}
}
this.props.updateLOC({...changedProps, account, address});
this.props.updateLOC({...changedProps, account, locAddress});
}
this.props.hideModal();
};
Expand Down
48 changes: 48 additions & 0 deletions src/components/pages/locsPage/Filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, {Component} from 'react';
import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem';

const styles = {
filterMenu: {
margin: "-15px -25px"
},
underlineStyle: {
borderTop: 'none',
},
};

class Filter extends Component {
constructor(props) {
super(props);
this.state = {value: 1};
}

handleChange = (event, index, value) => this.setState({value});

render() {
const {locs} = this.props;
return (
<div style={{ minWidth: 300}}>
<span>
{locs.size} entries
</span>
<span style={{ float: 'right'}}>
<span style={{verticalAlign: 'top'}}>Show only: </span>
<DropDownMenu value={this.state.value} onChange={this.handleChange} style={styles.filterMenu} underlineStyle={styles.underlineStyle}>
<MenuItem value={1} primaryText="LHUS" />
<MenuItem value={2} primaryText="LHEU" />
<MenuItem value={3} primaryText="LHAU" />
</DropDownMenu>
<span style={{verticalAlign: 'top'}}> Sorted by: </span>
<DropDownMenu value={this.state.value} onChange={this.handleChange} style={styles.filterMenu} underlineStyle={styles.underlineStyle}>
<MenuItem value={1} primaryText="Time added" />
<MenuItem value={2} primaryText="Time added" />
<MenuItem value={3} primaryText="Time added" />
</DropDownMenu>
</span>
</div>
);
}
}

export default Filter;
81 changes: 81 additions & 0 deletions src/components/pages/locsPage/LocBlock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import FlatButton from 'material-ui/FlatButton';
import Paper from 'material-ui/Paper';
import globalStyles from '../../../styles';
import {dateFormatOptions} from '../../../config';
import Slider from '../../common/slider';
import {handleShowLOCModal, handleShowIssueLHModal} from './handlers';

const OngoingStatusBlock = (props) => (
<div style={globalStyles.item.status.block}>
<div style={globalStyles.item.status.green}>
ACTIVE<br/>
</div>
<Slider value={props.value} cyan={true} />
</div>
);

const closedStatusBlock = <div style={globalStyles.item.status.block}>
<div style={globalStyles.item.status.grey}>
INACTIVE<br/>
</div>
<Slider value={1} disabled={true}/>
</div>;

const mapDispatchToProps = (dispatch) => ({
showLOCModal: locKey => dispatch(handleShowLOCModal(locKey)),
showIssueLHModal: locKey => dispatch(handleShowIssueLHModal(locKey)),
});

@connect(null, mapDispatchToProps)
class LocBlock extends Component {
constructor(props) {
super(props);
this.state = {value: 1};
}

render() {
const {item, showLOCModal, showIssueLHModal} = this.props;
const address = item.get('address');
const issueLimit = item.issueLimit();
const expDate = item.expDate();
return (
<Paper style={globalStyles.item.paper}>
<div>
{expDate > new Date().getTime() ? <OngoingStatusBlock value={
(((7776000000 - expDate) + new Date().getTime()) / 7776000000).toFixed(2)
}/> : closedStatusBlock}
<div style={globalStyles.item.title}>{item.get('locName')}</div>
<div style={globalStyles.item.greyText}>
Issue limit: {issueLimit} LHUS<br />
Total issued amount: {item.issued()} LHUS<br />
Total redeemed amount: {item.redeemed()} LHUS<br />
Amount in circulation: {item.issued() - item.redeemed()} LHUS<br />
Exp date: {new Date(expDate).toLocaleDateString("en-us", dateFormatOptions)}<br />
{item.get('address')}
</div>
<div style={globalStyles.item.lightGrey}>
Added on {new Date(expDate).toLocaleDateString("en-us", dateFormatOptions)}
</div>
</div>
<div>
<FlatButton label="VIEW CONTRACT" style={{color: 'grey'}}
onTouchTap={()=>{showLOCModal(address);}}
/>
<FlatButton label="ISSUE LH" style={{color: 'grey'}}
onTouchTap={()=>{showIssueLHModal(address);}}
/>
<FlatButton label="REDEEM LH" style={{color: 'grey'}}
onTouchTap={()=>{showLOCModal(address);}}
/>
<FlatButton label="EDIT LOC INFO" style={{color: 'grey'}}
onTouchTap={()=>{showLOCModal(address);}}
/>
</div>
</Paper>
);
}
}

export default LocBlock;
28 changes: 28 additions & 0 deletions src/components/pages/locsPage/PageTitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import RaisedButton from 'material-ui/RaisedButton';
import globalStyles from '../../../styles';
import {handleShowLOCModal} from './handlers';

const mapDispatchToProps = (dispatch) => ({
handleShowLOCModal: locKey => dispatch(handleShowLOCModal(locKey)),
});

@connect(null, mapDispatchToProps)
class PageTitle extends Component {
render() {
return (
<div><span style={{verticalAlign: 'sub'}}>LOCs </span> <RaisedButton
label="NEW LOC"
primary={true}
style={{verticalAlign: 'text-bottom', fontSize: 15}}
onTouchTap={this.props.handleShowLOCModal.bind(null, null)}
buttonStyle={{...globalStyles.raisedButton, }}
labelStyle={globalStyles.raisedButtonLabel}
/>
</div>
);
}
}

export default PageTitle;
28 changes: 28 additions & 0 deletions src/components/pages/locsPage/Search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, {Component} from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
import globalStyles from '../../../styles';

class Search extends Component {
render() {
// const {} = this.props;
return (
<div>
<TextField
floatingLabelText="Search by title"
style={{width: 'calc(100% - 98px)'}}
/>
<RaisedButton
label="SEARCH"
primary={true}
buttonStyle={globalStyles.raisedButton}
style={{marginTop: 33, width: 88, float: 'right'}}
labelStyle={globalStyles.raisedButtonLabel}
//onTouchTap={this.handleSubmitClick.bind(this)}
/>
</div>
);
}
}

export default Search;
13 changes: 13 additions & 0 deletions src/components/pages/locsPage/handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {showLOCModal, showIssueLHModal} from '../../../redux/ducks/ui/modal';
import {passLocAddress} from '../../../redux/ducks/locs/loc';


export const handleShowLOCModal = (locKey) => (dispatch) => {
dispatch(passLocAddress(locKey));
dispatch(showLOCModal({locKey}));
};

export const handleShowIssueLHModal = (locKey) => (dispatch) => {
dispatch(passLocAddress(locKey));
dispatch(showIssueLHModal({locKey}));
};
11 changes: 11 additions & 0 deletions src/components/pages/locsPage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import PageTitle from './PageTitle';
import Search from './Search';
import Filter from './Filter';
import LocBlock from './LocBlock';

export {
PageTitle,
Search,
Filter,
LocBlock,
}
4 changes: 2 additions & 2 deletions src/dao/AppDAO.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class AppDAO extends AbstractContractDAO {
return this.contract.then(deployed => deployed.getLOCbyID.call({index, from: account}));
};

reissueAsset = (asset: string, amount: number, account: string) => {
return this.contract.then(deployed => deployed.reissueAsset(asset, amount, {from: account, gas: 3000000}));
reissueAsset = (asset: string, amount: number, account: string, locAddress: string ) => {
return this.contract.then(deployed => deployed.reissueAsset(asset, amount, locAddress, {from: account, gas: 3000000}));
};

getBalance = (enumIndex: number) => {
Expand Down
5 changes: 3 additions & 2 deletions src/models/Operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class Operation extends record({
const argsStr = data.slice(74);
let argsArr = argsStr.match(/.{1,64}/g);
if (argsArr) {
argsArr = argsArr.map( item => parseInt(item, 16) );
return argsArr.join(', ');
let value = parseInt(item, 16);
argsArr = argsArr.map( item => value > 1e40 ? item : value);
return argsArr;
}
return "";
}
Expand Down
Loading

0 comments on commit 4ee9aec

Please sign in to comment.