device-shell/shell/shell.component.ts
providers |
OperationRealtimeService
ManagedObjectRealtimeService
|
selector | c8y-device-shell |
templateUrl | shell.component.html |
Properties |
Methods |
constructor(service: DeviceShellService, operationRealtime: OperationRealtimeService, moRealtime: ManagedObjectRealtimeService, operationService: OperationService, route: ActivatedRoute, modalService: BsModalService, alertService: AlertService)
|
||||||||||||||||||||||||
Parameters :
|
Async execute | ||||
execute(commandDeliveryType)
|
||||
Parameters :
Returns :
Promise<void>
|
getPredefinedCommand |
getPredefinedCommand()
|
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
Async ngOnInit |
ngOnInit()
|
Returns :
Promise<void>
|
resetSupportedDeliveryTypes |
resetSupportedDeliveryTypes()
|
Returns :
void
|
command |
Type : Command
|
Default value : {} as Command
|
deliveryTypes |
Type : Array<>
|
Default value : (
this.service.getDeliveryTypes() || []
).map(deliveryType => ({ ...deliveryType, isSupportedByCommand: true }))
|
device |
Type : IManagedObject
|
Default value : this.route.snapshot.parent.data.contextData
|
device$ |
Type : Observable<IManagedObject>
|
Default value : of({} as any)
|
executeViaLabel |
Default value : gettext('Execute via ({{deliveryType}})')
|
filterPipe |
Default value : pipe(
map((operations: IOperation[]) =>
(operations || []).filter((operation: IOperation) => !!operation.c8y_Command)
)
)
|
Public operationRealtime |
Type : OperationRealtimeService
|
operations |
Type : IResultList<IOperation>
|
sendingCommand$ |
Type : BehaviorSubject<boolean>
|
Default value : new BehaviorSubject(false)
|
Public service |
Type : DeviceShellService
|
smsEnabled |
Type : boolean
|
Default value : false
|
<c8y-action-bar-item [placement]="'right'">
<c8y-realtime-btn [service]="operationRealtime"></c8y-realtime-btn>
</c8y-action-bar-item>
<div class="card content-fullpage d-grid grid__col--6-6--md">
<div class="inner-scroll d-flex d-col bg-white">
<div class="card-header large-padding separator sticky-top">
<h4 class="card-title">
{{ 'Command' | translate }}
</h4>
</div>
<div class="card-block d-flex d-col flex-grow large-padding">
<div class="flex-row p-b-16">
<button
class="btn btn-default btn-sm"
type="button"
(click)="getPredefinedCommand()"
[title]="'Display a list of predefined commands' | translate"
>
{{ 'Predefined commands' | translate }}
</button>
<div class="flex-item-right">
<device-status [mo]="device$ | async"></device-status>
</div>
</div>
<textarea
class="form-control inner-scroll flex-grow bg-gray-lighter"
[(ngModel)]="command.text"
(ngModelChange)="$event || resetSupportedDeliveryTypes()"
>
</textarea>
</div>
<div class="card-footer large-padding separator">
<ng-container *ngFor="let deliveryType of deliveryTypes">
<button
class="btn btn-primary"
type="button"
*ngIf="deliveryType.isSupportedByCommand"
[disabled]="!command?.text || (sendingCommand$ | async)"
(click)="execute(deliveryType.name)"
>
<span
[title]="
deliveryType.default
? ('Execute' | translate)
: (executeViaLabel | translate: { deliveryType: deliveryType.name })
"
>
{{
deliveryType.default
? ('Execute' | translate)
: (executeViaLabel | translate: { deliveryType: deliveryType.name })
}}
</span>
</button>
</ng-container>
</div>
</div>
<div class="inner-scroll bg-gray-white">
<div class="card-header large-padding separator sticky-top">
<h4 class="card-title">
{{ 'Operations' | translate }}
</h4>
</div>
<div class="card-block large-padding">
<c8y-operations-timeline
[operations]="operations"
[sourceId]="device.id"
[filterPipe]="filterPipe"
[bodyTemplate]="timelineItemBody"
[footerTemplates]="[timelineItemFooter]"
[propertiesToHide]="['c8y_Command']"
></c8y-operations-timeline>
<ng-template #timelineItemBody let-operation>
<small>{{ operation.c8y_Command?.text || operation.description }}</small>
</ng-template>
<ng-template #timelineItemFooter let-operation>
<div *ngIf="operation.c8y_Command?.text">
<div class="legend form-block" translate>Command</div>
<pre class="text-pre-normal">
<code>{{operation.c8y_Command.text}}</code>
</pre>
</div>
<div *ngIf="operation.c8y_Command?.result">
<div class="legend form-block" translate>Response</div>
<pre class="text-pre-normal">
<code>{{operation.c8y_Command.result}}</code>
</pre>
</div>
</ng-template>
</div>
</div>
</div>