#11051 Add action to mark all notification as read
This commit is contained in:
parent
74c4b28fc5
commit
5f864d53a8
|
@ -539,6 +539,33 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
|
|||
element.style.display = "none"
|
||||
}
|
||||
|
||||
function notifications_clean_all() {
|
||||
let wrapper_inner = document.getElementById('notification-wrapper-inner');
|
||||
while (wrapper_inner.firstChild) {
|
||||
wrapper_inner.removeChild(wrapper_inner.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
function mark_all_notification_as_read() {
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page" : "godmode/setup/setup_notifications",
|
||||
"mark_all_notification_as_read" : 1
|
||||
},
|
||||
function (data, status) {
|
||||
notifications_clean_all();
|
||||
location.reload();
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.fail(function(xhr, textStatus, errorThrown){
|
||||
console.error(
|
||||
"Failed to mark al notification as read. Error: ",
|
||||
xhr.responseText
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function click_on_notification_toast(event) {
|
||||
var match = /notification-(.*)-id-([0-9]+)/.exec(event.target.id);
|
||||
if (!match) {
|
||||
|
|
|
@ -187,6 +187,27 @@ if (get_parameter('mark_notification_as_read', 0)) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('mark_all_notification_as_read', 0)) {
|
||||
$unread_messages = db_get_all_rows_sql('SELECT id_mensaje FROM tnotification_user WHERE utimestamp_read is NULL');
|
||||
|
||||
if ($unread_messages !== false) {
|
||||
foreach ($unread_messages as $messages) {
|
||||
messages_process_read($messages['id_mensaje']);
|
||||
}
|
||||
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
// If there is new messages, get the info.
|
||||
echo json_encode(
|
||||
['result' => $result]
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('get_notifications_dropdown', 0)) {
|
||||
echo notifications_print_dropdown();
|
||||
return;
|
||||
|
|
|
@ -169,6 +169,7 @@ class ConsoleSupervisor
|
|||
* NOTIF.PHP.DISABLE_FUNCTIONS
|
||||
* NOTIF.PHP.CHROMIUM
|
||||
* NOTIF.PHP.VERSION
|
||||
* NOTIF.PHP.VERSION.SUPPORT
|
||||
*/
|
||||
|
||||
$this->checkPHPSettings();
|
||||
|
@ -377,6 +378,7 @@ class ConsoleSupervisor
|
|||
* NOTIF.PHP.DISABLE_FUNCTIONS
|
||||
* NOTIF.PHP.CHROMIUM
|
||||
* NOTIF.PHP.VERSION
|
||||
* NOTIF.PHP.VERSION.SUPPORT
|
||||
*/
|
||||
|
||||
$this->checkPHPSettings();
|
||||
|
@ -853,6 +855,7 @@ class ConsoleSupervisor
|
|||
case 'NOTIF.PHP.DISABLE_FUNCTIONS':
|
||||
case 'NOTIF.PHP.CHROMIUM':
|
||||
case 'NOTIF.PHP.VERSION':
|
||||
case 'NOTIF.PHP.VERSION.SUPPORT':
|
||||
case 'NOTIF.HISTORYDB':
|
||||
case 'NOTIF.PANDORADB':
|
||||
case 'NOTIF.PANDORADB.HISTORICAL':
|
||||
|
@ -1807,14 +1810,14 @@ class ConsoleSupervisor
|
|||
$url = 'https://www.php.net/supported-versions.php';
|
||||
$this->notify(
|
||||
[
|
||||
'type' => 'NOTIF.PHP.VERSION',
|
||||
'type' => 'NOTIF.PHP.VERSION.SUPPORT',
|
||||
'title' => __('PHP UPDATE REQUIRED'),
|
||||
'message' => __('You should update your PHP version because it will be out of official support').'<br>'.__('Current PHP version: ').PHP_VERSION,
|
||||
'url' => $url,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->cleanNotifications('NOTIF.PHP.VERSION');
|
||||
$this->cleanNotifications('NOTIF.PHP.VERSION.SUPPORT');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2849,6 +2849,8 @@ function html_print_anchor(
|
|||
|
||||
$output .= '>';
|
||||
|
||||
$output .= (isset($options['text']) === true) ? $options['text'] : '';
|
||||
|
||||
$output .= (isset($options['content']) === true) ? io_safe_input_html($options['content']) : '';
|
||||
|
||||
$output .= '</a>';
|
||||
|
@ -6882,6 +6884,7 @@ function html_print_menu_button(array $options, bool $return=false)
|
|||
'class' => ($options['class'] ?? ''),
|
||||
'style' => ($options['style'] ?? ''),
|
||||
'onClick' => ($options['onClick'] ?? ''),
|
||||
'text' => ($options['text'] ?? ''),
|
||||
'content' => $content,
|
||||
],
|
||||
$return
|
||||
|
|
|
@ -136,6 +136,7 @@ function notifications_get_subtypes(?string $source=null)
|
|||
'NOTIF.PHP.DISABLE_FUNCTIONS',
|
||||
'NOTIF.PHP.CHROMIUM',
|
||||
'NOTIF.PHP.VERSION',
|
||||
'NOTIF.PHP.VERSION.SUPPORT',
|
||||
'NOTIF.HISTORYDB',
|
||||
'NOTIF.PANDORADB',
|
||||
'NOTIF.PANDORADB.HISTORICAL',
|
||||
|
@ -1025,9 +1026,20 @@ function notifications_print_dropdown()
|
|||
$mess = [];
|
||||
}
|
||||
|
||||
$notification_menu = html_print_menu_button(
|
||||
[
|
||||
'href' => 'javascript:',
|
||||
'class' => 'notification_menu_actions',
|
||||
'text' => __('Mark all as read'),
|
||||
'onClick' => 'mark_all_notification_as_read()',
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
"<div id='notification-wrapper'>
|
||||
<div id='notification-wrapper-inner'>
|
||||
<div class='menu_tab notification_menu'>%s</div>
|
||||
%s
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1037,6 +1049,7 @@ function notifications_print_dropdown()
|
|||
>
|
||||
</div>
|
||||
",
|
||||
$notification_menu,
|
||||
array_reduce(
|
||||
$mess,
|
||||
function ($carry, $message) {
|
||||
|
@ -1114,7 +1127,7 @@ function notifications_print_dropdown_element($message_info)
|
|||
</p>
|
||||
</div>
|
||||
</a>",
|
||||
$action.';click_on_notification_toast(event)',
|
||||
$action.'; click_on_notification_toast(event)',
|
||||
$message_info['id_mensaje'],
|
||||
messages_get_url($message_info['id_mensaje']),
|
||||
$target,
|
||||
|
|
|
@ -12289,3 +12289,8 @@ tr[id^="network_component-plugin-wmi-fields-dynamicMacroRow-"] input,
|
|||
tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.notification_menu {
|
||||
padding-top: 10px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue