<!--

    Copyright © 2016-2023 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]="commonMapSettingsFormGroup">
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.maps.common-map-settings</legend>
    <section  fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
      <tb-datasources-key-autocomplete fxFlex
                                       [fxShow]="provider === mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.x-pos-key-name"
                                       formControlName="xPosKeyName">
      </tb-datasources-key-autocomplete>
      <tb-datasources-key-autocomplete fxFlex
                                       [fxShow]="provider === mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.y-pos-key-name"
                                       formControlName="yPosKeyName">
      </tb-datasources-key-autocomplete>
      <tb-datasources-key-autocomplete fxFlex
                                       [fxShow]="provider !== mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.latitude-key-name"
                                       formControlName="latKeyName">
      </tb-datasources-key-autocomplete>
      <tb-datasources-key-autocomplete fxFlex
                                       [fxShow]="provider !== mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.longitude-key-name"
                                       formControlName="lngKeyName">
      </tb-datasources-key-autocomplete>
    </section>
    <mat-expansion-panel class="tb-settings">
      <mat-expansion-panel-header fxLayout="row wrap">
        <mat-panel-description fxLayoutAlign="end center" translate>
          widget-config.advanced-settings
        </mat-panel-description>
      </mat-expansion-panel-header>
      <ng-template matExpansionPanelContent>
        <section [fxShow]="provider !== mapProvider.image" fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
          <mat-form-field fxFlex class="mat-block">
            <mat-label translate>widgets.maps.default-map-zoom-level</mat-label>
            <input matInput type="number" min="0" max="20" step="1" formControlName="defaultZoomLevel">
          </mat-form-field>
          <mat-form-field fxFlex class="mat-block">
            <mat-label translate>widgets.maps.default-map-center-position</mat-label>
            <input matInput formControlName="defaultCenterPosition">
          </mat-form-field>
        </section>
        <section fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px" style="margin-bottom: 15px;">
          <section fxFlex fxLayout="column">
            <mat-slide-toggle formControlName="disableScrollZooming" class="slide-block">
              {{ 'widgets.maps.disable-scroll-zooming' | translate }}
            </mat-slide-toggle>
            <mat-slide-toggle formControlName="disableDoubleClickZooming" class="slide-block">
              {{ 'widgets.maps.disable-double-click-zooming' | translate }}
            </mat-slide-toggle>
            <mat-slide-toggle formControlName="disableZoomControl" class="slide-block">
              {{ 'widgets.maps.disable-zoom-control-buttons' | translate }}
            </mat-slide-toggle>
            <mat-slide-toggle [fxShow]="provider !== mapProvider.image" formControlName="fitMapBounds" class="slide-block">
              {{ 'widgets.maps.fit-map-bounds' | translate }}
            </mat-slide-toggle>
          </section>
          <section fxFlex fxLayout="column">
            <mat-slide-toggle [fxShow]="provider !== mapProvider.image" formControlName="useDefaultCenterPosition" class="slide-block">
              {{ 'widgets.maps.use-default-map-center-position' | translate }}
            </mat-slide-toggle>
          </section>
        </section>
        <mat-form-field fxFlex class="mat-block">
          <mat-label translate>widgets.maps.entities-limit</mat-label>
          <input matInput type="number" min="1" step="1" formControlName="mapPageSize">
        </mat-form-field>
      </ng-template>
    </mat-expansion-panel>
  </fieldset>
</section>
