<!--

    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.

-->
<div fxLayout="column" class="tb-progress-cover" fxLayoutAlign="center center"
  *ngIf="layoutCtx.widgets.isLoading()">
  <mat-spinner color="warn" mode="indeterminate" diameter="100">
  </mat-spinner>
</div>
<div class="mat-content"
          style="position: relative; width: 100%; height: 100%;" tb-hotkeys [hotkeys]="hotKeys"
          [cheatSheet]="dashboardCheatSheet"
          [style.backgroundImage]="backgroundImage"
          [ngStyle]="dashboardStyle">
  <section *ngIf="layoutCtx.widgets.isEmpty()" fxLayoutAlign="center center"
           style="display: flex; z-index: 1; pointer-events: none;"
           class="mat-headline tb-absolute-fill">
    <span *ngIf="!isEdit">
      {{'dashboard.no-widgets' | translate}}
    </span>
    <button mat-button *ngIf="isEdit && !widgetEditMode" class="tb-add-new-widget"
            (click)="addWidget($event)">
      <mat-icon class="tb-mat-96">add</mat-icon>
      {{ 'dashboard.add-widget' | translate }}
    </button>
  </section>
  <tb-dashboard #dashboard [dashboardStyle]="dashboardStyle"
                [backgroundImage]="backgroundImage"
                [widgets]="layoutCtx.widgets"
                [widgetLayouts]="layoutCtx.widgetLayouts"
                [columns]="layoutCtx.gridSettings.columns"
                [margin]="layoutCtx.gridSettings.margin"
                [aliasController]="dashboardCtx.aliasController"
                [stateController]="dashboardCtx.stateController"
                [dashboardTimewindow]="dashboardCtx.dashboardTimewindow"
                [isEdit]="isEdit"
                [autofillHeight]="layoutCtx.gridSettings.autoFillHeight && !isEdit"
                [mobileAutofillHeight]="layoutCtx.gridSettings.mobileAutoFillHeight && !isEdit"
                [mobileRowHeight]="layoutCtx.gridSettings.mobileRowHeight"
                [isMobile]="isMobile"
                [isMobileDisabled]="widgetEditMode"
                [disableWidgetInteraction]="isEdit"
                [isEditActionEnabled]="isEdit"
                [isExportActionEnabled]="isEdit && !widgetEditMode"
                [isRemoveActionEnabled]="isEdit && !widgetEditMode"
                [callbacks]="this"
                [ignoreLoading]="layoutCtx.ignoreLoading"
                [parentDashboard]="parentDashboard">
  </tb-dashboard>
</div>
