<!--

    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.

-->
<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$ | async"
          [ngStyle]="dashboardStyle">
  <section *ngIf="layoutCtx.widgets.isEmpty()" fxLayoutAlign="center center"
           style="display: flex; z-index: 1; pointer-events: none;"
           class="mat-headline-5 tb-absolute-fill">
    <span *ngIf="!isEdit" style="text-align: center;">
      {{'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>
      <span>{{ 'dashboard.add-widget' | translate }}</span>
    </button>
  </section>
  <tb-dashboard #dashboard [dashboardStyle]="dashboardStyle"
                [backgroundImage]="backgroundImage$ | async"
                [widgets]="layoutCtx.widgets"
                [widgetLayouts]="layoutCtx.widgetLayouts"
                [columns]="layoutCtx.gridSettings.columns"
                [outerMargin]="layoutCtx.gridSettings.outerMargin"
                [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"
                [popoverComponent]="popoverComponent">
  </tb-dashboard>
</div>
