index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. <label for="" class="col-sm-4 control-label">
  151. {{ t('Upload new image') }}
  152. </label>
  153. <div class="col-sm-8">
  154. {% if fileUploadService.getIsUploadable() %}
  155. <form action="/_api/attachments.uploadProfileImage" id="pictureUploadForm" method="post" class="form-horizontal" role="form">
  156. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  157. <input type="file" name="profileImage" accept="image/*">
  158. <div id="pictureUploadFormProgress" class="d-flex align-items-center">
  159. </div>
  160. </form>
  161. {% else %}
  162. * {{ t('page_me.form_help.profile_image1') }}<br>
  163. * {{ t('page_me.form_help.profile_image2') }}<br>
  164. {% endif %}
  165. </div>
  166. </div><!-- /.form-group -->
  167. </div><!-- /.col-sm- -->
  168. <div class="form-group">
  169. <div class="col-sm-offset-4 col-sm-6">
  170. <button type="submit" form="formImageType" class="btn btn-primary">{{ t('Update') }}</button>
  171. </div>
  172. </div>
  173. </fieldset>
  174. </div><!-- /.form-box -->
  175. <script>
  176. $("#pictureUploadForm input[name=profileImage]").on('change', function(){
  177. if ($(this).val() == '') {
  178. return false;
  179. }
  180. var $form = $('#pictureUploadForm');
  181. var formData = new FormData();
  182. formData.append('file', this.files[0]);
  183. formData.append('_csrf', document.getElementsByName("_csrf")[0].value);
  184. $('#pictureUploadFormProgress').html('<div class="speeding-wheel-sm m-r-5"></div> アップロード中...');
  185. $.ajax($form.attr("action"), {
  186. type: 'post',
  187. processData: false,
  188. contentType: false,
  189. data: formData
  190. })
  191. .then(function(data) {
  192. if (data.ok) {
  193. var attachment = data.attachment;
  194. $('#settingUserPicture').attr('src', attachment.filePathProxied + '?time=' + (new Date()));
  195. $('form#remove-attachment').show();
  196. $('form#remove-attachment input[name=attachment_id]').val(attachment.id);
  197. $('#pictureUploadFormMessage')
  198. .addClass('alert alert-success')
  199. .html('変更しました');
  200. }
  201. else {
  202. throw new Error('statis is invalid');
  203. }
  204. })
  205. .catch(function(err) {
  206. $('#pictureUploadFormMessage')
  207. .addClass('alert alert-danger')
  208. .html('変更中にエラーが発生しました。');
  209. })
  210. // finally
  211. .then(function() {
  212. $('#pictureUploadFormProgress').html('');
  213. });
  214. return false;
  215. });
  216. $('form#remove-attachment').on('submit', function(event) {
  217. // process with jQuery
  218. event.preventDefault();
  219. $.post($(this).attr('action'), $(this).serializeArray())
  220. .then(function(data) {
  221. if (data.ok) {
  222. $('#settingUserPicture').attr('src', '/images/icons/user.svg');
  223. $('form#remove-attachment').hide();
  224. }
  225. else {
  226. throw new Error('statis is invalid');
  227. }
  228. })
  229. .catch(function(err) {
  230. $('#pictureUploadFormMessage')
  231. .addClass('alert alert-danger')
  232. .html('変更中にエラーが発生しました。');
  233. })
  234. });
  235. </script>
  236. </div> {# end of .tab-contents #}
  237. {#
  238. <div class="form-box">
  239. <form action="/me/username" method="post" class="form-horizontal" role="form">
  240. <fieldset>
  241. <legend>ユーザーID (ユーザー名) の変更</legend>
  242. <div class="form-group">
  243. <label for="userNameForm[username]" class="col-sm-2 control-label">ユーザーID</label>
  244. <div class="col-sm-4">
  245. <input class="form-control" type="text" name="userNameForm[username]" value="{{ user.username }}" required>
  246. <p class="help-block">すべてのマイページの</p>
  247. </div>
  248. </div>
  249. <div class="form-group">
  250. <div class="col-sm-offset-2 col-sm-10">
  251. <p class="alert alert-warning">
  252. ユーザーIDを変更すると、<code>/user/{{ user.username }}</code> 以下のページがすべて <code>/user/新しいユーザーID</code> の下に移動されます。<br>
  253. また、これまでのページにリダイレクトは設定されず、この操作の取り消しもできません。<br>
  254. 実行には十分に注意をしてください。
  255. </p>
  256. <button type="submit" class="btn btn-warning">ユーザーIDの変更を実行する</button>
  257. </div>
  258. </div>
  259. </fieldset>
  260. </form>
  261. </div>
  262. #}
  263. </div>
  264. </div>
  265. {% endblock content_main %}
  266. {% block content_footer %}
  267. {% endblock content_footer %}
  268. {% block layout_footer %}
  269. {% endblock layout_footer %}