Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/ajax/mobile.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
}
ajax::success($return);
}

if (init('action') == 'getNotificationsV2') {
$return = '';
$iq = init('iq');
$mobile = eqLogic::byLogicalId($iq, 'mobile');
if (is_object($mobile)) {
$return = mobile::getNotificationsV2($iq);
}
ajax::success($return);
}

if (init('action') == 'removeNotificationV2') {
ajax::success(mobile::removeNotificationV2(init('iq', ''), init('id', '')));
}

// APP V1

Expand Down
56 changes: 54 additions & 2 deletions core/class/mobile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class mobile extends eqLogic

/* * ***********************Methode static*************************** */

/**
* Core callback to returns the directory of data not to be saved in the Jeedom backup
*
* @return array
*/
public static function backupExclude()
{
return ['data'];
}

public static function cronDaily()
{
foreach (eqLogic::byType('mobile') as $mobile) {
Expand Down Expand Up @@ -1002,6 +1012,48 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif
log::add('mobile', 'debug', '|└────────────────────');
}

/**
* Get all notifications from Iq
* Call by ajax getNotificationsV2
* @return array
*/
public static function getNotificationsV2($Iq)
{
$return = __('Aucune notification.', __FILE__);
$filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json';
if (file_exists($filePath)) {
$notifs = json_decode(file_get_contents($filePath), true);
if (is_array($notifs) && count($notifs) > 0) $return = json_encode(array_reverse($notifs));
}
return $return;
}

/**
* remove notification from Id into filepath id
* Call by ajax removeNotificationV2
*/
public static function removeNotificationV2($_iq, $_id)
{
$pathNotificationData = '/../data/notifications';
$filePath = dirname(__FILE__) . $pathNotificationData . '/' . $_iq . '.json';
if (file_exists($filePath)) {
$notificationsContent = file_get_contents($filePath);
$notifications = json_decode($notificationsContent, true);
if ($notifications === null) {
throw new Exception(__('Fichier de notification vide !.', __FILE__));
}
if (isset($notifications[$_id])) {
unset($notifications[$_id]);
file_put_contents($filePath, json_encode($notifications));
return count($notifications);
} else {
throw new Exception(__('Id notification introuvable :', __FILE__) . ' ' . $_id);
}
} else {
throw new Exception(__('Fichier de notifications non trouvé : ', __FILE__) . $filePath);
}
}

/**
* Create and update cmd geoloc
* Call By api : setConfigs
Expand Down Expand Up @@ -1841,7 +1893,7 @@ public function execute($_options = array())
$askParams = json_decode($notif['data']['askParams'], true);
$notifTime = strtotime($notif['data']['date']);
$currentTime = time();
$timeout = $askParams['timeout'] / 1000;
$timeout = (isset($askParams['timeout'])) ? $askParams['timeout'] / 1000 : 0;
return $notif['data']['askVariable'] == 'rien' || ($currentTime - $notifTime) < $timeout;
});
file_put_contents($filePath, json_encode($notifs));
Expand All @@ -1850,7 +1902,7 @@ public function execute($_options = array())
case 3:
$notifs = json_decode(file_get_contents($filePath), true);
$notifs = array_filter($notifs, function ($notif) {
return $notif['data']['choiceAsk'] == '';
return !isset($notif['data']['choiceAsk']) || $notif['data']['choiceAsk'] == '';
});
file_put_contents($filePath, json_encode($notifs));
log::add('mobile', 'info', '| Suppression des asks répondus effectuée');
Expand Down
129 changes: 129 additions & 0 deletions desktop/css/notification.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
.notification-box {
padding: 32px;
}

.notification-step {
display: flex;
margin-bottom: 32px;
position: relative;
}

.notification-step:last-child {
margin-bottom: 0px;
}

.notification-line {
position: absolute;
left: 114px;
top: 40px;
bottom: -32px;
width: 2px;
background-color: var(--logo-primary-color);
z-index: 1;
}

.notification-date {
display: flex;
height: 40px;
align-items: center;
margin-right: 16px;
width: 79px;
font-size: 12px;
padding: 5px;
text-align: center;
border-radius: var(--border-radius) var(--border-radius) var(--border-radius) var(--border-radius) !important;
background-color: var(--form-bg-color);
/* z-index: 1;*/
}

.notification-step:last-child .notification-line {
display: none;
}

.notification-circle {
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16px;
background-color: var(--form-bg-color);
border: 2px solid var(--txt-color);
z-index: 2;
}

.ask-timeout .notification-circle {
color: var(--linkHoverLight-color) !important;
background-color: var(--al-info-color) !important;
border: none;
}

.ask-success .notification-circle {
color: var(--linkHoverLight-color) !important;
background-color: var(--al-success-color) !important;
border: none;
}

.ask-in-progress .notification-circle {
color: var(--linkHoverLight-color) !important;
background-color: var(--al-warning-color) !important;
border: none;
}

.stepper-critical .notification-circle {
border: 1px solid red;
}

.notification-content {
flex: 1;
padding: 10px;
border-radius: var(--border-radius) var(--border-radius) var(--border-radius) var(--border-radius);
background-color: var(--form-bg-color);
}

.notification-img {
margin-top: 10px;
}

.notification-img img {
max-width: 250px;
}

.notification-title {
font-weight: 600;
margin-bottom: 4px;
font-size: 18px;
}

.notification-status {
font-size: 13px;
display: inline-block;
padding: 2px 8px;
border-radius: 12px;
margin-top: 4px;
}

.ask-success .notification-status {
color: var(--linkHoverLight-color) !important;
background-color: var(--al-success-color) !important;
border: none;
}

.ask-timeout .notification-status {
color: var(--linkHoverLight-color) !important;
background-color: var(--al-info-color) !important;
border: none;
}

.ask-in-progress .notification-status {
color: var(--linkHoverLight-color) !important;
background-color: var(--al-warning-color) !important;
border: none;
}

.notification-button {
display: flex;
margin-bottom: 32px;
justify-content: end;
}
Loading