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