You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

512 lines
20 KiB

  1. {% extends "base.html" %}
  2. {% load compress static hc_extras %}
  3. {% block title %}Project Settings - {{ project }}{% endblock %}
  4. {% block content %}
  5. {% with project.transfer_request as transfer_request %}
  6. <div class="row">
  7. <div class="col-sm-9 col-md-6">
  8. {% for message in messages %}
  9. <p class="alert alert-{{ message.tags }}">{{ message }}</p>
  10. {% endfor %}
  11. {% if transfer_request and transfer_request.user == request.user %}
  12. {% with can_accept=transfer_request.can_accept %}
  13. <div id="transfer-request" class="panel">
  14. <div class="panel-body settings-block">
  15. <h2>Ownership Transfer Request</h2>
  16. <p>
  17. <strong>{{ project.owner.email }}</strong> would like to transfer
  18. the ownership of this project to you.
  19. </p>
  20. {% if not can_accept %}
  21. {% with num_checks=project.num_checks num_available=request.profile.num_checks_available %}
  22. <p>
  23. This project has
  24. <strong>{{ num_checks }} check{{ num_checks|pluralize}}</strong>,
  25. but your account only has space for
  26. <strong>{{ num_available }} additional check{{ num_available|pluralize }}</strong>.
  27. To accept the transfer, please
  28. <a href="{% url 'hc-billing' %}">upgrade your account first!</a>
  29. </p>
  30. {% endwith%}
  31. {% endif %}
  32. <div class="pull-right">
  33. <form method="post">
  34. {% csrf_token %}
  35. <button
  36. type="submit"
  37. name="reject_transfer"
  38. class="btn btn-default">Reject</button>
  39. <button
  40. type="submit"
  41. name="accept_transfer"
  42. {% if not can_accept %}disabled{% endif %}
  43. class="btn btn-primary">Accept</button>
  44. </form>
  45. </div>
  46. </div>
  47. </div>
  48. {% endwith %}
  49. {% endif %}
  50. <div class="panel panel-{{ project_name_status|default:'default' }}">
  51. <div class="panel-body settings-block">
  52. <h2>Project Name</h2>
  53. {{ project }}
  54. <a
  55. href="#"
  56. class="btn btn-default pull-right"
  57. data-toggle="modal"
  58. data-target="#set-project-name-modal">Change Project Name</a>
  59. </div>
  60. {% if project_name_updated %}
  61. <div class="panel-footer">
  62. Project name updated
  63. </div>
  64. {% endif %}
  65. </div>
  66. <div class="panel panel-{{ api_status|default:'default' }}">
  67. <div class="panel-body settings-block">
  68. <h2>API Access</h2>
  69. {% if project.api_key %}
  70. {% if show_api_keys %}
  71. <p>
  72. API key: <br />
  73. <code>{{ project.api_key }}</code>
  74. </p>
  75. {% if project.api_key_readonly %}
  76. <p>
  77. API key (read-only): <br />
  78. <code>{{ project.api_key_readonly }}</code>
  79. </p>
  80. <p>
  81. Prometheus metrics endpoint:
  82. <a href="{% url 'hc-metrics' project.code project.api_key_readonly %}">here</a>
  83. </p>
  84. {% endif %}
  85. <button
  86. data-toggle="modal"
  87. data-target="#revoke-api-key-modal"
  88. class="btn btn-danger pull-right">Revoke</button>
  89. {% else %}
  90. <form method="post">
  91. <span class="icon-ok"></span>
  92. API access is enabled.
  93. {% csrf_token %}
  94. <button
  95. type="submit"
  96. name="show_api_keys"
  97. class="btn btn-default pull-right">Show API keys</button>
  98. </form>
  99. {% endif %}
  100. {% else %}
  101. <span class="icon-cancel"></span>
  102. API access is disabled.
  103. <form method="post">
  104. {% csrf_token %}
  105. <button
  106. type="submit"
  107. name="create_api_keys"
  108. class="btn btn-default pull-right">Create API keys</button>
  109. </form>
  110. {% endif %}
  111. </div>
  112. {% if api_keys_created %}
  113. <div class="panel-footer">
  114. API keys created
  115. </div>
  116. {% endif %}
  117. {% if api_keys_revoked %}
  118. <div class="panel-footer">
  119. API keys revoked
  120. </div>
  121. {% endif %}
  122. </div>
  123. {% with invite_suggestions=project.invite_suggestions %}
  124. <div class="panel panel-{{ team_status|default:'default' }}">
  125. <div class="panel-body settings-block">
  126. <h2>Team Access</h2>
  127. {% if project.team.exists or invite_suggestions %}
  128. <table id="team-table" class="table">
  129. <tr>
  130. <th>Email</th>
  131. <th>Role</th>
  132. <th></th>
  133. </tr>
  134. <tr>
  135. <td>{{ project.owner.email }}</td>
  136. <td>Owner</td>
  137. <td></td>
  138. </tr>
  139. {% for user in project.team %}
  140. <tr>
  141. <td>{{ user.email }} </td>
  142. <td>Member</td>
  143. <td>
  144. {% if is_owner %}
  145. <a
  146. href="#"
  147. data-email="{{ user.email }}"
  148. class="pull-right member-remove">Remove</a>
  149. {% endif %}
  150. </td>
  151. </tr>
  152. {% endfor %}
  153. {% if is_owner and invite_suggestions %}
  154. <tr id="suggestions-row">
  155. <td colspan="3">
  156. Add Users from Other Teams
  157. </td>
  158. </tr>
  159. {% for user in invite_suggestions %}
  160. <tr class="invite-suggestion">
  161. <td>{{ user.email }} </td>
  162. <td></td>
  163. <td>
  164. <a
  165. href="#"
  166. data-email="{{ user.email }}"
  167. class="pull-right add-to-team">Add to Team</a>
  168. </td>
  169. </tr>
  170. {% endfor %}
  171. {% endif %}
  172. </table>
  173. {% else %}
  174. <p>
  175. <strong>Invite team members to your project.</strong>
  176. Share access to your checks and configured integrations
  177. without having to share login details.
  178. </p>
  179. {% endif %}
  180. <br />
  181. {% if is_owner %}
  182. {% if project.can_invite_new_users %}
  183. <a
  184. href="#"
  185. class="btn btn-primary pull-right"
  186. data-toggle="modal"
  187. data-target="#invite-team-member-modal">Invite a Team Member</a>
  188. {% else %}
  189. <div class="alert alert-info">
  190. <strong>Team size limit reached.</strong>
  191. To invite new members by email, please
  192. <a href="{% url 'hc-pricing' %}">upgrade your account!</a>
  193. </div>
  194. {% endif %}
  195. {% endif %}
  196. </div>
  197. {% endwith %}
  198. {% if team_member_invited %}
  199. <div class="panel-footer">
  200. {{ team_member_invited }} invited to team
  201. </div>
  202. {% endif %}
  203. {% if team_member_removed %}
  204. <div class="panel-footer">
  205. {{ team_member_removed }} removed from team
  206. </div>
  207. {% endif %}
  208. </div>
  209. {% if is_owner %}
  210. <div class="panel panel-{{ transfer_status|default:'default' }}"">
  211. <div class="panel-body settings-block">
  212. <h2>Transfer Ownership</h2>
  213. {% if transfer_request %}
  214. <form method="post">
  215. {% csrf_token %}
  216. <button
  217. type="submit"
  218. name="cancel_transfer"
  219. class="btn btn-default pull-right">Cancel Transfer</button>
  220. </form>
  221. Transfer initiated, awaiting confirmation from
  222. <strong>{{ transfer_request.user.email }}</strong>.
  223. {% else %}
  224. <a href="#"
  225. class="btn btn-default pull-right"
  226. data-toggle="modal"
  227. data-target="#transfer-modal">Transfer Project&hellip;</a>
  228. Transfer this project to a team member.
  229. {% endif %}
  230. </div>
  231. {% if transfer_initiated %}
  232. <div class="panel-footer">
  233. Transfer initiated!
  234. </div>
  235. {% endif %}
  236. {% if transfer_cancelled %}
  237. <div class="panel-footer">
  238. Transfer cancelled!
  239. </div>
  240. {% endif %}
  241. </div>
  242. {% endif %}
  243. {% if is_owner %}
  244. <div class="panel panel-default">
  245. <div class="panel-body settings-block">
  246. {% csrf_token %}
  247. <h2>Remove Project</h2>
  248. <a href="#"
  249. id="remove-project"
  250. class="btn btn-default pull-right"
  251. data-toggle="modal"
  252. data-target="#remove-project-modal">Remove Project</a>
  253. This will permanently remove project {{ project }}.
  254. <form action="{% url 'hc-remove-project' project.code %}" method="post">
  255. </form>
  256. </div>
  257. </div>
  258. {% endif %}
  259. </div>
  260. </div>
  261. <div id="revoke-api-key-modal" class="modal">
  262. <div class="modal-dialog">
  263. <form id="revoke-api-key-form" method="post">
  264. {% csrf_token %}
  265. <div class="modal-content">
  266. <div class="modal-header">
  267. <button type="button" class="close" data-dismiss="modal">&times;</button>
  268. <h4>Revoke API Keys?</h4>
  269. </div>
  270. <div class="modal-body">
  271. <p>You are about to revoke your current API keys.</p>
  272. <p>Afterwards, you can create new API keys, but there will
  273. be <strong>no way of getting the current API
  274. keys back</strong>.
  275. </p>
  276. <p>Are you sure?</p>
  277. </div>
  278. <div class="modal-footer">
  279. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  280. <button
  281. type="submit"
  282. name="revoke_api_keys"
  283. class="btn btn-danger">Revoke API Keys</button>
  284. </div>
  285. </div>
  286. </form>
  287. </div>
  288. </div>
  289. <div id="remove-team-member-modal" class="modal">
  290. <div class="modal-dialog">
  291. <form id="remove-team-member-form" method="post">
  292. {% csrf_token %}
  293. <div class="modal-content">
  294. <div class="modal-header">
  295. <button type="button" class="close" data-dismiss="modal">&times;</button>
  296. <h4>Remove Team Member</h4>
  297. </div>
  298. <div class="modal-body">
  299. <p>You are about to remove <strong id="rtm-email"></strong> from the project.</p>
  300. <p>Are you sure?</p>
  301. <input
  302. type="hidden"
  303. name="email"
  304. id="remove-team-member-email" />
  305. </div>
  306. <div class="modal-footer">
  307. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  308. <button
  309. type="submit"
  310. name="remove_team_member"
  311. class="btn btn-danger">Remove Member from Project</button>
  312. </div>
  313. </div>
  314. </form>
  315. </div>
  316. </div>
  317. <div id="invite-team-member-modal" class="modal">
  318. <div class="modal-dialog">
  319. <form method="post" class="form-horizontal">
  320. {% csrf_token %}
  321. <input type="hidden" name="invite_team_member" value="1" />
  322. <div class="modal-content">
  323. <div class="modal-header">
  324. <button type="button" class="close" data-dismiss="modal">&times;</button>
  325. <h4>Invite a Team Member</h4>
  326. </div>
  327. <div class="modal-body">
  328. <ul>
  329. <li>Team Members can create and manage Checks and Integrations</li>
  330. <li>Only the project owner (you) can view and edit billing settings</li>
  331. </ul>
  332. <div class="form-group">
  333. <label for="itm-email" class="col-sm-2 control-label">Email</label>
  334. <div class="col-sm-9">
  335. <input
  336. type="email"
  337. class="form-control"
  338. id="itm-email"
  339. name="email"
  340. placeholder="[email protected]">
  341. </div>
  342. </div>
  343. </div>
  344. <div class="modal-footer">
  345. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  346. <button
  347. type="submit"
  348. name="invite_team_member"
  349. class="btn btn-primary">Send Invite</button>
  350. </div>
  351. </div>
  352. </form>
  353. </div>
  354. </div>
  355. <div id="set-project-name-modal" class="modal">
  356. <div class="modal-dialog">
  357. <form method="post" class="form-horizontal">
  358. {% csrf_token %}
  359. <div class="modal-content">
  360. <div class="modal-header">
  361. <button type="button" class="close" data-dismiss="modal">&times;</button>
  362. <h4>Change Project Name</h4>
  363. </div>
  364. <div class="modal-body">
  365. <div class="form-group">
  366. <label for="project-name" class="col-sm-4 control-label">Project Name</label>
  367. <div class="col-sm-7">
  368. <input
  369. type="text"
  370. class="form-control"
  371. id="project-name"
  372. name="name"
  373. value="{{ project }}">
  374. </div>
  375. </div>
  376. </div>
  377. <div class="modal-footer">
  378. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  379. <button
  380. type="submit"
  381. name="set_project_name"
  382. class="btn btn-primary">Set Project Name</button>
  383. </div>
  384. </div>
  385. </form>
  386. </div>
  387. </div>
  388. <div id="remove-project-modal" class="modal">
  389. <div class="modal-dialog">
  390. <form method="post" action="{% url 'hc-remove-project' project.code %}">
  391. {% csrf_token %}
  392. <div class="modal-content">
  393. <div class="modal-header">
  394. <button type="button" class="close" data-dismiss="modal">&times;</button>
  395. <h4>Remove "{{ project }}"?</h4>
  396. </div>
  397. <div class="modal-body">
  398. <p>Danger zone! You are about to permanently remove
  399. project <strong>{{ project }}</strong> and all
  400. of its associated checks and integrations. Are you sure?
  401. </p>
  402. </div>
  403. <div class="modal-footer">
  404. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  405. <button
  406. type="submit"
  407. class="btn btn-danger">Remove Project</button>
  408. </div>
  409. </div>
  410. </form>
  411. </div>
  412. </div>
  413. {% if not transfer_request %}
  414. <div id="transfer-modal" class="modal">
  415. <div class="modal-dialog">
  416. <form
  417. class="form-horizontal"
  418. method="post">
  419. {% csrf_token %}
  420. <input type="hidden" name="transfer_project" value="1" />
  421. <div class="modal-content">
  422. <div class="modal-header">
  423. <button type="button" class="close" data-dismiss="modal">&times;</button>
  424. <h4>Transfer Ownership</h4>
  425. </div>
  426. <div class="modal-body">
  427. {% if project.team %}
  428. <div class="form-group">
  429. <label for="update-name-input" class="col-sm-4 control-label">
  430. Choose owner
  431. </label>
  432. <div class="col-sm-7">
  433. <select
  434. id="new-owner"
  435. name="email"
  436. title="Select..."
  437. class="form-control selectpicker">
  438. {% for user in project.team %}
  439. <option>{{ user.email }}</option>
  440. {% endfor %}
  441. </select>
  442. </div>
  443. </div>
  444. {% else %}
  445. <p>
  446. This project currently has no team members.
  447. To transfer the ownership of this project, please start by
  448. inviting the new owner as a team member.
  449. </p>
  450. {% endif %}
  451. </div>
  452. <div class="modal-footer">
  453. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  454. <button
  455. id="transfer-confirm"
  456. disabled
  457. type="submit"
  458. class="btn btn-primary">Initiate Transfer</button>
  459. </div>
  460. </div>
  461. </form>
  462. </div>
  463. </div>
  464. {% endif %}
  465. {% endwith %}
  466. {% endblock %}
  467. {% block scripts %}
  468. {% compress js %}
  469. <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
  470. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  471. <script src="{% static 'js/bootstrap-select.min.js' %}"></script>
  472. <script src="{% static 'js/project.js' %}"></script>
  473. {% endcompress %}
  474. {% endblock %}