mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
add Tor logs to UI
This commit is contained in:
@@ -54,7 +54,6 @@ const ICONS = [
|
|||||||
'mail-outline',
|
'mail-outline',
|
||||||
'map-outline',
|
'map-outline',
|
||||||
'medkit-outline',
|
'medkit-outline',
|
||||||
'newspaper-outline',
|
|
||||||
'notifications-outline',
|
'notifications-outline',
|
||||||
'open-outline',
|
'open-outline',
|
||||||
'options-outline',
|
'options-outline',
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ const routes: Routes = [
|
|||||||
m => m.KernelLogsPageModule,
|
m => m.KernelLogsPageModule,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'tor-logs',
|
||||||
|
loadChildren: () =>
|
||||||
|
import('./tor-logs/tor-logs.module').then(m => m.TorLogsPageModule),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'metrics',
|
path: 'metrics',
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ export class ServerShowPage {
|
|||||||
{
|
{
|
||||||
title: 'OS Logs',
|
title: 'OS Logs',
|
||||||
description: 'Raw, unfiltered operating system logs',
|
description: 'Raw, unfiltered operating system logs',
|
||||||
icon: 'newspaper-outline',
|
icon: 'receipt-outline',
|
||||||
action: () =>
|
action: () =>
|
||||||
this.navCtrl.navigateForward(['logs'], { relativeTo: this.route }),
|
this.navCtrl.navigateForward(['logs'], { relativeTo: this.route }),
|
||||||
detail: true,
|
detail: true,
|
||||||
@@ -488,6 +488,17 @@ export class ServerShowPage {
|
|||||||
detail: true,
|
detail: true,
|
||||||
disabled$: of(false),
|
disabled$: of(false),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Tor Logs',
|
||||||
|
description: 'Diagnostic log stream for the Tor daemon on StartOS',
|
||||||
|
icon: 'receipt-outline',
|
||||||
|
action: () =>
|
||||||
|
this.navCtrl.navigateForward(['tor-logs'], {
|
||||||
|
relativeTo: this.route,
|
||||||
|
}),
|
||||||
|
detail: true,
|
||||||
|
disabled$: of(false),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
Support: [
|
Support: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { NgModule } from '@angular/core'
|
||||||
|
import { CommonModule } from '@angular/common'
|
||||||
|
import { Routes, RouterModule } from '@angular/router'
|
||||||
|
import { IonicModule } from '@ionic/angular'
|
||||||
|
import { TorLogsPage } from './tor-logs.page'
|
||||||
|
import { LogsComponentModule } from 'src/app/components/logs/logs.component.module'
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: TorLogsPage,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
IonicModule,
|
||||||
|
RouterModule.forChild(routes),
|
||||||
|
LogsComponentModule,
|
||||||
|
],
|
||||||
|
declarations: [TorLogsPage],
|
||||||
|
})
|
||||||
|
export class TorLogsPageModule {}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<logs
|
||||||
|
[fetchLogs]="fetchLogs()"
|
||||||
|
[followLogs]="followLogs()"
|
||||||
|
context="tor"
|
||||||
|
defaultBack="system"
|
||||||
|
pageTitle="Tor Logs"
|
||||||
|
class="ion-page"
|
||||||
|
></logs>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { Component } from '@angular/core'
|
||||||
|
import { RR } from 'src/app/services/api/api.types'
|
||||||
|
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'tor-logs',
|
||||||
|
templateUrl: './tor-logs.page.html',
|
||||||
|
styleUrls: ['./tor-logs.page.scss'],
|
||||||
|
})
|
||||||
|
export class TorLogsPage {
|
||||||
|
constructor(private readonly api: ApiService) {}
|
||||||
|
|
||||||
|
followLogs() {
|
||||||
|
return async (params: RR.FollowServerLogsReq) => {
|
||||||
|
return this.api.followTorLogs(params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchLogs() {
|
||||||
|
return async (params: RR.GetServerLogsReq) => {
|
||||||
|
return this.api.getTorLogs(params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,8 @@ export abstract class ApiService {
|
|||||||
params: RR.GetServerLogsReq,
|
params: RR.GetServerLogsReq,
|
||||||
): Promise<RR.GetServerLogsRes>
|
): Promise<RR.GetServerLogsRes>
|
||||||
|
|
||||||
|
abstract getTorLogs(params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes>
|
||||||
|
|
||||||
abstract followServerLogs(
|
abstract followServerLogs(
|
||||||
params: RR.FollowServerLogsReq,
|
params: RR.FollowServerLogsReq,
|
||||||
): Promise<RR.FollowServerLogsRes>
|
): Promise<RR.FollowServerLogsRes>
|
||||||
@@ -81,6 +83,10 @@ export abstract class ApiService {
|
|||||||
params: RR.FollowServerLogsReq,
|
params: RR.FollowServerLogsReq,
|
||||||
): Promise<RR.FollowServerLogsRes>
|
): Promise<RR.FollowServerLogsRes>
|
||||||
|
|
||||||
|
abstract followTorLogs(
|
||||||
|
params: RR.FollowServerLogsReq,
|
||||||
|
): Promise<RR.FollowServerLogsRes>
|
||||||
|
|
||||||
abstract getServerMetrics(
|
abstract getServerMetrics(
|
||||||
params: RR.GetServerMetricsReq,
|
params: RR.GetServerMetricsReq,
|
||||||
): Promise<RR.GetServerMetricsRes>
|
): Promise<RR.GetServerMetricsRes>
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ export class LiveApiService extends ApiService {
|
|||||||
return this.rpcRequest({ method: 'server.kernel-logs', params })
|
return this.rpcRequest({ method: 'server.kernel-logs', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getTorLogs(params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes> {
|
||||||
|
return this.rpcRequest({ method: 'server.tor-logs', params })
|
||||||
|
}
|
||||||
|
|
||||||
async followServerLogs(
|
async followServerLogs(
|
||||||
params: RR.FollowServerLogsReq,
|
params: RR.FollowServerLogsReq,
|
||||||
): Promise<RR.FollowServerLogsRes> {
|
): Promise<RR.FollowServerLogsRes> {
|
||||||
@@ -147,6 +151,12 @@ export class LiveApiService extends ApiService {
|
|||||||
return this.rpcRequest({ method: 'server.kernel-logs.follow', params })
|
return this.rpcRequest({ method: 'server.kernel-logs.follow', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async followTorLogs(
|
||||||
|
params: RR.FollowServerLogsReq,
|
||||||
|
): Promise<RR.FollowServerLogsRes> {
|
||||||
|
return this.rpcRequest({ method: 'server.tor-logs.follow', params })
|
||||||
|
}
|
||||||
|
|
||||||
async getServerMetrics(
|
async getServerMetrics(
|
||||||
params: RR.GetServerMetricsReq,
|
params: RR.GetServerMetricsReq,
|
||||||
): Promise<RR.GetServerMetricsRes> {
|
): Promise<RR.GetServerMetricsRes> {
|
||||||
|
|||||||
@@ -211,6 +211,17 @@ export class MockApiService extends ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getTorLogs(params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes> {
|
||||||
|
await pauseFor(2000)
|
||||||
|
const entries = this.randomLogs(params.limit)
|
||||||
|
|
||||||
|
return {
|
||||||
|
entries,
|
||||||
|
'start-cursor': 'startCursor',
|
||||||
|
'end-cursor': 'endCursor',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async followServerLogs(
|
async followServerLogs(
|
||||||
params: RR.FollowServerLogsReq,
|
params: RR.FollowServerLogsReq,
|
||||||
): Promise<RR.FollowServerLogsRes> {
|
): Promise<RR.FollowServerLogsRes> {
|
||||||
@@ -231,6 +242,16 @@ export class MockApiService extends ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async followTorLogs(
|
||||||
|
params: RR.FollowServerLogsReq,
|
||||||
|
): Promise<RR.FollowServerLogsRes> {
|
||||||
|
await pauseFor(2000)
|
||||||
|
return {
|
||||||
|
'start-cursor': 'start-cursor',
|
||||||
|
guid: '7251d5be-645f-4362-a51b-3a85be92b31e',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
randomLogs(limit = 1): Log[] {
|
randomLogs(limit = 1): Log[] {
|
||||||
const arrLength = Math.ceil(limit / Mock.ServerLogs.length)
|
const arrLength = Math.ceil(limit / Mock.ServerLogs.length)
|
||||||
const logs = new Array(arrLength)
|
const logs = new Array(arrLength)
|
||||||
|
|||||||
Reference in New Issue
Block a user