Advertisement
Guest User

teachers

a guest
Aug 3rd, 2015
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.20 KB | None | 0 0
  1. import React from 'react';
  2. import FixedDataTable from 'fixed-data-table';
  3. require('./fixed-data-table.less');
  4. var Table = FixedDataTable.Table;
  5. var Column = FixedDataTable.Column;
  6. var data = [
  7. {
  8. "_id": "55be9f654fc6e869d1279dbe",
  9. "index": 0,
  10. "guid": "2cde01f2-277f-4730-8c99-4b07c0b729ff",
  11. "isActive": false,
  12. "balance": "$215.21",
  13. "picture": "http://lorempixel.com/64/64/people/0/",
  14. "age": 20,
  15. "name": {
  16. "first": "York",
  17. "last": "Gibson"
  18. },
  19. "language": "EN",
  20. "email": "york.gibson@barkarama.org",
  21. "phone": "+1 (852) 428-3413",
  22. "address": "511 Butler Street, Kersey, Mississippi, 1986",
  23. "registered": "2012-12-13T00:18:52Z"
  24. },
  25. {
  26. "_id": "55be9f65d8fe86664a5e015e",
  27. "index": 1,
  28. "guid": "914c2951-7df2-4cfe-be6d-c4a3421e8b1f",
  29. "isActive": false,
  30. "balance": "$212.05",
  31. "picture": "http://lorempixel.com/64/64/people/1/",
  32. "age": 37,
  33. "name": {
  34. "first": "Helena",
  35. "last": "Robertson"
  36. },
  37. "language": "EN",
  38. "email": "helena.robertson@zytrek.us",
  39. "phone": "+1 (812) 508-3800",
  40. "address": "786 Seba Avenue, Fivepointville, Arkansas, 6488",
  41. "registered": "Sunday, September 7, 2014 11:02 AM"
  42. },
  43. {
  44. "_id": "55be9f65665e9dcde1eceecc",
  45. "index": 2,
  46. "guid": "620083fd-da65-4309-8666-92a8ec96a9f7",
  47. "isActive": false,
  48. "balance": "$689.41",
  49. "picture": "http://lorempixel.com/64/64/people/2/",
  50. "age": 33,
  51. "name": {
  52. "first": "Roth",
  53. "last": "Levine"
  54. },
  55. "language": "FR",
  56. "email": "roth.levine@jumpstack.ca",
  57. "phone": "+1 (945) 574-3812",
  58. "address": "716 Danforth Street, Garfield, Wyoming, 3868",
  59. "registered": "Wednesday, September 10, 2014 1:39 AM"
  60. },
  61. {
  62. "_id": "55be9f65e269c46ab1940733",
  63. "index": 3,
  64. "guid": "f230aebf-5ab0-4136-83fc-c4ec520374ac",
  65. "isActive": false,
  66. "balance": "$640.70",
  67. "picture": "http://lorempixel.com/64/64/people/3/",
  68. "age": 28,
  69. "name": {
  70. "first": "Edwards",
  71. "last": "Mccullough"
  72. },
  73. "language": "ES",
  74. "email": "edwards.mccullough@realysis.biz",
  75. "phone": "+1 (831) 519-2595",
  76. "address": "856 Middleton Street, Williamson, Massachusetts, 463",
  77. "registered": "Tuesday, March 17, 2015 3:57 AM"
  78. },
  79. {
  80. "_id": "55be9f6510d70b848d01f776",
  81. "index": 4,
  82. "guid": "643fdf5f-e101-43a3-b40e-d25a4aabb71e",
  83. "isActive": true,
  84. "balance": "$282.25",
  85. "picture": "http://lorempixel.com/64/64/people/4/",
  86. "age": 31,
  87. "name": {
  88. "first": "Erickson",
  89. "last": "Riggs"
  90. },
  91. "language": "EN",
  92. "email": "erickson.riggs@extro.name",
  93. "phone": "+1 (921) 462-3783",
  94. "address": "284 Stuyvesant Avenue, Jugtown, Puerto Rico, 4455",
  95. "registered": "Tuesday, May 13, 2014 2:29 PM"
  96. },
  97. {
  98. "_id": "55be9f65a8096f7e13bc369c",
  99. "index": 5,
  100. "guid": "977ed1ec-88b1-45e4-96cb-6b740c823cc1",
  101. "isActive": true,
  102. "balance": "$434.79",
  103. "picture": "http://lorempixel.com/64/64/people/5/",
  104. "age": 21,
  105. "name": {
  106. "first": "Patty",
  107. "last": "Rivers"
  108. },
  109. "language": "ES",
  110. "email": "patty.rivers@bolax.io",
  111. "phone": "+1 (810) 482-3302",
  112. "address": "692 Sackett Street, Calpine, Vermont, 634",
  113. "registered": "Friday, April 11, 2014 10:04 PM"
  114. },
  115. {
  116. "_id": "55be9f6531b0ab1d66a5b1b1",
  117. "index": 6,
  118. "guid": "f1fb8d0a-3470-48ec-a58a-bf468825ea82",
  119. "isActive": false,
  120. "balance": "$275.39",
  121. "picture": "http://lorempixel.com/64/64/people/6/",
  122. "age": 22,
  123. "name": {
  124. "first": "Ines",
  125. "last": "Mendoza"
  126. },
  127. "language": "ES",
  128. "email": "ines.mendoza@biflex.biz",
  129. "phone": "+1 (941) 461-3076",
  130. "address": "194 Williams Court, Garberville, North Carolina, 7582",
  131. "registered": "Wednesday, April 9, 2014 11:07 AM"
  132. },
  133. {
  134. "_id": "55be9f6599aa361dc4dc0869",
  135. "index": 7,
  136. "guid": "d6d3ce39-2dba-4ed5-8306-c549001bf1b6",
  137. "isActive": true,
  138. "balance": "$549.77",
  139. "picture": "http://lorempixel.com/64/64/people/7/",
  140. "age": 34,
  141. "name": {
  142. "first": "Rosie",
  143. "last": "Vang"
  144. },
  145. "language": "EN",
  146. "email": "rosie.vang@fuelworks.me",
  147. "phone": "+1 (899) 576-3457",
  148. "address": "230 Adams Street, Loomis, Texas, 2782",
  149. "registered": "Saturday, December 20, 2014 2:27 PM"
  150. },
  151. {
  152. "_id": "55be9f6513cd875ae0fc7459",
  153. "index": 8,
  154. "guid": "80043e1b-6d13-4875-bb50-9dcb7e58ecd5",
  155. "isActive": false,
  156. "balance": "$745.37",
  157. "picture": "http://lorempixel.com/64/64/people/8/",
  158. "age": 39,
  159. "name": {
  160. "first": "Parker",
  161. "last": "Mckenzie"
  162. },
  163. "language": "EN",
  164. "email": "parker.mckenzie@retrotex.co.uk",
  165. "phone": "+1 (990) 464-3159",
  166. "address": "764 Coles Street, Sehili, Idaho, 2608",
  167. "registered": "Friday, April 11, 2014 11:53 PM"
  168. },
  169. {
  170. "_id": "55be9f653d4e3726137b686e",
  171. "index": 9,
  172. "guid": "4e6d7591-dd85-4352-b65e-af9f823bbf2b",
  173. "isActive": false,
  174. "balance": "$656.66",
  175. "picture": "http://lorempixel.com/64/64/people/9/",
  176. "age": 35,
  177. "name": {
  178. "first": "Adela",
  179. "last": "Mclaughlin"
  180. },
  181. "language": "EN",
  182. "email": "adela.mclaughlin@silodyne.info",
  183. "phone": "+1 (983) 593-3713",
  184. "address": "932 Dahl Court, Bethany, Pennsylvania, 1665",
  185. "registered": "Thursday, May 21, 2015 12:04 PM"
  186. },
  187. {
  188. "_id": "55be9f658c71fe66e4c2bf5f",
  189. "index": 10,
  190. "guid": "0ca7a1b5-ada1-441f-bd7c-f6de2a3ca77e",
  191. "isActive": false,
  192. "balance": "$994.66",
  193. "picture": "http://lorempixel.com/64/64/people/0/",
  194. "age": 20,
  195. "name": {
  196. "first": "Hudson",
  197. "last": "Bonner"
  198. },
  199. "language": "ES",
  200. "email": "hudson.bonner@deviltoe.com",
  201. "phone": "+1 (970) 515-2982",
  202. "address": "768 Dekoven Court, Belmont, Alaska, 8958",
  203. "registered": "Monday, September 22, 2014 6:13 PM"
  204. },
  205. {
  206. "_id": "55be9f65e13e87aebbd96704",
  207. "index": 11,
  208. "guid": "8271f962-0558-45ab-ab43-ac6fa5379002",
  209. "isActive": true,
  210. "balance": "$903.49",
  211. "picture": "http://lorempixel.com/64/64/people/1/",
  212. "age": 22,
  213. "name": {
  214. "first": "Shannon",
  215. "last": "Patel"
  216. },
  217. "language": "FR",
  218. "email": "shannon.patel@lunchpod.net",
  219. "phone": "+1 (873) 421-2516",
  220. "address": "365 Columbia Place, Sunriver, South Carolina, 7761",
  221. "registered": "Saturday, March 21, 2015 10:57 PM"
  222. },
  223. {
  224. "_id": "55be9f65fc8a125ab60273d1",
  225. "index": 12,
  226. "guid": "e578fc3f-0a5b-48e1-a54c-e5bc5abcfda8",
  227. "isActive": false,
  228. "balance": "$198.76",
  229. "picture": "http://lorempixel.com/64/64/people/2/",
  230. "age": 39,
  231. "name": {
  232. "first": "Erna",
  233. "last": "Walters"
  234. },
  235. "language": "IT",
  236. "email": "erna.walters@geekol.org",
  237. "phone": "+1 (854) 455-3527",
  238. "address": "562 Furman Avenue, Windsor, Palau, 2265",
  239. "registered": "Tuesday, August 12, 2014 2:48 PM"
  240. },
  241. {
  242. "_id": "55be9f65dae5cb63d3a740af",
  243. "index": 13,
  244. "guid": "b4137f73-1a1f-4f3f-9e0b-c665adf60f43",
  245. "isActive": false,
  246. "balance": "$753.38",
  247. "picture": "http://lorempixel.com/64/64/people/3/",
  248. "age": 26,
  249. "name": {
  250. "first": "Deidre",
  251. "last": "Hill"
  252. },
  253. "language": "ES",
  254. "email": "deidre.hill@medicroix.us",
  255. "phone": "+1 (904) 441-2303",
  256. "address": "421 Polar Street, Hamilton, Virginia, 2326",
  257. "registered": "Monday, January 5, 2015 7:20 PM"
  258. },
  259. {
  260. "_id": "55be9f65b38fd9cdc5403385",
  261. "index": 14,
  262. "guid": "1fdf4081-862f-4c26-87da-8a237ff74eeb",
  263. "isActive": true,
  264. "balance": "$430.71",
  265. "picture": "http://lorempixel.com/64/64/people/4/",
  266. "age": 35,
  267. "name": {
  268. "first": "Isabel",
  269. "last": "Bruce"
  270. },
  271. "language": "EN",
  272. "email": "isabel.bruce@retrack.ca",
  273. "phone": "+1 (922) 427-2409",
  274. "address": "183 Hart Street, Nanafalia, American Samoa, 2917",
  275. "registered": "Sunday, May 4, 2014 12:43 PM"
  276. },
  277. {
  278. "_id": "55be9f65398329b33a24ff36",
  279. "index": 15,
  280. "guid": "805b5054-45c5-4d0c-a26d-f1b1ac269f18",
  281. "isActive": true,
  282. "balance": "$849.73",
  283. "picture": "http://lorempixel.com/64/64/people/5/",
  284. "age": 30,
  285. "name": {
  286. "first": "Melanie",
  287. "last": "Molina"
  288. },
  289. "language": "EN",
  290. "email": "melanie.molina@pheast.biz",
  291. "phone": "+1 (860) 507-2650",
  292. "address": "362 Calder Place, Kenwood, Kansas, 8178",
  293. "registered": "Wednesday, October 8, 2014 8:20 PM"
  294. },
  295. {
  296. "_id": "55be9f6508a049a8b5ab03dd",
  297. "index": 16,
  298. "guid": "8076d8fe-f9d8-4689-8b73-fb709198083a",
  299. "isActive": true,
  300. "balance": "$895.34",
  301. "picture": "http://lorempixel.com/64/64/people/6/",
  302. "age": 35,
  303. "name": {
  304. "first": "Brown",
  305. "last": "Cortez"
  306. },
  307. "language": "EN",
  308. "email": "brown.cortez@xerex.name",
  309. "phone": "+1 (897) 597-2194",
  310. "address": "817 Fleet Place, Itmann, Missouri, 8544",
  311. "registered": "Tuesday, October 14, 2014 1:25 PM"
  312. },
  313. {
  314. "_id": "55be9f652e9cb46d32e353bb",
  315. "index": 17,
  316. "guid": "67b4dd41-3c15-4401-ba05-6e0f437add66",
  317. "isActive": false,
  318. "balance": "$160.49",
  319. "picture": "http://lorempixel.com/64/64/people/7/",
  320. "age": 22,
  321. "name": {
  322. "first": "Austin",
  323. "last": "Lloyd"
  324. },
  325. "language": "EN",
  326. "email": "austin.lloyd@earthwax.io",
  327. "phone": "+1 (854) 486-2262",
  328. "address": "254 Aurelia Court, Gordon, Illinois, 7457",
  329. "registered": "Monday, March 17, 2014 5:32 AM"
  330. },
  331. {
  332. "_id": "55be9f654bba09df5bad6a83",
  333. "index": 18,
  334. "guid": "6c5c261a-541a-42a2-805c-2b2f7c650c7e",
  335. "isActive": false,
  336. "balance": "$424.84",
  337. "picture": "http://lorempixel.com/64/64/people/8/",
  338. "age": 21,
  339. "name": {
  340. "first": "Church",
  341. "last": "Stewart"
  342. },
  343. "language": "ES",
  344. "email": "church.stewart@sureplex.biz",
  345. "phone": "+1 (865) 587-2528",
  346. "address": "754 Norman Avenue, Gilgo, Washington, 7022",
  347. "registered": "Friday, July 3, 2015 5:10 PM"
  348. },
  349. {
  350. "_id": "55be9f65f6c9e901e272df2f",
  351. "index": 19,
  352. "guid": "3b3cf174-e8fc-49a4-96c1-d2cca56b57e6",
  353. "isActive": false,
  354. "balance": "$980.33",
  355. "picture": "http://lorempixel.com/64/64/people/9/",
  356. "age": 28,
  357. "name": {
  358. "first": "Mejia",
  359. "last": "Hays"
  360. },
  361. "language": "FR",
  362. "email": "mejia.hays@waretel.me",
  363. "phone": "+1 (990) 439-2885",
  364. "address": "348 President Street, Alafaya, Marshall Islands, 5442",
  365. "registered": "Monday, June 22, 2015 4:26 AM"
  366. }
  367. ];
  368. var Rows = [];
  369. for (var i = data.length - 1; i >= 0; i--) {
  370. Rows[i]= [
  371. data[i].picture,
  372. data[i].name.first,
  373. data[i].name.last,
  374. data[i].language,
  375. data[i]._id,
  376. data[i].email,
  377. data[i].balance,
  378. data[i].isActive
  379. ];
  380. };
  381.  
  382. class SuperAdminTeachers extends React.Component {
  383.  
  384.  
  385.  
  386. constructor() {
  387. super();
  388. //console.log(this.props);
  389. this.state = {tableWidth : window.innerWidth};
  390. }
  391.  
  392. loadteachersFromServer() {
  393. // console.log(this);
  394. $.ajax({
  395. url: "http://localhost:1337/teachers",
  396. dataType: 'json',
  397. success: (data) => {
  398.  
  399. var Rows = [];
  400. for (var i = data.length - 1; i >= 0; i--) {
  401. Rows[i]= [
  402. data[i].picture,
  403. data[i].name.first,
  404. data[i].name.last,
  405. data[i]._id,
  406. data[i].email,
  407. data[i].balance,
  408. data[i].registered,
  409. data[i].isActive,
  410.  
  411.  
  412. ];
  413. };
  414. this.setState({Rowss: Rows}, function(){
  415. // console.log(this.state.Rowss);
  416. }.bind(this));
  417.  
  418. // this.setState({Rowss: [Rows]});
  419. },
  420. error: (xhr, status, err) => {
  421. console.error('http://localhost:1337/teachers', status, err.toString());
  422. }
  423. });
  424. }
  425.  
  426. componentDidMount() {
  427. this._update();
  428. var win = window;
  429. if (win.addEventListener) {
  430. win.addEventListener('resize', this._onResize, false);
  431. } else if (win.attachEvent) {
  432. win.attachEvent('onresize', this._onResize);
  433. } else {
  434. win.onresize = this._onResize;
  435. }
  436. }
  437.  
  438. _onResize() {
  439. clearTimeout(this._updateTimer);
  440. this._updateTimer = setTimeout(this._update, 16);
  441. }
  442.  
  443. _update() {
  444. var win = window;
  445.  
  446. var widthOffset = win.innerWidth < 680 ? 0 : 240;
  447. console.log(widthOffset);
  448.  
  449. this.setState({
  450. renderPage: true,
  451. tableWidth: win.innerWidth - widthOffset,
  452. tableHeight: win.innerHeight - 200,
  453. });
  454. }
  455.  
  456.  
  457. imagefunc(imgurl){
  458. var style = { backgroundImage : 'url(' + imgurl + ')', backgroundRepeat : 'no-repeat',height: '60px'};
  459.  
  460. return <div className="exampleImage" style={style} />;
  461. };
  462.  
  463.  
  464. RenUserid(uid){
  465. var link = "http://verbling.com/"+uid;
  466. return <a href={link} target="_blank">{uid}</a>;
  467.  
  468. }
  469.  
  470.  
  471. statusfunc(status){
  472. var activity;
  473. var style;
  474.  
  475. if (status) {
  476. var style = { color: 'green'};
  477. activity = <div style={style}> Active</div>;
  478. } else {
  479. var style = { color: 'red'};
  480. activity = <div style={style}> Inactive</div>;
  481. }
  482.  
  483. return activity;
  484. }
  485.  
  486.  
  487.  
  488. _rowGetter(rowIndex) {
  489. return Rows[rowIndex];
  490. }
  491.  
  492. _rowscount() {
  493. return Rows.length;
  494. }
  495.  
  496.  
  497. render() {
  498.  
  499. return(
  500. <div className='container'>
  501. <div className='row' >
  502. <div className='col-xs-12' ref='whatever'>
  503. <Table
  504. rowHeight={50}
  505. rowGetter={this._rowGetter}
  506. rowsCount={Rows.length}
  507. width={this.state.tableWidth}
  508. maxHeight={500}
  509. headerHeight={50}>
  510. <Column
  511. label=""
  512. cellRenderer= {this.imagefunc}
  513. width={64}
  514. height={64}
  515. dataKey={0}
  516. />
  517. <Column
  518. label="First name"
  519. width={130}
  520. dataKey={1}
  521. />
  522. <Column
  523. label="Last name"
  524. width={130}
  525. dataKey={2}
  526. />
  527. <Column
  528. label="Language"
  529. width={130}
  530. dataKey={3}
  531. />
  532. <Column
  533. label="UserID"
  534. cellRenderer= {this.RenUserid}
  535. width={200}
  536. dataKey={4}
  537. />
  538. <Column
  539. label="Email"
  540. width={300}
  541. dataKey={5}
  542. />
  543. <Column
  544. label="$ Earnings"
  545. width={100}
  546. dataKey={6}
  547. />
  548. <Column
  549. label="Accepted"
  550. width={100}
  551. cellRenderer={function(cellData) {return new Intl.DateTimeFormat().format(cellData); }}
  552. dataKey={8}
  553. />
  554. <Column
  555. label="Profile"
  556. cellRenderer={this.statusfunc}
  557. width={100}
  558. dataKey={7}
  559. />
  560. </Table>
  561.  
  562.  
  563. </div>
  564. </div>
  565. </div>
  566. )
  567. }
  568.  
  569. }
  570.  
  571. export default SuperAdminTeachers;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement