global-notification.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <a href="/admin/global-notification/detail">
  2. <p data-toggle="collapse" class="btn btn-default">通知設定の追加</p>
  3. </a>
  4. <h2>通知設定一覧</h2>
  5. {% set tags = {
  6. pageCreate: '<span class="label label-info"><i class="icon-doc"></i> CREATE</span>',
  7. pageEdit: '<span class="label label-info"><i class="icon-doc"></i> EDIT</span>',
  8. pageDelete: '<span class="label label-info"><i class="icon-doc"></i> DELETE</span>',
  9. pageMove: '<span class="label label-info"><i class="icon-doc"></i> MOVE</span>',
  10. pageLike: '<span class="label label-info"><i class="icon-doc"></i> LIKE</span>',
  11. comment: '<span class="label label-info"><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. </thead>
  20. <tbody class="admin-notif-list">
  21. {% set detailPageUrl = '/admin/global-notification/detail' %}
  22. {% for globalNotif in globalNotifications %}
  23. <tr class="clickable-row" data-href="{{ detailPageUrl }}" data-updatepost-id="{{ globalNotif._id.toString() }}">
  24. <td class="unclickable">
  25. <label class="switch">
  26. <input type="checkbox" class="isEnabledToggle" {% if globalNotif.isEnabled %}checked{% endif %}>
  27. <span class="slider round"></span>
  28. </label>
  29. </td>
  30. <td>
  31. {{ globalNotif.triggerPath }}
  32. </td>
  33. <td style="max-width: 200px;">
  34. {% for event in globalNotif.triggerEvents %}
  35. {{ tags[event] | safe }}
  36. {% endfor %}
  37. </td>
  38. <td>
  39. {% if globalNotif.__t == 'mail' %}<i class="ti-email"></i> {{ globalNotif.toEmail }}
  40. {% elseif globalNotif.__t == 'slack' %}<i class="fa fa-slack"></i> {{ globalNotif.slackChannels }}
  41. {% endif %}
  42. </td>
  43. </tr>
  44. {% endfor %}
  45. </tbody>
  46. </table>
  47. <style>
  48. /* The switch - the box around the slider */
  49. .switch {
  50. position: relative;
  51. display: inline-block;
  52. width: 30px;
  53. height: 17px;
  54. }
  55. /* Hide default HTML checkbox */
  56. .switch input {display:none;}
  57. /* The slider */
  58. .slider {
  59. position: absolute;
  60. cursor: pointer;
  61. top: 0;
  62. left: 0;
  63. right: 0;
  64. bottom: 0;
  65. background-color: #ccc;
  66. -webkit-transition: .4s;
  67. transition: .4s;
  68. }
  69. .slider:before {
  70. position: absolute;
  71. content: "";
  72. height: 13px;
  73. width: 13px;
  74. left: 2px;
  75. bottom: 2px;
  76. background-color: white;
  77. -webkit-transition: .4s;
  78. transition: .4s;
  79. }
  80. input:checked + .slider {
  81. background-color: #2196F3;
  82. }
  83. input:focus + .slider {
  84. box-shadow: 0 0 1px #2196F3;
  85. }
  86. input:checked + .slider:before {
  87. -webkit-transform: translateX(13px);
  88. -ms-transform: translateX(13px);
  89. transform: translateX(13px);
  90. }
  91. /* Rounded sliders */
  92. .slider.round {
  93. border-radius: 34px;
  94. }
  95. .slider.round:before {
  96. border-radius: 50%;
  97. }
  98. </style>
  99. <script>
  100. $(".clickable-row > :not('.unclickable')").click(function(event) {
  101. window.location = $(event.currentTarget).parent().data("href")
  102. });
  103. $(".isEnabledToggle").on("change", function(event) {
  104. var id = $(event.currentTarget).closest("tr").data("updatepost-id")
  105. $.post('/_api/admin/global-notification/toggleIsEnabled?id=' + id, function(res) {
  106. if (res.ok) {
  107. // do something
  108. }
  109. });
  110. });
  111. </script>