Skip to content

Commit

Permalink
5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Nov 16, 2024
1 parent 250de7e commit ae0f7cd
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 212 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
A web responsive interface to manage <a href="https://motion-project.github.io/"><b>motion</b></a> (an open-source motion detection software) and visualize cameras live stream.

<div align="center">
<img src="https://github.com/user-attachments/assets/870aef98-5e5c-42e0-8387-261f6981561e" width=25% align="top">
<img src="https://github.com/user-attachments/assets/76b7150b-6439-445d-815f-e899563dacbd" width=25% align="top">
<img src="https://github.com/user-attachments/assets/26cbd47b-d2c4-483d-8b37-857018876df7" width=25% align="top">
<img src="https://github.com/user-attachments/assets/bdae2550-819d-40c4-895b-541ee64bdc03" width=25% align="top">
&nbsp;
<img src="https://github.com/user-attachments/assets/afe3e48a-3a26-4e75-a6a7-a97b2ac2bf9e" width=25% align="top">
&nbsp;
<img src="https://github.com/user-attachments/assets/a2472f8b-24fc-4967-bb6a-f8ad8af95270" width=25% align="top">
</div>
<br>
<div align="center">
<img src="https://github.com/user-attachments/assets/93d00121-defb-42ae-b655-83ef339eee0b" width=25% align="top">
<img src="https://github.com/user-attachments/assets/a8e596cc-e5f5-4123-bae4-d94f3ba7de1d" width=25% align="top">
<img src="https://github.com/user-attachments/assets/50509fd8-6af0-46e4-be29-0592b43cc306" width=25% align="top">
<img src="https://github.com/user-attachments/assets/cb9137c7-484a-4c2c-ad0f-c33ef7a602bd" width=25% align="top">
&nbsp;
<img src="https://github.com/user-attachments/assets/81c05e3f-599d-4cc1-9d9a-9748fce54763" width=25% align="top">
&nbsp;
<img src="https://github.com/user-attachments/assets/04b18116-2af0-4bd3-8438-e9f1fed8c7ed" width=25% align="top">
</div>

<br>
Expand Down
6 changes: 6 additions & 0 deletions android/motionUI/.idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

188 changes: 118 additions & 70 deletions www/public/resources/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,102 +32,150 @@ function closePanel(name = null)
}

