index.html 11 KB

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