global-notification.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <a href="/admin/global-notification/detail">
  2. <p data-toggle="collapse" class="btn btn-default">通知設定の追加</p>
  3. </a>
  4. <h2>通知設定一覧</h2>
  5. {% set icons = {
  6. pageCreate: '<i class="icon-note"></i>',
  7. pageEdit: '<i class="icon-note"></i>',
  8. pageDelete: '<i class="icon-note"></i>',
  9. pageMove: '<i class="icon-note"></i>',
  10. pageLike: '<i class="icon-note"></i>',
  11. comment: '<i class="icon-note"></i>'
  12. } %}
  13. <table class="table table-bordered">
  14. <thead>
  15. <th>ON/OFF</th>
  16. <th>Pattern</th>
  17. <th>Triggers</th>
  18. <th>Notify To</th>
  19. </thead>
  20. <tbody class="admin-notif-list">
  21. <form id="">
  22. <tr>
  23. <td></td>
  24. <td>
  25. <input class="form-control" type="text" placeholder="e.g. /projects/xxx/MTG/*">
  26. <p class="help-block">
  27. Path Pattern of wiki. Expression with <code>*</code> is supported.
  28. </p>
  29. </td>
  30. <td>
  31. {% for icon in icons %}
  32. {{ icon | safe }}
  33. {% endfor %}
  34. </td>
  35. <td>
  36. <input class="form-control" type="text" placeholder="e.g. xxx@example.com">
  37. <p class="help-block">
  38. Notifications are sent to this email.
  39. </p>
  40. </td>
  41. </tr>
  42. </form>
  43. {% set detailPageUrl = '/admin/global-notification/detail' %}
  44. {% for globalNotif in globalNotifications %}
  45. <tr class="clickable-row" data-href="{{ detailPageUrl }}" data-updatepost-id="{{ globalNotif._id.toString() }}">
  46. <td class="unclickable">
  47. <label class="switch">
  48. <input type="checkbox" class="isEnabledToggle" {% if globalNotif.isEnabled %}checked{% endif %}>
  49. <span class="slider round"></span>
  50. </label>
  51. </td>
  52. <td>
  53. {{ globalNotif.triggerPath }}
  54. </td>
  55. <td>
  56. {% for event in globalNotif.triggerEvents %}
  57. {{ icons[event] | safe }}
  58. {% endfor %}
  59. </td>
  60. <td>
  61. {% if globalNotif.__t == 'mail' %}emailicon {{ globalNotif.toEmail }}
  62. {% elseif globalNotif.__t == 'slack' %}slackicon {{ globalNotif.slackChannels }}
  63. {% endif %}
  64. </td>
  65. </tr>
  66. {% endfor %}
  67. </tbody>
  68. </table>
  69. <style>
  70. /* The switch - the box around the slider */
  71. .switch {
  72. position: relative;
  73. display: inline-block;
  74. width: 30px;
  75. height: 17px;
  76. }
  77. /* Hide default HTML checkbox */
  78. .switch input {display:none;}
  79. /* The slider */
  80. .slider {
  81. position: absolute;
  82. cursor: pointer;
  83. top: 0;
  84. left: 0;
  85. right: 0;
  86. bottom: 0;
  87. background-color: #ccc;
  88. -webkit-transition: .4s;
  89. transition: .4s;
  90. }
  91. .slider:before {
  92. position: absolute;
  93. content: "";
  94. height: 13px;
  95. width: 13px;
  96. left: 2px;
  97. bottom: 2px;
  98. background-color: white;
  99. -webkit-transition: .4s;
  100. transition: .4s;
  101. }
  102. input:checked + .slider {
  103. background-color: #2196F3;
  104. }
  105. input:focus + .slider {
  106. box-shadow: 0 0 1px #2196F3;
  107. }
  108. input:checked + .slider:before {
  109. -webkit-transform: translateX(13px);
  110. -ms-transform: translateX(13px);
  111. transform: translateX(13px);
  112. }
  113. /* Rounded sliders */
  114. .slider.round {
  115. border-radius: 34px;
  116. }
  117. .slider.round:before {
  118. border-radius: 50%;
  119. }
  120. </style>
  121. <script>
  122. $(".clickable-row > :not('.unclickable')").click(function(event) {
  123. window.location = $(event.currentTarget).parent().data("href")
  124. });
  125. $(".isEnabledToggle").on("change", function(event) {
  126. var id = $(event.currentTarget).closest("tr").data("updatepost-id")
  127. $.post('/_api/admin/global-notification/toggleIsEnabled?id=' + id, function(res) {
  128. if (res.ok) {
  129. // do something
  130. }
  131. });
  132. });
  133. </script>