diff --git a/core/ajax/frigate.ajax.php b/core/ajax/frigate.ajax.php
index 848cb94c..d256d80f 100644
--- a/core/ajax/frigate.ajax.php
+++ b/core/ajax/frigate.ajax.php
@@ -173,6 +173,14 @@
ajax::success();
}
+ if (init('action') == 'frigateDebug') {
+ $data = frigate::showEvents(false, true);
+
+ ajax::success(array(
+ "object" => $data,
+ "json" => json_encode($data),
+ ));
+ }
throw new Exception(__('Aucune méthode correspondante à', __FILE__) . ' : ' . init('action'));
/* * *********Catch exeption*************** */
diff --git a/core/class/frigate.class.php b/core/class/frigate.class.php
index c1011ce1..92abbea2 100644
--- a/core/class/frigate.class.php
+++ b/core/class/frigate.class.php
@@ -302,7 +302,8 @@ public function postInsert() {}
public function preUpdate() {}
// Fonction exécutée automatiquement après la mise à jour de l'équipement
- public function postUpdate() {}
+ public function postUpdate() {
+ }
// Fonction exécutée automatiquement avant la sauvegarde (création ou mise à jour) de l'équipement
public function preSave()
@@ -1677,44 +1678,55 @@ public static function deleteEvent($id, $all = false)
log::add(__CLASS__, 'debug', "╚════════════════════════════════════════════════════════");
return "OK";
}
- public static function showEvents()
+ public static function showEvents(bool $_onlyEnable = FALSE, bool $_allType = FALSE)
{
$result = [];
- $events = frigate_events::all();
+
+ $events = frigate_events::all($_onlyEnable, $_allType);
foreach ($events as $event) {
$date = date("d-m-Y H:i:s", $event->getStartTime());
$duree = round($event->getEndTime() - $event->getStartTime(), 0);
- $box = $event->getBox();
- $boxArray = is_array($box) ? $box : json_decode($box, true);
$result[] = array(
- "id" => $event->getId(),
- "img" => $event->getLasted(),
- "camera" => $event->getCamera(),
- "label" => $event->getLabel(),
- "box" => $boxArray,
- "date" => $date,
- "duree" => $duree,
- "startTime" => $event->getStartTime(),
- "endTime" => $event->getEndTime(),
- "snapshot" => $event->getSnapshot(),
- "clip" => $event->getClip(),
- "thumbnail" => $event->getThumbnail(),
- "hasSnapshot" => $event->getHasSnapshot(),
- "hasClip" => $event->getHasClip(),
- "eventId" => $event->getEventId(),
- "score" => $event->getScore(),
- "top_score" => $event->getTopScore(),
- "type" => $event->getType(),
- "isFavorite" => $event->getIsFavorite() ?? 0,
- "zones" => $event->getZones() ?? '',
- "description" => $event->getRecognition_description()
+ "id" => $event->getId(),
+ "eventId" => $event->getEventId(),
+ "img" => $event->getLasted(),
+ "camera" => $event->getCamera(),
+ "label" => $event->getLabel(),
+ "subLabel" => $event->getSubLabel(),
+ "box" => json_decode($event->getBox(), true),
+ "date" => $date,
+ "duree" => $duree,
+ "startTime" => $event->getStartTime(),
+ "endTime" => $event->getEndTime(),
+ "falsePositive" => $event->getFalsePositive(),
+ "snapshot" => $event->getSnapshot(),
+ "clip" => $event->getClip(),
+ "thumbnail" => $event->getThumbnail(),
+ "hasSnapshot" => $event->getHasSnapshot(),
+ "hasClip" => $event->getHasClip(),
+ "score" => $event->getScore(),
+ "top_score" => $event->getTopScore(),
+ "plusId" => $event->getPlusId(),
+ "retain" => $event->getRetain(),
+ "type" => $event->getType(),
+ "isFavorite" => $event->getIsFavorite() ?? 0,
+ "zones" => $event->getZones() ?? '',
+ "data" => $event->getData(),
+ "recognition_type" => $event->getRecognition_type(),
+ "description" => $event->getRecognition_description(),
+ "recognition_name" => $event->getRecognition_name(),
+ "recognition_subname" => $event->getRecognition_subname(),
+ "recognition_attributes" => $event->getRecognition_attributes(),
+ "recognition_plate" => $event->getRecognition_plate(),
+ "recognition_score" => $event->getRecognition_score()
);
}
- usort($result, [self::class, 'orderByDate']);
-
+ if (!empty($result)) {
+ usort($result, 'frigate::orderByDate');
+ }
return $result;
}
diff --git a/core/class/frigate_events.class.php b/core/class/frigate_events.class.php
index 6fa972a6..b4d070c5 100644
--- a/core/class/frigate_events.class.php
+++ b/core/class/frigate_events.class.php
@@ -57,14 +57,26 @@ class frigate_events
/**
* @throws Exception
*/
- public static function all(bool $_onlyEnable = FALSE)
+ public static function all(bool $_onlyEnable = FALSE, bool $_allType = FALSE)
{
- $sql = 'SELECT ' . DB::buildField(__CLASS__) . '
- FROM frigate_events
- WHERE type IS NOT NULL';
+ $sql = 'SELECT ' . DB::buildField(__CLASS__) . ' FROM frigate_events';
+ $where = [];
+
+ if (!$_allType) {
+ $where[] = 'type IS NOT NULL';
+ }
+ if ($_onlyEnable) {
+ $where[] = 'enabled = 1';
+ }
+ if (!empty($where)) {
+ $sql .= ' WHERE ' . implode(' AND ', $where);
+ }
+
return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
}
+
+
/**
* @throws Exception
*/
diff --git a/desktop/js/frigate.js b/desktop/js/frigate.js
index d643b026..61436b44 100644
--- a/desktop/js/frigate.js
+++ b/desktop/js/frigate.js
@@ -690,6 +690,31 @@ document.getElementById('addCmdHttp').addEventListener('click', function () {
})
});
+document.getElementById('frigateDebug').addEventListener('click', function () {
+ domUtils.ajax({
+ type: "POST",
+ url: "plugins/frigate/core/ajax/frigate.ajax.php",
+ data: {
+ action: "frigateDebug",
+ data: { function: "getAllEvents" }
+ },
+ dataType: 'json',
+ error: function (error) {
+ jeedomUtils.showAlert({
+ message: error.message,
+ level: 'danger'
+ });
+ },
+ success: function (data) {
+ var json = data.result.json;
+ const blob = new Blob([json], {
+ type: "text/plain;charset=utf-8"
+ });
+ saveAs(blob, "getAllEvents.json.txt");
+ }
+ })
+});
+
function editHTTP(cmd) {
var id = cmd.id; // Récupère l'id
var data = cmd.getAttribute('data-request'); // Récupère la valeur de data-request
diff --git a/desktop/php/frigate.php b/desktop/php/frigate.php
index 229f7da6..9226e5ae 100644
--- a/desktop/php/frigate.php
+++ b/desktop/php/frigate.php
@@ -67,6 +67,11 @@
{{Logs Frigate}}
+