mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
refactor loaders, better err toasts, rework Embassy tab organization
This commit is contained in:
committed by
Aiden McClelland
parent
2ff9c622ac
commit
eb245aea50
@@ -24,6 +24,9 @@ export module RR {
|
||||
|
||||
// server
|
||||
|
||||
export type SetShareStatsReq = WithExpire<{ value: any }> // server.config.share-stats
|
||||
export type SetShareStatsRes = WithRevision<null>
|
||||
|
||||
export type GetServerLogsReq = { before?: string } // server.logs
|
||||
export type GetServerLogsRes = Log[]
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
|
||||
// server
|
||||
|
||||
protected abstract setShareStatsRaw (params: RR.SetShareStatsReq): Promise<RR.SetShareStatsRes>
|
||||
setShareStats = (params: RR.SetShareStatsReq) => this.syncResponse(
|
||||
() => this.setShareStatsRaw(params),
|
||||
)()
|
||||
|
||||
abstract getServerLogs (params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes>
|
||||
|
||||
abstract getServerMetrics (params: RR.GetServerMetricsReq): Promise<RR.GetServerMetricsRes>
|
||||
|
||||
@@ -43,6 +43,10 @@ export class LiveApiService extends ApiService {
|
||||
|
||||
// server
|
||||
|
||||
async setShareStatsRaw (params: RR.SetShareStatsReq): Promise<RR.SetShareStatsRes> {
|
||||
return this.http.rpcRequest( { method: 'server.config.share-stats', params })
|
||||
}
|
||||
|
||||
async getServerLogs (params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes> {
|
||||
return this.http.rpcRequest( { method: 'server.logs', params })
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'
|
||||
import { pauseFor } from '../../../util/misc.util'
|
||||
import { ApiService } from './embassy-api.service'
|
||||
import { Operation, PatchOp } from 'patch-db-client'
|
||||
import { DataModel, InstallProgress, PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model'
|
||||
import { InstallProgress, PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model'
|
||||
import { RR, WithRevision } from '../api.types'
|
||||
import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
||||
import { Mock } from '../api.fixures'
|
||||
@@ -27,39 +27,14 @@ export class MockApiService extends ApiService {
|
||||
// db
|
||||
|
||||
async getRevisions (since: number): Promise<RR.GetRevisionsRes> {
|
||||
// await pauseFor(2000)
|
||||
// return {
|
||||
// ...Mock.DbDump,
|
||||
// id: this.nextSequence(),
|
||||
// }
|
||||
return this.http.rpcRequest<RR.GetRevisionsRes>({ method: 'db.revisions', params: { since } })
|
||||
}
|
||||
|
||||
async getDump (): Promise<RR.GetDumpRes> {
|
||||
// await pauseFor(2000)
|
||||
// return {
|
||||
// ...Mock.DbDump,
|
||||
// id: this.nextSequence(),
|
||||
// }
|
||||
return this.http.rpcRequest<RR.GetDumpRes>({ method: 'db.dump' })
|
||||
}
|
||||
|
||||
async setDbValueRaw (params: RR.SetDBValueReq): Promise<RR.SetDBValueRes> {
|
||||
// await pauseFor(2000)
|
||||
// return {
|
||||
// response: null,
|
||||
// revision: {
|
||||
// id: this.nextSequence(),
|
||||
// patch: [
|
||||
// {
|
||||
// op: PatchOp.REPLACE,
|
||||
// path: params.pointer,
|
||||
// value: params.value,
|
||||
// },
|
||||
// ],
|
||||
// expireId: null,
|
||||
// },
|
||||
// }
|
||||
return this.http.rpcRequest<WithRevision<null>>({ method: 'db.put.ui', params })
|
||||
}
|
||||
|
||||
@@ -77,6 +52,18 @@ export class MockApiService extends ApiService {
|
||||
|
||||
// server
|
||||
|
||||
async setShareStatsRaw (params: RR.SetShareStatsReq): Promise<RR.SetShareStatsRes> {
|
||||
await pauseFor(2000)
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: '/server-info/share-stats',
|
||||
value: params.value,
|
||||
},
|
||||
]
|
||||
return this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async getServerLogs (params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes> {
|
||||
await pauseFor(2000)
|
||||
return Mock.ServerLogs
|
||||
@@ -94,20 +81,19 @@ export class MockApiService extends ApiService {
|
||||
|
||||
async updateServerRaw (params: RR.UpdateServerReq): Promise<RR.UpdateServerRes> {
|
||||
await pauseFor(2000)
|
||||
const path = '/server-info/status'
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path,
|
||||
path: '/server-info/status',
|
||||
value: ServerStatus.Updating,
|
||||
},
|
||||
]
|
||||
const res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path,
|
||||
path: '/server-info/status',
|
||||
value: ServerStatus.Running,
|
||||
},
|
||||
{
|
||||
@@ -116,7 +102,7 @@ export class MockApiService extends ApiService {
|
||||
value: this.config.version + '.1',
|
||||
},
|
||||
]
|
||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
// quickly revert patch to proper version to prevent infinite refresh loop
|
||||
const patch2 = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user