mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
re-introduce watch
This commit is contained in:
committed by
Aiden McClelland
parent
2255089484
commit
c02c0a0c3d
@@ -1,5 +1,5 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
import { Observable } from 'rxjs'
|
||||
import { combineLatest, 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'
|
||||
@@ -14,11 +14,14 @@ export class DisplayBulbPipe implements PipeTransform {
|
||||
) { }
|
||||
|
||||
transform (pkgId: string, bulb: DisplayBulb, connected: boolean): Observable<boolean> {
|
||||
return this.patch.sequence$.pipe(
|
||||
map(_ => {
|
||||
return combineLatest([
|
||||
this.patch.watch$('package-data', pkgId, 'state'),
|
||||
this.patch.watch$('package-data', pkgId, 'installed', 'status'),
|
||||
])
|
||||
.pipe(
|
||||
map(([state, status]) => {
|
||||
if (!connected) return bulb === 'off'
|
||||
const pkg = this.patch.data['package-data'][pkgId]
|
||||
const { color } = renderPkgStatus(pkg.state, pkg.installed.status)
|
||||
const { color } = renderPkgStatus(state, status)
|
||||
switch (color) {
|
||||
case 'danger': return bulb === 'red'
|
||||
case 'success': return bulb === 'green'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
import { Observable } from 'rxjs'
|
||||
import { combineLatest, 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'
|
||||
@@ -14,10 +14,13 @@ export class StatusPipe implements PipeTransform {
|
||||
) { }
|
||||
|
||||
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
|
||||
return combineLatest([
|
||||
this.patch.watch$('package-data', pkgId, 'state'),
|
||||
this.patch.watch$('package-data', pkgId, 'installed', 'status'),
|
||||
])
|
||||
.pipe(
|
||||
map(([state, status]) => {
|
||||
return renderPkgStatus(state, status).feStatus
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user