global-notification.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <a href="/admin/global-notification/detail">
  2. <p class="btn btn-default">通知設定の追加</p>
  3. </a>
  4. <h2>通知設定一覧</h2>
  5. {% set tags = {
  6. pageCreate: '<span class="label label-info" data-toggle="tooltip" data-placement="top" title="Page Create"><i class="icon-doc"></i> CREATE</span>',
  7. pageEdit: '<span class="label label-info" data-toggle="tooltip" data-placement="top" title="Page Edit"><i class="icon-doc"></i> EDIT</span>',
  8. pageDelete: '<span class="label label-info" data-toggle="tooltip" data-placement="top" title="Page Delte"><i class="icon-doc"></i> DELETE</span>',
  9. pageMove: '<span class="label label-info" data-toggle="tooltip" data-placement="top" title="Page Move"><i class="icon-doc"></i> MOVE</span>',
  10. pageLike: '<span class="label label-info" data-toggle="tooltip" data-placement="top" title="Page Like"><i class="icon-doc"></i> LIKE</span>',
  11. comment: '<span class="label label-info" data-toggle="tooltip" data-placement="top" title="New Comment"><i class="icon-fw icon-bubbles"></i> POST</span>'
  12. } %}
  13. <table class="table table-bordered">
  14. <thead>
  15. <th>ON/OFF</th>
  16. <th>Trigger Path (expression with <code>*</code> is supported)</th>
  17. <th>Trigger Events</th>
  18. <th>Notify To</th>
  19. <th>Action</th>
  20. </thead>
  21. <tbody class="admin-notif-list">
  22. {% set detailPageUrl = '/admin/global-notification/detail' %}
  23. {% for globalNotif in globalNotifications %}
  24. <tr class="clickable-row" data-href="{{ detailPageUrl }}" data-updatepost-id="{{ globalNotif._id.toString() }}">
  25. <td class="unclickable align-middle">
  26. <label class="switch">
  27. <input type="checkbox" class="isEnabledToggle" {% if globalNotif.isEnabled %}checked{% endif %}>
  28. <span class="slider round"></span>
  29. </label>
  30. </td>
  31. <td>
  32. {{ globalNotif.triggerPath }}
  33. </td>
  34. <td style="max-width: 200px;">
  35. {% for event in globalNotif.triggerEvents %}
  36. {{ tags[event] | safe }}
  37. {% endfor %}
  38. </td>
  39. <td>
  40. {% if globalNotif.__t == 'mail' %}<span data-toggle="tooltip" data-placement="top" title="Email"><i class="ti-email"></i> {{ globalNotif.toEmail }}</span>
  41. {% elseif globalNotif.__t == 'slack' %}<span data-toggle="tooltip" data-placement="top" title="Slack"><i class="fa fa-slack"></i> {{ globalNotif.slackChannels }}</span>
  42. {% endif %}
  43. </td>
  44. <td class="unclickable">
  45. <p class="btn btn-danger btn-delete">{{ t('Delete') }}</p>
  46. </td>
  47. </tr>
  48. {% endfor %}
  49. </tbody>
  50. </table>
  51. <script>
  52. $(".clickable-row > :not('.unclickable')").click(function(event) {
  53. var $target = $(event.currentTarget).parent();
  54. window.location = $target.data("href") + "/" + $target.data("updatepost-id");
  55. });
  56. $(".unclickable > .btn-delete").click(function(event) {
  57. var id = $(event.currentTarget).closest("tr").data("updatepost-id");
  58. var $target = $(event.currentTarget).parent();
  59. $.post('/admin/global-notification/remove?id=' + id, function(res) {
  60. if (res.ok) {
  61. $target.closest('tr').remove();
  62. }
  63. });
  64. });
  65. $(".isEnabledToggle").on("change", function(event) {
  66. var id = $(event.currentTarget).closest("tr").data("updatepost-id");
  67. $.post('/_api/admin/global-notification/toggleIsEnabled?id=' + id, function(res) {
  68. if (res.ok) {
  69. // do something
  70. }
  71. });
  72. });
  73. </script>