-
Notifications
You must be signed in to change notification settings - Fork 13
/
dashboard-accounts.5e587c06dc6b2dec5680.js
1 lines (1 loc) · 14 KB
/
dashboard-accounts.5e587c06dc6b2dec5680.js
1
"use strict";(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[998],{97314:(t,e,s)=>{s.r(e),s.d(e,{default:()=>F});var n=s(96540),a=s(9404),i=s.n(a),r=s(87040),o=s(80849),c=s.n(o),l=s(9476),d=s(74248),h=s(14644),u=s(12569),p=s(72342),m=s(84259),g=s(99429),A=s(36234),b=s(72090),E=s(3145),w=s(55840),v=s(10658),y=s.n(v),_=s(46863),f=s(24180);class S extends n.Component{static propTypes={accounts:u.A.ChainAccountsList.isRequired,ignoredAccounts:u.A.ChainAccountsList};static defaultProps={width:2e3,compact:!1};constructor(t){super(),this.state={inverseSort:t.viewSettings.get("dashboardSortInverse",!0),sortBy:t.viewSettings.get("dashboardSort","star"),dashboardFilter:t.viewSettings.get("dashboardFilter","")}}shouldComponentUpdate(t,e){return!r.A.are_equal_shallow(t.accounts,this.props.accounts)||t.isContactsList!==this.props.isContactsList||t.showMyAccounts!==this.props.showMyAccounts||t.width!==this.props.width||t.showIgnored!==this.props.showIgnored||t.locked!==this.props.locked||t.passwordAccount!==this.props.passwordAccount||!r.A.are_equal_shallow(t.starredAccounts,this.props.starredAccounts)||!r.A.are_equal_shallow(e,this.state)}_onStar(t,e,s){s.preventDefault(),e?g.A.removeStarAccount(t):g.A.addStarAccount(t)}_goAccount(t,e){this.props.history.push(`/account/${t}`),m.A.changeViewSetting({overviewTab:e})}_createAccount(){this.props.history.push("/create-account/wallet")}_onFilter(t){this.setState({dashboardFilter:t.target.value.toLowerCase()}),m.A.changeViewSetting({dashboardFilter:t.target.value.toLowerCase()})}_setSort(t){let e=t===this.state.sortBy?!this.state.inverseSort:this.state.inverseSort;this.setState({sortBy:t,inverseSort:e}),m.A.changeViewSetting({dashboardSort:t,dashboardSortInverse:e})}_onAddContact(t){g.A.addAccountContact(t)}_onRemoveContact(t){g.A.removeAccountContact(t)}_renderList(t,e){const{width:s,starredAccounts:a,isContactsList:o,passwordAccount:c}=this.props,{dashboardFilter:l,sortBy:d,inverseSort:h}=this.state;let u=i().List();return t.filter((t=>{if(!t)return!1;let e=t.get("name"),s=w.A.isMyAccount(t)||e===c;return!!o||s===this.props.showMyAccounts})).filter((t=>!!t&&-1!==t.get("name").toLowerCase().indexOf(l))).sort(((t,e)=>{switch(d){case"star":return function(t,e,s,n){let a=t.get("name"),i=e.get("name"),o=n.has(a),c=n.has(i);return o&&!c?s?-1:1:c&&!o||a>i?s?1:-1:a<i?s?-1:1:r.A.sortText(a,i,!s)}(t,e,h,a);case"name":return r.A.sortText(t.get("name"),e.get("name"),h)}})).map((t=>{if(t){let i={},r={},l={};u=u.clear();let d=t.get("name"),h=t.get("lifetime_referrer_name")===d;t.get("orders")&&t.get("orders").forEach(((t,e)=>{let s=b.ChainStore.getObject(t);if(s){let t=s.getIn(["sell_price","base","asset_id"]);l[t]?l[t]+=parseInt(s.get("for_sale"),10):l[t]=parseInt(s.get("for_sale"),10)}})),t.get("call_orders")&&t.get("call_orders").forEach(((t,e)=>{let s=b.ChainStore.getObject(t);if(s){let t=s.getIn(["call_price","base","asset_id"]);i[t]?i[t]+=parseInt(s.get("collateral"),10):i[t]=parseInt(s.get("collateral"),10);let e=s.getIn(["call_price","quote","asset_id"]);r[e]?r[e]+=parseInt(s.get("debt"),10):r[e]=parseInt(s.get("debt"),10)}}));let p=t.get("balances");t.get("balances")&&p.forEach((t=>{let e=b.ChainStore.getObject(t);if(!e||!e.get("balance"))return null;u=u.push(t)}));let m=w.A.isMyAccount(t)||d===c,g=a.has(d),v=g?"gold-star":"grey-star";return n.createElement("tr",{key:d},n.createElement("td",{className:"clickable",onClick:this._onStar.bind(this,d,g)},n.createElement(A.A,{className:v,name:"fi-star",title:"icons.fi_star.account"})),o?e&&n.createElement("td",{onClick:this._onAddContact.bind(this,d)},n.createElement(A.A,{name:"plus-circle",title:"icons.plus_circle.add_contact"}))||n.createElement("td",{onClick:this._onRemoveContact.bind(this,d)},n.createElement(A.A,{name:"minus-circle",title:"icons.minus_circle.remove_contact"})):null,n.createElement("td",{style:{textAlign:"left"}},t.get("id")),n.createElement("td",{style:{textAlign:"left",paddingLeft:10},onClick:this._goAccount.bind(this,d,0),className:"clickable"+(m?" my-account":"")},n.createElement("span",{className:h?"lifetime":""},d)),n.createElement("td",{className:"clickable",onClick:this._goAccount.bind(this,d,1),style:{textAlign:"right"}},n.createElement(E.A,{noTip:!0,balances:[],openOrders:l})),s>=750?n.createElement("td",{className:"clickable",onClick:this._goAccount.bind(this,d,2),style:{textAlign:"right"}},n.createElement(E.A,{noTip:!0,balances:[],collateral:i})):null,s>=1200?n.createElement("td",{className:"clickable",onClick:this._goAccount.bind(this,d,2),style:{textAlign:"right"}},n.createElement(E.A,{noTip:!0,balances:[],debt:r})):null,n.createElement("td",{className:"clickable",onClick:this._goAccount.bind(this,d,0),style:{textAlign:"right"}},n.createElement(E.A,{noTip:!0,balances:u,collateral:i,debt:r,openOrders:l})))}}))}render(){let{width:t,showIgnored:e,isContactsList:s}=this.props;const{dashboardFilter:a}=this.state;let i=this._renderList(this.props.accounts),r=this._renderList(this.props.ignoredAccounts,!0),o=s?y().translate("explorer.accounts.filter_contacts"):y().translate("explorer.accounts.filter");o+="...";let l=!!_.A.getWallet();return n.createElement("div",{style:this.props.style},this.props.compact?null:n.createElement("section",{style:{paddingTop:"1rem",paddingLeft:"2rem"}},n.createElement("input",{placeholder:o,style:{maxWidth:"20rem",display:"inline-block"},type:"text",value:a,onChange:this._onFilter.bind(this)}),l&&!s?n.createElement("div",{onClick:this._createAccount.bind(this),style:{display:"inline-block",marginLeft:5,marginBottom:"1rem"},className:"button small"},n.createElement(c(),{content:"header.create_account"})):null,r&&r.length?n.createElement("div",{onClick:this.props.onToggleIgnored,style:{display:"inline-block",float:"right",marginRight:"20px"},className:"button small"},n.createElement(c(),{content:"account."+(this.props.showIgnored?"hide_ignored":"show_ignored")})):null),n.createElement("table",{className:"table table-hover dashboard-table",style:{fontSize:"0.85rem"}},this.props.compact?null:n.createElement("thead",null,n.createElement("tr",null,n.createElement("th",{onClick:this._setSort.bind(this,"star"),className:"clickable"},n.createElement(A.A,{className:"grey-star",name:"fi-star",title:"icons.fi_star.sort_accounts"})),s?n.createElement("th",null,n.createElement(A.A,{name:"user",title:"icons.user.account"})):null,n.createElement("th",{style:{textAlign:"left"}},"ID"),n.createElement("th",{style:{textAlign:"left",paddingLeft:10},onClick:this._setSort.bind(this,"name"),className:"clickable"},n.createElement(c(),{content:"header.account"})),n.createElement("th",{style:{textAlign:"right"}},n.createElement(c(),{content:"account.open_orders"})),t>=750?n.createElement("th",{style:{textAlign:"right"}},n.createElement(c(),{content:"account.as_collateral"})):null,t>=1200?n.createElement("th",{style:{textAlign:"right"}},n.createElement(c(),{content:"transaction.borrow_amount"})):null,n.createElement("th",{style:{textAlign:"right",marginRight:20}},n.createElement(c(),{content:"account.total_value"})))),n.createElement("tbody",null,i,e&&r.length?n.createElement("tr",{className:"dashboard-table--hiddenAccounts",style:{backgroundColor:"transparent"},key:"hidden"},n.createElement("td",{colSpan:"8"},y().translate("account.hidden_accounts_row"),":")):null,e&&r)))}}S=(0,p.A)(S);class C extends n.Component{render(){return n.createElement(S,this.props)}}C=(0,f.y)(C);const T=(0,l.N)(C,{listenTo:()=>[d.A,h.A,w.A],getProps:()=>({locked:h.A.getState().locked,starredAccounts:w.A.getState().starredAccounts,viewSettings:d.A.getState().viewSettings})});var k=s(1282),x=s(40702),N=s(81423),L=s(58586),I=s(23654),D=s(57127);function R(){return R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},R.apply(this,arguments)}class O extends n.Component{render(){return n.createElement(D.A,{stores:[w.A,d.A,L.A],inject:{contacts:()=>w.A.getState().accountContacts,myActiveAccounts:()=>w.A.getState().myActiveAccounts,myHiddenAccounts:()=>w.A.getState().myHiddenAccounts,accountsReady:()=>w.A.getState().accountsLoaded&&w.A.getState().refsLoaded,passwordAccount:()=>w.A.getState().passwordAccount,currentEntry:d.A.getState().viewSettings.get("dashboardEntry","accounts")}},n.createElement(B,this.props))}}class B extends n.Component{constructor(t){super(),this.state={width:null,showIgnored:!1,currentEntry:t.currentEntry},this._setDimensions=this._setDimensions.bind(this)}componentDidMount(){this._setDimensions(),window.addEventListener("resize",this._setDimensions,{capture:!1,passive:!0})}shouldComponentUpdate(t,e){return t.myActiveAccounts!==this.props.myActiveAccounts||t.contacts!==this.props.contacts||t.ignoredAccounts!==this.props.ignoredAccounts||t.passwordAccount!==this.props.passwordAccount||e.width!==this.state.width||t.accountsReady!==this.props.accountsReady||e.showIgnored!==this.state.showIgnored||e.currentEntry!==this.state.currentEntry}componentWillUnmount(){window.removeEventListener("resize",this._setDimensions)}_setDimensions(){let t=window.innerWidth;t!==this.state.width&&this.setState({width:t})}_onToggleIgnored(){this.setState({showIgnored:!this.state.showIgnored})}_onSwitchType(t){this.setState({currentEntry:t}),m.A.changeViewSetting({dashboardEntry:t})}render(){let{myActiveAccounts:t,myHiddenAccounts:e,accountsReady:s,passwordAccount:a}=this.props,{width:r,showIgnored:o}=this.state;a&&!t.has(a)&&(t=t.add(a));let c=t.toArray().sort();a&&-1===c.indexOf(a)&&c.push(a);let l=e.toArray().sort(),d=t.size+e.size+(a?1:0);if(!s)return n.createElement(x.A,null);if(!d)return n.createElement(N.A,null);const h=this.props.contacts.toArray();return n.createElement("div",{ref:"wrapper",className:"grid-block page-layout vertical"},n.createElement("div",{ref:"container",className:"tabs-container generic-bordered-box"},n.createElement(I.t,{setting:"accountTab",className:"account-tabs",defaultActiveTab:1,segmented:!1,tabsClass:"account-overview no-padding bordered-header content-block"},n.createElement(I.o,{title:"account.accounts"},n.createElement("div",{className:"generic-bordered-box"},n.createElement("div",{className:"box-content"},n.createElement(T,{accounts:i().List(c),ignoredAccounts:i().List(l),width:r,onToggleIgnored:this._onToggleIgnored.bind(this),showIgnored:o,showMyAccounts:!0})))),n.createElement(I.o,{title:"account.contacts"},n.createElement("div",{className:"generic-bordered-box"},n.createElement("div",{className:"box-content"},n.createElement(T,{accounts:h,passwordAccount:a,ignoredAccounts:i().List(l),width:r,onToggleIgnored:this._onToggleIgnored.bind(this),showIgnored:o,isContactsList:!0})))),n.createElement(I.o,{title:"account.recent"},n.createElement(k.$,{accountsList:t,limit:10,compactView:!1,fullHeight:!0,showFilters:!0,dashboard:!0})))))}}const F=t=>n.createElement(O,R({},t,{onlyAccounts:!0}))},23654:(t,e,s)=>{s.d(e,{o:()=>m,t:()=>g});var n=s(96540),a=s(5556),i=s.n(a),r=s(32485),o=s.n(r),c=s(9476),l=s(84259),d=s(74248),h=s(10658),u=s.n(h),p=s(24180);class m extends n.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:t,index:e,changeTab:s,title:a,className:i,updatedTab:r,disabled:c,subText:l}=this.props,d=o()({"is-active":t},i);return"string"==typeof a&&a.indexOf(".")>0&&(a=u().translate(a)),this.props.collapsed?("string"==typeof l&&(l=l.trim()),"span"===a.type&&(a=a.props.children[2]),n.createElement("option",{value:e,"data-is-link-to":this.props.isLinkTo},a,r?"*":"",l&&" (",l&&l,l&&")")):n.createElement("li",{className:d,onClick:c?null:s.bind(this,e,this.props.isLinkTo)},n.createElement("a",null,n.createElement("span",{className:"tab-title"},a,r?"*":""),l&&n.createElement("div",{className:"tab-subtext"},l)))}}class g extends n.Component{static propTypes={setting:i().string,defaultActiveTab:i().number,segmented:i().bool};static defaultProps={active:0,defaultActiveTab:0,segmented:!0,contentClass:"",style:{}};constructor(t){super(),this.state={activeTab:t.setting?t.viewSettings.get(t.setting,t.defaultActiveTab):t.defaultActiveTab,width:window.innerWidth},this._setDimensions=this._setDimensions.bind(this)}componentDidMount(){this._setDimensions(),window.addEventListener("resize",this._setDimensions,{capture:!1,passive:!0})}UNSAFE_componentWillReceiveProps(t){let e=t.viewSettings.get(t.setting);e!==this.props.viewSettings.get(this.props.setting)&&this.setState({activeTab:e})}componentWillUnmount(){window.removeEventListener("resize",this._setDimensions)}_setDimensions(){let t=window.innerWidth;t!==this.state.width&&this.setState({width:t})}_changeTab(t,e){t!==this.state.activeTab&&(""!==e&&this.props.history.push(e),this.props.setting&&l.A.changeViewSetting({[this.props.setting]:t}),this.setState({activeTab:t}),this.props.onChangeTab&&this.props.onChangeTab(t))}render(){let{children:t,contentClass:e,tabsClass:s,style:a,segmented:i}=this.props;const r=this.state.width<900&&n.Children.count(t)>2;let c=null,l=n.Children.map(t,((t,e)=>{if(!t)return null;if(r&&t.props.disabled)return null;let s=e===this.state.activeTab;return s&&(c=t.props.children),n.cloneElement(t,{collapsed:r,isActive:s,changeTab:this._changeTab.bind(this),index:e})})).filter((t=>null!==t));return c||(c=l[0].props.children),n.createElement("div",{className:o()(this.props.actionButtons?"with-buttons":"",this.props.className)},n.createElement("div",{className:"service-selector"},n.createElement("ul",{style:a,className:o()("button-group no-margin",s,{segmented:i})},r?n.createElement("li",{style:{paddingLeft:10,paddingRight:10,minWidth:"15rem"}},n.createElement("select",{value:this.state.activeTab,style:{marginTop:10,marginBottom:10},className:"bts-select",onChange:t=>{let e=parseInt(t.target.value,10);this._changeTab(e,t.target[e].attributes["data-is-link-to"].value)}},l)):l,this.props.actionButtons?n.createElement("li",{className:"tabs-action-buttons"},this.props.actionButtons):null)),n.createElement("div",{className:o()("tab-content",e)},c))}}g=(0,c.N)(g,{listenTo:()=>[d.A],getProps:()=>({viewSettings:d.A.getState().viewSettings})}),g=(0,p.y)(g)}}]);