|
|
|
@ -4,6 +4,7 @@ import {HttpClient} from "@angular/common/http"; |
|
|
|
import {NodeDTO} from "../../entities/NodeDTO"; |
|
|
|
import {Subscription} from "rxjs"; |
|
|
|
import {DatePipe} from "@angular/common"; |
|
|
|
import {numToColor} from "../../utils/Utils"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: "app-nodes-map", |
|
|
|
@ -26,6 +27,8 @@ export class NodesMapComponent implements OnInit { |
|
|
|
}) |
|
|
|
nodes: NodeDTO[] = [] |
|
|
|
|
|
|
|
numToColor = numToColor; |
|
|
|
|
|
|
|
constructor(private http: HttpClient, |
|
|
|
private datepipe: DatePipe) { |
|
|
|
} |
|
|
|
@ -42,7 +45,13 @@ export class NodesMapComponent implements OnInit { |
|
|
|
() => { |
|
|
|
this.nodes.filter((node) => node.havePosition).forEach( |
|
|
|
(node) => { |
|
|
|
L.marker(this.convertPosition(node), {icon: this.logo}).bindPopup(`<a href="network/status/${node.num}">${node.long_name} (${node.short_name})</a><p>snr: ${node.snr} hops: ${node.hops_away}</p><p>Изменена: ${this.datepipe.transform(node.position.time*1000, 'HH:mm dd.MM.yyyy')}</p>`).addTo(this.map) |
|
|
|
L.marker(this.convertPosition(node), { |
|
|
|
icon: this.createCircleIcon({ |
|
|
|
color: this.numToColor(node.num, 0), |
|
|
|
text: node.short_name}) |
|
|
|
}) |
|
|
|
.bindPopup(`<a href="network/status/${node.num}">${node.long_name} (${node.short_name})</a><p>snr: ${node.snr} hops: ${node.hops_away}</p><p>Изменена: ${this.datepipe.transform(node.position.time*1000, 'HH:mm dd.MM.yyyy')}</p>`) |
|
|
|
.addTo(this.map) |
|
|
|
} |
|
|
|
) |
|
|
|
} |
|
|
|
@ -72,4 +81,24 @@ export class NodesMapComponent implements OnInit { |
|
|
|
tiles.addTo(this.map) |
|
|
|
return Subscription.EMPTY; |
|
|
|
} |
|
|
|
|
|
|
|
private createCircleIcon(options: { color: string; text: string; size?: number }): L.DivIcon { |
|
|
|
const size = options.size || 24; |
|
|
|
const html = ` |
|
|
|
<div style=" |
|
|
|
width: ${size}px; |
|
|
|
height: ${size}px; |
|
|
|
border-radius: 50%; |
|
|
|
background-color: ${options.color}; |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: center; |
|
|
|
color: white; |
|
|
|
font-size: ${size * 0.35}px; |
|
|
|
font-weight: bold; |
|
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.5); |
|
|
|
">${options.text}</div> |
|
|
|
`;
|
|
|
|
return L.divIcon({ html, iconSize: [size, size], className: 'l-div-icon' }); |
|
|
|
} |
|
|
|
} |
|
|
|
|