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()"> <button mat-icon-button class="icon" (click)="drawer.toggle()">
<mat-icon>menu</mat-icon> <mat-icon>menu</mat-icon>
</button> </button>
@ -9,7 +9,7 @@
<mat-drawer-container class="container" autosize> <mat-drawer-container class="container" autosize>
<mat-drawer #drawer class="sidenav" mode="over"> <mat-drawer #drawer class="sidenav" mode="over">
<div style="width: 100px"> <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> </div>
</mat-drawer> </mat-drawer>

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

@ -3,12 +3,7 @@
height: 100% - 2.5%; height: 100% - 2.5%;
} }
.sidenav-content { .sidenav-content {}
display: flex;
//height: 100%;
align-items: center;
justify-content: center;
}
.sidenav { .sidenav {
padding: 20px; padding: 20px;
@ -17,3 +12,9 @@
.spacer { .spacer {
flex: 1 1 auto; 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 { Component } from '@angular/core';
import {Route, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -6,10 +7,17 @@ import { Component } from '@angular/core';
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent { export class AppComponent {
constructor(private route: Router) {
}
routes: {name: string, url: string}[] = [ routes: {name: string, url: string}[] = [
{name: "Команды бота", url:""}, {name: "Команды бота", url:""},
{name: "История сообщений", url:""}, {name: "История сообщений", url:""},
{name: "Прямые ноды", url:""}, {name: "Прямые ноды", url:"nodes/direct"},
{name: "Все ноды", url:""}, {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'], styleUrls: ['nodes.styles.scss'],
template: ` template: `
<!--<p *ngFor="let node of nodes">{{node.long_name}}</p>--> <!--<p *ngFor="let node of nodes">{{node.long_name}}</p>-->
<div class="card-wrapper"> <div style="width: 80%; padding: 0 10%; padding-top: 8px">
<mat-card *ngFor="let node of nodes" style="min-width: 250px"> <div class="card-wrapper">
<mat-card-header> <mat-card *ngFor="let node of nodes">
<mat-card-title>{{node.long_name}}</mat-card-title> <mat-card-header>
<mat-card-subtitle>{{node.short_name}} ({{node.num}})</mat-card-subtitle> <mat-card-title>{{node.long_name}}</mat-card-title>
</mat-card-header> <mat-card-subtitle>{{node.short_name}} ({{node.num}})</mat-card-subtitle>
<mat-card-content> </mat-card-header>
<p>график</p> <mat-card-content>
</mat-card-content> <p>график</p>
<mat-card-actions> </mat-card-content>
<button mat-button *ngIf="node.hops_away > 0">Прыжков: {{node.hops_away}}</button> <mat-card-actions>
<button mat-button>SNR: {{node.snr}}</button> <button mat-button *ngIf="node.hops_away > 0">Прыжков: {{node.hops_away}}</button>
<button mat-button>{{node.ts * 1000 | date:"hh:mm dd.MM.yyyy"}}</button> <button mat-button>SNR: {{node.snr}}</button>
</mat-card-actions> <button mat-button>{{node.ts * 1000 | date:"hh:mm dd.MM.yyyy"}}</button>
</mat-card> </mat-card-actions>
</mat-card>
</div>
</div> </div>
` `
}) })

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

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

13
webExtensions/publicEndpoints.py

@ -2,6 +2,7 @@ from fastapi import FastAPI
from fastapi.requests import Request from fastapi.requests import Request
from fastapi.responses import Response, JSONResponse from fastapi.responses import Response, JSONResponse
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from extra.NodeDTO import NodeDTO
class WebExtension: class WebExtension:
app: FastAPI app: FastAPI
@ -48,4 +49,14 @@ class WebExtension:
@self.app.get(f"{self.core.context}/auth/logout") @self.app.get(f"{self.core.context}/auth/logout")
async def clearSession(request:Request): 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