-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdashboard.aa385b2acc82f870eeed.js
1 lines (1 loc) · 16.1 KB
/
dashboard.aa385b2acc82f870eeed.js
1
"use strict";(this.webpackChunkRuDEX3_light=this.webpackChunkRuDEX3_light||[]).push([[966],{85831:(e,t,s)=>{s.r(t),s.d(t,{default:()=>F});var a=s(67294),n=s(89449),i=s(52531),r=(s(4207),s(32793)),l=s(39014),o=s(34091),c=s(55420),p=s(13973),d=s(12326),h=s(30806),u=s(58074),m=s.n(u),g=s(94184),b=s.n(g),v=s(55294),E=s(99869),k=s(76660),w=s(91684),S=s(99349),_=s(73727),f=s(60567);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(),h.ChainStore.subscribe(this.update)}componentWillUnmount(){h.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=h.ChainStore.getAsset(e.quote),a=h.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(`${e.quote}_${e.base}`,{}),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);v.Z.hideMarket(e.key,t)}_handleFlip(e,t){if(this.props.handleFlip)return this.props.handleFlip(e,t);v.Z.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(m(),{content:"account.asset"}),dataIndex:"asset",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)},this.props.isFavorite?{}:{title:a.createElement(m(),{content:"account.user_issued_assets.quote_name"}),dataIndex:"quote_name",align:"right",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)},{title:a.createElement(m(),{content:"exchange.price"}),dataIndex:"price",align:"right",sorter:this.sortFunctions.priceValue,render:e=>a.createElement("span",{style:{whiteSpace:"nowrap"}},e)},{title:a.createElement(m(),{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(m(),{content:"exchange.volume"}),dataIndex:"volume",align:"right",sorter:this.sortFunctions.volumeValue,defaultSortOrder:"descend",render:(e,t,s)=>a.createElement("span",{style:{whiteSpace:"nowrap"}},p.Z.format_volume(t.volume,t.basePrecision))},e?{title:a.createElement(m(),{content:"exchange.flip"}),dataIndex:"flip",render:e=>a.createElement("span",{className:"column-hide-small",style:{whiteSpace:"nowrap"}},e)}:{},{title:a.createElement(m(),{content:t?"account.perm.show":"exchange.hide"}),dataIndex:"hide",render:e=>a.createElement("span",{style:{whiteSpace:"nowrap",cursor:"pointer"}},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.refs[e.toLowerCase()].src="asset-symbols/unknown.png",this.setState({imgError:!0}))}_toggleFavoriteMarket(e,t){let s=`${e}_${t}`;this.props.starredMarkets.has(s)?v.Z.removeStarMarket(e,t):v.Z.addStarMarket(e,t)}getTableData(e){let{base:t,quote:s,marketStats:n,isHidden:i,inverted:r,basePrecision:l}=e,o=(0,f.sA)(s),c=`${s}_${t}`;const d=this.props.starredMarkets.has(c)?"gold-star":"grey-star";return{key:c,star:a.createElement("div",{onClick:this._toggleFavoriteMarket.bind(this,s,t)},a.createElement(w.Z,{style:{cursor:"pointer"},className:d,name:"fi-star",title:"icons.fi_star.market"})),asset:a.createElement(_.rU,{to:`/market/${s}_${t}`},a.createElement("img",{ref:o.toLowerCase(),className:"column-hide-small",onError:this._onError.bind(this,o),style:{maxWidth:20,marginRight:10},src:`asset-symbols/${o.toLowerCase()}.png`}),a.createElement(S.Z,{dataPlace:"top",name:s})," ",this.props.isFavorite?a.createElement("span",null,": ",a.createElement(S.Z,{dataPlace:"top",name:t})):null),quote_name:this.props.isFavorite?null:a.createElement("span",{style:{textAlign:"right"}},a.createElement(S.Z,{noTip:!0,name:t})),price:a.createElement("div",{className:"column-hide-small",style:{textAlign:"right"}},n&&n.price?p.Z.price_text(n.price.toReal(!1),h.ChainStore.getAsset(s),h.ChainStore.getAsset(t)):null),hour_24:n&&n.change&&"0.00"!==n.change?n.change:0,volume:n&&n.volumeBase?n.volumeBase: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(w.Z,{name:"shuffle",title:"icons.shuffle"}))):null,hide:a.createElement(k.Tooltip,{title:i?a.createElement(m(),{content:"icons.plus_circle.show_market"}):a.createElement(m(),{content:"icons.cross_circle.hide_market"}),style:{marginRight:0},onClick:this._handleHide.bind(this,e,!e.isHidden)},a.createElement(w.Z,{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.volumeQuote))).map((e=>{let t=!0;if(e.isHidden!==this.state.showHidden)t=!1;else if(s){const a=h.ChainStore.getAsset(e.quote),n=h.ChainStore.getAsset(e.base),{isBitAsset:i}=p.Z.replaceName(a),{isBitAsset:r}=p.Z.replaceName(n);let l=e.quote,o=e.base;if(i&&(l="gp"+l),r&&(o="gp"+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(k.Input,{type:"text",placeholder:"Filter...",onChange:this._handleFilterInput.bind(this),addonAfter:a.createElement(k.Icon,{type:"search"})})),a.createElement("div",{className:"selector inline-block",style:{position:"relative",top:"6px"}},a.createElement("div",{className:b()("inline-block",{inactive:t}),onClick:this._toggleShowHidden.bind(this,!1)},a.createElement(m(),{content:"account.hide_hidden"})),a.createElement("div",{className:b()("inline-block",{inactive:!t}),onClick:this._toggleShowHidden.bind(this,!0)},a.createElement(m(),{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:()=>{v.Z.changeViewSetting({onlyLiquid:!this.props.onlyLiquid})}}),a.createElement("span",{style:{paddingLeft:"0.4rem"}},a.createElement(m(),{content:"exchange.show_only_liquid"}))))),a.createElement(E.Z,{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 C=(0,n.$)(y,{listenTo:()=>[l.Z,d.Z],getProps(){let{marketDirections:e,hiddenMarkets:t}=l.Z.getState();return{marketDirections:e,hiddenMarkets:t,allMarketStats:d.Z.getState().allMarketStats,starredMarkets:l.Z.getState().starredMarkets,onlyLiquid:l.Z.getState().viewSettings.get("onlyLiquid",!0)}}});class N extends a.Component{render(){return a.createElement(C,{markets:this.props.starredMarkets,forceDirection:!0,isFavorite:!0})}}N=(0,n.$)(N,{listenTo:()=>[l.Z],getProps:()=>({starredMarkets:l.Z.getState().starredMarkets})});class T extends a.Component{constructor(){super();let e=c.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"7fcf452d"===s?t.markets:[["TEST","PEG.FAKEUSD"],["TEST","BTWTY"]]}shouldComponentUpdate(e){return!p.Z.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)||"RUDEX.RUBLE"===n.base||"RUBLE"!==e.quotes[s]||(t=t.set(i,n))}));this.setState({markets:t})}render(){return a.createElement(C,{markets:this.state.markets,showFlip:!1,isFavorite:!1})}}T=(0,n.$)(T,{listenTo:()=>[d.Z,l.Z],getProps(){let e=l.Z.getState().userMarkets,t=l.Z.getState().defaultMarkets;return e.size&&e.forEach(((e,s)=>{t.has(s)||(t=t.set(s,e))})),{markets:t}}}),a.Component;var x=s(23316);class A extends a.Component{render(){let{myActiveAccounts:e,myHiddenAccounts:t,accountsReady:s,passwordAccount:n,preferredBases:r}=this.props;return s?(e.size,t.size,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(o.m,{defaultActiveTab:0,segmented:!1,setting:"dashboardTab",className:"account-tabs",tabsClass:"account-overview no-padding bordered-header content-block"},a.createElement(o.O,{title:"dashboard.starred_markets"},a.createElement(N,null)),r.map((e=>{let t=a.createElement("span",null,a.createElement("img",{className:"column-hide-small",style:{maxWidth:30,marginRight:5},src:-1!==(0,f.sY)().indexOf(e)?`asset-symbols/${e.toLowerCase()}.png`:"asset-symbols/unknown.png"})," ",e.replace("RUDEX.",""));return a.createElement(o.O,{key:e,title:t},a.createElement(T,{quotes:[e].concat((0,x.bn)([e]))}))}))))))))):a.createElement(i.Z,null)}}const F=(0,n.$)(A,{listenTo:()=>[r.Z,l.Z],getProps(){let{myActiveAccounts:e,myHiddenAccounts:t,passwordAccount:s,accountsLoaded:a,refsLoaded:n}=r.Z.getState();return{myActiveAccounts:e,myHiddenAccounts:t,passwordAccount:s,accountsReady:a&&n,preferredBases:l.Z.getState().preferredBases}}})},99869:(e,t,s)=>{s.d(t,{Z:()=>l});var a=s(67294),n=s(112),i=s.n(n),r=s(76660);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)}}},34091:(e,t,s)=>{s.d(t,{m:()=>g,O:()=>m});var a=s(67294),n=s(45697),i=s.n(n),r=s(94184),l=s.n(r),o=s(89449),c=s(55294),p=s(39014),d=s(112),h=s.n(d),u=s(5977);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.Z.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.$)(g,{listenTo:()=>[p.Z],getProps:()=>({viewSettings:p.Z.getState().viewSettings})}),g=(0,u.EN)(g)}}]);