Fixed http requests

fix
yuobrezkov 2024-10-22 17:45:56 +03:00
parent 0c3825cdde
commit 745788f336
6 changed files with 74 additions and 7 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

9
.idea/client.iml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,36 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HttpUrlsUsage" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredUrls">
<list>
<option value="http://${apiServer}" />
<option value="http://0.0.0.0" />
<option value="http://127.0.0.1" />
<option value="http://activemq.apache.org/schema/" />
<option value="http://cxf.apache.org/schemas/" />
<option value="http://java.sun.com/" />
<option value="http://javafx.com/fxml" />
<option value="http://javafx.com/javafx/" />
<option value="http://json-schema.org/draft" />
<option value="http://localhost" />
<option value="http://maven.apache.org/POM/" />
<option value="http://maven.apache.org/xsd/" />
<option value="http://primefaces.org/ui" />
<option value="http://schema.cloudfoundry.org/spring/" />
<option value="http://schemas.xmlsoap.org/" />
<option value="http://tiles.apache.org/" />
<option value="http://www.ibm.com/webservices/xsd" />
<option value="http://www.jboss.com/xml/ns/" />
<option value="http://www.jboss.org/j2ee/schema/" />
<option value="http://www.springframework.org/schema/" />
<option value="http://www.springframework.org/security/tags" />
<option value="http://www.springframework.org/tags" />
<option value="http://www.thymeleaf.org" />
<option value="http://www.w3.org/" />
<option value="http://xmlns.jcp.org/" />
</list>
</option>
</inspection_tool>
</profile>
</component>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/client.iml" filepath="$PROJECT_DIR$/.idea/client.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -175,20 +175,20 @@
var isConnected = false;
var apiIsAlive = false;
// TODO: change to valid url
var apiServer = "localhost"
var apiServer = "http://localhost:8080"
function hello_api() {
$.ajax({
type: "POST",
url: `${apiServer}/hello`,
data: "",
dataType: "json",
contentType: "application/json",
success: function(data){
success: function(status){
console.log(status)
ok_msg_conn("API-Server is running. Connection established");
apiIsAlive = true;
},
error: function(er){
error: function(er,status){
err_msg_conn(`API-Server unreachable. Error: ${JSON.stringify(er)}`);
}
});
@ -201,7 +201,7 @@
"ip_address": ip,
"port": port
}),
dataType: "json",
// dataType: "json",
contentType: "application/json",
success: function(data){
ok_msg_conn(`Successfully connected to PLD ${ip}:${port}`);
@ -228,7 +228,7 @@
},
"data" : data,
}),
dataType: "json",
// dataType: "json",
contentType: "application/json",
success: function(data){
ok_msg_conn(`Successfully sent data to ${address}`);
@ -273,7 +273,7 @@
}
const address = document.getElementById('address').value;
const data = document.getElementById('data').value;
const wrd = () => document.querySelector('input[type=radio]:checked')?.value === "rd";
const wrd = () => document.querySelector('input[type=radio]:checked')?.value === "wr";
const inc = document.querySelector('#inc').checked;
if (isConnected) {