user-manager.html.twig 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. {% extends 'partials/base.html.twig' %}
  2. {% import 'user-manager-macros.html.twig' as macros %}
  3. {% set title = "PLUGIN_ADMIN_ADDON_USER_MANAGER.USER_MANAGER"|tu %}
  4. {% block titlebar %}
  5. {% if not user %}
  6. <div class="button-bar">
  7. <a class="button" href="#modal-admin-addon-user-manager-new" data-remodal-target="modal-admin-addon-user-manager-new"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.ADD"|tu }}</a>
  8. </div>
  9. <h1><i class="fa fa-fw fa-user-o"></i> {{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.USER_MANAGER"|tu }}</h1>
  10. {% else %}
  11. <div class="button-bar">
  12. <a class="button" href="{{ base_url }}/user-manager"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
  13. {% if exists %}
  14. <a class="button disable-after-click" href="{{ uri.addNonce(uri.route(true) ~ '/task' ~ ps ~ 'userDelete', 'admin-form', 'admin-nonce') }}" class="page-delete" ><i class="fa fa-close"></i> {{ "PLUGIN_ADMIN.DELETE"|tu }}</a>
  15. <a class="button disable-after-click" href="{{ uri.addNonce(uri.route(true) ~ '/task' ~ ps ~ 'userLoginAs', 'admin-form', 'admin-nonce') }}"><i class="fa fa-sign-in"></i> {{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.LOGIN_AS"|tu }}</a>
  16. {% endif %}
  17. <button class="button" type="submit" name="task" value="admin-addon-user-manager-save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
  18. </div>
  19. <h1><i class="fa fa-fw fa-user"></i> {{ "PLUGIN_ADMIN.USER"|tu }}: {{ user.username|e }}</h1>
  20. {% endif %}
  21. {% endblock %}
  22. {% set ps = config.system.param_sep %}
  23. {% set appendUrl = '?filter=' ~ filter|url_encode %}
  24. {% block content %}
  25. {% if not user %}
  26. {% set style = listStyle|default('grid') %}
  27. <h1>{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.USERS"|tu }}</h1>
  28. {% if filterException %}
  29. <div class="notices red"><h2>{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.FILTER_ERROR"|tu }}</h2><p>{{ filterException.message }}</p></div>
  30. {% endif %}
  31. <div class="admin-addon-user-manager-filter">
  32. <div class="admin-addon-user-manager-filter__input">
  33. <form method="get">
  34. <div class="block block-text">
  35. <div class="form-field vertical">
  36. <div class="form-data" data-grav-default="{{ filter }}">
  37. <div class="form-input-wrapper">
  38. <input name="filter" value="{{ filter }}" type="text" placeholder="{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.FILTER_USERS"|tu }}">
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </form>
  44. </div>
  45. <div class="admin-addon-user-manager-filter__help">
  46. <a href="https://github.com/david-szabo97/grav-plugin-admin-addon-user-manager/blob/master/docs/filter.md#users" class="button" target="_new"><i class="fa fa-question"></i> {{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.HELP"|tu }}</a>
  47. </div>
  48. </div>
  49. <div class="admin-addon-user-manager-style">
  50. {% if style != 'grid' %}<a href="{{ uri.route(true) ~ '/listStyle' ~ ps ~ 'grid' ~ '/page' ~ ps ~ pagination.current ~ appendUrl }}"><i class="fa fa-th"></i></a>{% else %}<i class="fa fa-th"></i>{% endif %}
  51. {% if style != 'list' %}<a href="{{ uri.route(true) ~ '/listStyle' ~ ps ~ 'list' ~ '/page' ~ ps ~ pagination.current ~ appendUrl }}"><i class="fa fa-list"></i></a>{% else %}<i class="fa fa-list"></i>{% endif %}
  52. </div>
  53. <form method="post">
  54. <div class="admin-addon-user-manager admin-addon-user-manager--{{ style }}">
  55. {% if users is empty %}
  56. <h2>{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.NO_RESULTS"|tu }}</h2>
  57. {% else %}
  58. {% if style == 'list' %}
  59. <div class="cell cell--header">
  60. <div class="user">
  61. <div class="user__checkbox"><input type="checkbox" id="selectAll" /></div>
  62. <div class="user__username">{{ "PLUGIN_ADMIN.USERNAME"|tu }}</div>
  63. <div class="user__email">{{ "PLUGIN_ADMIN.EMAIL"|tu }}</div>
  64. <div class="user__actions">{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.ACTIONS"|tu }}</div>
  65. </div>
  66. </div>
  67. {% endif %}
  68. {% for user in users %}
  69. <div class="cell">
  70. <div class="user">
  71. {% if style == 'grid' %}
  72. <div class="user__avatar"><a href="{{ base_url }}/user-manager/{{ user.username }}"><img src="{{ user.avatarUrl }}" /></a></div>
  73. {% else %}
  74. <div class="user__checkbox"><input type="checkbox" name="selected[]" value="{{ user.username }}" /></div>
  75. {% endif %}
  76. <div class="user__username"><a href="{{ base_url }}/user-manager/{{ user.username }}">{{ user.username }}</a></div>
  77. <div class="user__email">{{ user.email }}</div>
  78. <div class="user__actions">
  79. <a href="{{ base_url ~ '/user-expert/' ~ user.username }}" class="expert">{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.EXPERT"|tu }}</a>
  80. <a href="{{ uri.addNonce(base_url ~ '/user-manager/' ~ user.username ~ '/task' ~ ps ~ 'userDelete', 'admin-form', 'admin-nonce') }}" class="delete" onclick="return confirm('{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.USER_CONFIRM_DELETE"|tu }}');">{{ "PLUGIN_ADMIN.DELETE"|tu }}</a>
  81. </div>
  82. </div>
  83. </div>
  84. {% endfor %}
  85. {% endif %}
  86. </div>
  87. <div class="admin-addon-user-manager-bulk-action">
  88. <a data-remodal-target="modal-admin-addon-user-manager-bulk" class="button">{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.BULK_ACTION"|tu }}</a>
  89. </div>
  90. </form>
  91. {{ macros.pagination(pagination, uri.route(true) ~ '/listStyle' ~ ps ~ listStyle, ps, appendUrl) }}
  92. <div class="remodal" data-remodal-id="modal-admin-addon-user-manager-new" data-remodal-options="hashTracking: false">
  93. <form method="post" onsubmit='handleAdminAddonUserManagerSubmit(this); return false;'>
  94. {% for field in fields %}
  95. {% if field.type %}
  96. {% if field.name == 'username' %}
  97. {% set field = field|merge({ validate: field.validate|merge({ pattern: grav.config.system.username_regex })}) %}
  98. {% endif %}
  99. <div class="block block-{{field.type}}">
  100. {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
  101. </div>
  102. {% endif %}
  103. {% endfor %}
  104. <div class="button-bar">
  105. <button class="button primary" >{{ "PLUGIN_ADMIN.CONTINUE"|tu }}</button>
  106. </div>
  107. </form>
  108. </div>
  109. <div class="remodal" data-remodal-id="modal-admin-addon-user-manager-bulk" data-remodal-options="hashTracking: false">
  110. <form method="post" onsubmit='handleAdminAddonUserManagerBulkSubmit(this);'>
  111. {% for field in bulkFields %}
  112. {% if field.type %}
  113. {% if field.name == 'groups' %}
  114. {% set field = field|merge({options: groupnames}) %}
  115. {% endif %}
  116. {% if field.name == 'permissions' %}
  117. {% set field = field|merge({selectize: { options: permissions }}) %}
  118. {% endif %}
  119. <div class="block block-{{field.type}}">
  120. {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
  121. </div>
  122. {% endif %}
  123. {% endfor %}
  124. <div class="button-bar">
  125. <button class="button primary" >{{ "PLUGIN_ADMIN.CONTINUE"|tu }}</button>
  126. </div>
  127. </form>
  128. </div>
  129. <script>
  130. function handleAdminAddonUserManagerSubmit(form) {
  131. var username = form.querySelector('[name=username]').value;
  132. window.location = '{{ base_url }}/user-manager/' + username;
  133. }
  134. var selectAllEle = document.getElementById('selectAll');
  135. var selectEles = document.querySelectorAll('input[name="selected[]"]');
  136. selectAllEle.addEventListener('change', function(e) {
  137. for (var i = 0; i < selectEles.length; i++) {
  138. selectEles[i].checked = this.checked;
  139. }
  140. });
  141. function handleAdminAddonUserManagerBulkSubmit(form) {
  142. for (var i = 0; i < selectEles.length; i++) {
  143. form.appendChild(selectEles[i]);
  144. }
  145. }
  146. </script>
  147. {% else %}
  148. <h1>{{ user.username }}</h1>
  149. {% include 'partials/blueprints.html.twig' with { data: user, blueprints: blueprints } %}
  150. <div class="remodal" data-remodal-id="changes">
  151. <form>
  152. <h1>{{ "PLUGIN_ADMIN.MODAL_CHANGED_DETECTED_TITLE"|tu }}</h1>
  153. <p class="bigger">
  154. {{ "PLUGIN_ADMIN.MODAL_CHANGED_DETECTED_DESC"|tu }}
  155. </p>
  156. <br>
  157. <div class="button-bar">
  158. <a class="button secondary" data-leave-action="cancel" href="#"><i class="fa fa-fw fa-close"></i> {{ "PLUGIN_ADMIN.CANCEL"|tu }}</a>
  159. <a class="button" data-leave-action="continue" href="#"><i class="fa fa-fw fa-check"></i> {{ "PLUGIN_ADMIN.CONTINUE"|tu }}</a>
  160. </div>
  161. </form>
  162. </div>
  163. <script>
  164. $('[name="task"][value$="save"]').on('click._grav', function(event) {
  165. $(global).off('beforeunload');
  166. });
  167. </script>
  168. <!-- Temporary fix: https://github.com/getgrav/grav-plugin-admin/pull/1379 -->
  169. <style>
  170. .permission-container {
  171. overflow: hidden;
  172. }
  173. </style>
  174. {% endif %}
  175. {% endblock %}