index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. {% extends '../layout-growi/base/layout.html' %}
  2. {% block html_title %}{{ customizeService.generateCustomTitle(t('User Settings')) }}{% endblock %}
  3. {% block content_header %}
  4. <header id="page-header">
  5. <h1 id="mypage-title" class="title">{{ t('User Settings') }}</h1>
  6. </header>
  7. {% endblock %}
  8. {% block content_main %}
  9. <div class="content-main">
  10. <ul class="nav nav-tabs mb-4" role="tablist">
  11. <li class="nav-item">
  12. <a class="nav-link active" href="/me" role="tab" data-toggle="tab"><i class="icon-user"></i> {{ t('User Information') }}</a>
  13. </li>
  14. <li class="nav-item">
  15. <a class="nav-link" href="/me/external-accounts" role="tab" data-toggle="tab"><i class="icon-share-alt"></i> {{ t('External Accounts') }}</a>
  16. </li>
  17. <li class="nav-item">
  18. <a class="nav-link" href="/me/password" role="tab" data-toggle="tab"><i class="icon-lock"></i> {{ t('Password Settings') }}</a>
  19. </li>
  20. <li class="nav-item">
  21. <a class="nav-link" href="/me/apiToken" role="tab" data-toggle="tab"><i class="icon-paper-plane"></i> {{ t('API Settings') }}</a>
  22. </li>
  23. </ul>
  24. <div class="tab-content">
  25. {% set smessage = req.flash('successMessage') %}
  26. {% if smessage.length %}
  27. <div class="alert alert-success grw-mt-10px">
  28. {{ smessage }}
  29. </div>
  30. {% endif %}
  31. {% set wmessage = req.flash('warningMessage') %}
  32. {% if wmessage.length %}
  33. <div class="alert alert-danger grw-mt-10px">
  34. {{ wmessage }}
  35. </div>
  36. {% endif %}
  37. {% if req.form.errors.length > 0 %}
  38. <div class="alert alert-danger grw-mt-10px">
  39. <ul>
  40. {% for error in req.form.errors %}
  41. <li>{{ error }}</li>
  42. {% endfor %}
  43. </ul>
  44. </div>
  45. {% endif %}
  46. <div class="form-box mt-3">
  47. <form action="/me" method="post" role="form">
  48. <fieldset>
  49. <legend class="border-bottom mb-4">{{ t('Basic Info') }}</legend>
  50. <div class="form-group row">
  51. <label for="userForm[name]" class="col-sm-2 col-form-label">Name</label>
  52. <div class="col-sm-4">
  53. <input type="text" class="form-control" name="userForm[name]" value="{{ user.name }}" required>
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <div class="row">
  58. <label for="userForm[email]" class="col-sm-2 col-form-label">Email</label>
  59. <div class="col-sm-4">
  60. <input type="email" class="form-control" name="userForm[email]" value="{{ user.email }}" aria-describedby="userForm[email]" required>
  61. </div>
  62. </div>
  63. <div class="offset-sm-2 col-sm-10">
  64. {% if getConfig('crowi', 'security:registrationWhiteList') && getConfig('crowi', 'security:registrationWhiteList').length %}
  65. <p id="userForm[email]" class="form-text text-muted">
  66. {{ t('page_register.form_help.email') }}
  67. <ul>
  68. {% for em in getConfig('crowi', 'security:registrationWhiteList') %}
  69. <li><code>{{ em }}</code></li>
  70. {% endfor %}
  71. </ul>
  72. </p>
  73. {% endif %}
  74. </div>
  75. </div>
  76. <div class="form-group row">
  77. <label for="userForm[isEmailPublished]" class="col-sm-2 col-form-label">{{ t('Disclose E-mail') }}</label>
  78. <div class="col-sm-4">
  79. <div class="custom-control custom-radio custom-control-inline">
  80. <input
  81. type="radio"
  82. id="radioEmailShow"
  83. name="userForm[isEmailPublished]"
  84. value="{{ true }}"
  85. {% if user.isEmailPublished == true %}checked="checked"{% endif %}
  86. class="custom-control-input"
  87. >
  88. <label class="custom-control-label" for="radioEmailShow">{{ t('Show') }}</label>
  89. </div>
  90. <div class="custom-control custom-radio custom-control-inline">
  91. <input
  92. type="radio"
  93. id="radioEmailHide"
  94. name="userForm[isEmailPublished]"
  95. value="{{ false }}"
  96. {% if user.isEmailPublished == false %}checked="checked"{% endif %}
  97. class="custom-control-input"
  98. >
  99. <label class="custom-control-label" for="radioEmailHide">{{ t('Hide') }}</label>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="form-group row {% if not user.lang %}has-error{% endif %}">
  104. <label for="userForm[lang]" class="col-sm-2 col-form-label">Language</label>
  105. <div class="col-sm-4">
  106. <div class="custom-control custom-radio custom-control-inline">
  107. <input
  108. type="radio"
  109. id="radioLangEn"
  110. name="userForm[lang]"
  111. value="{{ consts.language.LANG_EN_US }}"
  112. class="custom-control-input"
  113. {% if user.lang == consts.language.LANG_EN_US %}checked="checked"{% endif %}
  114. >
  115. <label class="custom-control-label" for="radioLangEn">{{ t('English') }}</label>
  116. </div>
  117. <div class="custom-control custom-radio custom-control-inline">
  118. <input
  119. type="radio"
  120. id="radioLangJa"
  121. name="userForm[lang]"
  122. value="{{ consts.language.LANG_JA }}"
  123. class="custom-control-input"
  124. {% if user.lang == consts.language.LANG_JA %}checked="checked"{% endif %}
  125. >
  126. <label class="custom-control-label" for="radioLangJa">{{ t('Japanese') }}</label>
  127. </div>
  128. </div>
  129. </div>
  130. <div class="form-group row">
  131. <div class="offset-sm-2 col-sm-10">
  132. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  133. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  134. </div>
  135. </div>
  136. </fieldset>
  137. </form>
  138. </div>
  139. <div class="form-box mt-3">
  140. <!-- separeted form tag -->
  141. <form action="/me/imagetype" id="formImageType" method="post" class="form" role="form"></form>
  142. <fieldset>
  143. <legend class="border-bottom mb-5">{{ t('Set Profile Image') }}</legend>
  144. <div class="form-group row">
  145. <div class="col-sm-4 offset-sm-1">
  146. <h4>
  147. <div class="custom-control custom-radio custom-control-inline">
  148. <input
  149. type="radio"
  150. id="radioGravatar"
  151. form="formImageType"
  152. name="imagetypeForm[isGravatarEnabled]"
  153. value="true"
  154. {% if user.isGravatarEnabled %}checked="checked"{% endif %}
  155. class="custom-control-input"
  156. >
  157. <label class="custom-control-label custom-control-inline" for="radioGravatar">
  158. <img src="https://gravatar.com/avatar/00000000000000000000000000000000?s=24" />
  159. <span class="pl-1">Gravatar</span>
  160. </label>
  161. <a href="https://gravatar.com/">
  162. <small>
  163. <i class="icon-arrow-right-circle" aria-hidden="true"></i>
  164. </small>
  165. </a>
  166. </div>
  167. </h4>
  168. <img src="{{ user|gravatar }}" width="64">
  169. </div>
  170. <div class="col-sm-7">
  171. <h4>
  172. <div class="custom-control custom-radio custom-control-inline">
  173. <input
  174. type="radio"
  175. id="radioUploadPicture"
  176. form="formImageType"
  177. name="imagetypeForm[isGravatarEnabled]"
  178. value="false"
  179. {% if !user.isGravatarEnabled %}checked="checked"{% endif %}
  180. class="custom-control-input"
  181. >
  182. <label for="radioUploadPicture" class="custom-control-label">{{ t('Upload Image') }}</label>
  183. </div>
  184. </h4>
  185. <div class="form-group">
  186. <div id="pictureUploadFormMessage" class=""></div>
  187. <div class="row">
  188. <label for="" class="col-sm-4">{{ t('Current Image') }}</label>
  189. <div class="col-sm-8">
  190. <p><img src="{{ user|uploadedpicture }}" class="picture picture-lg rounded-circle" id="settingUserPicture"></p>
  191. <form
  192. id="remove-attachment"
  193. action="/_api/attachments.removeProfileImage"
  194. method="post"
  195. class="form-horizontal"
  196. style="{% if not user.imageAttachment %}display: none{% endif %}"
  197. >
  198. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  199. <button type="submit" class="btn btn-danger">{{ t('Delete Image') }}</button>
  200. </form>
  201. </div>
  202. </div>
  203. </div>
  204. <div class="row">
  205. <label for="" class="col-sm-4">{{ t('Upload new image') }}</label>
  206. <div class="col-sm-8">
  207. {% if fileUploadService.getIsUploadable() %}
  208. <form action="/_api/attachments.uploadProfileImage" id="pictureUploadForm" method="post" class="form-group" role="form">
  209. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  210. <input type="file" name="profileImage" accept="image/*">
  211. <div id="pictureUploadFormProgress" class="d-flex align-items-center"></div>
  212. </form>
  213. {% else %}
  214. * {{ t('page_me.form_help.profile_image1') }}<br>
  215. * {{ t('page_me.form_help.profile_image2') }}<br>
  216. {% endif %}
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. <div class="form-group">
  222. <div class="offset-sm-4 col-sm-6">
  223. <button type="submit" form="formImageType" class="btn btn-primary">{{ t('Update') }}</button>
  224. </div>
  225. </div>
  226. </fieldset>
  227. </div><!-- /.form-box -->
  228. <script>
  229. $("#pictureUploadForm input[name=profileImage]").on('change', function(){
  230. if ($(this).val() == '') {
  231. return false;
  232. }
  233. var $form = $('#pictureUploadForm');
  234. var formData = new FormData();
  235. formData.append('file', this.files[0]);
  236. formData.append('_csrf', document.getElementsByName("_csrf")[0].value);
  237. $('#pictureUploadFormProgress').html('<div class="speeding-wheel-sm mr-2"></div> アップロード中...');
  238. $.ajax($form.attr("action"), {
  239. type: 'post',
  240. processData: false,
  241. contentType: false,
  242. data: formData
  243. })
  244. .then(function(data) {
  245. if (data.ok) {
  246. var attachment = data.attachment;
  247. $('#settingUserPicture').attr('src', attachment.filePathProxied + '?time=' + (new Date()));
  248. $('form#remove-attachment').show();
  249. $('form#remove-attachment input[name=attachment_id]').val(attachment.id);
  250. $('#pictureUploadFormMessage')
  251. .addClass('alert alert-success')
  252. .html('変更しました');
  253. }
  254. else {
  255. throw new Error('statis is invalid');
  256. }
  257. })
  258. .catch(function(err) {
  259. $('#pictureUploadFormMessage')
  260. .addClass('alert alert-danger')
  261. .html('変更中にエラーが発生しました。');
  262. })
  263. // finally
  264. .then(function() {
  265. $('#pictureUploadFormProgress').html('');
  266. });
  267. return false;
  268. });
  269. $('form#remove-attachment').on('submit', function(event) {
  270. // process with jQuery
  271. event.preventDefault();
  272. $.post($(this).attr('action'), $(this).serializeArray())
  273. .then(function(data) {
  274. if (data.ok) {
  275. $('#settingUserPicture').attr('src', '/images/icons/user.svg');
  276. $('form#remove-attachment').hide();
  277. }
  278. else {
  279. throw new Error('statis is invalid');
  280. }
  281. })
  282. .catch(function(err) {
  283. $('#pictureUploadFormMessage')
  284. .addClass('alert alert-danger')
  285. .html('変更中にエラーが発生しました。');
  286. })
  287. });
  288. </script>
  289. </div> {# end of .tab-contents #}
  290. {#
  291. <div class="form-box">
  292. <form action="/me/username" method="post" class="form-horizontal" role="form">
  293. <fieldset>
  294. <legend>ユーザーID (ユーザー名) の変更</legend>
  295. <div class="form-group">
  296. <label for="userNameForm[username]" class="col-sm-2 control-label">ユーザーID</label>
  297. <div class="col-sm-4">
  298. <input class="form-control" type="text" name="userNameForm[username]" value="{{ user.username }}" required>
  299. <p class="help-block">すべてのマイページの</p>
  300. </div>
  301. </div>
  302. <div class="form-group">
  303. <div class="col-sm-offset-2 col-sm-10">
  304. <p class="alert alert-warning">
  305. ユーザーIDを変更すると、<code>/user/{{ user.username }}</code> 以下のページがすべて <code>/user/新しいユーザーID</code> の下に移動されます。<br>
  306. また、これまでのページにリダイレクトは設定されず、この操作の取り消しもできません。<br>
  307. 実行には十分に注意をしてください。
  308. </p>
  309. <button type="submit" class="btn btn-warning">ユーザーIDの変更を実行する</button>
  310. </div>
  311. </div>
  312. </fieldset>
  313. </form>
  314. </div>
  315. #}
  316. </div>
  317. </div>
  318. {% endblock content_main %}
  319. {% block content_footer %}
  320. {% endblock content_footer %}
  321. {% block layout_footer %}
  322. {% endblock layout_footer %}