global-notification.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 $targetRow = $(event.currentTarget).closest("tr");
  58. var id = $targetRow.data("updatepost-id");
  59. $.post('/admin/global-notification/remove?id=' + id, function(res) {
  60. if (res.ok) {
  61. $targetRow.closest('tr').remove();
  62. $('.admin-notification > .row > .col-md-9').prepend(
  63. '<div class=\"alert alert-success\">Successfully Deleted</div>'
  64. );
  65. $message = $('.admin-notification > .row > .col-md-9 > .alert.alert-success');
  66. setTimeout(function()
  67. {
  68. $message.fadeOut({
  69. complete: function() {
  70. $message.remove();
  71. }
  72. });
  73. }, 2000);
  74. }
  75. else {
  76. $('.admin-notification > .row > .col-md-9').prepend(
  77. '<div class=\"alert alert-danger\">Error occurred in deleting global notifcation setting.</div>'
  78. );
  79. location.reload();
  80. }
  81. });
  82. });
  83. $(".isEnabledToggle").on("change", function(event) {
  84. var $targetRow = $(event.currentTarget).closest("tr");
  85. var id = $targetRow.data("updatepost-id");
  86. var isEnabled = !$targetRow.find(".isEnabledToggle").is(':checked');
  87. $.post('/_api/admin/global-notification/toggleIsEnabled?id=' + id + '&isEnabled=' + isEnabled, function(res) {
  88. if (res.ok) {
  89. $('.admin-notification > .row > .col-md-9').prepend(
  90. '<div class=\"alert alert-success\">Successfully Upated</div>'
  91. );
  92. $message = $('.admin-notification > .row > .col-md-9 > .alert.alert-success');
  93. setTimeout(function()
  94. {
  95. $message.fadeOut({
  96. complete: function() {
  97. $message.remove();
  98. }
  99. });
  100. }, 2000);
  101. }
  102. else {
  103. $('.admin-notification > .row > .col-md-9').prepend(
  104. '<div class=\"alert alert-danger\">Error occurred in deleting global notifcation setting.</div>'
  105. );
  106. location.reload();
  107. }
  108. });
  109. });
  110. </script>