leonsuke

SocialWidget.js

Jan 26th, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.06 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import logo from '../kepeng.png';
  3. import ListTransaction from '../API/ListTransaction'
  4. import DetailTransaction from '../API/DetailTransaction'
  5.  
  6. const navDashboard = {
  7. 'textAlign': 'left'
  8. }
  9.  
  10. const imageResponsive = {
  11. 'minWidth': '95px',
  12. 'float': 'none',
  13. 'margin': 'auto',
  14. 'position': 'relative',
  15. 'top': '-10px'
  16. }
  17.  
  18. const h2xLarge = {
  19. 'fontSize': 'x-large'
  20. }
  21.  
  22. const tileItem = {
  23. 'height': '165px',
  24. 'textAlign': '-webkit-right',
  25. 'textAlign': 'right'
  26. }
  27.  
  28. const tileInfo = {
  29. 'color': '#ffffff'
  30. }
  31.  
  32. const tdAlign = {
  33. 'margin': 'auto'
  34. }
  35.  
  36. const contentHeader = {
  37. 'top': '-15px',
  38. 'padding': '0'
  39. }
  40.  
  41. const widgetUser = {
  42. 'height': '100%',
  43. 'maxHeight': '55px'
  44. }
  45.  
  46. const contentWrapper = {
  47. 'marginLeft': '0'
  48. }
  49.  
  50. const aHref = {
  51. 'cursor': 'pointer'
  52. }
  53.  
  54. const tdStyle = {
  55. 'color': 'rgb(128, 128, 128)',
  56. 'fontSize': 'small'
  57. }
  58.  
  59. export default class SocialWidget extends Component {
  60. constructor(props) {
  61. super(props)
  62.  
  63. this.state = {
  64. ListTransaction: ''
  65. }
  66. }
  67.  
  68. componentDidMount() {
  69. setInterval(() => {
  70. ListTransaction()
  71. .then((response) => response.json())
  72. .then((responseJson) => {
  73. var result = responseJson.result
  74. this.setState({ ListTransaction: result })
  75. })
  76. }, 1000)
  77.  
  78. }
  79.  
  80. DetailTransaction (e) {
  81. console.log('Clicked', e)
  82.  
  83. }
  84.  
  85. duration(minDateTimes, maxDateTimes) {
  86. var mintime = new Date((parseInt(minDateTimes)))
  87. var maxtime = new Date()
  88.  
  89. // console.log(maxtime)
  90. let date1 = mintime.toISOString()
  91. let date2 = maxtime.toISOString()
  92.  
  93.  
  94. date1 = new Date(date1.toString())
  95. date2 = new Date(date2.toString())
  96. var e1 = Math.round(date1 / 1000)
  97. var e2 = Math.round(date2 / 1000)
  98. var diff = e2 - e1
  99. // console.log(diff)
  100. var str = ''
  101. if (diff < 0) {
  102. diff = (diff + 86400)
  103. str += (Math.floor(diff / 3600)) + 'j '
  104. diff = diff % 3600
  105. str += (Math.floor(diff / 60)) + 'm'
  106. } else {
  107. str += (Math.floor(diff / 86400)) + '[D] '
  108. diff = diff % 86400
  109. str += (Math.floor(diff / 3600)) + '[H] '
  110. diff = diff % 3600
  111. str += (Math.floor(diff / 60)) + '[M] '
  112. diff = diff % 60
  113. str += (Math.floor(diff / 1)) + '[S] '
  114. }
  115. // diff = diff / 1000
  116. return str
  117. }
  118.  
  119. ellipsis(str) {
  120. str = str.substring(0, 26) + '...'
  121. return str
  122. }
  123.  
  124. countGas(gasLim, gasUsed) {
  125. const gasValue = gasLim * gasUsed
  126. return gasValue
  127. }
  128.  
  129. render() {
  130. return (
  131. // start root
  132. <div>
  133. {/* start warpper */}
  134. <div className="content-wrapper" style={contentWrapper}>
  135. {/* start content */}
  136. <section className="content">
  137. {/* start nav-tabs-custom */}
  138. <div className="nav-tabs-custom">
  139. <ul className="nav nav-tabs">
  140. <li className="active"><a href="#tab_1" data-toggle="tab">Dashboard</a></li>
  141. <li><a href="#tab_2" data-toggle="tab">Chart</a></li>
  142. </ul>
  143. {/* start tab-content */}
  144. <div className="tab-content">
  145. <div className="tab-pane active fade-in" id="tab_1">
  146. {/* start row */}
  147. <div className="row">
  148. {/* start col */}
  149. <div className="col-md-3">
  150. {/* start box box-widget */}
  151. <div className="box box-widget widget-user-2">
  152. {/* Add the bg color to the header using any of the bg-* classes */}
  153. <div className="widget-user-header bg-aqua-active">
  154. {/* start widget-user-image */}
  155. <div className="widget-user-image" style={widgetUser}>
  156. <img className="img-responsive" src={logo} alt="User Avatar" style={imageResponsive} />
  157. </div><br />
  158. {/* end widget-user-image */}
  159. {/* <h3 className="widget-user-username" style={textAlignLeft}><b>Kepeng (K)</b></h3>
  160. <h4 className="widget-user-desc" style={widgetUserDesc}>
  161. <b>1,242.</b>79624002 IDR
  162. </h4>
  163. <h4 className="widget-user-desc" style={widgetUserDesc}><b>0.</b>00002477 BTC</h4> */}
  164. </div>
  165. {/* start box-footer no-padding */}
  166. <div className="box-footer no-padding">
  167. <ul className="nav nav-stacked">
  168. <li style={navDashboard}><a href="#">Coin Name: <span className="pull-right badge bg-blue"><b>Kepeng (K)</b></span></a></li>
  169. <li style={navDashboard}><a href="#">Sale per coin: <span className="pull-right badge bg-blue"><b>1,242.</b>79624002 IDR</span></a></li>
  170. <li style={navDashboard}><a href="#">Purchase per coin: <span className="pull-right badge bg-blue"><b>0.</b>00002477 BTC</span></a></li>
  171. <li style={navDashboard}><a href="#">Market Cap: <span className="pull-right badge bg-blue"><b>5,717,386,802</b> IDR</span></a></li>
  172. <li style={navDashboard}><a href="#">Volume (24h): <span className="pull-right badge bg-aqua"><b>717,607</b> IDR</span></a></li>
  173. <li style={navDashboard}><a href="#">Change (24h): <span className="pull-right badge bg-green">+<b>3.</b><small>34%</small></span></a></li>
  174. </ul>
  175. </div>
  176. {/* end box-footer no-padding */}
  177. </div>
  178. {/* end box box-widget */}
  179. </div>
  180. {/* end col */}
  181. <div className="col-md-2">
  182. <div className="tile-item tile-primary" style={tileItem}>
  183. <div className="tile-bubbles"></div>
  184. <h1 className="tile-title">Last Block Found</h1>
  185. <h6 className="tile-info"><a style={tileInfo}><b>1540501</b></a></h6>
  186. </div>
  187. </div>
  188. <div className="col-md-2">
  189. <div className="tile-item tile-primary" style={tileItem}>
  190. <div className="tile-bubbles"></div>
  191. <h1 className="tile-title">Circulation Supply</h1>
  192. <h6 className="tile-info"><b>4,600,422 D</b></h6>
  193. </div>
  194. </div>
  195. <div className="col-md-2">
  196. <div className="tile-item tile-primary" style={tileItem}>
  197. <div className="tile-bubbles"></div>
  198. <h1 className="tile-title">Masternodes</h1>
  199. <h6 className="tile-info"><a style={tileInfo}>119</a></h6>
  200. </div>
  201. </div>
  202. <div className="col-md-3">
  203. <div className="tile-item tile-primary" style={tileItem}>
  204. <div className="tile-bubbles"></div>
  205. <h1 className="tile-title">Masternodes Cost</h1>
  206. <h6 className="tile-info"><b>6,213,981.2</b>0 <b>IDR</b></h6><br />
  207. <span>5,000 D</span>
  208. </div>
  209. </div>
  210. <div className="col-md-2">
  211. <div className="tile-item tile-primary" style={tileItem}>
  212. <div className="tile-bubbles"></div>
  213. <h1 className="tile-title">Coins Locked</h1>
  214. <h6 className="tile-info"><b>595,000 D</b></h6><br />
  215. <span><b>12</b>.93 % of the supply</span>
  216. </div>
  217. </div>
  218. <div className="col-md-2">
  219. <div className="tile-item tile-primary" style={tileItem}>
  220. <div className="tile-bubbles"></div>
  221. <h1 className="tile-title">PoW Difficulty</h1>
  222. <h6 className="tile-info"><b>4,920.</b> 44254063</h6>
  223. </div>
  224. </div>
  225. <div className="col-md-2">
  226. <div className="tile-item tile-primary" style={tileItem}>
  227. <div className="tile-bubbles"></div>
  228. <h1 className="tile-title">PoS Difficulty</h1>
  229. <h6 className="tile-info"><b>0.</b> 00024414</h6>
  230. </div>
  231. </div>
  232. <div className="col-md-3">
  233. <div className="tile-item tile-primary" style={tileItem}>
  234. <div className="tile-bubbles"></div>
  235. <h1 className="tile-title">Stake Weight Spent</h1>
  236. <h6 className="tile-info"><b>99</b></h6>
  237. <span>Last 100 PoS blocks AVG</span>
  238. </div>
  239. </div>
  240. <div className="col-md-12">
  241. <div className="tile-item tile-primary" style={tileItem}>
  242. <div className="tile-bubbles"></div>
  243. <h1 className="tile-title">Peers Info</h1>
  244. <span>22 active Connections</span>
  245. </div>
  246. </div>
  247. </div>
  248. {/* end row */}
  249.  
  250. {/* start row */}
  251. <div className="row">
  252. {/* start col */}
  253. <div className="col-xs-12 col-sm-12 col-md-12">
  254. {/* start content-header */}
  255. <section className="content-header" style={contentHeader}>
  256. {/* start box */}
  257. <div className="box">
  258. {/* start box-header */}
  259. <div className="box-header">
  260. <h3 className="box-title pull pull-left" style={h2xLarge}><b>Blocks</b></h3>
  261. </div>
  262. {/* end box-header */}
  263.  
  264. {/* start box-body */}
  265. <div className="box-body">
  266. {/* start table-responsive */}
  267. <div className="table-responsive">
  268. <table id="example2" className="table table-bordered">
  269. <thead>
  270. <tr>
  271. <th>Height</th>
  272. <th>Age</th>
  273. <th>Txs</th>
  274. <th>Difficult</th>
  275. <th>Proof-Type</th>
  276. <th>Block Size</th>
  277. <th>Extracted by</th>
  278. </tr>
  279. </thead>
  280. <tbody>
  281. <tr>
  282. <td><a>1540501</a></td>
  283. <td>1 week</td>
  284. <td>2</td>
  285. <td><b>4,920.</b>44254063</td>
  286. <td><span className="btn btn-default" style={tdAlign}>PoW</span></td>
  287. <td><b>435</b>B</td>
  288. <td><a>DRN58D1XeKFZpxCVDfpxy6AGdGjHhQfnDC</a></td>
  289. </tr>
  290. <tr>
  291. <td><a>1540500</a></td>
  292. <td>1 week</td>
  293. <td>6</td>
  294. <td><b>4,920.</b>44254063</td>
  295. <td><span className="btn btn-primary" style={tdAlign}>PoS</span></td>
  296. <td><b>123</b>kB</td>
  297. <td><a>DJRMtgTF7PDX3nCSRDDuLxYSbuzw8JEHpu</a></td>
  298. </tr>
  299. <tr>
  300. <td><a>1540499</a></td>
  301. <td>1 week</td>
  302. <td>2</td>
  303. <td><b>2,733.</b>57779737</td>
  304. <td><span className="btn btn-default" style={tdAlign}>PoW</span></td>
  305. <td><b>434</b>B</td>
  306. <td><a>DRN58D1XeKFZpxCVDfpxy6AGdGjHhQfnDC</a></td>
  307. </tr>
  308. <tr>
  309. <td><a>1540498</a></td>
  310. <td>1 week</td>
  311. <td>2</td>
  312. <td><b>2,915.</b>81470881</td>
  313. <td><span className="btn btn-default" style={tdAlign}>PoW</span></td>
  314. <td><b>434</b>B</td>
  315. <td><a>DRN58D1XeKFZpxCVDfpxy6AGdGjHhQfnDC</a></td>
  316. </tr>
  317. <tr>
  318. <td><a>1540497</a></td>
  319. <td>1 week</td>
  320. <td>2</td>
  321. <td><b>1,555.</b>10061496</td>
  322. <td><span className="btn btn-default" style={tdAlign}>PoW</span></td>
  323. <td><b>435</b>B</td>
  324. <td><a>DRN58D1XeKFZpxCVDfpxy6AGdGjHhQfnDC</a></td>
  325. </tr>
  326. </tbody>
  327. </table>
  328. </div>
  329. {/* end table-responsive */}
  330. </div>
  331. {/* end box-body */}
  332. </div>
  333. {/* end box */}
  334. </section>
  335. {/* end content-header */}
  336. </div>
  337. {/* end col */}
  338.  
  339. {/* start col */}
  340. <div className="col-xs-12 col-sm-12 col-md-12">
  341. {/* start content-header */}
  342. <section className="content-header" style={contentHeader}>
  343. {/* start box */}
  344. <div className="box">
  345. {/* start box-header */}
  346. <div className="box-header">
  347. <h3 className="box-title pull pull-left" style={h2xLarge}><b>Transactions</b></h3>
  348. </div>
  349. {/* end box-header */}
  350.  
  351. {/* start box-body */}
  352. <div className="box-body">
  353. {/* start table-responsive */}
  354. <div className="table-responsive">
  355. <table id="example2" className="table table-bordered">
  356. <thead>
  357. <tr>
  358. <th>TxHash</th>
  359. <th>Block</th>
  360. <th>Age</th>
  361. <th>From</th>
  362. <th>To</th>
  363. <th>Value</th>
  364. <th><small>[TxFree]</small></th>
  365. </tr>
  366. </thead>
  367. <tbody>
  368. {this.state.ListTransaction ?
  369. this.state.ListTransaction.map((list, i) => {
  370. return (
  371. <tr>
  372. <td><a onClick={this.DetailTransaction.bind(this)} style={aHref}>{this.ellipsis(list.hash)}</a></td>
  373. <td>{list.blockNumber}</td>
  374. <td>{this.duration(list.timeStamp)}</td>
  375. <td><a style={aHref}>{this.ellipsis(list.from)}</a></td>
  376. <td><a style={aHref}>{this.ellipsis(list.to)}</a></td>
  377. <td>{list.value} Ether</td>
  378. <td style={tdStyle}><small>{this.countGas(list.gas, list.gasUsed)}</small></td>
  379. </tr>
  380. )
  381. })
  382. : null
  383. }
  384. </tbody>
  385. </table>
  386. </div>
  387. {/* end table-responsive */}
  388. </div>
  389. {/* end box-body */}
  390. </div>
  391. {/* end box */}
  392. </section>
  393. {/* end content-header */}
  394. </div>
  395. {/* end col */}
  396. </div>
  397. {/* end row */}
  398. </div>
  399. <div className="tab-pane fade-in" id="tab_2">
  400. The European languages are members of the same family. Their separate existence is a myth.
  401. For science, music, sport, etc, Europe uses the same vocabulary. The languages only differ
  402. in their grammar, their pronunciation and their most common words. Everyone realizes why a
  403. new common language would be desirable: one could refuse to pay expensive translators. To
  404. achieve this, it would be necessary to have uniform grammar, pronunciation and more common
  405. words. If several languages coalesce, the grammar of the resulting language is more simple
  406. and regular than that of the individual languages.
  407. </div>
  408. </div>
  409. </div>
  410. {/* end nav-tabs-custom */}
  411. </section>
  412. {/* <!-- end content --> */}
  413. </div>
  414. {/* end content-wrapper */}
  415. </div>
  416. // end root
  417. )
  418. }
  419. }
Advertisement
Add Comment
Please, Sign In to add comment