diff --git a/frontend/Exence/src/app/private/statistics/statistics.component.html b/frontend/Exence/src/app/private/statistics/statistics.component.html index 950b5dd..094ab3c 100644 --- a/frontend/Exence/src/app/private/statistics/statistics.component.html +++ b/frontend/Exence/src/app/private/statistics/statistics.component.html @@ -1,18 +1,30 @@ - - @if (store.statCards().length) { - - } +@if (isEmpty()) { + + + + Your dashboard is empty + Add charts and stat cards to customize your statistics dashboard. + + +} @else { + + @if (store.statCards().length) { + + } - + + +} - - + - - edit - Edit layout - + @if (!isEmpty()) { + + edit + Edit layout + + } add Add widget diff --git a/frontend/Exence/src/app/private/statistics/statistics.component.scss b/frontend/Exence/src/app/private/statistics/statistics.component.scss index 6a977c2..b6b018a 100644 --- a/frontend/Exence/src/app/private/statistics/statistics.component.scss +++ b/frontend/Exence/src/app/private/statistics/statistics.component.scss @@ -1,3 +1,7 @@ +.empty-state { + height: calc(100vh - 64px); +} + .action-buttons { display: flex; flex-direction: row; diff --git a/frontend/Exence/src/app/private/statistics/statistics.component.ts b/frontend/Exence/src/app/private/statistics/statistics.component.ts index 94345d2..0f36745 100644 --- a/frontend/Exence/src/app/private/statistics/statistics.component.ts +++ b/frontend/Exence/src/app/private/statistics/statistics.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { Component, effect, inject, signal, viewChild } from '@angular/core'; +import { Component, computed, effect, inject, signal, viewChild } from '@angular/core'; import { MatIconModule } from '@angular/material/icon'; import { MatMenuModule } from '@angular/material/menu'; import { mapToExChartType } from '../../data-model/modules/statistics/widget-config.model'; @@ -39,10 +39,16 @@ export class StatisticsComponent implements HasChangesComponent { private readonly snackbarService = inject(SnackbarService); readonly store = inject(WidgetStore); - private readonly chartWidgetList = viewChild.required(ChartWidgetListComponent); + private readonly chartWidgetList = viewChild(ChartWidgetListComponent); private readonly statCardList = viewChild(StatCardListComponent); editing = signal(false); + isEmpty = computed( + () => + !this.store.layoutResource.isLoading() && + this.store.statCards().length === 0 && + this.store.charts().length === 0, + ); constructor() { effect(() => { @@ -78,8 +84,8 @@ export class StatisticsComponent implements HasChangesComponent { const isStatCard = mapToExChartType(result.catalogItem.type) === 'statCard'; const nextFreePosition = isStatCard - ? (this.statCardList()?.getFirstPossiblePosition() ?? { cols: 1, rows: 1, x: 0, y: 0 }) - : this.chartWidgetList().getFirstPossiblePosition(); + ? (this.statCardList()?.getFirstPossiblePosition() ?? null) + : (this.chartWidgetList()?.getFirstPossiblePosition() ?? null); await this.store.addWidget(result, nextFreePosition); } diff --git a/frontend/Exence/src/assets/empty-statistics.svg b/frontend/Exence/src/assets/empty-statistics.svg new file mode 100644 index 0000000..a3325b9 --- /dev/null +++ b/frontend/Exence/src/assets/empty-statistics.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
Add charts and stat cards to customize your statistics dashboard.