vpn.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. {% extends "base.html" %}
  2. {% load subnets %}
  3. {% block content %}
  4. <div class="row">
  5. <h2>Configuration du VPN</h2>
  6. <form class="flatform" action="{{ object.get_absolute_url }}" method="post">{% csrf_token %}
  7. <p class="legend">Quand vous aurez terminé vos modifications, cliquez sur <input class="button" type="submit" value="Valider" /></p>
  8. {% for message in messages %}
  9. <div class="message eat-up{% if message.tags %} {{ message.tags }}{% endif %}">
  10. {{ message }}
  11. </div>
  12. {% endfor %}
  13. {% if form.non_field_errors or form.ipv4_endpoint.errors or form.ipv6_endpoint.errors %}
  14. <div class="alert-box alert nogap">
  15. {{ form.non_field_errors }}
  16. {{ form.ipv4_endpoint.errors }}
  17. {{ form.ipv6_endpoint.errors }}
  18. </div>{% endif %}
  19. <div class="large-6 columns">
  20. <div class="panel">
  21. <h3>Statut</h3>
  22. <table class="full-width">
  23. <tr>
  24. <td class="center"><span class="label">Identifiant</span></td>
  25. <td>{{object.login}}</td>
  26. </tr>
  27. <tr>
  28. <td class="center" colspan="2">
  29. <a class="button tiny radius" id="passgen" href="{% url 'vpn:generate_password' object.pk %}"><i class="fa fa-refresh"></i>
  30. Générer un nouveau mot de passe</a>
  31. </td>
  32. </tr>
  33. <tr class="flatfield">
  34. <td class="center">{{ form.comment.label_tag }}</td>
  35. <td>{{ form.comment }}</td>
  36. </tr>
  37. <tr>
  38. <td class="center boolviewer" colspan="2">
  39. <input type="checkbox" disabled="disabled"{% if object.activated %} checked="checked"{% endif %} />
  40. <span>Ce VPN est {{ object.activated|yesno:"activé,désactivé" }}</span>
  41. </td>
  42. </tr>
  43. </table>
  44. </div>
  45. </div>
  46. <div class="large-6 columns">
  47. <div class="panel">
  48. <h3>Adresses IP</h3>
  49. <table class="full-width">
  50. <tr class="flatfield">
  51. <td class="center">{{ form.ipv4_endpoint.label_tag }}</td>
  52. <td{% if form.non_field_errors or form.ipv4_endpoint.errors %} class="errored"{% endif %}>{{ form.ipv4_endpoint }}</td>
  53. </tr>
  54. <tr class="flatfield">
  55. <td class="center">{{ form.ipv6_endpoint.label_tag }}</td>
  56. <td{% if form.non_field_errors or form.ipv6_endpoint.errors %} class="errored"{% endif %}>{{ form.ipv6_endpoint }}</td>
  57. </tr>
  58. <tr>
  59. <td class="center"><span class="label">Sous-réseaux</span></td>
  60. <td>
  61. {% for subnet in object.ip_subnet.all %}{{ subnet|prettify }}<br/>{% endfor %}
  62. </td>
  63. </tr>
  64. </table>
  65. </div>
  66. </div>
  67. <p class="formcontrol"><input class="button" type="submit" value="Valider" /></p>
  68. </form>
  69. </div>
  70. <div class="row" id="graph">
  71. <h3>Graphe de trafic sur
  72. <select id="graph_period">
  73. <option value="hourly">une heure</option>
  74. <option value="daily" selected>24 heures</option>
  75. <option value="weekly">7 jours</option>
  76. <option value="monthly">un mois</option>
  77. <option value="yearly">un an</option>
  78. </select> : <small class="pending_request"></small></h3>
  79. <img id="graph_trafic" src="{% url 'vpn:get_graph' vpn_id=object.pk %}" alt="Graphe de trafic {{ object.login }}" />
  80. </div>
  81. {% endblock %}
  82. {% block extra_js %}
  83. <script>
  84. // Bouton génération du mot de passe
  85. $('#passgen').click(function(){
  86. if (!confirm("Ceci va effacer votre ancien mot de passe et en générer un nouveau. Continuer ?")) return false;
  87. parent_cell = $(this).parent();
  88. parent_cell.html('<span class="pending_request"><i class="fa fa-refresh fa-spin"></i> Génération en cours</span>');
  89. $.ajax({
  90. 'url': $(this).attr('href')
  91. }).done(function(html) {
  92. //Remplace le tr parent par le contenu renvoyé (qui est deux tr successifs)
  93. parent_cell.parent().replaceWith(html);
  94. }).fail(function( jqXHR, textStatus ) {
  95. parent_cell.html('<span class="error">Échec de la requête : ' + textStatus + '</span>');
  96. });
  97. return false;
  98. });
  99. // Graphe de conso data
  100. $('#graph_period').change(function(){
  101. $('#graph .pending_request').html('<i class="fa fa-refresh fa-spin"></i>');
  102. base_url = "{% url 'vpn:get_graph' vpn_id=object.pk %}/";
  103. $('#graph_trafic').attr('src', base_url + $(this).val());
  104. });
  105. $('#graph_trafic').load(function() {
  106. $('#graph .pending_request').html('');
  107. });
  108. </script>
  109. {% endblock extra_js %}