notification.html 6.0 KB

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