Browse Source

ui start 2

main
gsd 4 months ago
parent
commit
b8cbbba33b
  1. 4
      ui/src/app/app.component.html
  2. 13
      ui/src/app/app.component.scss
  3. 10
      ui/src/app/app.component.ts
  4. 32
      ui/src/app/components/nodes/DirectNodes.component.ts
  5. 8
      ui/src/app/components/nodes/nodes.styles.scss
  6. 13
      webExtensions/publicEndpoints.py

4
ui/src/app/app.component.html

@ -1,4 +1,4 @@
<mat-toolbar style="height: 2.5%">
<mat-toolbar style="height: 36px">
<button mat-icon-button class="icon" (click)="drawer.toggle()">
<mat-icon>menu</mat-icon>
</button>
@ -9,7 +9,7 @@
<mat-drawer-container class="container" autosize>
<mat-drawer #drawer class="sidenav" mode="over">
<div style="width: 100px">
<p *ngFor="let u of routes" [routerLink]="u.url">{{u.name}}</p>
<p class="routeUrl" *ngFor="let u of routes" [routerLink]="u.url" (click)="goTo(u.url)">{{u.name}}</p>
</div>
</mat-drawer>

13
ui/src/app/app.component.scss

@ -3,12 +3,7 @@
height: 100% - 2.5%;
}
.sidenav-content {
display: flex;
//height: 100%;
align-items: center;
justify-content: center;
}
.sidenav-content {}
.sidenav {
padding: 20px;
@ -17,3 +12,9 @@
.spacer {
flex: 1 1 auto;
}
.routeUrl:hover {
background: rgba(0, 0, 0, 0.13);
cursor: pointer;
border-radius: 5px;
}

10
ui/src/app/app.component.ts

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import {Route, Router} from "@angular/router";
@Component({
selector: 'app-root',
@ -6,10 +7,17 @@ import { Component } from '@angular/core';
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(private route: Router) {
}
routes: {name: string, url: string}[] = [
{name: "Команды бота", url:""},
{name: "История сообщений", url:""},
{name: "Прямые ноды", url:""},
{name: "Прямые ноды", url:"nodes/direct"},
{name: "Все ноды", url:""},
]
goTo(url: string) {
this.route.navigate([url]);
}
}

32
ui/src/app/components/nodes/DirectNodes.component.ts

@ -7,21 +7,23 @@ import {NodeDTO} from "../../entities/NodeDTO";
styleUrls: ['nodes.styles.scss'],
template: `
<!--<p *ngFor="let node of nodes">{{node.long_name}}</p>-->
<div class="card-wrapper">
<mat-card *ngFor="let node of nodes" style="min-width: 250px">
<mat-card-header>
<mat-card-title>{{node.long_name}}</mat-card-title>
<mat-card-subtitle>{{node.short_name}} ({{node.num}})</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>график</p>
</mat-card-content>
<mat-card-actions>
<button mat-button *ngIf="node.hops_away > 0">Прыжков: {{node.hops_away}}</button>
<button mat-button>SNR: {{node.snr}}</button>
<button mat-button>{{node.ts * 1000 | date:"hh:mm dd.MM.yyyy"}}</button>
</mat-card-actions>
</mat-card>
<div style="width: 80%; padding: 0 10%; padding-top: 8px">
<div class="card-wrapper">
<mat-card *ngFor="let node of nodes">
<mat-card-header>
<mat-card-title>{{node.long_name}}</mat-card-title>
<mat-card-subtitle>{{node.short_name}} ({{node.num}})</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>график</p>
</mat-card-content>
<mat-card-actions>
<button mat-button *ngIf="node.hops_away > 0">Прыжков: {{node.hops_away}}</button>
<button mat-button>SNR: {{node.snr}}</button>
<button mat-button>{{node.ts * 1000 | date:"hh:mm dd.MM.yyyy"}}</button>
</mat-card-actions>
</mat-card>
</div>
</div>
`
})

8
ui/src/app/components/nodes/nodes.styles.scss

@ -1,11 +1,5 @@
.card-wrapper {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 8px;
}
.grid-card {
width: 100%;
height: 100%;
/* Additional styling as needed */
gap: 24px;
}

13
webExtensions/publicEndpoints.py

@ -2,6 +2,7 @@ from fastapi import FastAPI
from fastapi.requests import Request
from fastapi.responses import Response, JSONResponse
from fastapi.exceptions import HTTPException
from extra.NodeDTO import NodeDTO
class WebExtension:
app: FastAPI
@ -48,4 +49,14 @@ class WebExtension:
@self.app.get(f"{self.core.context}/auth/logout")
async def clearSession(request:Request):
return self.core.authManager.setAuth(JSONResponse({"status":True}), 0, True)
return self.core.authManager.setAuth(JSONResponse({"status":True}), 0, True)
@self.app.get(f"{self.core.context}/auth/me")
@self.core.authManager.authRequest()
async def userNode(request:Request):
userNum = request.cookies.get(self.core.authManager.NUM, None)
userNode = await self.dbService.oneNode(userNum)
if userNum:
return NodeDTO(userNode)
else:
return {}
Loading…
Cancel
Save