-
Notifications
You must be signed in to change notification settings - Fork 13
/
dashboard.dc714fe57b30147bd114.js
1 lines (1 loc) · 16.2 KB
/
dashboard.dc714fe57b30147bd114.js
1
"use strict";(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[945],{99614:(e,t,s)=>{s.r(t),s.d(t,{default:()=>F});var a=s(96540),n=s(9476),i=s(40702),r=s(81423),l=s(55840),o=s(74248),c=s(23654),p=s(62716),d=s(87040),h=s(58586),u=s(72090),m=s(80849),g=s.n(m),b=s(32485),v=s.n(b),E=s(84259),k=s(72257),w=s(46128),S=s(36234),A=s(91001),_=s(54625);class y extends a.Component{constructor(){super(),this.state={filter:"",showFlip:!1,showHidden:!1,markets:[]},this.update=this.update.bind(this);for(let e in this.sortFunctions)this.sortFunctions[e]=this.sortFunctions[e].bind(this)}UNSAFE_componentWillReceiveProps(e){this.update(e)}UNSAFE_componentWillMount(){this.update(),u.ChainStore.subscribe(this.update)}componentWillUnmount(){u.ChainStore.unsubscribe(this.update)}update(e=null){let t=e||this.props,s=t.forceDirection;if(t.markets&&t.markets.size>0){let e=t.markets.toArray().map((e=>{let s=u.ChainStore.getAsset(e.quote),a=u.ChainStore.getAsset(e.base);if(!a||!s)return null;let n=`${e.base}_${e.quote}`;return{key:n,inverted:void 0,quote:e.quote,base:e.base,basePrecision:a.get("precision"),isHidden:t.hiddenMarkets.includes(n),isFavorite:t.isFavorite,marketStats:t.allMarketStats.get(n,{}),isStarred:this.props.starredMarkets.has(n)}})).filter((e=>null!==e));this.setState({showFlip:s,markets:e})}}_toggleShowHidden(e){this.state.showHidden!==e&&this.setState({showHidden:e})}_handleFilterInput(e){e.preventDefault(),this.setState({filter:e.target.value.toUpperCase()})}_handleHide(e,t){if(this.props.handleHide)return this.props.handleHide(e,t);E.A.hideMarket(e.key,t)}_handleFlip(e,t){if(this.props.handleFlip)return this.props.handleFlip(e,t);E.A.changeMarketDirection({[e.key]:t})}sort(e,t){const s=e=>((e=e.replace(/\,/g,"")).includes("k")&&(e=1e3*e.replace(/k/g,"")),e.includes("M")&&(e=1e3*e.replace(/M/g,"")*1e3),e);return e=s(e),t=s(t),null===e&&null!==t?1:null!==e&&null===t?-1:e-t}sortFunctions={alphabetic:function(e,t,s){return e.key>t.key?s?1:-1:e.key<t.key?s?-1:1:0},priceValue:function(e,t){let s=e.price.props.children,a=t.price.props.children;return s&&a?this.sort(s,a):this.sortFunctions.alphabetic(e,t,!0)},volumeValue:function(e,t){let s=e.volume||0,a=t.volume||0,n=0;return s&&a&&(n=s-a),0==n?this.sortFunctions.alphabetic(e,t,!0):n},changeValue:function(e,t){let s=parseFloat(e.hour_24),a=parseFloat(t.hour_24),n=0;return s&&a&&!isNaN(s)&&!isNaN(a)&&(n=s-a),0==n?this.sortFunctions.alphabetic(e,t,!0):n}};getHeader(){const{showFlip:e,showHidden:t}=this.state;return[{dataIndex:"star",align:"right",width:"75px",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap",cursor:"pointer"}},e)},{title:a.createElement(g(),{content:"account.asset"}),dataIndex:"asset",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)},this.props.isFavorite?{}:{title:a.createElement(g(),{content:"account.user_issued_assets.quote_name"}),dataIndex:"quote_name",align:"right",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)},{title:a.createElement(g(),{content:"exchange.price"}),dataIndex:"price",align:"right",sorter:this.sortFunctions.priceValue,render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)},{title:a.createElement(g(),{content:"account.hour_24_short"}),dataIndex:"hour_24",align:"right",sorter:this.sortFunctions.changeValue,render:(e,t,s)=>{const n=parseFloat(t.hour_24)>0?"change-up":parseFloat(t.hour_24)<0?"change-down":"";return a.createElement("span",{style:{whiteSpace:"nowrap",textAlign:"right"},className:n},t.hour_24,"%")}},{title:a.createElement(g(),{content:"exchange.volume"}),dataIndex:"volume",align:"right",sorter:this.sortFunctions.volumeValue,defaultSortOrder:"descend",render:(e,t,s)=>a.createElement("span",{style:{whiteSpace:"nowrap"}},d.A.format_volume(t.volume,t.basePrecision))},e?{title:a.createElement(g(),{content:"exchange.flip"}),dataIndex:"flip",render:e=>a.createElement("span",{className:"column-hide-small",style:{whiteSpace:"nowrap"}},e)}:{},{title:a.createElement(g(),{content:t?"account.perm.show":"exchange.hide"}),dataIndex:"hide",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)}]}_setInterval(e=null){let{base:t,quote:s}=e||this.props;this.statsChecked=new Date,this.statsInterval=MarketsActions.getMarketStatsInterval(35e3,t,s)}_clearInterval(){this.statsInterval&&this.statsInterval()}_onError(e){this.state.imgError||this.setState({imgError:!0})}_toggleFavoriteMarket(e,t){let s=`${e}_${t}`;this.props.starredMarkets.has(s)?E.A.removeStarMarket(e,t):E.A.addStarMarket(e,t)}getTableData(e){let{base:t,quote:s,marketStats:n,isHidden:i,inverted:r,basePrecision:l}=e,o=function(e){if("OPEN.BTC"===e||"GDEX.BTC"===e)return e;if(e.startsWith("RUDEX."))return e;let t=e.split(".");return 2===t.length?t[1]:t[0]}(s),c=`${s}_${t}`;const p=this.props.starredMarkets.has(c)?"gold-star":"grey-star",h=this.state.imgError?`asset-symbols/${o.toLowerCase()}.png`:"asset-symbols/bts.png";return{key:c,star:a.createElement("div",{onClick:this._toggleFavoriteMarket.bind(this,s,t)},a.createElement(S.A,{style:{cursor:"pointer"},className:p,name:"fi-star",title:"icons.fi_star.market"})),asset:a.createElement(_.N_,{to:`/market/${s}_${t}`},a.createElement("img",{className:"column-hide-small",onError:this._onError.bind(this,o),style:{maxWidth:20,marginRight:10},src:h}),a.createElement(A.A,{dataPlace:"top",name:s})," ",this.props.isFavorite?a.createElement("span",null,": ",a.createElement(A.A,{dataPlace:"top",name:t})):null),quote_name:this.props.isFavorite?null:a.createElement("span",{style:{textAlign:"right"}},a.createElement(A.A,{noTip:!0,name:t})),price:a.createElement("div",{className:"column-hide-small",style:{textAlign:"right"}},n&&n.price?d.A.price_text(n.price.toReal(!0),u.ChainStore.getAsset(s),u.ChainStore.getAsset(t)):null),hour_24:n&&n.change&&"0.00"!==n.change?n.change:0,volume:n&&n.volumeQuote?n.volumeQuote:0,flip:null!==r&&this.props.isFavorite?a.createElement("span",{className:"column-hide-small"},a.createElement("a",{onClick:this._handleFlip.bind(this,e,!e.inverted)},a.createElement(S.A,{name:"shuffle",title:"icons.shuffle"}))):null,hide:a.createElement(w.Tooltip,{title:i?a.createElement(g(),{content:"icons.plus_circle.show_market"}):a.createElement(g(),{content:"icons.cross_circle.hide_market"}),style:{marginRight:0},onClick:this._handleHide.bind(this,e,!e.isHidden)},a.createElement(S.A,{name:i?"plus-circle":"cross-circle",title:i?"icons.plus_circle.show_market":"icons.cross_circle.hide_market",className:"icon-14px"})),basePrecision:l}}render(){let{markets:e,showHidden:t,filter:s}=this.state;const n=e.filter((e=>!(!s&&!e.isStarred&&(this.props.onlyLiquid||e.marketStats&&"volumeBase"in e.marketStats)&&!e.marketStats.volumeBase))).map((e=>{let t=!0;if(e.isHidden!==this.state.showHidden)t=!1;else if(s){const a=u.ChainStore.getAsset(e.quote),n=u.ChainStore.getAsset(e.base),{isBitAsset:i}=d.A.replaceName(a),{isBitAsset:r}=d.A.replaceName(n);let l=e.quote,o=e.base;if(i&&(l="bit"+l),r&&(o="bit"+o),s.includes(":")){const e=s.split(":")[0].trim(),a=s.split(":")[1].trim();t=l.toLowerCase().includes(String(e).toLowerCase())&&o.toLowerCase().includes(String(a).toLowerCase())}else t=l.toLowerCase().includes(String(s).toLowerCase())||o.toLowerCase().includes(String(s).toLowerCase())}return t?this.getTableData({...e}):null})).filter((e=>!!e));return a.createElement("div",null,a.createElement("div",{className:"header-selector"},a.createElement("div",{className:"filter inline-block"},a.createElement(w.Input,{type:"text",placeholder:"Filter...",onChange:this._handleFilterInput.bind(this),addonAfter:a.createElement(w.Icon,{type:"search"})})),a.createElement("div",{className:"selector inline-block",style:{position:"relative",top:"6px"}},a.createElement("div",{className:v()("inline-block",{inactive:t}),onClick:this._toggleShowHidden.bind(this,!1)},a.createElement(g(),{content:"account.hide_hidden"})),a.createElement("div",{className:v()("inline-block",{inactive:!t}),onClick:this._toggleShowHidden.bind(this,!0)},a.createElement(g(),{content:"account.show_hidden"}))),a.createElement("div",{style:{paddingTop:"0.5rem"}},a.createElement("label",{style:{margin:"3px 0 0",width:"fit-content"}},a.createElement("input",{style:{position:"relative",top:3},className:"no-margin",type:"checkbox",checked:this.props.onlyLiquid,onChange:()=>{E.A.changeViewSetting({onlyLiquid:!this.props.onlyLiquid})}}),a.createElement("span",{style:{paddingLeft:"0.4rem"}},a.createElement(g(),{content:"exchange.show_only_liquid"}))))),a.createElement(k.A,{style:{paddingLeft:0,paddingRight:0},className:"table dashboard-table table-hover",header:this.getHeader(),rows:n.length?n:[],pageSize:20,label:"utility.total_x_markets",leftPadding:"1.5rem"}))}}const f=(0,n.N)(y,{listenTo:()=>[o.A,h.A],getProps(){let{marketDirections:e,hiddenMarkets:t}=o.A.getState();return{marketDirections:e,hiddenMarkets:t,allMarketStats:h.A.getState().allMarketStats,starredMarkets:o.A.getState().starredMarkets,onlyLiquid:o.A.getState().viewSettings.get("onlyLiquid",!0)}}});class N extends a.Component{render(){return a.createElement(f,{markets:this.props.starredMarkets,forceDirection:!0,isFavorite:!0})}}N=(0,n.N)(N,{listenTo:()=>[o.A],getProps:()=>({starredMarkets:o.A.getState().starredMarkets})});class C extends a.Component{constructor(){super();let e=p.Apis.instance().chain_id;e&&(e=e.substr(0,8)),this.state={chainID:e,markets:[]},this._getMarkets=this._getMarkets.bind(this),this.update=this.update.bind(this)}_getMarkets(e=this.state,t=this.props){const{chainID:s}=e;return"4018d784"===s?t.markets:[["TEST","PEG.FAKEUSD"],["TEST","BTWTY"]]}shouldComponentUpdate(e){return!d.A.are_equal_shallow(e,this.props)}UNSAFE_componentWillMount(){this.update()}UNSAFE_componentWillReceiveProps(e){this.update(e)}update(e=this.props){let t=this._getMarkets(this.state,e);t=t.filter((t=>e.quotes[0]===t.base));for(var s=1;s<e.quotes.length;s++)t.forEach((a=>{let n={quote:a.quote,base:e.quotes[s]},i=`${n.quote}_${n.base}`;n.quote===n.base||t.has(i)||(t=t.set(i,n))}));this.setState({markets:t})}render(){return a.createElement(f,{markets:this.state.markets,showFlip:!1,isFavorite:!1})}}C=(0,n.N)(C,{listenTo:()=>[h.A,o.A],getProps(){let e=o.A.getState().userMarkets,t=o.A.getState().defaultMarkets;return e.size&&e.forEach(((e,s)=>{t.has(s)||(t=t.set(s,e))})),{markets:t}}}),a.Component;var T=s(28690);class x extends a.Component{render(){let{myActiveAccounts:e,myHiddenAccounts:t,accountsReady:s,passwordAccount:n,preferredBases:l}=this.props;return s?e.size+t.size+(n?1:0)?a.createElement("div",{className:"grid-block page-layout"},a.createElement("div",{className:"grid-block no-padding"},a.createElement("div",{className:"grid-content app-tables no-padding",ref:"appTables"},a.createElement("div",{className:"content-block small-12"},a.createElement("div",{className:"tabs-container generic-bordered-box"},a.createElement(c.t,{defaultActiveTab:1,segmented:!1,setting:"dashboardTab",className:"account-tabs",tabsClass:"account-overview no-padding bordered-header content-block"},a.createElement(c.o,{title:"dashboard.starred_markets"},a.createElement(N,null)),l.map((e=>{let t=a.createElement("span",null,a.createElement("img",{className:"column-hide-small",style:{maxWidth:30,marginRight:5},src:`asset-symbols/${e.replace(/^BTC/,"OPEN.BTC").toLowerCase()}.png`})," ",e);return a.createElement(c.o,{key:e,title:t},a.createElement(C,{quotes:[e].concat((0,T.wM)([e]))}))})))))))):a.createElement(r.A,null):a.createElement(i.A,null)}}const F=(0,n.N)(x,{listenTo:()=>[l.A,o.A],getProps(){let{myActiveAccounts:e,myHiddenAccounts:t,passwordAccount:s,accountsLoaded:a,refsLoaded:n}=l.A.getState();return{myActiveAccounts:e,myHiddenAccounts:t,passwordAccount:s,accountsReady:a&&n,preferredBases:o.A.getState().preferredBases}}})},72257:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(96540),n=s(10658),i=s.n(n),r=s(46128);class l extends a.Component{static defaultProps={rows:[],pageSize:20,className:"table",extraRow:null,style:{paddingBottom:"1rem"},loading:!1,totalLabel:"utility.total_x_items",label:null};constructor(e){super(e),this.state={pageSize:e.pageSize}}render(){const{pageSize:e}=this.state,{header:t,rows:s,extraRow:n,loading:l}=this.props,o=[10,20,30,40,50,100].filter((e=>e<Math.max(this.props.pageSize,s.length)));o.push(Math.max(this.props.pageSize,s.length));let c=null;return null!==this.props.label?c=e=>i().translate(this.props.label,{count:e}):"string"==typeof this.props.totalLabel?c=e=>i().translate(this.props.totalLabel,{count:e}):"object"==typeof this.props.totalLabel&&(c=e=>i().translate(this.props.totalLabel.key,{count:e,...this.props.totalLabel.args})),a.createElement("div",{className:"paginated-list",style:this.props.style},a.createElement(r.Table,{loading:l,dataSource:s,uns:!0,columns:Array.isArray(t)?t:[],footer:()=>n||a.createElement("span",null," "),onChange:this.props.toggleSortOrder,pagination:{showSizeChanger:!0,hideOnSinglePage:!1,defaultPageSize:e,pageSizeOptions:o.map((e=>e.toString())),showTotal:(e,t)=>c(e)},rowClassName:null==this.props.rowClassName?void 0:(e,t)=>this.props.rowClassName(e,t),rowSelection:this.props.rowSelection}),this.props.children)}}},23654:(e,t,s)=>{s.d(t,{o:()=>m,t:()=>g});var a=s(96540),n=s(5556),i=s.n(n),r=s(32485),l=s.n(r),o=s(9476),c=s(84259),p=s(74248),d=s(10658),h=s.n(d),u=s(24180);class m extends a.Component{static propTypes={changeTab:i().func,isActive:i().bool.isRequired,index:i().number.isRequired,className:i().string,isLinkTo:i().string,subText:i().oneOfType([i().object,i().string])};static defaultProps={isActive:!1,index:0,className:"",isLinkTo:"",subText:null};render(){let{isActive:e,index:t,changeTab:s,title:n,className:i,updatedTab:r,disabled:o,subText:c}=this.props,p=l()({"is-active":e},i);return"string"==typeof n&&n.indexOf(".")>0&&(n=h().translate(n)),this.props.collapsed?("string"==typeof c&&(c=c.trim()),"span"===n.type&&(n=n.props.children[2]),a.createElement("option",{value:t,"data-is-link-to":this.props.isLinkTo},n,r?"*":"",c&&" (",c&&c,c&&")")):a.createElement("li",{className:p,onClick:o?null:s.bind(this,t,this.props.isLinkTo)},a.createElement("a",null,a.createElement("span",{className:"tab-title"},n,r?"*":""),c&&a.createElement("div",{className:"tab-subtext"},c)))}}class g extends a.Component{static propTypes={setting:i().string,defaultActiveTab:i().number,segmented:i().bool};static defaultProps={active:0,defaultActiveTab:0,segmented:!0,contentClass:"",style:{}};constructor(e){super(),this.state={activeTab:e.setting?e.viewSettings.get(e.setting,e.defaultActiveTab):e.defaultActiveTab,width:window.innerWidth},this._setDimensions=this._setDimensions.bind(this)}componentDidMount(){this._setDimensions(),window.addEventListener("resize",this._setDimensions,{capture:!1,passive:!0})}UNSAFE_componentWillReceiveProps(e){let t=e.viewSettings.get(e.setting);t!==this.props.viewSettings.get(this.props.setting)&&this.setState({activeTab:t})}componentWillUnmount(){window.removeEventListener("resize",this._setDimensions)}_setDimensions(){let e=window.innerWidth;e!==this.state.width&&this.setState({width:e})}_changeTab(e,t){e!==this.state.activeTab&&(""!==t&&this.props.history.push(t),this.props.setting&&c.A.changeViewSetting({[this.props.setting]:e}),this.setState({activeTab:e}),this.props.onChangeTab&&this.props.onChangeTab(e))}render(){let{children:e,contentClass:t,tabsClass:s,style:n,segmented:i}=this.props;const r=this.state.width<900&&a.Children.count(e)>2;let o=null,c=a.Children.map(e,((e,t)=>{if(!e)return null;if(r&&e.props.disabled)return null;let s=t===this.state.activeTab;return s&&(o=e.props.children),a.cloneElement(e,{collapsed:r,isActive:s,changeTab:this._changeTab.bind(this),index:t})})).filter((e=>null!==e));return o||(o=c[0].props.children),a.createElement("div",{className:l()(this.props.actionButtons?"with-buttons":"",this.props.className)},a.createElement("div",{className:"service-selector"},a.createElement("ul",{style:n,className:l()("button-group no-margin",s,{segmented:i})},r?a.createElement("li",{style:{paddingLeft:10,paddingRight:10,minWidth:"15rem"}},a.createElement("select",{value:this.state.activeTab,style:{marginTop:10,marginBottom:10},className:"bts-select",onChange:e=>{let t=parseInt(e.target.value,10);this._changeTab(t,e.target[t].attributes["data-is-link-to"].value)}},c)):c,this.props.actionButtons?a.createElement("li",{className:"tabs-action-buttons"},this.props.actionButtons):null)),a.createElement("div",{className:l()("tab-content",t)},o))}}g=(0,o.N)(g,{listenTo:()=>[p.A],getProps:()=>({viewSettings:p.A.getState().viewSettings})}),g=(0,u.y)(g)}}]);