85 lines
1.7 KiB
JavaScript
85 lines
1.7 KiB
JavaScript
/**
|
|
* R3.Query.Devices.Known
|
|
* @param apiComponent
|
|
* @constructor
|
|
*/
|
|
R3.Query.Devices.Known = function(
|
|
apiComponent
|
|
) {
|
|
|
|
__RUNTIME_COMPONENT__;
|
|
|
|
R3.Query.Devices.call(
|
|
this,
|
|
apiComponent,
|
|
true
|
|
);
|
|
|
|
};
|
|
|
|
R3.Query.Devices.Known.prototype = Object.create(R3.Query.Devices.prototype);
|
|
R3.Query.Devices.Known.prototype.constructor = R3.Query.Devices.Known;
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.Query.Devices.Known.prototype.createInstance = function() {
|
|
|
|
this.instance = true;
|
|
|
|
__CREATE_INSTANCE__;
|
|
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.Query.Devices.Known.prototype.updateInstance = function(property) {
|
|
|
|
R3.Query.Devices.prototype.updateInstance.call(this, property);
|
|
|
|
};
|
|
|
|
R3.Query.Devices.Known.prototype.parse = function(data) {
|
|
|
|
this.columns = [
|
|
{
|
|
type: 'string',
|
|
name: 'Hostname'
|
|
},
|
|
{
|
|
type: 'string',
|
|
name: 'IP'
|
|
},
|
|
{
|
|
type: 'string',
|
|
name: 'MAC Address'
|
|
},
|
|
{
|
|
type: 'datetime',
|
|
name: 'Detected'
|
|
},
|
|
];
|
|
|
|
if (data.error) {
|
|
this.rows = [
|
|
['error', null, null, null]
|
|
]
|
|
} else {
|
|
this.rows = data.hits.hits.reduce(
|
|
function (result, hit) {
|
|
var row = [
|
|
hit._source.hostname,
|
|
hit._source.ip_v4,
|
|
hit._source.mac_address,
|
|
new Date(hit._source.timestamp)
|
|
];
|
|
result.push(row);
|
|
return result;
|
|
},
|
|
[]
|
|
);
|
|
}
|
|
|
|
};
|