<!--
Copyright 2017 The Kubernetes 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.
-->

<kd-card [initialized]="isInitialized()"
         [expandable]="true"
         *ngIf="!hasLoadError">
  <div title
       i18n>Global settings</div>
  <div content>
    <p i18n>
      Global settings are stored in config map, so all of them are applied for every instance of the
      app.
    </p>
    <br>
    <form #form="ngForm"
          (ngSubmit)="save(form)">
      <kd-settings-entry key="Cluster name"
                         i18n-key
                         desc="Cluster name appears in the browser window title if it is set."
                         i18n-desc>
        <mat-form-field fxFlex>
          <input [(ngModel)]="settings.clusterName"
                 name="clusterName"
                 i18n-placeholder
                 placeholder="Cluster name"
                 type="text"
                 matInput>
        </mat-form-field>
      </kd-settings-entry>
      <kd-settings-entry key="Items per page"
                         i18n-key
                         desc="Max number of items that can be displayed on each list page."
                         i18n-desc>
        <div fxFlex>
          <mat-slider [(ngModel)]="settings.itemsPerPage"
                      name="itemsPerPage"
                      color="primary"
                      min="5"
                      max="50"
                      step="5"
                      fxFlex>
          </mat-slider>
          <div class="kd-slider-value kd-muted"
               fxFlexAlign=" center">
            {{settings.itemsPerPage}}
          </div>
        </div>
      </kd-settings-entry>
      <kd-settings-entry key="Logs auto-refresh time interval"
                         i18n-key
                         desc="Number of seconds between every auto-refresh of logs."
                         i18n-desc>
        <div fxFlex>
          <mat-slider [(ngModel)]="settings.logsAutoRefreshTimeInterval"
                      name="autoRefreshTimeInterval"
                      color="primary"
                      min="1"
                      max="10"
                      step="1"
                      fxFlex>
          </mat-slider>
          <span class="kd-slider-value kd-muted"
                fxFlexAlign=" center">
            {{settings.logsAutoRefreshTimeInterval}}
          </span>
        </div>
      </kd-settings-entry>
      <kd-settings-entry key="Resource auto-refresh time interval"
                         i18n-key
                         desc="Number of seconds between every auto-refresh of every resource. Set 0 to disable."
                         i18n-desc>
        <div fxFlex>
          <mat-slider [(ngModel)]="settings.resourceAutoRefreshTimeInterval"
                      name="resourceAutoRefreshTimeInterval"
                      color="primary"
                      min="0"
                      max="60"
                      step="5"
                      fxFlex>
          </mat-slider>
          <span class="kd-slider-value kd-muted"
                fxFlexAlign=" center">
            {{settings.resourceAutoRefreshTimeInterval}}
          </span>
        </div>
      </kd-settings-entry>
      <br><br>
      <button [disabled]="form.pristine"
              type="submit"
              color="primary"
              mat-raised-button
              i18n>
        Save
      </button>
      <button type="button"
              (click)="load(form)"
              color="primary"
              mat-raised-button
              i18n>
        Reload
      </button>
    </form>
  </div>
</kd-card>
