parc_info_switch_index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. {% extends 'base.html' %}
  2. {% load crispy_forms_tags %}
  3. {% load static %}
  4. {% block modals%}
  5. <div class="modal" id="mo_get_info" tabindex="-1" role="dialog"></div>
  6. <div class="modal " id="mo_edit_info" data-backdrop="static" tabindex="-1" role="dialog"></div>
  7. <div class="modal " id="mo_edit_port" data-backdrop="static" tabindex="-1" role="dialog"></div>
  8. {% endblock %}
  9. {% block script %}
  10. <script type="text/javascript">
  11. function get_list() {
  12. var $list_get_list = $('#get_list');
  13. var get_search = document.getElementById("id_PSearch").value
  14. if (get_search.length >= 3) {
  15. $list_get_list.html('<h3> <i class="fas fa-spinner fa-pulse fa-fw"></i> Loading...</h3>');
  16. $.ajax({
  17. type : 'GET',
  18. url: '/parc/api/switch/get_list?get_search='+get_search,
  19. success: function(feeds) {
  20. $list_get_list.html(feeds);
  21. }
  22. });
  23. }
  24. if (get_search.length == "") {
  25. $list_get_list.html('<h3> <i class="fas fa-spinner fa-pulse fa-fw"></i> Loading...</h3>');
  26. $.ajax({
  27. type : 'GET',
  28. url: '/parc/api/switch/get_list',
  29. success: function(feeds) {
  30. $list_get_list.html(feeds);
  31. }
  32. });
  33. }
  34. };
  35. function bt_get_info(id){
  36. $.ajax({
  37. type : 'GET',
  38. url: '/parc/api/switch/get/'+id,
  39. success: function(data) {
  40. $('#mo_get_info').html(data).modal('toggle');
  41. },
  42. });
  43. };
  44. function bt_edit_info(id){
  45. var get_search = document.getElementById("id_PSearch").value
  46. $.ajax({
  47. type : 'GET',
  48. url: '/parc/api/switch/edit/'+id+'?get_search='+get_search,
  49. success: function(data) {
  50. $('#mo_edit_info').html(data).modal('toggle');
  51. },
  52. });
  53. };
  54. function bt_edit_port(switch_id, port_id){
  55. var get_search = document.getElementById("id_PSearch").value
  56. $.ajax({
  57. type : 'GET',
  58. url: '/parc/api/switch/edit/port/'+switch_id+'/'+port_id+'?get_search='+get_search,
  59. success: function(data) {
  60. $('#mo_edit_port').html(data).modal('toggle').modal('show');
  61. },
  62. });
  63. };
  64. function bt_update_port(switch_id){
  65. var get_search = document.getElementById("id_PSearch").value
  66. $.ajax({
  67. type : 'GET',
  68. url: '/parc/api/switch/update/'+switch_id+'?get_search='+get_search,
  69. success: function(data) {
  70. $('#mo_edit_port').html(data).modal('toggle').modal('show');
  71. },
  72. });
  73. };
  74. function bt_send_edit(){
  75. document.getElementById("form_edit").submit();
  76. };
  77. function onloading() {
  78. get_list();
  79. {% if page.item_id %}bt_get_info({{page.item_id}});{% endif %}
  80. };
  81. $(document).ready(function(){ onloading(); });
  82. </script>
  83. {% endblock %}
  84. {% block main %}
  85. <div class="card-body">
  86. {% if not page.output or page.err %}
  87. {{page.p_contenu|safe}}
  88. {% else %}
  89. {% if page.err %}{{page.err|safe}}{% endif %}
  90. {% if page.output and page.err %}<hr>{% endif %}
  91. {% if page.output %}{{page.output|safe|urlize}}{% endif %}
  92. {% endif %}
  93. </div>
  94. <div id="get_list"><h3><i class="fas fa-spinner fa-pulse fa-fw"></i> Loading...</h3></div>
  95. {% endblock %}
  96. {% block right_panel %}
  97. <div class="card-body">
  98. <div id="div_id_PSearch" class="form-group">
  99. <label for="id_PSearch" class=" requiredField">Recherche d'un switch (min 3 caractères) </label>
  100. <div class=""><input type="text" name="PSearch" maxlength="128" class="textinput textInput form-control" required="" id="id_PSearch" oninput="get_list()" value="{{page.search}}"></div>
  101. </div>
  102. <p>{{page.p_right|safe}}</p>
  103. <div class="d-grid gap-2 mb-2"><a class="btn btn-success" href="#" onclick="bt_edit_info(0)" role="button"><i class="far fa-plus-square"></i> Ajouter un Switch</a></div>
  104. <div class="d-grid gap-2"><a class="btn btn-primary" href="/parc" role="button"><i class="fas fa-undo-alt"></i> Retour</a></div>
  105. </div>
  106. {% endblock %}