notification.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. {% extends '../layout/admin.html' %}
  2. {% block html_title %}通知設定 · {{ path }}{% endblock %}
  3. {% block content_head %}
  4. <div class="header-wrap">
  5. <header id="page-header">
  6. <h1 class="title" id="">通知設定</h1>
  7. </header>
  8. </div>
  9. {% endblock %}
  10. {% block content_main %}
  11. <div class="content-main">
  12. <div class="row">
  13. <div class="col-md-3">
  14. {% include './widget/menu.html' with {current: 'notification'} %}
  15. </div>
  16. <div class="col-md-9">
  17. <ul class="nav nav-tabs">
  18. <li class="active"><a href="#slack" data-toggle="tab"><i class="fa fa-slack"></i> Slack</a></li>
  19. </ul>
  20. <br>
  21. {% set smessage = req.flash('successMessage') %}
  22. {% if smessage.length %}
  23. <div class="alert alert-success">
  24. {% for e in smessage %}
  25. {{ e }}<br>
  26. {% endfor %}
  27. </div>
  28. {% endif %}
  29. {% set emessage = req.flash('errorMessage') %}
  30. {% if emessage.length %}
  31. <div class="alert alert-danger">
  32. {% for e in emessage %}
  33. {{ e }}<br>
  34. {% endfor %}
  35. </div>
  36. {% endif %}
  37. <form action="/admin/notification/slackSetting" method="post" class="form-horizontal" id="appSettingForm" role="form">
  38. <fieldset>
  39. <legend>Slack App Configuration</legend>
  40. <div class="form-group">
  41. <label for="slackSetting[slack:clientId]" class="col-xs-3 control-label">clientId</label>
  42. <div class="col-xs-6">
  43. <input class="form-control" type="text" name="slackSetting[slack:clientId]" value="{{ slackSetting['slack:clientId'] }}">
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <label for="slackSetting[slack:clientSecret]" class="col-xs-3 control-label">clientSecret</label>
  48. <div class="col-xs-6">
  49. <input class="form-control" type="text" name="slackSetting[slack:clientSecret]" value="{{ slackSetting['slack:clientSecret'] }}">
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <div class="col-xs-offset-3 col-xs-6">
  54. <button type="submit" class="btn btn-primary">Submit</button>
  55. </div>
  56. </div>
  57. </fieldset>
  58. <input type="hidden" name="_csrf" value="{{ _csrf() }}">
  59. </form>
  60. {% if hasSlackConfig %}
  61. <div class="text-center">
  62. {% if hasSlackToken %}
  63. <p>Crowi and Slack is already <strong>connected</strong>. You can re-connect to refresh and overwirte the token with your Slack account.</p>
  64. <a class="btn btn-default" href="{{ slackAuthUrl }}">
  65. <i class="fa fa-slack"></i> Reconnect to Slack
  66. </a>
  67. {% else %}
  68. <p>Slack clientId and clientSecret is configured. Now, you can connect with Slack.</p>
  69. <a class="btn btn-primary" href="{{ slackAuthUrl }}">
  70. <i class="fa fa-slack"></i> Connect to Slack
  71. </a>
  72. {% endif %}
  73. </div>
  74. <hr>
  75. <h4>Default Notification Settings for Patterns</h4>
  76. <table class="table table-bordered">
  77. <thead>
  78. <th>Pattern</th>
  79. <th>Channel</th>
  80. <th>Operation</th>
  81. </thead>
  82. <tbody class="admin-notif-list">
  83. <form id="slackNotificationForm">
  84. <tr>
  85. <td>
  86. <input class="form-control" type="text" name="pathPattern" value="" placeholder="e.g. /projects/xxx/MTG/*">
  87. <p class="help-block">
  88. Path name of wiki. Pattern expression with <code>*</code> can be used.
  89. </p>
  90. </td>
  91. <td>
  92. <input class="form-control form-inline" type="text" name="channel" value="" placeholder="e.g. project-xxx">
  93. <p class="help-block">
  94. Slack channel name. Without <code>#</code>.
  95. </p>
  96. </td>
  97. <td>
  98. <input type="hidden" name="_csrf" value="{{ _csrf() }}">
  99. <input type="submit" value="Add" class="btn btn-primary">
  100. </td>
  101. </tr>
  102. </form>
  103. {% for notif in settings %}
  104. <tr class="admin-notif-row" data-updatepost-id="{{ notif._id.toString() }}">
  105. <td>
  106. {{ notif.pathPattern }}
  107. </td>
  108. <td>
  109. {{ notif.channel }}
  110. </td>
  111. <td>
  112. <form class="admin-remove-updatepost">
  113. <input type="hidden" name="id" value="{{ notif._id.toString() }}">
  114. <input type="hidden" name="_csrf" value="{{ _csrf() }}">
  115. <input type="submit" value="Delete" class="btn btn-default">
  116. </form>
  117. </td>
  118. </tr>
  119. {% endfor %}
  120. </tbody>
  121. </table>
  122. {% endif %}
  123. {% if not hasSlackConfig %}
  124. <h3>How to configure Slack app for Crowi</h3>
  125. <p>
  126. Register Crowi as a Slack application, the notification feature for Slack can be enabled.
  127. </p>
  128. <h4>1. Register Slack App</h4>
  129. <p>
  130. Create App from <a href="https://api.slack.com/applications/new">this link</a>, and fill the form out as below:
  131. </p>
  132. <dl class="dl-horizontal">
  133. <dt>App Name</dt> <dd><code>Crowi</code> </dd>
  134. <dt>Icon</dt> <dd>Upload this image as the icon (Free to download and use it) =&gt; <a href="https://github.com/crowi/crowi/tree/master/resource/logo">Crowi Logo</a></dd>
  135. <dt>Short description</dt> <dd><code>Crowi's Slack Notification Integration</code> </dd>
  136. <dt>Long description</dt> <dd><code>Crowi's Slack Notification Integration</code> </dd>
  137. </dl>
  138. <p>
  139. and <strong>Save</strong> it.
  140. </p>
  141. <h4>2. Get <code>clientId</code> and <code>clientSecret</code></h4>
  142. <h4>3. After clientId nad clientSecret set, click "Connect to Slack" button to start OAuth process.</h4>
  143. <h4>4. Configure Slack on this notification setting screen</h4>
  144. {% endif %}
  145. </div>
  146. </div>
  147. </div>
  148. {% endblock content_main %}
  149. {% block content_footer %}
  150. {% endblock content_footer %}