mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
Feature/sideload (#1520)
* base styling and action placeholders for package sideload * apparently didnt add new folder * wip * parse manifest and icon from s9pk to upload * wip handle s9pk upload * adjust types, finalize actions, cleanup * clean up and fix data clearing and response * include rest rpc in proxy conf sample * address feedback to use shorthand falsy coercion * update copy and invalid package file ux * do not wait package upload, instead show install progress * fix proxy for rest rpc rename sideload package page titles
This commit is contained in:
@@ -5,6 +5,7 @@ import { ConfigSpec } from 'src/app/pkg-config/config-types'
|
||||
import {
|
||||
DataModel,
|
||||
DependencyError,
|
||||
Manifest,
|
||||
} from 'src/app/services/patch-db/data-model'
|
||||
|
||||
export module RR {
|
||||
@@ -239,6 +240,12 @@ export module RR {
|
||||
spec: ConfigSpec
|
||||
}
|
||||
|
||||
export interface SideloadPackageReq {
|
||||
manifest: Manifest
|
||||
icon: string // base64
|
||||
}
|
||||
export type SideloadPacakgeRes = string //guid
|
||||
|
||||
// marketplace
|
||||
|
||||
export type GetMarketplaceDataReq = { 'server-id': string }
|
||||
|
||||
@@ -27,6 +27,9 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
// for getting static files: ex icons, instructions, licenses
|
||||
abstract getStatic(url: string): Promise<string>
|
||||
|
||||
// for sideloading packages
|
||||
abstract uploadPackage(guid: string, body: ArrayBuffer): Promise<string>
|
||||
|
||||
// db
|
||||
|
||||
abstract getRevisions(since: number): Promise<RR.GetRevisionsRes>
|
||||
@@ -260,6 +263,10 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
deleteRecoveredPackage = (params: RR.UninstallPackageReq) =>
|
||||
this.syncResponse(() => this.deleteRecoveredPackageRaw(params))()
|
||||
|
||||
abstract sideloadPackage(
|
||||
params: RR.SideloadPackageReq,
|
||||
): Promise<RR.SideloadPacakgeRes>
|
||||
|
||||
// Helper allowing quick decoration to sync the response patch and return the response contents.
|
||||
// Pass in a tempUpdate function which returns a UpdateTemp corresponding to a temporary
|
||||
// state change you'd like to enact prior to request and expired when request terminates.
|
||||
|
||||
@@ -23,6 +23,15 @@ export class LiveApiService extends ApiService {
|
||||
})
|
||||
}
|
||||
|
||||
async uploadPackage(guid: string, body: ArrayBuffer): Promise<string> {
|
||||
return this.http.httpRequest({
|
||||
method: Method.POST,
|
||||
body,
|
||||
url: `/rest/rpc/${guid}`,
|
||||
responseType: 'text',
|
||||
})
|
||||
}
|
||||
|
||||
// db
|
||||
|
||||
async getRevisions(since: number): Promise<RR.GetRevisionsRes> {
|
||||
@@ -333,4 +342,13 @@ export class LiveApiService extends ApiService {
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
async sideloadPackage(
|
||||
params: RR.SideloadPackageReq,
|
||||
): Promise<RR.SideloadPacakgeRes> {
|
||||
return this.http.rpcRequest({
|
||||
method: 'package.sideload',
|
||||
params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@ export class MockApiService extends ApiService {
|
||||
return markdown
|
||||
}
|
||||
|
||||
async uploadPackage(guid: string, body: ArrayBuffer): Promise<string> {
|
||||
await pauseFor(2000)
|
||||
return 'success'
|
||||
}
|
||||
|
||||
// db
|
||||
|
||||
async getRevisions(since: number): Promise<RR.GetRevisionsRes> {
|
||||
@@ -750,6 +755,13 @@ export class MockApiService extends ApiService {
|
||||
}
|
||||
}
|
||||
|
||||
async sideloadPackage(
|
||||
params: RR.SideloadPackageReq,
|
||||
): Promise<RR.SideloadPacakgeRes> {
|
||||
await pauseFor(2000)
|
||||
return '4120e092-05ab-4de2-9fbd-c3f1f4b1df9e' // no significance, randomly generated
|
||||
}
|
||||
|
||||
private async updateProgress(id: string): Promise<void> {
|
||||
const progress = { ...PROGRESS }
|
||||
const phases = [
|
||||
|
||||
@@ -47,7 +47,10 @@ function getDependencyStatus(pkg: PackageDataEntry): DependencyStatus | null {
|
||||
return depIds.length ? DependencyStatus.Warning : DependencyStatus.Satisfied
|
||||
}
|
||||
|
||||
function getHealthStatus(status: Status): HealthStatus | null {
|
||||
function getHealthStatus(
|
||||
status: Status,
|
||||
hasHealthChecks: boolean,
|
||||
): HealthStatus | null {
|
||||
if (status.main.status !== PackageMainStatus.Running || !status.main.health) {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user