mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
react to sequnce changes
This commit is contained in:
committed by
Aiden McClelland
parent
c4fa205c3d
commit
2255089484
@@ -1,5 +1,6 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
import { PackageState, Status } from '../services/patch-db/data-model'
|
||||
import { Observable } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
import { PatchDbModel } from '../services/patch-db/patch-db.service'
|
||||
import { renderPkgStatus } from '../services/pkg-status-rendering.service'
|
||||
|
||||
@@ -12,16 +13,20 @@ export class DisplayBulbPipe implements PipeTransform {
|
||||
private readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
transform (pkgId: string, bulb: DisplayBulb, connected: boolean): boolean {
|
||||
const pkg = this.patch.data['package-data'][pkgId]
|
||||
if (!connected) return bulb === 'off'
|
||||
const { color } = renderPkgStatus(pkg.state, pkg.installed.status)
|
||||
switch (color) {
|
||||
case 'danger': return bulb === 'red'
|
||||
case 'success': return bulb === 'green'
|
||||
case 'warning': return bulb === 'yellow'
|
||||
default: return bulb === 'off'
|
||||
}
|
||||
transform (pkgId: string, bulb: DisplayBulb, connected: boolean): Observable<boolean> {
|
||||
return this.patch.sequence$.pipe(
|
||||
map(_ => {
|
||||
if (!connected) return bulb === 'off'
|
||||
const pkg = this.patch.data['package-data'][pkgId]
|
||||
const { color } = renderPkgStatus(pkg.state, pkg.installed.status)
|
||||
switch (color) {
|
||||
case 'danger': return bulb === 'red'
|
||||
case 'success': return bulb === 'green'
|
||||
case 'warning': return bulb === 'yellow'
|
||||
default: return bulb === 'off'
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
import { Observable } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
import { PatchDbModel } from '../services/patch-db/patch-db.service'
|
||||
import { FEStatus, renderPkgStatus } from '../services/pkg-status-rendering.service'
|
||||
|
||||
@@ -11,9 +13,12 @@ export class StatusPipe implements PipeTransform {
|
||||
private readonly patch: PatchDbModel,
|
||||
) { }
|
||||
|
||||
transform (pkgId: string): FEStatus {
|
||||
console.log(pkgId)
|
||||
const pkg = this.patch.data['package-data'][pkgId]
|
||||
return renderPkgStatus(pkg.state, pkg.installed.status).feStatus
|
||||
transform (pkgId: string): Observable<FEStatus> {
|
||||
return this.patch.sequence$.pipe(
|
||||
map(_ => {
|
||||
const pkg = this.patch.data['package-data'][pkgId]
|
||||
return renderPkgStatus(pkg.state, pkg.installed.status).feStatus
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user