index.html 13 KB

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