/**
* Print alert or error message
* @param {string} message
* @param {string} type
* @param {int} timeout
* Print an alert
* @param {*} message
* @param {*} type
* @param {*} timeout
*/
function printAlert(message, type = null, timeout = 2500)
function printAlert(message, type = null, timeout = 3000)
{
$('#newalert').remove();
if (type == null) {
var alertType = 'alert';
var icon = 'info';
}

if (type == "error") {
$('footer').append('<div id="newalert" class="alert-error"><div>' + message + '</div></div>');
if (type == 'success') {
var alertType = 'alert-success';
var icon = 'check';
}
if (type == "success") {
$('footer').append('<div id="newalert" class="alert-success"><div>' + message + '</div></div>');

if (type == 'error') {
var alertType = 'alert-error';
var icon = 'error';
timeout = 4000;
}

// Remove any existing alert
$('#alert').remove();

$('footer').append(' \
<div id="alert" class="' + alertType + '"> \
<div class="flex align-item-center column-gap-8 padding-left-15 padding-right-15"> \
<img src="/assets/icons/' + icon + '.svg" class="icon" /> \
<div> \
<p>' + message + '</p> \
</div> \
</div> \
</div>');

$('#alert').css({
visibility: 'visible'
}).promise().done(function () {
$('#alert').animate({
right: '0'
}, 150)
})

if (timeout != 'none') {
window.setTimeout(function () {
$('#newalert').fadeTo(1000, 0).slideUp(1000, function () {
$('#newalert').remove();
});
closeAlert();
}, timeout);
}
}

/**
* Print a confirm alert box before executing specified function
* Print a confirm box
* @param {*} message
* @param {*} myfunction1
* @param {*} confirmBox1
* @param {*} confirmBoxFunction1
* @param {*} confirmBtn1
* @param {*} confirmBoxFunction2
* @param {*} confirmBtn2
*/
function confirmBox(message, myfunction1, confirmBox1 = 'Delete', myfunction2 = null, confirmBox2 = null)
function confirmBox(message = '', confirmBoxFunction1, confirmBtn1 = 'Delete', confirmBoxFunction2 = null, confirmBtn2 = null)
{
/**
* First, delete all active confirm box if any
*/
$("#newConfirmAlert").remove();
// Remove any existing confirm box
$("#confirm-box").remove();

/**
* Case there is three choices
*/
if (myfunction2 != null && confirmBox2 != null) {
var $content = '<div id="newConfirmAlert" class="confirmAlert"><span></span><span>' + message + '</span><div class="confirmAlert-buttons-container"><span class="pointer btn-doConfirm1">' + confirmBox1 + '</span><span class="pointer btn-doConfirm2">' + confirmBox2 + '</span><span class="pointer btn-doCancel">Cancel</span></div></div>';
/**
* Case there is two choices
*/
} else {
var $content = '<div id="newConfirmAlert" class="confirmAlert"><span></span><span>' + message + '</span><div class="confirmAlert-buttons-container"><span class="pointer btn-doConfirm1">' + confirmBox1 + '</span><span class="pointer btn-doCancel">Cancel</span></div></div>';
// Base html
var html = '<div id="confirm-box" class="confirm-box"><div class="flex flex-direction-column row-gap-10 padding-left-15 padding-right-15">'

// If there is a message
if (message != "") {
html += '<p class="wordbreakall">' + message + '</p>';
}

$('footer').append($content);
// Container for buttons
html += '<div class="flex flex-wrap column-gap-15 row-gap-10">';

/**
* If choice one is clicked
*/
$('.btn-doConfirm1').click(function () {
/**
* Execute function 1
*/
myfunction1();
// First function and button
html += '<div class="confirm-box-btn1 btn-small-red pointer">' + confirmBtn1 + '</div>';

/**
* Then remove alert
*/
$("#newConfirmAlert").slideToggle(0, function () {
$("#newConfirmAlert").remove();
});
// Second function and button
if (confirmBoxFunction2 != null && confirmBtn2 != null) {
html += '<div class="confirm-box-btn2 btn-small-blue pointer">' + confirmBtn2 + '</div>';
}

// Cancel button
html += '<div class="confirm-box-cancel-btn btn-small-blue pointer">Cancel</div>';

html += '</div>'

// Close base html
html += '</div></div>'

// Append html to footer
$('footer').append(html);

// Show confirm box
$('#confirm-box').css({
visibility: 'visible'
}).promise().done(function () {
$('#confirm-box').animate({
right: '0'
}, 150)
})

// If choice one is clicked
$('.confirm-box-btn1').click(function () {
// Execute function 1
confirmBoxFunction1();
closeConfirmBox();
});

/**
* If choice two is clicked
*/
$('.btn-doConfirm2').click(function () {
/**
* Execute function 2
*/
myfunction2();
// If choice two is clicked
$('.confirm-box-btn2').click(function () {
// Execute function 2
confirmBoxFunction2();
closeConfirmBox();
});

/**
* Then remove alert
*/
$("#newConfirmAlert").slideToggle(0, function () {
$("#newConfirmAlert").remove();
});
// If 'cancel' choice is clicked
$('.confirm-box-cancel-btn').click(function () {
closeConfirmBox();
});
}

/**
* If 'cancel' choice is clicked
*/
$('.btn-doCancel').click(function () {
/**
* Remove alert
*/
$("#newConfirmAlert").slideToggle(0, function () {
$("#newConfirmAlert").remove();
});
/**
* Close alert and confirm box modal
*/
function closeAlert()
{
$('#alert').animate({
right: '-1000px'
}, 150).promise().done(function () {
$('#alert').remove();
});
}

/**
* Close confirm box
*/
function closeConfirmBox()
{
$('#confirm-box').animate({
right: '-1000px'
}, 150).promise().done(function () {
$('#confirm-box').remove();
});
}

Expand Down
54 changes: 23 additions & 31 deletions www/public/resources/js/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ $(document).ready(function () {
/**
* Reload top and bottoms buttons to reload CPU load and unseen events total count
*/
setInterval(function () {
reloadContainer('buttons/top');
}, 5000);
// setInterval(function () {
// reloadContainer('buttons/top');
// }, 5000);
});

/**
Expand All @@ -17,6 +17,8 @@ $(document).ready(function () {
$(document).keyup(function (e) {
if (e.key === "Escape") {
closePanel();
closeAlert();
closeConfirmBox();
}
});

Expand All @@ -42,7 +44,24 @@ $(document).on('click','.slide-panel-close-btn',function () {
$(document).on('click','.acquit-log-btn',function () {
var id = $(this).attr('log-id');

acquitLog(id);
$.ajax({
type: "POST",
url: "ajax/controller.php",
data: {
controller: "general",
action: "acquitLog",
id: id
},
dataType: "json",
success: function (data, textStatus, jqXHR) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
reloadContainer('header/general-log-messages');
},
error : function (jqXHR, textStatus, thrownError) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
printAlert(jsonValue.message, 'error');
},
});
});

/**
Expand Down Expand Up @@ -103,33 +122,6 @@ function reloadOpenedClosedElements()
});
}

/**
* Ajax: Mark log as read
* @param {string} id
*/
function acquitLog(id)
{
$.ajax({
type: "POST",
url: "ajax/controller.php",
data: {
controller: "general",
action: "acquitLog",
id: id
},
dataType: "json",
success: function (data, textStatus, jqXHR) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
reloadContainer('header/general-log-messages');
},
error : function (jqXHR, textStatus, thrownError) {
jsonValue = jQuery.parseJSON(jqXHR.responseText);
printAlert(jsonValue.message, 'error');
},
});
}


/**
* Ajax: Get all containers state and reload them if needed
*/
Expand Down
Loading

0 comments on commit ae0f7cd

Please sign in to comment.