Skip to content

Commit

Permalink
fix: logs page not working
Browse files Browse the repository at this point in the history
  • Loading branch information
anonysoul committed Apr 5, 2023
1 parent d8b9134 commit 974dd15
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions controller/resources/config/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "pre-alpha",
"singbox-version": "Premium 2022.08.26",
"version": "pre-alpha-1",
"singbox-version": "1.2.2",
"logger": {
"directory": "log",
"level": "all"
Expand Down
20 changes: 9 additions & 11 deletions controller/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nz-sider class="menu-sidebar" nzWidth="180px" nzBreakpoint="md" [nzTrigger]="null">
<div class="sidebar-logo">
<img src="assets/logo.svg" alt="logo" />
<div class="version">Singland version: {{ version }}</div>
<div class="version">Singland: {{ version }}</div>
</div>
<ul nz-menu nzMode="inline">
<li nz-menu-item nzMatchRouter>
Expand All @@ -17,12 +17,12 @@
<a routerLink="/logs">Logs</a>
</span>
</li>
<li nz-menu-item nzMatchRouter>
<!-- <li nz-menu-item nzMatchRouter>
<i nz-icon nzType="setting" nzTheme="outline"></i>
<span>
<a routerLink="/setting">Setting</a>
</span>
</li>
</li> -->
<li nz-menu-item nzMatchRouter>
<i nz-icon nzType="info-circle" nzTheme="outline"></i>
<span>
Expand All @@ -31,13 +31,11 @@
</li>
</ul>
<div class="traffic {{ status === 'stopped' ? 'hide' : '' }}">
<div>
{{ 0 | formatBytes }}/s
<img src="assets/arrow/arrow.png" />
</div>
<div>
<img src="assets/arrow/arrow.png" />
{{ 0 | formatBytes }}/s
<div style="
text-align: center;
font-size: 14px;
font-weight: bold;">
connected
</div>
</div>
</nz-sider>
Expand All @@ -48,4 +46,4 @@
</div>
</nz-content>
</nz-layout>
</nz-layout>
</nz-layout>
7 changes: 4 additions & 3 deletions controller/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FormsModule } from "@angular/forms";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { getLogger } from "log4js";
import { en_US, NZ_I18N } from "ng-zorro-antd/i18n";
import { NZ_I18N, en_US } from "ng-zorro-antd/i18n";
import { NzLayoutModule } from "ng-zorro-antd/layout";
import { NzMenuModule } from "ng-zorro-antd/menu";
import * as os from "os";
Expand All @@ -15,6 +15,7 @@ import { AppComponent } from "./app.component";
import { InfrastructureModule } from "./core/infrastructure/infrastructure.module";
import { LoggerInfrastructure } from "./core/infrastructure/logger.infrastructure";
import { ManagerModule } from "./core/manager/manager.module";
import { LogMonitorService } from "./core/service/monitor-log.service";
import { IconsProviderModule } from "./icons-provider.module";
import { LogsModule } from "./pages/logs/logs.module";
import { ProfilesModule } from "./pages/profiles/profiles.module";
Expand Down Expand Up @@ -47,15 +48,15 @@ registerLocaleData(en);
{
provide: APP_INITIALIZER,
useFactory: initializeApp,
deps: [LoggerInfrastructure],
deps: [LoggerInfrastructure, LogMonitorService],
multi: true
}
],
bootstrap: [AppComponent]
})
export class AppModule {}

export function initializeApp(loggerInfrastructure: LoggerInfrastructure) {
export function initializeApp(loggerInfrastructure: LoggerInfrastructure, logMonitorService: LogMonitorService) {
return async (): Promise<void> => {
getLogger("APP_INITIALIZER").mark("OS information: ", os.platform(), os.arch());
};
Expand Down
11 changes: 2 additions & 9 deletions controller/src/app/pages/about/about.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<div class="item">
<div>Versions</div>
<div>
<div>Singland: 1.0.0</div>
<div>sing-box: 1.0.0</div>
</div>
</div>
<div class="item">
<div>Thinks</div>
<div>Thanks</div>
<div>
<div>
Singland is made possible by the following open source project:
Singland is made possible by the following open source project and another open source project.
</div>
<ul>
<li (click)="openExternalLink('https://github.com/SagerNet/sing-box/')">sing-box </li>
Expand Down
6 changes: 3 additions & 3 deletions controller/src/app/pages/logs/logs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</nz-radio-group>
<i nz-icon nzType="clear" nzTheme="outline" (click)="clear()"></i>
</div>
<nz-empty *ngIf="logs.length === 0" nzNotFoundContent="Nothing"></nz-empty>
<nz-list *ngIf="logs.length !== 0" nzItemLayout="horizontal">
<nz-list-item *ngFor="let log of logs">
<nz-empty *ngIf="viewLogs.length === 0" nzNotFoundContent="Nothing"></nz-empty>
<nz-list *ngIf="viewLogs.length !== 0" nzItemLayout="horizontal">
<nz-list-item *ngFor="let log of viewLogs">
<nz-list-item-meta>
<nz-list-item-meta-title>
{{ log.message }}
Expand Down
15 changes: 11 additions & 4 deletions controller/src/app/pages/logs/logs.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { Subscription } from "rxjs";
import { Subscription, timer } from "rxjs";
import { Log } from "src/app/core/infrastructure/singbox.infrastructure";
import { LogMonitorService } from "src/app/core/service/monitor-log.service";

Expand All @@ -11,11 +11,17 @@ import { LogMonitorService } from "src/app/core/service/monitor-log.service";
export class LogsComponent implements OnInit {
level = "ALL";
private logsSubscription: Subscription | undefined;
private viewRefreshSubscription: Subscription | undefined;

private allLogs: Log[] = [];
logs: Log[] = [];
private filteredLogs: Log[] = [];
viewLogs: Log[] = [];

constructor(private logMonitorService: LogMonitorService) {}
constructor(private logMonitorService: LogMonitorService) {
this.viewRefreshSubscription = timer(0, 300).subscribe(() => {
this.viewLogs = this.filteredLogs;
});
}

ngOnInit(): void {
this.logsSubscription = this.logMonitorService.logs$.subscribe((logs) => {
Expand All @@ -25,7 +31,7 @@ export class LogsComponent implements OnInit {
}

filterLogs() {
this.logs = this.allLogs.filter((log) => {
this.filteredLogs = this.allLogs.filter((log) => {
if (this.level === "ALL") return true;
return log.level == this.level;
});
Expand All @@ -37,5 +43,6 @@ export class LogsComponent implements OnInit {

ngOnDestroy(): void {
this.logsSubscription?.unsubscribe();
this.viewRefreshSubscription?.unsubscribe();
}
}

0 comments on commit 974dd15

Please sign in to comment.