Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into bitshares
Browse files Browse the repository at this point in the history
  • Loading branch information
valzav committed Nov 19, 2015
2 parents 5799a41 + 5d90223 commit 4df3598
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 47 deletions.
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@
market: "Market",
price_history: "Price Chart",
order_depth: "Market Depth",
market_history: "Market History",
history: "History",
my_history: "My History",
balance: "Your balance",
lowest_ask: "Lowest ask",
highest_bid: "Highest bid",
Expand Down
5 changes: 4 additions & 1 deletion web/app/components/Exchange/Exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1058,11 +1058,14 @@ class Exchange extends React.Component {


{/* Right Column - Market History */}
<div className="grid-block show-for-large large-3 right-column no-overflow vertical" style={{paddingRight: "0.5rem"}}>
<div className="grid-block show-for-large large-3 right-column no-overflow vertical" style={{paddingTop: 0, paddingRight: "0.5rem"}}>
{/* Market History */}
<div className="grid-block no-padding no-margin vertical" style={{flex: "1 1 50vh"}}>
<MarketHistory
className="left-order-book no-padding no-overflow"
headerStyle={{paddingTop: 0}}
history={activeMarketHistory}
myHistory={currentAccount.get("history")}
base={base}
quote={quote}
baseSymbol={baseSymbol}
Expand Down
106 changes: 100 additions & 6 deletions web/app/components/Exchange/MarketHistory.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
import React from "react";
import {PropTypes} from "react/addons";
import {Link} from "react-router";
import Immutable from "immutable";
import Ps from "perfect-scrollbar";
import utils from "common/utils";
import Translate from "react-translate-component";
import market_utils from "common/market_utils";
import PriceText from "../Utility/PriceText";
import cnames from "classnames";
import SettingsActions from "actions/SettingsActions";
import SettingsStore from "stores/SettingsStore";
import connectToStores from "alt/utils/connectToStores";
import {operations} from "chain/chain_types";

@connectToStores
class MarketHistory extends React.Component {
shouldComponentUpdate(nextProps) {

static getStores() {
return [SettingsStore]
}

static getPropsFromStores() {
return {
viewSettings: SettingsStore.getState().viewSettings
}
}

constructor(props) {
super();
this.state = {
activeTab: props.viewSettings.get("historyTab")
}
}

shouldComponentUpdate(nextProps, nextState) {
return (
!Immutable.is(nextProps.history, this.props.history) ||
nextProps.baseSymbol !== this.props.baseSymbol ||
nextProps.quoteSymbol !== this.props.quoteSymbol
nextProps.quoteSymbol !== this.props.quoteSymbol ||
nextState.activeTab !== this.state.activeTab
);
}

Expand All @@ -26,10 +52,66 @@ class MarketHistory extends React.Component {
Ps.update(historyContainer);
}

_changeTab(tab) {
SettingsActions.changeViewSetting({
historyTab: tab
});
this.setState({
activeTab: tab
});
}

render() {
let {history, base, quote, baseSymbol, quoteSymbol, flipped} = this.props;
let {history, myHistory, base, quote, baseSymbol, quoteSymbol, flipped} = this.props;
let {activeTab} = this.state;
let historyRows = null;
if (history.size > 0) {

if (activeTab === "my_history" && (myHistory && myHistory.size)) {
let index = 0;
let keyIndex = -1;
let flipped = base.get("id").split(".")[2] > quote.get("id").split(".")[2];
historyRows = myHistory.filter(a => {
let opType = a.getIn(["op", 0]);
return (opType === operations.fill_order);
}).filter(a => {
let quoteID = quote.get("id");
let baseID = base.get("id");
let pays = a.getIn(["op", 1, "pays", "asset_id"]);
let receives = a.getIn(["op", 1, "receives", "asset_id"]);
let hasQuote = quoteID === pays || quoteID === receives;
let hasBase = baseID === pays || baseID === receives;
return hasQuote && hasBase;
})
.sort((a, b) => {
return a.get("block_num") - a.get("block_num");
})
.map(trx => {
let order = trx.toJS().op[1];
keyIndex++;
let paysAsset, receivesAsset, isAsk = false;
if (order.pays.asset_id === base.get("id")) {
paysAsset = base;
receivesAsset = quote;
isAsk = true;

} else {
paysAsset = quote;
receivesAsset = base;
}

let parsed_order = market_utils.parse_order_history(order, paysAsset, receivesAsset, isAsk, flipped);
return (
<tr key={"my_history_" + keyIndex}>
<td className={parsed_order.className}>
<PriceText preFormattedPrice={parsed_order} />
</td>
<td>{parsed_order.receives}</td>
<td>{parsed_order.pays}</td>
<td><Link to="block" params={{height: trx.get("block_num")}}>#{utils.format_number(trx.get("block_num"), 0)}</Link></td>
</tr>
);
}).toArray();
} else if (history && history.size) {
let index = 0;
let keyIndex = -1;
let flipped = base.get("id").split(".")[2] > quote.get("id").split(".")[2];
Expand All @@ -54,7 +136,7 @@ class MarketHistory extends React.Component {

let parsed_order = market_utils.parse_order_history(order, paysAsset, receivesAsset, isAsk, flipped);
return (
<tr key={keyIndex}>
<tr key={"history_" + keyIndex}>
<td className={parsed_order.className}>
<PriceText preFormattedPrice={parsed_order} />
</td>
Expand All @@ -66,16 +148,28 @@ class MarketHistory extends React.Component {
}).toArray();
}

let hc = "mymarkets-header clickable";
let historyClass = cnames(hc, {inactive: activeTab === "my_history"});
let myHistoryClass = cnames(hc, {inactive: activeTab === "history"});

return (
<div className="left-order-book no-padding no-overflow">
<div style={this.props.headerStyle} className="grid-block shrink left-orderbook-header bottom-header">
<div className={historyClass} onClick={this._changeTab.bind(this, "history")}>
<Translate content="exchange.history" />
</div>
<div className={myHistoryClass} onClick={this._changeTab.bind(this, "my_history")} >
<Translate content="exchange.my_history" />
</div>
</div>
<div className="grid-block shrink left-orderbook-header market-right-padding-only">
<table className="table order-table text-right market-right-padding">
<thead>
<tr>
<th style={{textAlign: "right"}}><Translate content="exchange.price" /><br/><span className="header-sub-title">{baseSymbol}/{quoteSymbol}</span></th>
<th style={{textAlign: "right"}}><Translate content="transfer.amount" /><br/><span className="header-sub-title">({quoteSymbol})</span></th>
<th className="show-for-large" style={{textAlign: "right"}}><Translate content="exchange.value" /><br/><span className="header-sub-title">({baseSymbol})</span></th>
<th style={{textAlign: "right"}}><Translate content="explorer.block.date" /><br/><span style={{visibility: "hidden"}} className="header-sub-title">({quoteSymbol})</span></th>
<th style={{textAlign: "right"}}><Translate content={activeTab === "history" ? "explorer.block.date" : "explorer.block.title"} /><br/><span style={{visibility: "hidden"}} className="header-sub-title">({quoteSymbol})</span></th>
</tr>
</thead>
</table>
Expand Down
16 changes: 10 additions & 6 deletions web/app/components/Exchange/MyMarkets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ class MyMarkets extends React.Component {
});

if (this.state.lookupQuote !== quote || force) {
if (quote.length < 3 || now - lastLookup <= 250) {
if (quote.length < 2 || now - lastLookup <= 250) {
return false;
}
this.getAssetList(quote, 50);
} else {
if (base && this.state.lookupBase !== base) {
if (base.length < 3 || now - lastLookup <= 250) {
if (base.length < 2 || now - lastLookup <= 250) {
return false;
}
this.getAssetList(base, 50);
Expand Down Expand Up @@ -176,8 +176,10 @@ class MyMarkets extends React.Component {
return a.symbol.indexOf(lookupQuote) !== -1;
})
.forEach(asset => {
if (defaultBases.indexOf(asset.symbol) < 0) {
baseOptions.push(asset.symbol);
if (defaultBases.indexOf(asset.symbol) < 0 ) {
if (asset.symbol.length === lookupQuote.length) {
baseOptions.push(asset.symbol);
}
}
});

Expand Down Expand Up @@ -220,7 +222,7 @@ class MyMarkets extends React.Component {
marketRows = activeMarkets
.filter(a => {
if (activeTab === "all") {
if (lookupQuote.length < 3) {return false; }
if (lookupQuote.length < 2) {return false; }
return a.quote.indexOf(lookupQuote) !== -1;
} else {
return true;
Expand Down Expand Up @@ -287,7 +289,9 @@ class MyMarkets extends React.Component {
}
}

}).toArray();
})
.take(activeTab === "starred" ? 150 : 50)
.toArray();
}

let hc = "mymarkets-header clickable";
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/Exchange/MyOpenOrders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class MyOpenOrders extends React.Component {
}

return (
<div key="open_orders" className="grid-block small-12 no-padding small-vertical medium-horizontal align-spaced ps-container middle-content" ref="orders">
<div style={{maxHeight: "400px"}} key="open_orders" className="grid-block small-12 no-padding small-vertical medium-horizontal align-spaced ps-container middle-content" ref="orders">
<div className={classnames("small-12 medium-5", this.state.flip ? "order-1" : "order-3")}>
<table className="table order-table text-right table-hover">
<TableHeader type="buy" baseSymbol={baseSymbol} quoteSymbol={quoteSymbol}/>
Expand Down
8 changes: 5 additions & 3 deletions web/app/components/Exchange/exchange.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ $negative-color: #E1424A;
/* .left-column-2 {
min-width: 15rem;
}
*/
.right-column {
min-width: 15rem;
}*/
padding-top: 0 !important;
padding-bottom: 0 !important;
border-top: none;
}
}

.market-content {
Expand Down
48 changes: 24 additions & 24 deletions web/app/components/Explorer/CommitteeMembers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ class CommitteeMemberRow extends React.Component {

static propTypes = {
committee_member: ChainTypes.ChainAccount.isRequired
};

static contextTypes = {
router: React.PropTypes.func.isRequired
};

_onRowClick(e) {
e.preventDefault();
this.context.router.transitionTo("account", {account_name: this.props.committee_member.get("name")});
}

render() {
Expand All @@ -64,31 +73,13 @@ class CommitteeMemberRow extends React.Component {
if ( !committee_member_data ) return null;
let total_votes = committee_member_data.get( "total_votes" );

// let witness_aslot = witness_data.get('last_aslot')
let color = {};
// if( this.props.most_recent - witness_aslot > 100 ) {
// color = {borderLeft: "1px solid #FCAB53"};
// }
// else {
// color = {borderLeft: "1px solid #50D2C2"};
// }

// let currentClass = isCurrent ? "active-witness" : "";

// let missed = committee_member_data.get('total_missed');
// let missedClass = classNames("txtlabel",
// {"success": missed <= 25 },
// {"info": missed > 25 && missed <= 50},
// {"warning": missed > 50 && missed <= 150},
// {"error": missed >= 150}
// );

return (
<tr>
<tr onClick={this._onRowClick.bind(this)}>
<td>{rank}</td>
<td style={color}>{committee_member.get("name")}</td>
<td>{committee_member.get("name")}</td>
<td><FormattedAsset amount={committee_member_data.get('total_votes')} asset="1.3.0" /></td>
<td style={color}>{committee_member_data.get("url")}</td>
<td>{committee_member_data.get("url")}</td>
</tr>
)
}
Expand Down Expand Up @@ -116,13 +107,21 @@ class CommitteeMemberList extends React.Component {
}

render() {
let {committee_members, cardView} = this.props;
let {committee_members, cardView, membersList} = this.props;
let {sortBy, inverseSort} = this.state;

let itemRows = null;

let ranks = {};
committee_members.sort((a, b) => {

committee_members
.filter(a => {
if (!a) {
return false;
}
return membersList.indexOf(a.get("id")) !== -1;
})
.sort((a, b) => {
if (a && b) {
return parseInt(b.get("total_votes"), 10) - parseInt(a.get("total_votes"), 10);
}
Expand Down Expand Up @@ -185,7 +184,7 @@ class CommitteeMemberList extends React.Component {
// table view
if (!cardView) {
return (
<table className="table">
<table className="table table-hover">
<thead>
<tr>
<th className="clickable" onClick={this._setSort.bind(this, 'rank')}><Translate content="explorer.witnesses.rank" /></th>
Expand Down Expand Up @@ -285,6 +284,7 @@ class CommitteeMembers extends React.Component {
</div>
<CommitteeMemberList
committee_members={Immutable.List(globalObject.active_committee_members)}
membersList={globalObject.active_committee_members}
filter={this.state.filterCommitteeMember}
cardView={this.state.cardView}
/>
Expand Down
Loading

0 comments on commit 4df3598

Please sign in to comment.