mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
log backend integration fixes
This commit is contained in:
committed by
Aiden McClelland
parent
483e02a41b
commit
0d59952fb9
@@ -38,15 +38,16 @@ export class LogsPage {
|
||||
limit: this.limit,
|
||||
})
|
||||
|
||||
if (isBefore && logsRes.startCursor) {
|
||||
this.startCursor = logsRes.startCursor
|
||||
if ((isBefore || this.startCursor) && logsRes['start-cursor']) {
|
||||
this.startCursor = logsRes['start-cursor']
|
||||
}
|
||||
if (!isBefore && logsRes.endCursor) {
|
||||
this.endCursor = logsRes.endCursor
|
||||
|
||||
if ((!isBefore || !this.endCursor) && logsRes['end-cursor']) {
|
||||
this.endCursor = logsRes['end-cursor']
|
||||
}
|
||||
this.loading = false
|
||||
|
||||
return logsRes.logs
|
||||
return logsRes.entries
|
||||
} catch (e) {
|
||||
this.errToast.present(e)
|
||||
}
|
||||
@@ -61,7 +62,7 @@ export class LogsPage {
|
||||
const container = document.getElementById('container')
|
||||
const beforeContainerHeight = container.scrollHeight
|
||||
const newLogs = document.getElementById('template').cloneNode(true) as HTMLElement
|
||||
newLogs.innerHTML = logs.map(l => `${l.timestamp} ${l.log}`).join('\n\n') + (logs.length ? '\n\n' : '')
|
||||
newLogs.innerHTML = logs.map(l => `${l.timestamp} ${l.message}`).join('\n\n') + (logs.length ? '\n\n' : '')
|
||||
container.prepend(newLogs)
|
||||
const afterContainerHeight = container.scrollHeight
|
||||
|
||||
@@ -84,7 +85,7 @@ export class LogsPage {
|
||||
|
||||
const container = document.getElementById('container')
|
||||
const newLogs = document.getElementById('template').cloneNode(true) as HTMLElement
|
||||
newLogs.innerHTML = logs.map(l => `${l.timestamp} ${l.log}`).join('\n\n') + (logs.length ? '\n\n' : '')
|
||||
newLogs.innerHTML = logs.map(l => `${l.timestamp} ${l.message}`).join('\n\n') + (logs.length ? '\n\n' : '')
|
||||
container.append(newLogs)
|
||||
this.loadingMore = false
|
||||
this.scrollEvent()
|
||||
|
||||
@@ -72,6 +72,7 @@ export class AppListPage {
|
||||
}
|
||||
// subscribe to pkg
|
||||
this.pkgs[id].sub = this.patch.watch$('package-data', id).subscribe(pkg => {
|
||||
console.log('package', pkg)
|
||||
let bulbClass = 'bulb-on'
|
||||
let img = ''
|
||||
const statusRendering = renderPkgStatus(pkg.state, pkg.installed?.status)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||
|
||||
@Component({
|
||||
@@ -13,14 +14,17 @@ export class AppLogsPage {
|
||||
before: string
|
||||
|
||||
constructor (
|
||||
private readonly route: ActivatedRoute,
|
||||
private readonly embassyApi: ApiService,
|
||||
) { }
|
||||
) {
|
||||
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||
|
||||
}
|
||||
|
||||
fetchFetchLogs () {
|
||||
return async (params: { before_flag?: boolean, limit?: number, cursor?: string }) => {
|
||||
const pkgId = this.pkgId
|
||||
return this.embassyApi.getPackageLogs({
|
||||
id: pkgId,
|
||||
id: this.pkgId,
|
||||
before_flag: params.before_flag,
|
||||
cursor: params.cursor,
|
||||
limit: params.limit,
|
||||
|
||||
@@ -785,30 +785,30 @@ export module Mock {
|
||||
export const ServerLogs: Log[] = [
|
||||
{
|
||||
timestamp: '2019-12-26T14:20:30.872Z',
|
||||
log: '****** START *****',
|
||||
message: '****** START *****',
|
||||
},
|
||||
{
|
||||
timestamp: '2019-12-26T14:21:30.872Z',
|
||||
log: 'ServerLogs ServerLogs ServerLogs ServerLogs ServerLogs',
|
||||
message: 'ServerLogs ServerLogs ServerLogs ServerLogs ServerLogs',
|
||||
},
|
||||
{
|
||||
timestamp: '2019-12-26T14:22:30.872Z',
|
||||
log: '****** FINISH *****',
|
||||
message: '****** FINISH *****',
|
||||
},
|
||||
]
|
||||
|
||||
export const PackageLogs: Log[] = [
|
||||
{
|
||||
timestamp: '2019-12-26T14:20:30.872Z',
|
||||
log: '****** START *****',
|
||||
message: '****** START *****',
|
||||
},
|
||||
{
|
||||
timestamp: '2019-12-26T14:21:30.872Z',
|
||||
log: 'PackageLogs PackageLogs PackageLogs PackageLogs PackageLogs',
|
||||
message: 'PackageLogs PackageLogs PackageLogs PackageLogs PackageLogs',
|
||||
},
|
||||
{
|
||||
timestamp: '2019-12-26T14:22:30.872Z',
|
||||
log: '****** FINISH *****',
|
||||
message: '****** FINISH *****',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ export module RR {
|
||||
export type GetPackagePropertiesReq = { id: string } // package.properties
|
||||
export type GetPackagePropertiesRes<T extends number> = PackagePropertiesVersioned<T>
|
||||
|
||||
export type LogsRes = { logs: Log[], startCursor?: string, endCursor?: string }
|
||||
export type LogsRes = { entries: Log[], 'start-cursor'?: string, 'end-cursor'?: string }
|
||||
|
||||
export type GetPackageLogsReq = { id: string, cursor?: string, before_flag?: boolean, limit?: number } // package.logs
|
||||
export type GetPackageLogsRes = LogsRes
|
||||
@@ -250,7 +250,7 @@ export interface TaggedDependencyError {
|
||||
|
||||
export interface Log {
|
||||
timestamp: string
|
||||
log: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface ActionResponse {
|
||||
|
||||
@@ -75,18 +75,18 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async getServerLogs (params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes> {
|
||||
await pauseFor(2000)
|
||||
let logArr
|
||||
let entries
|
||||
if (Math.random() < .2) {
|
||||
console.log('last page')
|
||||
logArr = Mock.ServerLogs
|
||||
entries = Mock.ServerLogs
|
||||
} else {
|
||||
const arrLength = params.limit ? Math.ceil(params.limit / Mock.ServerLogs.length) : 10
|
||||
logArr = new Array(arrLength).fill(Mock.ServerLogs).reduce((acc, val) => acc.concat(val), [])
|
||||
entries = new Array(arrLength).fill(Mock.ServerLogs).reduce((acc, val) => acc.concat(val), [])
|
||||
}
|
||||
return {
|
||||
logs: logArr,
|
||||
startCursor: 'startCursor',
|
||||
endCursor: 'endCursor',
|
||||
entries,
|
||||
'start-cursor': 'startCursor',
|
||||
'end-cursor': 'endCursor',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,18 +322,18 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async getPackageLogs (params: RR.GetPackageLogsReq): Promise<RR.GetPackageLogsRes> {
|
||||
await pauseFor(2000)
|
||||
let logArr
|
||||
let entries
|
||||
if (Math.random() < .2) {
|
||||
console.log('last page')
|
||||
logArr = Mock.PackageLogs
|
||||
entries = Mock.PackageLogs
|
||||
} else {
|
||||
const arrLength = params.limit ? Math.ceil(params.limit / Mock.PackageLogs.length) : 10
|
||||
logArr = new Array(arrLength).fill(Mock.PackageLogs).reduce((acc, val) => acc.concat(val), [])
|
||||
entries = new Array(arrLength).fill(Mock.PackageLogs).reduce((acc, val) => acc.concat(val), [])
|
||||
}
|
||||
return {
|
||||
logs: logArr,
|
||||
startCursor: 'startCursor',
|
||||
endCursor: 'endCursor',
|
||||
entries,
|
||||
'start-cursor': 'startCursor',
|
||||
'end-cursor': 'endCursor',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user