global-notification.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <a href="/admin/global-notification/new">
  2. <p class="btn btn-default">{{ t('notification_setting.add_notification') }}</p>
  3. </a>
  4. <h2>{{ t('notification_setting.notification_list') }}</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>{{ t('notification_setting.trigger_path') }} {{ t('notification_setting.trigger_path_help', '<code>*</code>') }}</th>
  17. <th>{{ t('notification_setting.trigger_events') }}</th>
  18. <th>{{ t('notification_setting.notify_to') }}</th>
  19. <th></th>
  20. </thead>
  21. <tbody class="admin-notif-list">
  22. {% for globalNotif in globalNotifications %}
  23. {% set detailPageUrl = '/admin/global-notification/' + globalNotif.id %}
  24. <tr>
  25. <td class="align-middle td-abs-center">
  26. <input type="checkbox" class="js-switch" data-size="small" data-id="{{ globalNotif._id.toString() }}" {% if globalNotif.isEnabled %}checked{% endif %} />
  27. </td>
  28. <td>
  29. {{ globalNotif.triggerPath }}
  30. </td>
  31. <td style="max-width: 200px;">
  32. {% for event in globalNotif.triggerEvents %}
  33. {{ tags[event] | safe }}
  34. {% endfor %}
  35. </td>
  36. <td>
  37. {% if globalNotif.__t == 'mail' %}<span data-toggle="tooltip" data-placement="top" title="Email"><i class="ti-email"></i> {{ globalNotif.toEmail }}</span>
  38. {% elseif globalNotif.__t == 'slack' %}<span data-toggle="tooltip" data-placement="top" title="Slack"><i class="fa fa-slack"></i> {{ globalNotif.slackChannels }}</span>
  39. {% endif %}
  40. </td>
  41. <td class="td-abs-center">
  42. <div class="btn-group admin-group-menu">
  43. <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
  44. <i class="icon-settings"></i> <span class="caret"></span>
  45. </button>
  46. <ul class="dropdown-menu" role="menu">
  47. <li>
  48. <a href="{{ detailPageUrl }}">
  49. <i class="icon-fw icon-note"></i> {{ t('Edit') }}
  50. </a>
  51. </li>
  52. <li class="btn-delete">
  53. <a href="#"
  54. data-setting-id="{{ globalNotif.id }}"
  55. data-target="#admin-delete-global-notification"
  56. data-toggle="modal">
  57. <i class="icon-fw icon-fire text-danger"></i> {{ t('Delete') }}
  58. </a>
  59. </li>
  60. </ul>
  61. </div>
  62. </td>
  63. </tr>
  64. {% endfor %}
  65. </tbody>
  66. </table>
  67. <div class="modal fade" id="admin-delete-global-notification">
  68. <div class="modal-dialog">
  69. <div class="modal-content">
  70. <div class="modal-header bg-danger">
  71. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  72. <div class="modal-title">
  73. <i class="icon icon-fire"></i> Delete Global Notification Setting
  74. </div>
  75. </div>
  76. <div class="modal-body">
  77. <span class="text-danger">
  78. 削除すると元に戻すことはできませんのでご注意ください。
  79. </span>
  80. </div>
  81. <div class="modal-footer">
  82. <form action="#" method="post" id="admin-global-notification-setting-delete" class="text-right">
  83. <input type="hidden" name="setting-id" value="">
  84. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  85. <button type="submit" value="" class="btn btn-sm btn-danger">
  86. <i class="icon icon-fire"></i> 削除
  87. </button>
  88. </form>
  89. </div>
  90. </div>
  91. <!-- /.modal-content -->
  92. </div>
  93. <!-- /.modal-dialog -->
  94. </div>
  95. <script>
  96. $(".btn-delete").on("click", function(event) {
  97. var id = $(event.currentTarget).find("a").data("setting-id");
  98. $("#admin-global-notification-setting-delete").attr("action", "/admin/global-notification/" + id + "/remove");
  99. });
  100. $(".js-switch").on("change", function(event) {
  101. var id = event.currentTarget.dataset.id;
  102. var isEnabled = event.currentTarget.checked;
  103. $.post('/_api/admin/global-notification/toggleIsEnabled?id=' + id + '&isEnabled=' + isEnabled, function(res) {
  104. if (res.ok) {
  105. // do nothing
  106. }
  107. else {
  108. $('.admin-notification > .row > .col-md-9').prepend(
  109. '<div class=\"alert alert-danger\">Error occurred in deleting global notifcation setting.</div>'
  110. );
  111. location.reload();
  112. }
  113. });
  114. });
  115. </script>