Importer.jsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import React, { Fragment } from 'react';
  2. import axios from 'axios';
  3. import ReactDOM from 'react-dom';
  4. const GEOCODE_ENDPOINT = 'https://maps.googleapis.com/maps/api/geocode/json';
  5. class Importer extends React.Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. place: '通天閣', // ここに好きな場所を指定。
  10. };
  11. }
  12. handleGetLatAndLng() {
  13. // Google Maps APIが指定した必須パラメータ(この場合はaddress)をparamsに渡す。
  14. axios
  15. .POST("/_api/admin/settings/importerEsa", { params: { address: this.state.place } })
  16. .then((results) => {
  17. // 以下のGoogle API のレスポンスの例を元に欲しいデータを取得
  18. const data = results.data;
  19. const result = data.results[0];
  20. const location = result.geometry.location;
  21. this.setState({
  22. address: result.formatted_address,
  23. lat: location.lat,
  24. lng: location.lng,
  25. });
  26. })
  27. .catch(() => {
  28. console.log('通信に失敗しました。');
  29. });
  30. }
  31. render() {
  32. return (
  33. <div>
  34. <div className="app">
  35. <h1 className="app-title">緯度軽度検索</h1>
  36. <p> 土地名: {this.state.place} </p>
  37. <p> 経度: {this.state.lat}</p>
  38. <p> 経度: {this.state.lng}</p>
  39. <input
  40. type="button"
  41. value="経度・緯度を検索"
  42. onClick={() => { return this.handleGetLatAndLng() }}
  43. />
  44. </div>
  45. <div className="form-horizontal" method="post" className="form-horizontal" id="importerSettingFormEsa" role="form">
  46. <fieldset>
  47. <legend>
  48. {/* {{ t('importer_management.import_from', 'esa.io') }} */}を表示する
  49. </legend>
  50. <table className="table table-bordered table-mapping">
  51. <thead>
  52. <tr>
  53. <th width="45%">esa.io</th>
  54. <th width="10%"></th>
  55. <th>GROWI</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. <tr>
  60. <th>
  61. {/* {{ t('Article') }} */}
  62. を表示する
  63. </th>
  64. <th><i className="icon-arrow-right-circle text-success"></i></th>
  65. <th>
  66. {/* {{ t('Page') }} */}
  67. を表示する
  68. </th>
  69. </tr>
  70. <tr>
  71. <th>
  72. {/* {{ t('Category') }} */}
  73. を表示する
  74. </th>
  75. <th>
  76. <i className="icon-arrow-right-circle text-success"></i>
  77. </th>
  78. <th>
  79. {/* {{ t('Page Path') }} */}
  80. を表示する
  81. </th>
  82. </tr>
  83. <tr>
  84. <th>
  85. {/* {{ t('User') }} */}
  86. を表示する
  87. </th>
  88. <th></th>
  89. <th>(TBD)</th>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <div className="well well-sm mb-0 small">
  94. <ul>
  95. <li>
  96. {/* {{ t("importer_management.page_skip") }} */}
  97. を表示する
  98. </li>
  99. </ul>
  100. </div>
  101. <div className="form-group">
  102. <input type="password" name="dummypass" style="display:none; top: -100px; left: -100px;" />
  103. </div>
  104. <div class="form-group">
  105. <label for="settingForm[importer:esa:team_name]" class="col-xs-3 control-label">{{ t('importer_management.esa_settings.team_name') }}</label>
  106. <div class="col-xs-6">
  107. <input class="form-control" type="text" name="settingForm[importer:esa:team_name]" value="{{ settingForm['importer:esa:team_name'] | default('') }}">
  108. </div>
  109. </div>
  110. </fieldset>
  111. </div>
  112. </div>
  113. );
  114. }
  115. }
  116. export default Importer;
  117. { /* <div>
  118. <div className="app">
  119. <h1 className="app-title">緯度軽度検索</h1>
  120. <p> 土地名: {this.state.place} </p>
  121. <p> 経度: {this.state.lat}</p>
  122. <p> 経度: {this.state.lng}</p>
  123. <input
  124. type="button"
  125. value="経度・緯度を検索"
  126. onClick={() => { return this.handleGetLatAndLng() }}
  127. />
  128. </div> */ }