<!--

    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 [formGroup]="parentForm">
  <mat-form-field class="mat-block" fxFlex>
    <mat-label *ngIf="isDeviceSetting">{{ "device-profile.power-saving-mode" | translate }}</mat-label>
    <mat-select formControlName="powerMode">
      <mat-option [value]="null" *ngIf="isDeviceSetting">{{ "device-profile.power-saving-mode-type.default" | translate }}</mat-option>
      <mat-option *ngFor="let powerMod of powerMods" [value]="powerMod">
        {{ powerModeTranslationMap.get(powerMod) | translate}}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <section class="mat-block" fxFlex *ngIf="parentForm.get('powerMode').value === 'E_DRX'">
    <tb-time-unit-select [labelText]="'device-profile.edrx-cycle'"
                         [requiredText]="'device-profile.edrx-cycle-required'"
                         [patternText]="'device-profile.edrx-cycle-pattern'"
                         [minTime]="5120"
                         [minText]="'device-profile.edrx-cycle-min'"
                         formControlName="edrxCycle">
    </tb-time-unit-select>
    <tb-time-unit-select [labelText]="'device-profile.paging-transmission-window'"
                         [requiredText]="'device-profile.paging-transmission-window-required'"
                         [patternText]="'device-profile.paging-transmission-window-pattern'"
                         [minTime]="1280"
                         [minText]="'device-profile.paging-transmission-window-min'"
                         formControlName="pagingTransmissionWindow">
    </tb-time-unit-select>
  </section>
  <tb-time-unit-select *ngIf="parentForm.get('powerMode').value === 'PSM'"
                       [labelText]="'device-profile.psm-activity-timer'"
                       [requiredText]="'device-profile.psm-activity-timer-required'"
                       [patternText]="'device-profile.psm-activity-timer-pattern'"
                       [minTime]="1280"
                       [minText]="'device-profile.psm-activity-timer-min'"
                       formControlName="psmActivityTimer">
  </tb-time-unit-select>
</section>
