global-notification.html 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. else {
  64. $('.admin-notification > .row > .col-md-9').prepend(
  65. '<div class=\"alert alert-danger\">Error occurred in deleting global notifcation setting.</div>'
  66. );
  67. }
  68. });
  69. });
  70. $(".isEnabledToggle").on("change", function(event) {
  71. var id = $(event.currentTarget).closest("tr").data("updatepost-id");
  72. $.post('/_api/admin/global-notification/toggleIsEnabled?id=' + id, function(res) {
  73. if (res.ok) {
  74. // do something
  75. }
  76. else {
  77. $('.admin-notification > .row > .col-md-9').prepend(
  78. '<div class=\"alert alert-danger\">Error occurred in deleting global notifcation setting.</div>'
  79. );
  80. }
  81. });
  82. });
  83. </script>