2019-07-02 09:44:32 +02:00
|
|
|
|
/*! Icinga Web 2 | (c) 2019 Icinga GmbH | GPLv2+ */
|
|
|
|
|
|
|
|
|
|
(function (Icinga, $) {
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2019-07-09 15:55:52 +02:00
|
|
|
|
const KEY_TTL = 7776000000; // 90 days (90×24×60×60×1000)
|
|
|
|
|
|
2019-07-02 09:44:32 +02:00
|
|
|
|
/**
|
|
|
|
|
* Icinga.Storage
|
|
|
|
|
*
|
|
|
|
|
* localStorage access
|
2019-07-04 10:21:50 +02:00
|
|
|
|
*
|
|
|
|
|
* @param {string} prefix
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*/
|
2019-07-04 10:21:50 +02:00
|
|
|
|
Icinga.Storage = function(prefix) {
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-04 10:21:50 +02:00
|
|
|
|
* Prefix to use for keys
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @type {string}
|
|
|
|
|
*/
|
2019-07-04 10:21:50 +02:00
|
|
|
|
this.prefix = prefix;
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Callbacks for storage events on particular keys
|
|
|
|
|
*
|
|
|
|
|
* @type {{function}}
|
|
|
|
|
*/
|
|
|
|
|
this.subscribers = {};
|
|
|
|
|
|
|
|
|
|
this.setup();
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-04 10:21:50 +02:00
|
|
|
|
/**
|
|
|
|
|
* Create a new storage with `behavior.<name>` as prefix
|
|
|
|
|
*
|
|
|
|
|
* @param {string} name
|
|
|
|
|
*
|
|
|
|
|
* @returns {Icinga.Storage}
|
|
|
|
|
*/
|
|
|
|
|
Icinga.Storage.BehaviorStorage = function(name) {
|
|
|
|
|
return new Icinga.Storage('behavior.' + name);
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-02 09:44:32 +02:00
|
|
|
|
Icinga.Storage.prototype = {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prefix the given key
|
|
|
|
|
*
|
|
|
|
|
* @param {string} key
|
2019-07-09 11:35:41 +02:00
|
|
|
|
*
|
2019-07-02 09:44:32 +02:00
|
|
|
|
* @returns {string}
|
|
|
|
|
*/
|
|
|
|
|
prefixKey: function(key) {
|
2019-07-04 10:21:50 +02:00
|
|
|
|
if (typeof this.prefix !== 'undefined') {
|
|
|
|
|
return this.prefix + '.' + key;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-02 09:44:32 +02:00
|
|
|
|
return key;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Store the given key-value pair
|
|
|
|
|
*
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {*} value
|
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
set: function(key, value) {
|
2019-07-08 13:26:32 +02:00
|
|
|
|
window.localStorage.setItem(this.prefixKey(key), JSON.stringify(value));
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get value for the given key
|
|
|
|
|
*
|
|
|
|
|
* @param {string} key
|
|
|
|
|
*
|
|
|
|
|
* @returns {*}
|
|
|
|
|
*/
|
|
|
|
|
get: function(key) {
|
2019-07-08 13:26:32 +02:00
|
|
|
|
return JSON.parse(window.localStorage.getItem(this.prefixKey(key)));
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove given key from storage
|
|
|
|
|
*
|
|
|
|
|
* @param {string} key
|
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
remove: function(key) {
|
2019-07-08 13:26:32 +02:00
|
|
|
|
window.localStorage.removeItem(this.prefixKey(key));
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Subscribe with a callback for events on a particular key
|
|
|
|
|
*
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {function} callback
|
2019-07-08 13:34:38 +02:00
|
|
|
|
* @param {object} context
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
2019-07-10 07:33:07 +02:00
|
|
|
|
onChange: function(key, callback, context) {
|
2019-07-08 13:34:38 +02:00
|
|
|
|
this.subscribers[this.prefixKey(key)] = [callback, context];
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pass storage events to subscribers
|
|
|
|
|
*
|
|
|
|
|
* @param {StorageEvent} event
|
|
|
|
|
*/
|
|
|
|
|
onStorage: function(event) {
|
|
|
|
|
if (typeof this.subscribers[event.key] !== 'undefined') {
|
2019-07-08 13:34:38 +02:00
|
|
|
|
var subscriber = this.subscribers[event.key];
|
|
|
|
|
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add the event listener
|
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
setup: function() {
|
|
|
|
|
window.addEventListener('storage', this.onStorage.bind(this));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove the event listener
|
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
destroy: function() {
|
|
|
|
|
window.removeEventListener('storage', this.onStorage.bind(this));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Icinga.Storage.StorageAwareMap
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Emits events `StorageAwareMapDelete` and `StorageAwareMapAdd` in case an update occurs in the storage.
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @param {object} items
|
2019-07-02 09:44:32 +02:00
|
|
|
|
* @constructor
|
|
|
|
|
*/
|
2019-07-09 11:35:41 +02:00
|
|
|
|
Icinga.Storage.StorageAwareMap = function(items) {
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Storage object
|
|
|
|
|
*
|
|
|
|
|
* @type {Icinga.Storage}
|
|
|
|
|
*/
|
|
|
|
|
this.storage = undefined;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Storage key
|
|
|
|
|
*
|
|
|
|
|
* @type {string}
|
|
|
|
|
*/
|
|
|
|
|
this.key = undefined;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* The internal (real) map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @type {Map<*>}
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*/
|
2019-07-09 11:35:41 +02:00
|
|
|
|
this.data = new Map();
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
|
|
|
|
// items is not passed directly because IE11 doesn't support constructor arguments
|
2019-07-09 11:35:41 +02:00
|
|
|
|
if (typeof items !== 'undefined' && !! items) {
|
|
|
|
|
Object.keys(items).forEach(function(key) {
|
|
|
|
|
this.data.set(key, items[key]);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
}, this);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Create a new StorageAwareMap for the given storage and key
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @param {Icinga.Storage} storage
|
|
|
|
|
* @param {string} key
|
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @returns {Icinga.Storage.StorageAwareMap}
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*/
|
2019-07-09 11:35:41 +02:00
|
|
|
|
Icinga.Storage.StorageAwareMap.withStorage = function(storage, key) {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
var items = storage.get(key);
|
|
|
|
|
if (typeof items !== 'undefined' && !! items) {
|
|
|
|
|
Object.keys(items).forEach(function(key) {
|
|
|
|
|
var value = items[key];
|
|
|
|
|
|
|
|
|
|
if (typeof value !== 'object' || typeof value['lastAccess'] === 'undefined') {
|
|
|
|
|
items[key] = {'value': value, 'lastAccess': Date.now()};
|
|
|
|
|
} else if (Date.now() - value['lastAccess'] > KEY_TTL) {
|
|
|
|
|
delete items[key];
|
|
|
|
|
}
|
|
|
|
|
}, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
storage.set(key, items);
|
|
|
|
|
return (new Icinga.Storage.StorageAwareMap(items).setStorage(storage, key));
|
2019-07-02 09:44:32 +02:00
|
|
|
|
};
|
|
|
|
|
|
2019-07-09 11:35:41 +02:00
|
|
|
|
Icinga.Storage.StorageAwareMap.prototype = {
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Bind this map to the given storage and key
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @param {Icinga.Storage} storage
|
|
|
|
|
* @param {string} key
|
|
|
|
|
*
|
|
|
|
|
* @returns {this}
|
|
|
|
|
*/
|
|
|
|
|
setStorage: function(storage, key) {
|
|
|
|
|
this.storage = storage;
|
|
|
|
|
this.key = key;
|
|
|
|
|
|
2019-07-10 07:33:07 +02:00
|
|
|
|
storage.onChange(key, this.onChange, this);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Return a boolean indicating this map got a storage
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
hasStorage: function() {
|
|
|
|
|
return typeof this.storage !== 'undefined' && typeof this.key !== 'undefined';
|
|
|
|
|
},
|
|
|
|
|
|
2019-07-09 15:55:52 +02:00
|
|
|
|
/**
|
|
|
|
|
* Update the storage
|
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
updateStorage: function() {
|
|
|
|
|
if (! this.hasStorage()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.size > 0) {
|
|
|
|
|
this.storage.set(this.key, this.toObject());
|
|
|
|
|
} else {
|
|
|
|
|
this.storage.remove(this.key);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-07-02 09:44:32 +02:00
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Update the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 15:55:52 +02:00
|
|
|
|
* @param {object} newValue
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*/
|
2019-07-10 07:51:48 +02:00
|
|
|
|
onChange: function(newValue) {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
// Check for deletions first. Uses keys() to iterate over a copy
|
2019-07-09 11:35:41 +02:00
|
|
|
|
this.keys().forEach(function (key) {
|
2019-07-10 07:51:48 +02:00
|
|
|
|
if (newValue === null || typeof newValue[key] === 'undefined') {
|
2019-07-10 07:52:21 +02:00
|
|
|
|
$(window).trigger('StorageAwareMapDelete', [key, this.data.get(key)['value']]);
|
2019-07-09 11:35:41 +02:00
|
|
|
|
this.data.delete(key);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
}
|
|
|
|
|
}, this);
|
|
|
|
|
|
2019-07-10 07:51:48 +02:00
|
|
|
|
if (newValue === null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-02 09:44:32 +02:00
|
|
|
|
// Now check for new entries
|
2019-07-09 11:35:41 +02:00
|
|
|
|
Object.keys(newValue).forEach(function(key) {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
var known = this.data.has(key);
|
|
|
|
|
// Always override any known value as we want to keep track of all `lastAccess` changes
|
|
|
|
|
this.data.set(key, newValue[key]);
|
|
|
|
|
|
|
|
|
|
if (! known) {
|
2019-07-10 07:52:21 +02:00
|
|
|
|
$(window).trigger('StorageAwareMapAdd', [key, newValue[key]['value']]);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
}
|
|
|
|
|
}, this);
|
|
|
|
|
},
|
|
|
|
|
|
2019-07-03 15:56:08 +02:00
|
|
|
|
/**
|
|
|
|
|
* Register an event handler to handle storage updates
|
|
|
|
|
*
|
2019-07-10 07:52:21 +02:00
|
|
|
|
* Available events are: add, delete. The handler receives the
|
|
|
|
|
* key and its value as second and third argument, respectively.
|
2019-07-03 15:56:08 +02:00
|
|
|
|
*
|
|
|
|
|
* @param {string} event
|
|
|
|
|
* @param {object} data
|
|
|
|
|
* @param {function} handler
|
|
|
|
|
*
|
|
|
|
|
* @returns {this}
|
|
|
|
|
*/
|
|
|
|
|
on: function(event, data, handler) {
|
|
|
|
|
$(window).on(
|
2019-07-09 11:35:41 +02:00
|
|
|
|
'StorageAwareMap' + event.charAt(0).toUpperCase() + event.slice(1),
|
2019-07-03 15:56:08 +02:00
|
|
|
|
data,
|
|
|
|
|
handler
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
|
2019-07-02 09:44:32 +02:00
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Return the number of key/value pairs in the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {number}
|
|
|
|
|
*/
|
|
|
|
|
get size() {
|
|
|
|
|
return this.data.size;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Set the value for the key in the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @param {string} key
|
2019-07-10 08:04:10 +02:00
|
|
|
|
* @param {*} value Default null
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {this}
|
|
|
|
|
*/
|
2019-07-09 11:35:41 +02:00
|
|
|
|
set: function(key, value) {
|
2019-07-10 08:04:10 +02:00
|
|
|
|
if (typeof value === 'undefined') {
|
|
|
|
|
value = null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.data.set(key, {'value': value, 'lastAccess': Date.now()});
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.updateStorage();
|
2019-07-02 09:44:32 +02:00
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Remove all key/value pairs from the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
clear: function() {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.data.clear();
|
|
|
|
|
this.updateStorage();
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Remove the given key from the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @param {string} key
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
2019-07-09 11:35:41 +02:00
|
|
|
|
delete: function(key) {
|
|
|
|
|
var retVal = this.data.delete(key);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.updateStorage();
|
2019-07-02 09:44:32 +02:00
|
|
|
|
return retVal;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Return a list of [key, value] pairs for every item in the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @returns {Array}
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*/
|
|
|
|
|
entries: function() {
|
2019-07-09 11:35:41 +02:00
|
|
|
|
var list = [];
|
|
|
|
|
|
|
|
|
|
if (this.size > 0) {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.data.forEach(function (value, key) {
|
|
|
|
|
list.push([key, value['value']]);
|
2019-07-09 11:35:41 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Execute a provided function once for each item in the map, in insertion order
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @param {function} callback
|
2019-07-09 15:55:52 +02:00
|
|
|
|
* @param {object} thisArg
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
2019-07-09 15:55:52 +02:00
|
|
|
|
forEach: function(callback, thisArg) {
|
|
|
|
|
if (typeof thisArg === 'undefined') {
|
|
|
|
|
thisArg = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.data.forEach(function(value, key) {
|
|
|
|
|
callback.call(thisArg, value['value'], key);
|
|
|
|
|
});
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Return the value associated to the key, or undefined if there is none
|
|
|
|
|
*
|
|
|
|
|
* @param {string} key
|
|
|
|
|
*
|
|
|
|
|
* @returns {*}
|
|
|
|
|
*/
|
|
|
|
|
get: function(key) {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
var value = this.data.get(key)['value'];
|
|
|
|
|
this.set(key, value); // Update `lastAccess`
|
|
|
|
|
|
|
|
|
|
return value;
|
2019-07-09 11:35:41 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a boolean asserting whether a value has been associated to the key in the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* @param {string} key
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
2019-07-09 11:35:41 +02:00
|
|
|
|
has: function(key) {
|
|
|
|
|
return this.data.has(key);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-09 11:35:41 +02:00
|
|
|
|
* Return an array of keys in the map
|
|
|
|
|
*
|
|
|
|
|
* @returns {Array}
|
|
|
|
|
*/
|
|
|
|
|
keys: function() {
|
|
|
|
|
var list = [];
|
|
|
|
|
|
|
|
|
|
if (this.size > 0) {
|
|
|
|
|
// .forEach() is used because IE11 doesn't support .keys()
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.data.forEach(function(_, key) {
|
2019-07-09 11:35:41 +02:00
|
|
|
|
list.push(key);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return an array of values in the map
|
2019-07-02 09:44:32 +02:00
|
|
|
|
*
|
|
|
|
|
* @returns {Array}
|
|
|
|
|
*/
|
|
|
|
|
values: function() {
|
|
|
|
|
var list = [];
|
|
|
|
|
|
|
|
|
|
if (this.size > 0) {
|
|
|
|
|
// .forEach() is used because IE11 doesn't support .values()
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.data.forEach(function(value) {
|
|
|
|
|
list.push(value['value']);
|
2019-07-02 09:44:32 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
2019-07-09 11:35:41 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return this map as simple object
|
|
|
|
|
*
|
|
|
|
|
* @returns {object}
|
|
|
|
|
*/
|
|
|
|
|
toObject: function() {
|
|
|
|
|
var obj = {};
|
|
|
|
|
|
|
|
|
|
if (this.size > 0) {
|
2019-07-09 15:55:52 +02:00
|
|
|
|
this.data.forEach(function (value, key) {
|
2019-07-09 11:35:41 +02:00
|
|
|
|
obj[key] = value;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return obj;
|
2019-07-02 09:44:32 +02:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}(Icinga, jQuery));
|