214 lines
6.5 KiB
HTML
214 lines
6.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<title>Redis Caching UI</title>
|
|
<style>
|
|
h1 {
|
|
text-align: left;
|
|
color: #333;
|
|
font-size: 24px;
|
|
margin-bottom: 10px;
|
|
padding-left: 20px; /* Add padding to move the title to the left */
|
|
}
|
|
/* Style for buttons */
|
|
button {
|
|
padding: 10px 20px;
|
|
margin: 10px;
|
|
background-color: #007bff;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s ease;
|
|
float: right; /* Float the button to the right */
|
|
}
|
|
|
|
button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
button:disabled {
|
|
background-color: #2666ab;
|
|
cursor: not-allowed;
|
|
}
|
|
/* Style for checkboxes and label */
|
|
label {
|
|
display: block;
|
|
margin: 3px 0;
|
|
font-size: 16px;
|
|
padding-left: 20px; /* Add padding to move the title to the left */
|
|
}
|
|
|
|
.tableCheckbox {
|
|
margin-right: 5px;
|
|
}
|
|
|
|
/* Style for the container holding checkboxes */
|
|
.checkbox-container {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
margin: 10px;
|
|
}
|
|
|
|
/* Style for alerts */
|
|
.alert {
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
margin: 10px;
|
|
}
|
|
.alert-success {
|
|
background-color: #4caf50;
|
|
color: #fff;
|
|
}
|
|
.alert-error {
|
|
background-color: #f44336;
|
|
color: #fff;
|
|
}
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background-color: #f0f0f0;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.boxDiv {
|
|
background-color: #fff;
|
|
padding: 20px;
|
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
|
|
}
|
|
.tableCheckbox {
|
|
margin-right: 10px;
|
|
}
|
|
.spinner {
|
|
border: 4px solid rgba(255, 255, 255, 0.3);
|
|
border-top: 4px solid #007bff;
|
|
border-radius: 50%;
|
|
width: 8px;
|
|
height: 8px;
|
|
animation: spin 1s linear infinite;
|
|
display: none; /* Initially hidden */
|
|
margin-left: 10px;
|
|
}
|
|
|
|
/* Style for the Clear All Cache button with spinner */
|
|
#clearAllButton {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
/* Style for the Cache Selected Tables button with spinner */
|
|
#cacheButton {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
/* Keyframes animation for the spinner */
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="boxDiv">
|
|
<div style="display: flex; justify-content: space-between">
|
|
<h1>Redis Caching UI</h1>
|
|
<button id="cacheButton">
|
|
Cache
|
|
<span class="spinner"></span>
|
|
</button>
|
|
</div>
|
|
<label>Select Tables:</label>
|
|
<!-- <button id="cacheButton">
|
|
Cache
|
|
<span class="spinner"></span>
|
|
</button> -->
|
|
<div class="checkbox-container boxDiv">
|
|
<!-- Add a "Select All" checkbox -->
|
|
<div class="boxDiv"><input id="selectAllCheckbox" type="checkbox" class="tableCheckbox" /> Select All</div>
|
|
<div class="boxdiv">
|
|
<div class="boxDiv">
|
|
<input type="checkbox" class="tableCheckbox" value="EntityRequestMapping" /> EntityRequestMapping
|
|
</div>
|
|
<div class="boxDiv">
|
|
<input type="checkbox" class="tableCheckbox" value="RoleAuthorityOwnerShipView" />
|
|
RoleAuthorityOwnerShipView
|
|
</div>
|
|
<div class="boxDiv">
|
|
<input type="checkbox" class="tableCheckbox" value="RoleAuthorityView" /> RoleAuthorityView
|
|
</div>
|
|
<div class="boxDiv"><input type="checkbox" class="tableCheckbox" value="LTCaptions" /> LTCaptions</div>
|
|
</div>
|
|
|
|
<!-- Add more checkboxes for additional tables as needed -->
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const cacheButton = document.getElementById('cacheButton');
|
|
const tableCheckboxes = document.querySelectorAll('.tableCheckbox');
|
|
const selectAllCheckbox = document.getElementById('selectAllCheckbox');
|
|
const spinner = document.querySelectorAll('.spinner'); // Select all spinners
|
|
const backendurl = 'http://';
|
|
|
|
// Add a click event listener to the "Select All" checkbox
|
|
selectAllCheckbox.addEventListener('click', () => {
|
|
const isChecked = selectAllCheckbox.checked;
|
|
|
|
// Set the checked state of all table checkboxes to match the "Select All" checkbox
|
|
tableCheckboxes.forEach((checkbox) => {
|
|
checkbox.checked = isChecked;
|
|
});
|
|
});
|
|
|
|
cacheButton.addEventListener('click', async () => {
|
|
const selectedTables = Array.from(tableCheckboxes)
|
|
.filter((checkbox) => checkbox.checked && checkbox.value !== 'on')
|
|
.map((checkbox) => checkbox.value);
|
|
|
|
if (selectedTables.length === 0) {
|
|
Swal.fire('Warning', 'Please select at least one table to cache.', 'warning');
|
|
return;
|
|
}
|
|
|
|
// Disable the cache button and show the spinner
|
|
cacheButton.disabled = true;
|
|
spinner[0].style.display = 'inline-block'; // Display the spinner
|
|
|
|
try {
|
|
const response = await fetch(`${backendurl}/api/caching`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(selectedTables),
|
|
});
|
|
|
|
if (response.status === 200) {
|
|
Swal.fire('Success', 'Tables cached successfully!', 'success');
|
|
//uncheck all checkboxes
|
|
tableCheckboxes.forEach((checkbox) => {
|
|
checkbox.checked = false;
|
|
});
|
|
} else {
|
|
Swal.fire('Error', `Error: Status Code ${response.status}`, 'error');
|
|
}
|
|
} catch (error) {
|
|
Swal.fire('Error', 'Error: ' + error.message, 'error');
|
|
} finally {
|
|
// Re-enable the cache button and hide the spinner
|
|
cacheButton.disabled = false;
|
|
spinner[0].style.display = 'none';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|