From 641c556bb65602fc24dbb1fffdba68086aed0591 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 12 May 2019 21:16:46 +0200 Subject: [PATCH] Simplify code --- .../hosting/js/virtual_machine_detail.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/hosting/static/hosting/js/virtual_machine_detail.js b/hosting/static/hosting/js/virtual_machine_detail.js index 32ae3f53..5fb9f6e5 100644 --- a/hosting/static/hosting/js/virtual_machine_detail.js +++ b/hosting/static/hosting/js/virtual_machine_detail.js @@ -81,16 +81,7 @@ $(document).ready(function() { }) }); - $('#modal-add-ssh-key').on('hidden.bs.modal', function () { - location.reload(); - }); - - haveResponse = false; - $('#modal-add-ssh-key').on('click', '.btn-ok', function(e) { - if(haveResponse) { - console.log("We had response, so reload"); - location.reload(); - } + $('#modal-add-ssh-key-button').click(function(e) { var url = $('#add_ssh_key_to_vm_form').attr('action'); console.log("Url to POST " + url); @@ -106,7 +97,7 @@ $(document).ready(function() { console.log("Encoded data = " + encoded_data); fa_icon = $('#ssh-key-modal-icon'); - modal_btn = $('#ssh-key-modal-button'); + modal_btn = $('#modal-add-ssh-key-button'); modal_btn.prop("disabled", true); modal_btn.html(''); $.post(url, {selected_key: encoded_data}) @@ -115,7 +106,7 @@ $(document).ready(function() { modal_btn.prop("disabled", false); modal_btn.html("OK"); if (data.status === true) { - fa_icon.html(''); + fa_icon.html(''); } else { fa_icon.html(''); modal_btn.attr('class', '').addClass('btn btn-danger btn-ok btn-wide'); @@ -136,7 +127,9 @@ $(document).ready(function() { }) .always(function () { console.log("changing href to location: " + location); - haveResponse = true; + $('#modal-add-ssh-key-button').unbind('click').click(function () { + location.reload(); + }); }) });