Source
xxxxxxxxxx
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* Represents DOM node for notification list. Stores the collection of ZBX_Notification objects.
*/
function ZBX_NotificationCollection() {
this._dangling_nodes = [];
this._list_sequence = [];
this._list_obj = {};
this.makeNodes();
this.node.style.right = '10px';
this.node.style.top = '0px';
}
/**
* @return {array}
*/
ZBX_NotificationCollection.prototype.getIds = function() {
return this._list_sequence;
};
/**
* @param {callable} callback
*/
ZBX_NotificationCollection.prototype.map = function(callback) {
var len = this._list_sequence.length;
while (--len > -1) {
callback(this.getById(this._list_sequence[len]), len);
}
};
/**
* @param {callable} callback
*
* @return {array}
*/
ZBX_NotificationCollection.prototype.filterList = function(callback) {
var list = [],
len = this._list_sequence.length;
while (--len > -1) {
var ret = callback(this.getById(this._list_sequence[len]));
(ret !== false) && list.push(ret);
}
return list;
};
/**
* @return {array} List of raw notification objects.
*/
ZBX_NotificationCollection.prototype.getRawList = function() {
return this.filterList(function(notif) {
return notif.getRaw();
});
};
/**
* Merges current with new list. Updates changes for ZBX_Notification if possible, or creates new ZBX_Notification.
* Recoverable notification is just partial of raw with one mandatory field - `eventid`. New iterator sequence reflects
* the order of list given to this method. During merge, nodes that are not present in list will be removed.
*
* @param {array} list List of raw/recoverable notification objects.
*/
ZBX_NotificationCollection.prototype.consumeList = function(list) {
var new_list_sequence = [];
while (raw = list.pop()) {
/*