notification.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. </form>
  59. {% if hasSlackConfig %}
  60. <div class="text-center">
  61. {% if hasSlackToken %}
  62. <p>Crowi and Slack is already <strong>connected</strong>. You can re-connect to refresh and overwirte the token with your Slack account.</p>
  63. <a class="btn btn-default" href="{{ slackAuthUrl }}">
  64. <i class="fa fa-slack"></i> Reconnect to Slack
  65. </a>
  66. {% else %}
  67. <p>Slack clientId and clientSecret is configured. Now, you can connect with Slack.</p>
  68. <a class="btn btn-primary" href="{{ slackAuthUrl }}">
  69. <i class="fa fa-slack"></i> Connect to Slack
  70. </a>
  71. {% endif %}
  72. </div>
  73. <hr>
  74. <h4>Default Notification Settings for Patterns</h4>
  75. <table class="table table-bordered">
  76. <thead>
  77. <th>Pattern</th>
  78. <th>Channel</th>
  79. <th>Operation</th>
  80. </thead>
  81. <tbody class="admin-notif-list">
  82. <form id="slackNotificationForm">
  83. <tr>
  84. <td>
  85. <input class="form-control" type="text" name="pathPattern" value="" placeholder="e.g. /projects/xxx/MTG/*">
  86. <p class="help-block">
  87. Path name of wiki. Pattern expression with <code>*</code> can be used.
  88. </p>
  89. </td>
  90. <td>
  91. <input class="form-control form-inline" type="text" name="channel" value="" placeholder="e.g. project-xxx">
  92. <p class="help-block">
  93. Slack channel name. Without <code>#</code>.
  94. </p>
  95. </td>
  96. <td>
  97. <input type="submit" value="Add" class="btn btn-primary">
  98. </td>
  99. </tr>
  100. </form>
  101. {% for notif in settings %}
  102. <tr class="admin-notif-row" data-updatepost-id="{{ notif._id.toString() }}">
  103. <td>
  104. {{ notif.pathPattern }}
  105. </td>
  106. <td>
  107. {{ notif.channel }}
  108. </td>
  109. <td>
  110. <form class="admin-remove-updatepost">
  111. <input type="hidden" name="id" value="{{ notif._id.toString() }}">
  112. <input type="submit" value="Delete" class="btn btn-default">
  113. </form>
  114. </td>
  115. </tr>
  116. {% endfor %}
  117. </tbody>
  118. </table>
  119. {% endif %}
  120. {% if not hasSlackConfig %}
  121. <h3>How to configure Slack app for Crowi</h3>
  122. <p>
  123. Register Crowi as a Slack application, the notification feature for Slack can be enabled.
  124. </p>
  125. <h4>1. Register Slack App</h4>
  126. <p>
  127. Create App from <a href="https://api.slack.com/applications/new">this link</a>, and fill the form out as below:
  128. </p>
  129. <dl class="dl-horizontal">
  130. <dt>App Name</dt> <dd><code>Crowi</code> </dd>
  131. <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>
  132. <dt>Short description</dt> <dd><code>Crowi's Slack Notification Integration</code> </dd>
  133. <dt>Long description</dt> <dd><code>Crowi's Slack Notification Integration</code> </dd>
  134. </dl>
  135. <p>
  136. and <strong>Save</strong> it.
  137. </p>
  138. <h4>2. Get <code>clientId</code> and <code>clientSecret</code></h4>
  139. <h4>3. After clientId nad clientSecret set, click "Connect to Slack" button to start OAuth process.</h4>
  140. <h4>4. Configure Slack on this notification setting screen</h4>
  141. {% endif %}
  142. </div>
  143. </div>
  144. </div>
  145. {% endblock content_main %}
  146. {% block content_footer %}
  147. {% endblock content_footer %}