File
Implements
Methods
Async
execute
|
execute(commandDeliveryType)
|
Parameters :
Name |
Optional |
commandDeliveryType |
No
|
Returns : Promise<void>
|
getPredefinedCommand
|
getPredefinedCommand()
|
|
ngOnDestroy
|
ngOnDestroy()
|
|
Async
ngOnInit
|
ngOnInit()
|
Returns : Promise<void>
|
resetSupportedDeliveryTypes
|
resetSupportedDeliveryTypes()
|
|
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)
)
)
|
operations
|
Type : IResultList<IOperation>
|
sendingCommand$
|
Type : BehaviorSubject<boolean>
|
Default value : new BehaviorSubject(false)
|
smsEnabled
|
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-level-0">
<div class="card-header large-padding separator sticky-top">
<div class="card-title">
{{ 'Command' | translate }}
</div>
</div>
<div class="card-block d-flex d-col flex-grow large-padding">
<div class="d-flex p-b-16">
<button
class="btn btn-default btn-sm"
type="button"
(click)="getPredefinedCommand()"
[title]="'Display a list of predefined commands' | translate"
data-cy="shell--predefined-commands"
>
{{ 'Predefined commands' | translate }}
</button>
<div class="m-l-auto">
<device-status [mo]="device$ | async"></device-status>
</div>
</div>
<textarea
[attr.aria-label]="'Commands' | translate"
class="form-control inner-scroll flex-grow bg-level-2 text-monospace"
[(ngModel)]="command.text"
data-cy="shell-component--commands"
(ngModelChange)="$event || resetSupportedDeliveryTypes()"
placeholder="{{ 'Add commands or use predefined commands above.' | translate }}"
></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-level-1">
<div class="card-header large-padding separator sticky-top">
<div class="card-title">
{{ 'Operations' | translate }}
</div>
</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>
<!-- Keep this in a single line since `pre-text` will preserve all whitespaces in the `pre` tag.-->
<pre class="p-8 text-pre"><code>{{operation.c8y_Command.text}}</code></pre>
</div>
<div *ngIf="operation.c8y_Command?.result">
<div class="legend form-block" translate>Response</div>
<!-- Keep this in a single line since `pre-text` will preserve all whitespaces in the `pre` tag.-->
<pre class="p-8 text-pre"><code>{{operation.c8y_Command.result}}</code></pre>
</div>
</ng-template>
</div>
</div>
</div>