mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
🆕 db locked icon #685
This commit is contained in:
@@ -144,6 +144,17 @@
|
||||
{
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
.header-status-locked-db
|
||||
{
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
color: red;
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: -17px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navbar-nav > li > a
|
||||
{
|
||||
line-height: 30px;
|
||||
|
||||
@@ -628,7 +628,7 @@
|
||||
<script src="lib/AdminLTE/bower_components/fullcalendar/dist/locale-all.js"></script>
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
|
||||
<script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
|
||||
<!-- Dark-Mode Patch -->
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// General utilities to interact with teh database
|
||||
// General utilities to interact with the database
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
// Read data and place intotarget location, callback processies the results
|
||||
function readData(sqlQuery, processDataCallback, valuesArray, targetLocation, targetField, nameTransformer) {
|
||||
var apiUrl = `php/server/dbHelper.php?action=read&rawSql=${encodeURIComponent(sqlQuery)}`;
|
||||
@@ -15,4 +17,31 @@ function readData(sqlQuery, processDataCallback, valuesArray, targetLocation, ta
|
||||
// Place the resulting HTML into the specified placeholder div
|
||||
$("#" + targetLocation).replaceWith(htmlResult);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// Check if database is locked
|
||||
function checkDbLock() {
|
||||
$.ajax({
|
||||
url: 'php/server/dbHelper.php', // Replace with the actual path to your PHP file
|
||||
type: 'GET',
|
||||
data: { action: 'checkLock' },
|
||||
success: function(response) {
|
||||
if (response == 1) {
|
||||
console.log('🟥 Database is locked');
|
||||
$(".header-status-locked-db").show()
|
||||
} else {
|
||||
// console.log('Database is not locked');
|
||||
$(".header-status-locked-db").hide()
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
console.log('Error checking database lock status');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Start the loop
|
||||
setInterval(() => {
|
||||
checkDbLock();
|
||||
}, 1000);
|
||||
|
||||
@@ -326,7 +326,6 @@ getData();
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
|
||||
<script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
case 'read' : read($rawSql); break;
|
||||
case 'update': update($columnName, $id, $defaultValue, $expireMinutes, $dbtable, $columns, $values); break;
|
||||
case 'delete': delete($columnName, $id, $dbtable); break;
|
||||
case 'checkLock': checkLock(); break;
|
||||
default: logServerConsole ('Action: '. $action); break;
|
||||
}
|
||||
}
|
||||
@@ -264,4 +265,20 @@ function delete($columnName, $id, $dbtable)
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// check if the database is locked
|
||||
//------------------------------------------------------------------------------
|
||||
function checkLock() {
|
||||
global $db;
|
||||
try {
|
||||
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
||||
$db->exec('COMMIT');
|
||||
echo 0; // Not locked
|
||||
return 0;
|
||||
} catch (Exception $e) {
|
||||
echo 1; // Locked
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<!-- NetAlertX -->
|
||||
<script src="js/handle_version.js"></script>
|
||||
<script src="js/ui_components.js?v=<?php include 'php/templates/version.php'; ?>"></script>
|
||||
<script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
|
||||
|
||||
<!-- Select2 JavaScript -->
|
||||
<script src="lib/AdminLTE/bower_components/select2/dist/js/select2.full.min.js" defer></script>
|
||||
|
||||
@@ -57,12 +57,6 @@ require dirname(__FILE__).'/security.php';
|
||||
<!-- NetAlertX CSS -->
|
||||
<link rel="stylesheet" href="css/app.css">
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<!-- Google Font -->
|
||||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic"> -->
|
||||
@@ -173,6 +167,9 @@ if ($ENABLED_DARKMODE === True) {
|
||||
<div class="header-status">
|
||||
<code id="state"></code>
|
||||
</div>
|
||||
<div class="header-status-locked-db">
|
||||
<i class="fa-solid fa-database fa-fade"></i>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<!-- Server Name -->
|
||||
|
||||
@@ -54,7 +54,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
<!-- Page ------------------------------------------------------------------ -->
|
||||
|
||||
<script src="js/settings_utils.js?v=<?php include 'php/templates/version.php'; ?>"></script>
|
||||
<script src="js/db_methods.js?v=<?php include 'php/templates/version.php'; ?>"></script>
|
||||
|
||||
<script src="lib/crypto/crypto-js.min.js"></script>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user