Commit 98bdb218 authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent e5b8f2f0
Pipeline #16063 failed with stages
in 1 minute and 17 seconds
This diff is collapsed.
<mat-toolbar color="primary">Menu</mat-toolbar> <mat-toolbar color='primary'>Menu</mat-toolbar>
<div id="wrapper"> <div id='wrapper' *ngIf='api.routers'>
<mat-nav-list> <mat-nav-list>
<a mat-list-item routerLink="">总览</a> <a mat-list-item routerLink=''>总览</a>
<a mat-list-item [routerLink]="router.id.toString()" *ngFor="let router of routers | async">{{router.name}}</a> <a mat-list-item [routerLink]='router.id.toString()' *ngFor='let router of api.routers'>{{router.name}}</a>
</mat-nav-list> </mat-nav-list>
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>
<!--<router-outlet></router-outlet>--> <!--<router-outlet></router-outlet>-->
import {Component, OnInit} from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ApiService} from "./api.service"; import { ApiService } from './api.service';
import {firstValueFrom} from "rxjs";
import * as _ from 'lodash'; import * as _ from 'lodash';
...@@ -10,27 +9,24 @@ import * as _ from 'lodash'; ...@@ -10,27 +9,24 @@ import * as _ from 'lodash';
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent implements OnInit { export class AppComponent implements OnInit {
routers = firstValueFrom(this.api.status())
constructor(private api: ApiService) { constructor(public api: ApiService) {
} }
async ngOnInit() { async ngOnInit() {
const protos = [] await this.api.init();
const routers = await this.routers; const protos = [];
const routers = this.api.routers;
for (const from of routers) { for (const from of routers) {
for (const [id1, peer] of Object.entries(from.peers)) { for (const [id1, peer] of Object.entries(from.peers)) {
const id = parseInt(id1); const id = parseInt(id1);
const reverse = routers.find(r => r.id === id)?.peers?.[from.id]; const reverse = routers.find(r => r.id === id)?.peers?.[from.id];
if (!reverse) continue; if (!reverse) continue;
const link = this.api.link(from.id, id); const link = this.api.connections[from.id][id];
if (!link) continue; if (!link) continue;
// @ts-ignore
if (peer.reliability * reverse.reliability <= 0.01) { if (peer.reliability * reverse.reliability <= 0.01) {
const proto = link.split(',')[1]; protos.push(link.proto);
protos.push(proto);
if (proto === 'wg') {
// console.log
}
} }
} }
} }
......
...@@ -14,7 +14,7 @@ import {Quality} from "../Quality"; ...@@ -14,7 +14,7 @@ import {Quality} from "../Quality";
export class DashboardComponent implements OnInit { export class DashboardComponent implements OnInit {
routers: RouterStatus[] = []; routers: RouterStatus[] = [];
displayedColumns: string[] = []; displayedColumns: string[] = [];
links = this.api.status().pipe( links = this.api.state().pipe(
map(routers => routers.map(router => map(routers => routers.map(router =>
({ ({
id: router.id, id: router.id,
...@@ -83,7 +83,7 @@ export class DashboardComponent implements OnInit { ...@@ -83,7 +83,7 @@ export class DashboardComponent implements OnInit {
} }
async ngOnInit() { async ngOnInit() {
this.routers = await firstValueFrom(this.api.status()) this.routers = await firstValueFrom(this.api.state())
this.displayedColumns = ['name', 'id'].concat(this.routers.map(r => r.name)); this.displayedColumns = ['name', 'id'].concat(this.routers.map(r => r.name));
} }
......
...@@ -13,7 +13,7 @@ export class RouterComponent { ...@@ -13,7 +13,7 @@ export class RouterComponent {
displayedColumns: string[] = ['id', 'delay', 'loss', 'loss2', 'jitter']; displayedColumns: string[] = ['id', 'delay', 'loss', 'loss2', 'jitter'];
dataSource = this.id.pipe( dataSource = this.id.pipe(
switchMap(id => this.api.status().pipe( switchMap(id => this.api.state().pipe(
map(routers => map(routers =>
Object.entries(routers.find(r => r.id == id)!.peers).map(([id1, peer]) => { Object.entries(routers.find(r => r.id == id)!.peers).map(([id1, peer]) => {
const peerId = parseInt(id1); const peerId = parseInt(id1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment