gsd 4 months ago
parent
commit
f2f170e305
  1. 4
      tileManager.py
  2. 10
      ui/src/app/components/nodes/nodes-map.component.ts
  3. 15
      ui/src/assets/meshtastic-logo.svg
  4. 2
      webExtensions/publicEndpoints.py

4
tileManager.py

@ -33,7 +33,7 @@ class TileManager:
async with session.get(url, ssl=False, headers=self.generateHeaders()) as resp:
# Read the entire response body as bytes
img = await resp.read()
logger.info(url, resp.status)
#logger.info(url, resp.status)
if resp.status == 200:
query['ts'] = time()
query['img'] = img
@ -41,4 +41,4 @@ class TileManager:
await collection.insert_one(query)
return img
else:
raise Exception("cannot get img")
raise Exception("cannot get img, code: " + str(resp.status))

10
ui/src/app/components/nodes/nodes-map.component.ts

@ -3,6 +3,7 @@ import * as L from 'leaflet';
import {HttpClient} from "@angular/common/http";
import {NodeDTO} from "../../entities/NodeDTO";
import {Subscription} from "rxjs";
import {DatePipe} from "@angular/common";
@Component({
selector: "app-nodes-map",
@ -19,9 +20,14 @@ import {Subscription} from "rxjs";
})
export class NodesMapComponent implements OnInit {
map!: L.Map;
logo: any = new L.Icon({
iconUrl: '../../../assets/meshtastic-logo.svg',
iconSize: [32, 32]
})
nodes: NodeDTO[] = []
constructor(private http: HttpClient) {
constructor(private http: HttpClient,
private datepipe: DatePipe) {
}
ngOnInit(): void {
@ -36,7 +42,7 @@ export class NodesMapComponent implements OnInit {
() => {
this.nodes.filter((node) => node.havePosition).forEach(
(node) => {
L.marker(this.convertPosition(node)).addTo(this.map)
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)
}
)
}

15
ui/src/assets/meshtastic-logo.svg

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="512" height="512" viewBox="0 0 512 512" xml:space="preserve">
<desc>Created with Fabric.js 4.6.0</desc>
<defs>
</defs>
<g transform="matrix(1 0 0 1 256 256)" id="xYQ9Gk9Jwpgj_HMOXB3F_" >
<path style="stroke: rgb(213,130,139); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(103,234,148); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-256, -256)" d="M 0 0 L 512 0 L 512 512 L 0 512 z" stroke-linecap="round" />
</g>
<g transform="matrix(1.79 0 0 1.79 313.74 258.36)" id="1xBsk2n9FZp60Rz1O-ceJ" >
<path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: round; stroke-miterlimit: 2; fill: rgb(44,45,60); fill-rule: evenodd; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-250.97, -362.41)" d="M 250.908 330.267 L 193.126 415.005 L 180.938 406.694 L 244.802 313.037 C 246.174 311.024 248.453 309.819 250.889 309.816 C 253.326 309.814 255.606 311.015 256.982 313.026 L 320.994 406.536 L 308.821 414.869 L 250.908 330.267 Z" stroke-linecap="round" />
</g>
<g transform="matrix(1.81 0 0 1.81 145 256.15)" id="KxN7E9YpbyPgz0S4z4Cl6" >
<path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: round; stroke-miterlimit: 2; fill: rgb(44,45,60); fill-rule: evenodd; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-115.14, -528.06)" d="M 87.642 581.398 L 154.757 482.977 L 142.638 474.713 L 75.523 573.134 L 87.642 581.398 Z" stroke-linecap="round" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

2
webExtensions/publicEndpoints.py

@ -67,8 +67,6 @@ class WebExtension:
async def grabTile(request:Request, z:int, x:int, y:int):
try:
img = await self.core.tileManager.grabTile(z, x, y)
print(type(img))
#return StreamingResponse(img, media_type="image/png")
return Response(content=img, media_type="image/png")
except:
traceback.print_exc()

Loading…
Cancel
Save