Source
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* In case if user has set incredibly long notification timeout - they would end up never seeing them, because JS would
* execute scheduled timeout immediately. So limit the upper bound.
*/
ZBX_Notification.max_timeout = Math.pow(2, 30);
/**
* Represents notification object.
*
* @param {object} raw A server or LS format of this notification.
*/
function ZBX_Notification(raw) {
/*
* These are pseudo that properties will cycle back into store, to be reused when rendering next time.
* If `received_at` property has not been set it is first render. This property might be updated to a new client
* time when it's raw state changes from unresolved into resolved.
*/
this._raw = {
snoozed: false,
received_at: raw.received_at || (+new Date / 1000)
};
this.updateRaw(raw);
this.node = this.makeNode();
}
/**
* @return {string}
*/
ZBX_Notification.prototype.getId = function() {
return this._raw.eventid;
};
/**
* @return {object}
*/
ZBX_Notification.prototype.getRaw = function() {
return this._raw;
};
/**
* Merge another raw object into current. If resolution state changes into resolved during this merge, then
* raw object is assumed to be just received.
*
* @param {object} raw An object in format that is used in store. All keys are optional.
*
* @return {ZBX_Notification}