thingsboard/ui-ngx/src/app/shared/components/device/gateway-connectors.component.html

129 lines
5.6 KiB
HTML
Raw Normal View History

2023-04-08 00:57:57 +03:00
<!--
2023-04-08 01:50:36 +03:00
Copyright © 2016-2023 The Thingsboard Authors
2023-04-08 00:57:57 +03:00
2023-04-08 01:50:36 +03:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
2023-04-08 00:57:57 +03:00
2023-04-08 01:50:36 +03:00
http://www.apache.org/licenses/LICENSE-2.0
2023-04-08 00:57:57 +03:00
2023-04-08 01:50:36 +03:00
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2023-04-08 00:57:57 +03:00
-->
<form style="height: 100%" fxLayout="column" [formGroup]="gatewayConnectorsGroup">
<mat-toolbar color="primary">
<h2 translate>gateway.connectors</h2>
<span fxFlex></span>
<button mat-icon-button
type="button"
(click)="cancel()"
*ngIf="dialogRef">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<div fxLayout="row" fxLayoutGap="15px" fxFlex style="height: calc(100% - 35px)">
<div fxFlex="30" fxLayout="column" style="overflow: auto">
<mat-accordion multi>
<mat-expansion-panel expanded="true"
formArrayName="connectors"
*ngFor="let connectorControl of connectorsFormArray().controls; let $index = index"
[ngClass]="{'mat-card-selected': $index === selectedConnector}">
<mat-expansion-panel-header>
<mat-panel-title class="expansion-panel-header">
{{generatePanelTitle(connectorControl)}}
</mat-panel-title>
</mat-expansion-panel-header>
<div fxLayout="row">
<mat-card fxLayout="row wrap" style="margin-bottom: 15px" [formGroupName]="$index">
<mat-slide-toggle color="primary" fxFlex="100" formControlName="active">
{{ (connectorControl.get('active').value ? 'gateway.connectors-active' : 'gateway.connectors-inactive') | translate }}
</mat-slide-toggle>
<mat-form-field fxFlex="calc(50%-15px)">
<mat-label translate>gateway.connector-name</mat-label>
<input matInput formControlName="name" required/>
<mat-error
*ngIf="connectorControl.get('name').hasError('required')">
{{'gateway.connector-name-required' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="calc(50%-15px)">
<mat-label translate>gateway.connector-configuration</mat-label>
<input matInput formControlName="configuration" required/>
<mat-error
*ngIf="connectorControl.get('configuration').hasError('required')">
{{'gateway.connector-configuration-required' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="calc(50%-15px)">
<mat-label translate>gateway.connector-type</mat-label>
<mat-select formControlName="type" required>
<mat-option *ngFor="let type of gatewayConnectorDefaultTypes" [value]="type">{{type}}</mat-option>
</mat-select>
<mat-error
*ngIf="connectorControl.get('type').hasError('required')">
{{'gateway.connector-type-required' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="calc(50%-15px)">
<mat-label translate>gateway.connector-key</mat-label>
<input matInput formControlName="key" required/>
<mat-error
*ngIf="connectorControl.get('key').hasError('required')">
{{'gateway.connector-key-required' | translate }}
</mat-error>
</mat-form-field>
</mat-card>
<div fxLayout="column">
<button mat-icon-button (click)="removeConnector($index)"
matTooltip="{{ 'gateway.statistics.remove' | translate }}"
matTooltipPosition="above">
<mat-icon>close</mat-icon>
</button>
<button mat-icon-button (click)="selectConnector($index)"
matTooltip="{{ 'gateway.select-connector' | translate }}"
matTooltipPosition="above">
<mat-icon>code</mat-icon>
</button>
</div>
</div>
</mat-expansion-panel>
</mat-accordion>
<button mat-raised-button color="primary"
style="margin-top: 15px"
type="button"
(click)="addConnector(true)">
{{ 'gateway.connector-add' | translate }}
</button>
</div>
<tb-json-object-edit
fxFlex
fxLayout="column"
required
*ngIf="selectedConnector !== undefined"
label="{{ 'gateway.connector-json' | translate }}"
[formControl]="getJsonControl(selectedConnector)">
</tb-json-object-edit>
</div>
<div mat-dialog-actions fxLayoutAlign="end center">
<button mat-button color="primary"
class="action-btns"
type="button"
(click)="cancel()">
{{ 'action.cancel' | translate }}
</button>
<button mat-raised-button color="primary"
class="action-btns"
type="button"
[disabled]="gatewayConnectorsGroup.invalid || !gatewayConnectorsGroup.dirty"
(click)="saveConnectors()">
{{ 'action.save' | translate }}
</button>
</div>
</form>