mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
* update actions response types and partially implement in UI * further remove diagnostic ui * convert action response nested to array * prepare action res modal for Alex * ad dproperties action for Bitcoin * feat: add action success dialog (#2753) * feat: add action success dialog * mocks for string action res and hide properties from actions page --------- Co-authored-by: Matt Hill <mattnine@protonmail.com> * return null * remove properties from backend * misc fixes * make severity separate argument * rename ActionRequest to ActionRequestOptions * add clearRequests * fix s9pk build * remove config and properties, introduce action requests * better ux, better moocks, include icons * fix dependency types * add variant for versionCompat * fix dep icon display and patch operation display * misc fixes * misc fixes * alpha 12 * honor provided input to set values in action * fix: show full descriptions of action success items (#2758) * fix type * fix: fix build:deps command on Windows (#2752) * fix: fix build:deps command on Windows * fix: add escaped quotes --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> * misc db compatibility fixes --------- Co-authored-by: Alex Inkin <alexander@inkin.ru> Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
165 lines
3.6 KiB
TypeScript
165 lines
3.6 KiB
TypeScript
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
|
|
import { PkgDependencyErrors } from './dep-error.service'
|
|
import { T } from '@start9labs/start-sdk'
|
|
|
|
export interface PackageStatus {
|
|
primary: PrimaryStatus
|
|
dependency: DependencyStatus | null
|
|
health: T.HealthStatus | null
|
|
}
|
|
|
|
export function renderPkgStatus(
|
|
pkg: PackageDataEntry,
|
|
depErrors: PkgDependencyErrors,
|
|
): PackageStatus {
|
|
let primary: PrimaryStatus
|
|
let dependency: DependencyStatus | null = null
|
|
let health: T.HealthStatus | null = null
|
|
|
|
if (pkg.stateInfo.state === 'installed') {
|
|
primary = getInstalledPrimaryStatus(pkg)
|
|
dependency = getDependencyStatus(depErrors)
|
|
health = getHealthStatus(pkg.status)
|
|
} else {
|
|
primary = pkg.stateInfo.state
|
|
}
|
|
|
|
return { primary, dependency, health }
|
|
}
|
|
|
|
function getInstalledPrimaryStatus(pkg: T.PackageDataEntry): PrimaryStatus {
|
|
if (
|
|
Object.values(pkg.requestedActions).some(
|
|
r => r.active && r.request.severity === 'critical',
|
|
)
|
|
) {
|
|
return 'actionRequired'
|
|
} else {
|
|
return pkg.status.main
|
|
}
|
|
}
|
|
|
|
function getDependencyStatus(depErrors: PkgDependencyErrors): DependencyStatus {
|
|
return Object.values(depErrors).some(err => !!err) ? 'warning' : 'satisfied'
|
|
}
|
|
|
|
function getHealthStatus(status: T.MainStatus): T.HealthStatus | null {
|
|
if (status.main !== 'running' || !status.main) {
|
|
return null
|
|
}
|
|
|
|
const values = Object.values(status.health)
|
|
|
|
if (values.some(h => h.result === 'failure')) {
|
|
return 'failure'
|
|
}
|
|
|
|
if (values.some(h => h.result === 'loading')) {
|
|
return 'loading'
|
|
}
|
|
|
|
if (values.some(h => h.result === 'starting')) {
|
|
return 'starting'
|
|
}
|
|
|
|
return 'success'
|
|
}
|
|
|
|
export interface StatusRendering {
|
|
display: string
|
|
color: string
|
|
showDots?: boolean
|
|
}
|
|
|
|
export type PrimaryStatus =
|
|
| 'installing'
|
|
| 'updating'
|
|
| 'removing'
|
|
| 'restoring'
|
|
| 'starting'
|
|
| 'running'
|
|
| 'stopping'
|
|
| 'restarting'
|
|
| 'stopped'
|
|
| 'backingUp'
|
|
| 'actionRequired'
|
|
| 'error'
|
|
|
|
export type DependencyStatus = 'warning' | 'satisfied'
|
|
|
|
export const PrimaryRendering: Record<PrimaryStatus, StatusRendering> = {
|
|
installing: {
|
|
display: 'Installing',
|
|
color: 'primary',
|
|
showDots: true,
|
|
},
|
|
updating: {
|
|
display: 'Updating',
|
|
color: 'primary',
|
|
showDots: true,
|
|
},
|
|
removing: {
|
|
display: 'Removing',
|
|
color: 'danger',
|
|
showDots: true,
|
|
},
|
|
restoring: {
|
|
display: 'Restoring',
|
|
color: 'primary',
|
|
showDots: true,
|
|
},
|
|
stopping: {
|
|
display: 'Stopping',
|
|
color: 'dark-shade',
|
|
showDots: true,
|
|
},
|
|
restarting: {
|
|
display: 'Restarting',
|
|
color: 'tertiary',
|
|
showDots: true,
|
|
},
|
|
stopped: {
|
|
display: 'Stopped',
|
|
color: 'dark-shade',
|
|
showDots: false,
|
|
},
|
|
backingUp: {
|
|
display: 'Backing Up',
|
|
color: 'primary',
|
|
showDots: true,
|
|
},
|
|
starting: {
|
|
display: 'Starting',
|
|
color: 'primary',
|
|
showDots: true,
|
|
},
|
|
running: {
|
|
display: 'Running',
|
|
color: 'success',
|
|
showDots: false,
|
|
},
|
|
actionRequired: {
|
|
display: 'Action Required',
|
|
color: 'warning',
|
|
showDots: false,
|
|
},
|
|
error: {
|
|
display: 'Service Launch Error',
|
|
color: 'danger',
|
|
showDots: false,
|
|
},
|
|
}
|
|
|
|
export const DependencyRendering: Record<DependencyStatus, StatusRendering> = {
|
|
warning: { display: 'Issue', color: 'warning' },
|
|
satisfied: { display: 'Satisfied', color: 'success' },
|
|
}
|
|
|
|
export const HealthRendering: Record<T.HealthStatus, StatusRendering> = {
|
|
failure: { display: 'Failure', color: 'danger' },
|
|
starting: { display: 'Starting', color: 'primary' },
|
|
loading: { display: 'Loading', color: 'primary' },
|
|
success: { display: 'Healthy', color: 'success' },
|
|
disabled: { display: 'Disabled', color: 'dark' },
|
|
}
|