index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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" id="personal-setting">
  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. </h4>
  205. <img src="{{ user|gravatar }}" width="64">
  206. </div><!-- /.col-sm* -->
  207. <div class="form-group col-md-4 col-sm-7">
  208. <h4>
  209. <div class="radio radio-primary">
  210. <input type="radio" id="radioUploadPicture" form="formImageType" name="imagetypeForm[isGravatarEnabled]" value="false" {% if !user.isGravatarEnabled %}checked="checked"{% endif %}>
  211. <label for="radioUploadPicture">
  212. {{ t('Upload Image') }}
  213. </label>
  214. </div>
  215. </h4>
  216. <div class="form-group">
  217. <div id="pictureUploadFormMessage"></div>
  218. <label for="" class="col-sm-4 control-label">
  219. {{ t('Current Image') }}
  220. </label>
  221. <div class="col-sm-8">
  222. <p>
  223. <img src="{{ user|uploadedpicture }}" class="picture picture-lg img-circle" id="settingUserPicture"><br>
  224. </p>
  225. <p>
  226. <form id="remove-attachment" action="/_api/attachments.removeProfileImage" method="post" class="form-horizontal"
  227. style="{% if not user.imageAttachment %}display: none{% endif %}">
  228. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  229. <button type="submit" class="btn btn-danger">{{ t('Delete Image') }}</button>
  230. </form>
  231. </p>
  232. </div>
  233. </div><!-- /.form-group -->
  234. <div class="form-group">
  235. <div id="profile-image-uploader"></div>
  236. </div>
  237. </div>
  238. <div class="form-group">
  239. <div class="offset-sm-4 col-sm-6">
  240. <button type="submit" form="formImageType" class="btn btn-primary">{{ t('Update') }}</button>
  241. </div>
  242. </div>
  243. </fieldset>
  244. </div><!-- /.form-box -->
  245. <script>
  246. $("#pictureUploadForm input[name=profileImage]").on('change', function(){
  247. if ($(this).val() == '') {
  248. return false;
  249. }
  250. var $form = $('#pictureUploadForm');
  251. var formData = new FormData();
  252. formData.append('file', this.files[0]);
  253. formData.append('_csrf', document.getElementsByName("_csrf")[0].value);
  254. $('#pictureUploadFormProgress').html('<div class="speeding-wheel-sm mr-2"></div> アップロード中...');
  255. $.ajax($form.attr("action"), {
  256. type: 'post',
  257. processData: false,
  258. contentType: false,
  259. data: formData
  260. })
  261. .then(function(data) {
  262. if (data.ok) {
  263. var attachment = data.attachment;
  264. $('#settingUserPicture').attr('src', attachment.filePathProxied + '?time=' + (new Date()));
  265. $('form#remove-attachment').show();
  266. $('form#remove-attachment input[name=attachment_id]').val(attachment.id);
  267. $('#pictureUploadFormMessage')
  268. .addClass('alert alert-success')
  269. .html('変更しました');
  270. }
  271. else {
  272. throw new Error('statis is invalid');
  273. }
  274. })
  275. .catch(function(err) {
  276. $('#pictureUploadFormMessage')
  277. .addClass('alert alert-danger')
  278. .html('変更中にエラーが発生しました。');
  279. })
  280. // finally
  281. .then(function() {
  282. $('#pictureUploadFormProgress').html('');
  283. });
  284. return false;
  285. });
  286. $('form#remove-attachment').on('submit', function(event) {
  287. // process with jQuery
  288. event.preventDefault();
  289. $.post($(this).attr('action'), $(this).serializeArray())
  290. .then(function(data) {
  291. if (data.ok) {
  292. $('#settingUserPicture').attr('src', '/images/icons/user.svg');
  293. $('form#remove-attachment').hide();
  294. }
  295. else {
  296. throw new Error('statis is invalid');
  297. }
  298. })
  299. .catch(function(err) {
  300. $('#pictureUploadFormMessage')
  301. .addClass('alert alert-danger')
  302. .html('変更中にエラーが発生しました。');
  303. })
  304. });
  305. </script>
  306. </div> {# end of .tab-contents #}
  307. {#
  308. <div class="form-box">
  309. <form action="/me/username" method="post" class="form-horizontal" role="form">
  310. <fieldset>
  311. <legend>ユーザーID (ユーザー名) の変更</legend>
  312. <div class="form-group">
  313. <label for="userNameForm[username]" class="col-sm-2 control-label">ユーザーID</label>
  314. <div class="col-sm-4">
  315. <input class="form-control" type="text" name="userNameForm[username]" value="{{ user.username }}" required>
  316. <p class="help-block">すべてのマイページの</p>
  317. </div>
  318. </div>
  319. <div class="form-group">
  320. <div class="col-sm-offset-2 col-sm-10">
  321. <p class="alert alert-warning">
  322. ユーザーIDを変更すると、<code>/user/{{ user.username }}</code> 以下のページがすべて <code>/user/新しいユーザーID</code> の下に移動されます。<br>
  323. また、これまでのページにリダイレクトは設定されず、この操作の取り消しもできません。<br>
  324. 実行には十分に注意をしてください。
  325. </p>
  326. <button type="submit" class="btn btn-warning">ユーザーIDの変更を実行する</button>
  327. </div>
  328. </div>
  329. </fieldset>
  330. </form>
  331. </div>
  332. #}
  333. </div>
  334. </div>
  335. {% endblock content_main %}
  336. {% block content_footer %}
  337. {% endblock content_footer %}
  338. {% block layout_footer %}
  339. {% endblock layout_footer %}