mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
add boot param to logs subscription
This commit is contained in:
@@ -62,7 +62,7 @@ export class LogsComponent {
|
|||||||
| 'connected'
|
| 'connected'
|
||||||
| 'reconnecting'
|
| 'reconnecting'
|
||||||
| 'disconnected' = 'connecting'
|
| 'disconnected' = 'connecting'
|
||||||
limit = 400
|
limit = 200
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class LogsPage {
|
|||||||
loading = true
|
loading = true
|
||||||
needInfinite = true
|
needInfinite = true
|
||||||
startCursor?: string
|
startCursor?: string
|
||||||
limit = 200
|
limit = 400
|
||||||
isOnBottom = true
|
isOnBottom = true
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ function convertAnsi(entries: readonly any[]): string {
|
|||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class LogsService extends Observable<readonly string[]> {
|
export class LogsService extends Observable<readonly string[]> {
|
||||||
private readonly api = inject(ApiService)
|
private readonly api = inject(ApiService)
|
||||||
private readonly log$ = defer(() => this.api.initFollowLogs({})).pipe(
|
private readonly log$ = defer(() =>
|
||||||
|
this.api.initFollowLogs({ boot: 0 }),
|
||||||
|
).pipe(
|
||||||
switchMap(({ guid }) => this.api.openWebsocket$<Log>(guid, {})),
|
switchMap(({ guid }) => this.api.openWebsocket$<Log>(guid, {})),
|
||||||
bufferTime(250),
|
bufferTime(250),
|
||||||
filter(logs => !!logs.length),
|
filter(logs => !!logs.length),
|
||||||
|
|||||||
@@ -70,7 +70,12 @@ export module RR {
|
|||||||
export type GetServerLogsReq = ServerLogsReq // server.logs & server.kernel-logs
|
export type GetServerLogsReq = ServerLogsReq // server.logs & server.kernel-logs
|
||||||
export type GetServerLogsRes = LogsRes
|
export type GetServerLogsRes = LogsRes
|
||||||
|
|
||||||
export type FollowServerLogsReq = { limit?: number } // server.logs.follow & server.kernel-logs.follow
|
// @param limit: BE default is 50
|
||||||
|
// @param boot: number is offset (0: current, -1 prev, +1 first), string is a specific boot id, and null is all
|
||||||
|
export type FollowServerLogsReq = {
|
||||||
|
limit?: number
|
||||||
|
boot?: number | string | null
|
||||||
|
} // server.logs.follow & server.kernel-logs.follow
|
||||||
export type FollowServerLogsRes = {
|
export type FollowServerLogsRes = {
|
||||||
startCursor: string
|
startCursor: string
|
||||||
guid: string
|
guid: string
|
||||||
|
|||||||
@@ -160,8 +160,10 @@ export class LiveApiService extends ApiService {
|
|||||||
return this.rpcRequest({ method: 'init.subscribe', params: {} })
|
return this.rpcRequest({ method: 'init.subscribe', params: {} })
|
||||||
}
|
}
|
||||||
|
|
||||||
async initFollowLogs(): Promise<RR.FollowServerLogsRes> {
|
async initFollowLogs(
|
||||||
return this.rpcRequest({ method: 'init.logs.follow', params: {} })
|
params: RR.FollowServerLogsReq,
|
||||||
|
): Promise<RR.FollowServerLogsRes> {
|
||||||
|
return this.rpcRequest({ method: 'init.logs.follow', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
// server
|
// server
|
||||||
@@ -379,8 +381,8 @@ export class LiveApiService extends ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async followPackageLogs(
|
async followPackageLogs(
|
||||||
params: RR.FollowServerLogsReq,
|
params: RR.FollowPackageLogsReq,
|
||||||
): Promise<RR.FollowServerLogsRes> {
|
): Promise<RR.FollowPackageLogsRes> {
|
||||||
return this.rpcRequest({ method: 'package.logs.follow', params })
|
return this.rpcRequest({ method: 'package.logs.follow', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user