<!--

    Copyright © 2016-2022 The Thingsboard Authors

    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.

-->
<section class="tb-widget-settings" [formGroup]="tripAnimationMarkerSettingsFormGroup">
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.maps.markers-settings</legend>
    <mat-form-field fxFlex class="mat-block">
      <mat-label translate>widgets.maps.rotation-angle</mat-label>
      <input matInput type="number" min="0" max="360" formControlName="rotationAngle">
    </mat-form-field>
    <fieldset class="fields-group fields-group-slider">
      <legend class="group-title" translate>widgets.maps.label</legend>
      <mat-expansion-panel class="tb-settings" [expanded]="tripAnimationMarkerSettingsFormGroup.get('showLabel').value">
        <mat-expansion-panel-header fxLayout="row wrap">
          <mat-panel-title>
            <mat-slide-toggle formControlName="showLabel" (click)="$event.stopPropagation()"
                              fxLayoutAlign="center">
              {{ 'widgets.maps.show-label' | translate }}
            </mat-slide-toggle>
          </mat-panel-title>
          <mat-panel-description fxLayoutAlign="end center" fxHide.xs translate>
            widget-config.advanced-settings
          </mat-panel-description>
        </mat-expansion-panel-header>
        <ng-template matExpansionPanelContent>
          <mat-slide-toggle formControlName="useLabelFunction" class="slide-block">
            {{ 'widgets.maps.use-label-function' | translate }}
          </mat-slide-toggle>
          <tb-html [fxShow]="!tripAnimationMarkerSettingsFormGroup.get('useLabelFunction').value"
                   formControlName="label"
                   minHeight="100px"
                   label="{{ 'widgets.maps.label-pattern' | translate }}">
          </tb-html>
          <tb-js-func [fxShow]="tripAnimationMarkerSettingsFormGroup.get('useLabelFunction').value"
                      formControlName="labelFunction"
                      [globalVariables]="functionScopeVariables"
                      [functionArgs]="['data', 'dsData', 'dsIndex']"
                      functionTitle="{{ 'widgets.maps.label-function' | translate }}"
                      helpId="widget/lib/map/label_fn">
          </tb-js-func>
        </ng-template>
      </mat-expansion-panel>
    </fieldset>
    <fieldset class="fields-group fields-group-slider">
      <legend class="group-title" translate>widgets.maps.marker-image</legend>
      <mat-expansion-panel class="tb-settings" expanded>
        <mat-expansion-panel-header fxLayout="row wrap">
          <mat-panel-title>
            <mat-slide-toggle formControlName="useMarkerImageFunction" (click)="$event.stopPropagation()"
                              fxLayoutAlign="center">
              {{ 'widgets.maps.use-marker-image-function' | translate }}
            </mat-slide-toggle>
          </mat-panel-title>
          <mat-panel-description fxLayoutAlign="end center" fxHide.xs translate>
            widget-config.advanced-settings
          </mat-panel-description>
        </mat-expansion-panel-header>
        <ng-template matExpansionPanelContent>
          <tb-image-input [fxShow]="!tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                          label="{{ 'widgets.maps.custom-marker-image' | translate }}"
                          formControlName="markerImage">
          </tb-image-input>
          <mat-form-field [fxShow]="!tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                          fxFlex class="mat-block">
            <mat-label translate>widgets.maps.custom-marker-image-size</mat-label>
            <input matInput type="number" min="1" formControlName="markerImageSize">
          </mat-form-field>
          <tb-js-func [fxShow]="tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                      formControlName="markerImageFunction"
                      [globalVariables]="functionScopeVariables"
                      [functionArgs]="['data', 'images', 'dsData', 'dsIndex']"
                      functionTitle="{{ 'widgets.maps.marker-image-function' | translate }}"
                      helpId="widget/lib/map/marker_image_fn">
          </tb-js-func>
          <tb-multiple-image-input [fxShow]="tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                                   label="{{ 'widgets.maps.marker-images' | translate }}"
                                   formControlName="markerImages">
          </tb-multiple-image-input>
        </ng-template>
      </mat-expansion-panel>
    </fieldset>
  </fieldset>
</section>
