sigfox-device-registration/sigfox-device-registration.component.ts
selector | c8y-sigfox-device-registration |
templateUrl | sigfox-device-registration.component.html |
Properties |
Methods |
constructor(bsModalRef: BsModalRef, sigfoxService: SigfoxProviderService, translateService: TranslateService, gainsightService: GainsightService)
|
|||||||||||||||
Parameters :
|
Async create | ||||||
create(event: literal type)
|
||||||
Parameters :
Returns :
any
|
getConnections$ |
getConnections$()
|
Returns :
any
|
getContracts$ | ||||
getContracts$(name)
|
||||
Parameters :
Returns :
any
|
getProtocols$ |
getProtocols$()
|
Returns :
any
|
getSigfoxDeviceToSend |
getSigfoxDeviceToSend()
|
Returns :
SigfoxDevice
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
Public bsModalRef |
Type : BsModalRef
|
connections$ |
Default value : this.getConnections$()
|
errorMessages$ |
Default value : this.errors$.pipe(
map(errors => errors.map(error => error.message)),
map(messages => uniq(messages))
)
|
errors$ |
Default value : new BehaviorSubject<Error[]>([])
|
finalStepLabels |
Type : object
|
Default value : {
back: gettext('Close')
}
|
form |
Default value : new FormGroup({})
|
model |
Type : SigfoxDeviceFormly
|
Default value : {} as any
|
Readonly PAGING |
Type : object
|
Default value : {
withTotalPages: true,
pageSize: 10
}
|
protocols$ |
Default value : this.getProtocols$()
|
registrationStepLabels |
Type : object
|
Default value : {
next: gettext('Register')
}
|
state |
Type : SigfoxState
|
Default value : 'loadPending'
|
stepper |
Type : C8yStepper
|
unsubscribe$ |
Type : Subject<void>
|
Default value : new Subject()
|
<c8y-modal
[title]="'Sigfox registration' | translate"
[headerClasses]="'dialog-header'"
[customFooter]="true"
>
<ng-container c8y-modal-title>
<span [c8yIcon]="'c8y-device-connect'"></span>
</ng-container>
<ng-container *ngIf="state === 'loadPending'; else registrationForm">
<div class="p-16 text-center">
<c8y-loading></c8y-loading>
</div>
</ng-container>
<ng-template #registrationForm>
<c8y-stepper
[hideStepProgress]="true"
linear
c8y-modal-body
*ngIf="(errorMessages$ | async).length === 0; else errorMessagesPresent"
>
<cdk-step [stepControl]="form">
<div class="p-b-16">
<p class="modal-subtitle sticky-top">
{{ 'Register a single Sigfox device' | translate }}
</p>
<formly-form
class="d-block p-l-24 p-r-24 p-t-16"
[form]="form"
[fields]="fields"
[model]="model"
></formly-form>
</div>
<c8y-stepper-buttons
class="modal-footer d-block sticky-bottom separator-top bg-component"
[labels]="registrationStepLabels"
(onNext)="create($event)"
(onCancel)="bsModalRef.hide()"
[showButtons]="{ cancel: true, next: true }"
[pending]="state === 'registrationPending'"
[disabled]="!form.valid"
></c8y-stepper-buttons>
</cdk-step>
<cdk-step state="final">
<div
class="p-16 text-center"
*ngIf="state === 'registrationPending'"
>
<c8y-loading></c8y-loading>
</div>
<div class="m-24">
<c8y-operation-result
class="lead m-b-0"
type="success"
*ngIf="state === 'registrationSuccess'"
text="{{ 'Device registered' | translate }}"
[size]="84"
[vertical]="true"
></c8y-operation-result>
</div>
<c8y-stepper-buttons
class="sticky-bottom d-block p-t-16 p-b-16 separator-top bg-component"
(onCustom)="bsModalRef.hide()"
[showButtons]="{ custom: true }"
[labels]="finalStepLabels"
></c8y-stepper-buttons>
</cdk-step>
</c8y-stepper>
</ng-template>
<ng-template #errorMessagesPresent>
<div class="m-24">
<c8y-operation-result
class="lead"
type="error"
*ngIf="state === 'registrationError'"
text="{{ 'Failed to register' | translate }}"
[size]="84"
[vertical]="true"
></c8y-operation-result>
<div
class="m-b-8"
*ngFor="let msg of errorMessages$ | async"
data-cy="sigfox-device-registration.component--registration-error"
[ngClass]="{
'text-center': state === 'registrationError',
'alert alert-danger': state === 'loadError'
}"
>
<span [innerHTML]="msg | translate"></span>
</div>
</div>
<div class="modal-footer">
<button
class="btn btn-default"
title="{{ 'Close' | translate }}"
type="button"
(click)="bsModalRef.hide()"
>
{{ 'Close' | translate }}
</button>
</div>
</ng-template>
</c8y-modal>