thingsboard/ui-ngx/src/app/modules/home/components/widget/lib/json-input-widget.component.html

59 lines
2.3 KiB
HTML
Raw Normal View History

2021-04-05 20:56:15 +03:00
<!--
2024-01-09 10:46:16 +02:00
Copyright © 2016-2024 The Thingsboard Authors
2021-04-05 20:56:15 +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
http://www.apache.org/licenses/LICENSE-2.0
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.
-->
<div class="tb-json-input" tb-toast toastTarget="{{ toastTargetId }}">
<form *ngIf="attributeUpdateFormGroup"
class="tb-json-input__form flex flex-col"
2021-04-05 20:56:15 +03:00
[formGroup]="attributeUpdateFormGroup"
(ngSubmit)="save()">
<div class="flex flex-1 flex-col gap-2.5" *ngIf="datasourceDetected && !errorMessage; else errorContainer">
<fieldset class="flex-1">
2021-04-05 20:56:15 +03:00
<tb-json-object-edit
[editorStyle]="{minHeight: '100px'}"
fillHeight="true"
[jsonRequired]="settings.attributeRequired"
2021-04-05 20:56:15 +03:00
label="{{ settings.showLabel ? labelValue : '' }}"
formControlName="currentValue"
(focusin)="isFocused = true;"
(focusout)="isFocused = false;"
></tb-json-object-edit>
</fieldset>
<div class="tb-json-input__actions flex flex-row items-center justify-end gap-5">
2021-04-05 20:56:15 +03:00
<button mat-button color="primary"
type="button"
[disabled]="!attributeUpdateFormGroup.dirty"
(click)="discard()"
matTooltip="{{ 'widgets.input-widgets.discard-changes' | translate }}"
matTooltipPosition="above">
{{ "action.undo" | translate }}
</button>
<button mat-raised-button color="primary"
2021-04-05 20:56:15 +03:00
type="submit"
[disabled]="attributeUpdateFormGroup.invalid || !attributeUpdateFormGroup.dirty">
{{ "action.save" | translate }}
</button>
</div>
</div>
<ng-template #errorContainer>
<div class="tb-json-input__error flex flex-1 flex-col items-center justify-center">
2021-04-05 20:56:15 +03:00
{{ errorMessage | translate }}
</div>
</ng-template>
2021-04-05 20:56:15 +03:00
</form>
</div>