File
Methods
getAndAssignRepositoryBinaries
|
getAndAssignRepositoryBinaries(mos: IManagedObject[])
|
Parameters :
Name |
Type |
Optional |
mos |
IManagedObject[]
|
No
|
Returns : {}
|
getRepositoryEntriesWithVersions$
|
getRepositoryEntriesWithVersions$(searchTerm$: BehaviorSubject)
|
Parameters :
Name |
Type |
Optional |
searchTerm$ |
BehaviorSubject<FilterCriteria>
|
No
|
|
getRepositoryEntryWithPatches$
|
getRepositoryEntryWithPatches$()
|
|
installFirmware
|
installFirmware()
|
|
Async
loadDevice
|
loadDevice()
|
|
Async
ngOnInit
|
ngOnInit()
|
|
changesInProgress$
|
Type : Observable<boolean>
|
Default value : this.changesOperation$.pipe(
map(operation => this.isInProgress(operation))
)
|
changesOperation$
|
Default value : new BehaviorSubject<IOperation>(null)
|
device$
|
Type : BehaviorSubject<IManagedObject>
|
Default value : new BehaviorSubject(
this.route.parent.snapshot.data.contextData
)
|
firmwareBinary$
|
Type : Observable<IManagedObject>
|
Default value : this.deviceFirmwareFragment$.pipe(
filter(deviceFirmwareFragment => !isEmpty(deviceFirmwareFragment)),
switchMap(deviceFirmwareFragment =>
from(
this.repository.getRepositoryBinaryMoByVersion(
deviceFirmwareFragment,
RepositoryType.FIRMWARE
)
)
),
shareReplay(1)
)
|
isEmpty
|
Default value : isEmpty
|
patches$
|
Type : Observable<IManagedObject[]>
|
Default value : combineLatest(
this.firmwareBinary$,
this.repositoryEntry$
).pipe(
switchMap(([firmwareBinary, repositoryEntry]) => {
if (repositoryEntry && firmwareBinary) {
const version: string = this.repository.getBaseVersionFromMO(
firmwareBinary as FirmwareBinary
);
return from(this.repository.listPatchVersions(repositoryEntry, version)).pipe(
map(({ data }) => data)
);
} else {
return of([]);
}
}),
shareReplay(1)
)
|
reloading
|
Type : boolean
|
Default value : false
|
repositoryEntry$
|
Type : Observable<IManagedObject>
|
Default value : this.firmwareBinary$.pipe(
switchMap(mo => this.repository.getRepositoryEntryMO$(mo)),
shareReplay(1)
)
|
supportsFirmwareOperations$
|
Type : Observable<boolean>
|
Default value : this.device$.pipe(
map(
(device: IManagedObject) =>
get(device, 'c8y_SupportedOperations', []).indexOf('c8y_Firmware') > -1
)
)
|
<div class="row">
<div class="col-lg-12 col-lg-max">
<div class="card">
<div class="card-header separator">
<h4 class="card-title" translate>Current firmware</h4>
</div>
<div class="inner-scroll">
<fieldset *ngIf="changesOperation$ | async" class="card-block bg-gray-white">
<c8y-operation-details [operation]="changesOperation$ | async"></c8y-operation-details>
</fieldset>
<div class="card-block p-t-0 p-b-0">
<!-- EMPTY STATE -->
<ng-container *ngIf="isEmpty(deviceFirmwareFragment$ | async); else firmwareBlock">
<div class="c8y-empty-state text-center">
<h1 c8yIcon="c8y-firmware" class="c8y-icon-duocolor"></h1>
<p>
<strong translate>No firmware installed.</strong> <br />
<small translate>Click below to install firmware into this device.</small>
</p>
</div>
</ng-container>
<!-- FIRMWARE -->
<ng-template #firmwareBlock>
<c8y-list-group class="no-border-last">
<c8y-li>
<c8y-li-icon>
<i c8yIcon="c8y-firmware"></i>
</c8y-li-icon>
<c8y-li-body *ngIf="deviceFirmwareFragment$ | async as deviceFirmwareFragment">
<!-- Firmware title -->
<p class="m-b-16 text-medium">
{{ deviceFirmwareFragment.name }}
</p>
<!-- Firmware description -->
<div *ngIf="repositoryEntry$ | async as repositoryEntry">
<p class="text-label-small" translate>Description</p>
<p>
{{ repositoryEntry.description }}
</p>
</div>
<!-- BASE/PATCH VERSION -->
<div class="m-b-16">
<p class="text-label-small" translate>Version</p>
<p *ngIf="deviceFirmwareFragment.version; else versionNotSpecified">
{{ deviceFirmwareFragment.version }}
</p>
<ng-template #versionNotSpecified>
<p>
<em class="text-muted"> ({{ 'not specified`version`' | translate }}) </em>
</p>
</ng-template>
</div>
<!-- ADD PATCH -->
<button
*ngIf="
(supportsFirmwareOperations$ | async) && (this.patches$ | async)?.length > 0
"
(click)="addPatch()"
class="btn btn-xs btn-primary"
[disabled]="changesInProgress$ | async"
title="{{ 'Patches available' | translate }}"
>
{{ 'Patches available' | translate }}
</button>
</c8y-li-body>
</c8y-li>
</c8y-list-group>
</ng-template>
</div>
</div>
<div *ngIf="supportsFirmwareOperations$ | async" class="card-footer separator-top">
<!-- INSTALL FIRMWARE -->
<button
*ngIf="isEmpty(deviceFirmwareFragment$ | async)"
class="btn btn-primary"
(click)="installFirmware()"
title="{{ 'Install firmware' | translate }}"
>
{{ 'Install firmware' | translate }}
</button>
<!-- REPLACE FIRMWARE -->
<button
*ngIf="!isEmpty(deviceFirmwareFragment$ | async)"
class="btn btn-primary"
(click)="installFirmware()"
[disabled]="changesInProgress$ | async"
title="{{ 'Replace firmware' | translate }}"
>
{{ 'Replace firmware' | translate }}
</button>
</div>
</div>
</div>
</div>