Reload the client page after adding new client
This commit is contained in:
		
							parent
							
								
									6589b41cc1
								
							
						
					
					
						commit
						d72163cf6b
					
				| 
						 | 
					@ -246,19 +246,19 @@
 | 
				
			||||||
    <!-- AdminLTE App -->
 | 
					    <!-- AdminLTE App -->
 | 
				
			||||||
    <script src="static/dist/js/adminlte.min.js"></script>
 | 
					    <script src="static/dist/js/adminlte.min.js"></script>
 | 
				
			||||||
    <script>
 | 
					    <script>
 | 
				
			||||||
        // submitNewClient function for new client form submition
 | 
					        // submitNewClient function for new client form submission
 | 
				
			||||||
        function submitNewClient() {
 | 
					        function submitNewClient() {
 | 
				
			||||||
            var name = $("#client_name").val();
 | 
					            const name = $("#client_name").val();
 | 
				
			||||||
            var email = $("#client_email").val();
 | 
					            const email = $("#client_email").val();
 | 
				
			||||||
            var allocated_ips = $("#client_allocated_ips").val().split(",");
 | 
					            const allocated_ips = $("#client_allocated_ips").val().split(",");
 | 
				
			||||||
            var allowed_ips = $("#client_allowed_ips").val().split(",");
 | 
					            const allowed_ips = $("#client_allowed_ips").val().split(",");
 | 
				
			||||||
            var enabled = false;
 | 
					            let enabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($("#enabled").is(':checked')){
 | 
					            if ($("#enabled").is(':checked')){
 | 
				
			||||||
                enabled = true;
 | 
					                enabled = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var data = {"name": name, "email": email, "allocated_ips": allocated_ips, "allowed_ips": allowed_ips,
 | 
					            const data = {"name": name, "email": email, "allocated_ips": allocated_ips, "allowed_ips": allowed_ips,
 | 
				
			||||||
            "enabled": enabled};
 | 
					            "enabled": enabled};
 | 
				
			||||||
            console.log(data);
 | 
					            console.log(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -272,10 +272,13 @@
 | 
				
			||||||
                success: function(data) {
 | 
					                success: function(data) {
 | 
				
			||||||
                    $("#modal_new_client").modal('hide');
 | 
					                    $("#modal_new_client").modal('hide');
 | 
				
			||||||
                    toastr.success('Created new client successfully');
 | 
					                    toastr.success('Created new client successfully');
 | 
				
			||||||
                    // TODO: trigger reloading the dashboard
 | 
					                    // Refresh the home page (clients page) after adding successfully
 | 
				
			||||||
 | 
					                    if (window.location.pathname === "/") {
 | 
				
			||||||
 | 
					                        location.reload();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                error: function(jqXHR, exception) {
 | 
					                error: function(jqXHR, exception) {
 | 
				
			||||||
                    var responseJson = jQuery.parseJSON(jqXHR.responseText);
 | 
					                    const responseJson = jQuery.parseJSON(jqXHR.responseText);
 | 
				
			||||||
                    toastr.error(responseJson['message']);
 | 
					                    toastr.error(responseJson['message']);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
| 
						 | 
					@ -296,7 +299,7 @@
 | 
				
			||||||
                    })
 | 
					                    })
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                error: function(jqXHR, exception) {
 | 
					                error: function(jqXHR, exception) {
 | 
				
			||||||
                    var responseJson = jQuery.parseJSON(jqXHR.responseText);
 | 
					                    const responseJson = jQuery.parseJSON(jqXHR.responseText);
 | 
				
			||||||
                    toastr.error(responseJson['message']);
 | 
					                    toastr.error(responseJson['message']);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
| 
						 | 
					@ -392,7 +395,7 @@
 | 
				
			||||||
                        toastr.success('Applied config successfully');
 | 
					                        toastr.success('Applied config successfully');
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    error: function(jqXHR, exception) {
 | 
					                    error: function(jqXHR, exception) {
 | 
				
			||||||
                        var responseJson = jQuery.parseJSON(jqXHR.responseText);
 | 
					                        const responseJson = jQuery.parseJSON(jqXHR.responseText);
 | 
				
			||||||
                        toastr.error(responseJson['message']);
 | 
					                        toastr.error(responseJson['message']);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue