File
Index
Properties
|
|
Methods
|
|
Outputs
|
|
Methods
Async
ngOnInit
|
ngOnInit()
|
|
setInitialState
|
setInitialState()
|
|
baseVersions$
|
Type : Observable<IResultList<IManagedObject>>
|
Default value : merge(
this.firmwareInput$.pipe(
tap(() => {
this.model.dependency = null;
if (this.form) {
this.form.form.get('patchDependency').reset();
}
}),
switchMap(() => of(null))
),
this.firmwareSelected$
).pipe(
switchMap(selectedFirmware =>
selectedFirmware ? this.repository.listBaseVersions(selectedFirmware) : of(null)
),
shareReplay(1)
)
|
baseVersionsFilterPipe
|
Default value : pipe(
switchMap((data: []) =>
this.patchDependencyInput$.pipe(
map(partialVersion =>
data.filter((mo: any) => {
const version = mo.c8y_Firmware.version?.toLowerCase();
return (
partialVersion.length === 0 || version?.indexOf(partialVersion.toLowerCase()) > -1
);
})
)
)
)
)
|
dropdown
|
Type : BsDropdownDirective
|
Decorators :
@ViewChild('dropdown', {static: false})
|
firmwareInput$
|
Default value : new BehaviorSubject<string>('')
|
firmwarePreselected
|
Default value : false
|
firmwares$
|
Type : Observable<IResultList<IManagedObject>>
|
Default value : this.firmwareInput$.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap(searchStr =>
from(
this.repository.listRepositoryEntries(RepositoryType.FIRMWARE, {
partialName: searchStr,
skipLegacy: true
})
)
),
shareReplay(1)
)
|
firmwareSelected$
|
Default value : new BehaviorSubject<Partial<RepositoryCategory>>(null)
|
form
|
Type : NgForm
|
Decorators :
@ViewChild('firmwarePatchForm', {static: false})
|
model
|
Type : ModalModel
|
Default value : {
selected: undefined,
dependency: null,
patchVersion: undefined,
binary: {
file: undefined,
url: undefined
}
}
|
patchDependencyInput$
|
Default value : new BehaviorSubject<string>('')
|
PRODUCT_EXPERIENCE
|
Default value : PRODUCT_EXPERIENCE_REPOSITORY_SHARED
|
saving
|
Default value : false
|
textForFirmwareUrlPopover
|
Type : string
|
Default value : gettext(`Path for binaries can vary depending on device agent implementation, for example:
/firmware/binaries/firmware1.bin
https://firmware/binary/123
ftp://firmware/binary/123.tar.gz
`)
|
<div class="viewport-modal">
<div class="modal-header dialog-header">
<i [c8yIcon]="'c8y-firmware'"></i>
<h4 translate id="addFirmwarePatchModalTitle">Add firmware patch</h4>
</div>
<div class="p-16 text-center separator-bottom" id="addFirmwarePatchModalDescription">
<p class="text-medium text-16 m-0" translate>Select a firmware version</p>
</div>
<form
class="d-contents"
autocomplete="off"
#firmwarePatchForm="ngForm"
(ngSubmit)="firmwarePatchForm.form.valid && save()"
>
<div class="modal-inner-scroll">
<div class="modal-body">
<div [hidden]="firmwarePreselected">
<c8y-form-group>
<label for="firmwareName" translate>Firmware</label>
<c8y-typeahead
[ngModel]="model.selected"
name="firmwareName"
placeholder="{{ 'Select or enter' | translate }}"
(onSearch)="firmwareInput$.next($event)"
[allowFreeEntries]="false"
[required]="true"
>
<c8y-li
*c8yFor="let firmware of firmwares$ | async; loadMore: 'auto'"
class="p-l-8 p-r-8 c8y-list__item--link"
(click)="model.selected = firmware; firmwareSelected$.next(firmware)"
[active]="model.selected === firmware"
>
<c8y-highlight
[text]="firmware.name || '--'"
[pattern]="firmwareInput$ | async"
></c8y-highlight>
</c8y-li>
</c8y-typeahead>
<c8y-messages>
<c8y-message
name="notExisting"
[text]="'Select one of the existing firmwares.' | translate"
></c8y-message>
</c8y-messages>
</c8y-form-group>
</div>
<c8y-form-group>
<label for="patchDependency" class="m-r-8" translate>Version</label>
<c8y-typeahead
[ngModel]="model.dependency"
name="patchDependency"
data-cy="add-firmware-patch-modal--patchDependency"
placeholder="{{ 'Select or enter' | translate }}"
(onSearch)="patchDependencyInput$.next($event)"
[displayProperty]="'c8y_Firmware.version'"
[allowFreeEntries]="false"
[disabled]="
(baseVersions$ | async) === null || (baseVersions$ | async)?.data.length === 0
"
[required]="true"
>
<c8y-li
*c8yFor="
let baseVersion of baseVersions$;
loadMore: 'auto';
pipe: baseVersionsFilterPipe
"
class="p-l-8 p-r-8 c8y-list__item--link"
(click)="model.dependency = baseVersion"
[active]="model.dependency === baseVersion"
>
<c8y-highlight
[text]="baseVersion.c8y_Firmware.version || '--'"
[pattern]="patchDependencyInput$ | async"
></c8y-highlight>
</c8y-li>
</c8y-typeahead>
<c8y-messages>
<c8y-message
name="notExisting"
[text]="'Select one of the existing versions.' | translate"
></c8y-message>
</c8y-messages>
</c8y-form-group>
<c8y-form-group>
<label for="patchVersion" translate>Patch</label>
<input
id="patchVersion"
class="form-control"
autocomplete="off"
name="patchVersion"
data-cy="add-firmware-patch-modal--patchVersion"
[(ngModel)]="model.patchVersion"
placeholder="{{ 'e.g.' | translate }} 1.0.0"
required
/>
</c8y-form-group>
<c8y-form-group>
<div class="legend form-block m-t-40" translate>Patch file</div>
<c8y-file-picker
[maxAllowedFiles]="1"
(onFilesPicked)="onFile($event)"
[fileUrlPopover]="textForFirmwareUrlPopover"
></c8y-file-picker>
</c8y-form-group>
</div>
</div>
<div class="modal-footer">
<button
title="{{ 'Cancel' | translate }}"
data-cy="add-firmware-patch-modal--cancel-btn"
class="btn btn-default"
type="button"
(click)="cancel()"
[disabled]="saving"
translate
>
Cancel
</button>
<button
title="{{ 'Add firmware patch' | translate }}"
class="btn btn-primary"
type="submit"
[ngClass]="{ 'btn-pending': saving }"
[disabled]="
!firmwarePatchForm.form.valid ||
firmwarePatchForm.form.pristine ||
(!model.binary?.url && !model.binary?.file) ||
saving
"
translate
c8yProductExperience
[actionName]="PRODUCT_EXPERIENCE.FIRMWARE.EVENTS.REPOSITORY"
[actionData]="{
component: PRODUCT_EXPERIENCE.FIRMWARE.COMPONENTS.ADD_FIRMWAR_PATCH_MODAL,
result: PRODUCT_EXPERIENCE.FIRMWARE.RESULTS.ADD_FIRMWARE_PATCH
}"
>
Add firmware patch
</button>
</div>
</form>
</div>