global-notification.html 4.2 KB

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