Move of API folder from /app/front/api to app/api

This commit is contained in:
jokob-sk
2024-12-08 19:17:10 +11:00
parent d7858c6042
commit f7160f0843
27 changed files with 115 additions and 75 deletions

View File

@@ -199,26 +199,31 @@ function getDevicesTotals() {
// Fetch data via AJAX
$.ajax({
url: '/api/table_devices_tiles.json?nocache=' + Date.now(),
type: "GET",
dataType: "json",
success: function(response) {
if (response && response.data) {
resultJSON = response.data[0]; // Assuming the structure {"data": [ ... ]}
// Save the result to cache
setCache("getDevicesTotals", JSON.stringify(resultJSON));
url: '/php/server/query_json.php',
type: "GET",
dataType: "json",
data: {
file: 'table_devices_tiles.json', // Pass the file parameter
nocache: Date.now() // Prevent caching with a timestamp
},
success: function(response) {
if (response && response.data) {
resultJSON = response.data[0]; // Assuming the structure {"data": [ ... ]}
// Save the result to cache
setCache("getDevicesTotals", JSON.stringify(resultJSON));
// Process the fetched data
processDeviceTotals(resultJSON);
} else {
console.error("Invalid response format from API");
// Process the fetched data
processDeviceTotals(resultJSON);
} else {
console.error("Invalid response format from API");
}
},
error: function(xhr, status, error) {
console.error("Failed to fetch devices data:", error);
}
},
error: function(xhr, status, error) {
console.error("Failed to fetch devices data:", error);
}
});
}