class NetworkComparisonHandler {
constructor({apNetwork, otherNetwork, sharedItems}) {
this.sharedItems = sharedItems
this.otherNetwork = otherNetwork
this.apNetwork = apNetwork
}
element(element) {
element.append(this.networkTable(), { html: true })
}
networkTable() {
if (this.sharedItems.length == 0) {
return `<h4>No shared exchanges or facilities between ${this.apNetwork.name} and ${this.otherNetwork.name}</h4>`
}
let table = `<h4>Shared facilities and exchanges between ${this.apNetwork.name} and ${this.otherNetwork.name}</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Location</th>
<th>Networks</th>
<th>Type</th>
</tr>
</thead>
<tbody>
`
for (let item of this.sharedItems) {
table += `<tr>
<td><a href="${item.url}">${item.name}</a></td>
<td>${item.location}</td>
<td>${item.networks}</td>
<td>${item.type}</td>
</tr>
`
}
table += ` </tbody>
</table>`
return table
}
}
class ErrorConditionHandler {
constructor(asn) {
this.asn = asn
}
element(element) {
element.append(`<h4>ASN ${this.asn} Not Found on PeeringDB</h4>`, {html: true})
}
}
class AsnHandler {
constructor(asn) {
this.asn = asn
}
element(element) {
element.setAttribute("value", this.asn)
}
}
export { NetworkComparisonHandler, ErrorConditionHandler, AsnHandler }