Commit 7ba8fc42 by Ooh-Ao

ss

parent 67977999
<div class="min-h-screen dashboard-background"> <!-- Error Message -->
<!-- Enhanced Dashboard Header --> <div *ngIf="errorMessage" class="error-message">
<div class="dashboard-header-container"> <div class="error-message-content">
<div class="header-content"> <i class="bi bi-exclamation-triangle-fill error-icon"></i>
<div class="header-flex"> <span class="error-text">Error:</span>
<div class="header-left"> <span class="error-description">{{ errorMessage }}</span>
<!-- Dashboard Title with Icon -->
<div class="header-title-section">
<!-- <div class="title-icon">
<i class="bi bi-grid-3x3-gap"></i>
</div> -->
<div class="title-content">
<h1>{{dashboardData?.thName}}</h1>
<!-- <p>Create and manage your dashboards</p> -->
</div>
</div>
</div>
</div>
</div>
<!-- Enhanced Dashboard Content Area -->
<div class="dashboard-content-area">
<!-- Dashboard Content -->
<div class="dashboard-content-card">
<div *ngIf="!panels || panels.length === 0" class="empty-state">
<div class="empty-state-icon">
<i class="bi bi-grid-3x3-gap"></i>
</div>
<h3 class="empty-state-title">Empty Dashboard</h3>
<p class="empty-state-description">
To get started, select a dashboard from the dropdown above or create
a new one. Then, click on a widget from the sidebar on the left to
add it to this canvas.
</p>
</div> </div>
</div>
<!-- Dashboard Layout --> <!-- Dashboard Viewer Container - Clean Layout -->
<div *ngIf="panels.length > 0" class="dashboard-layout-container"> <div *ngIf="dashboardData" class="viewer-container-clean">
<!-- Dashboard Content Only -->
<div class="viewer-content-clean">
<ejs-dashboardlayout <ejs-dashboardlayout
id="dashboard_default" id="dashboard_default"
[columns]="columns" #editLayout
[cellSpacing]="cellSpacing" [cellSpacing]="cellSpacing"
[panels]="panels" [panels]="panels"
#editLayout [columns]="columns"
[allowResizing]="false" [allowResizing]="false"
[allowDragging]="false" [allowDragging]="false"
[allowFloating]="false"
[showGridLines]="false"
class="dashboard-layout" class="dashboard-layout"
> >
<e-panels> <e-panels>
<e-panel <e-panel
*ngFor="let panel of panels" *ngFor="let panel of panels"
[id]="panel.id + '-' + panel.row + '-' + panel.col" [zIndex]="999"
[sizeX]="panel.sizeX"
[sizeY]="panel.sizeY"
[row]="panel.row" [row]="panel.row"
[col]="panel.col" [col]="panel.col"
[zIndex]="999" [sizeX]="panel.sizeX"
[sizeY]="panel.sizeY"
[id]="panel.id + '-' + panel.row + '-' + panel.col"
class="widget-panel-clean"
> >
<ng-template #header> <ng-template #header>
<!-- No header -->
</ng-template> </ng-template>
<ng-template #content> <ng-template #content>
<div class="widget-content-clean">
<ng-container <ng-container
[ngComponentOutlet]="panel.componentType" [ngComponentOutlet]="panel.componentType"
[ngComponentOutletInputs]="panel.componentInputs" [ngComponentOutletInputs]="panel.componentInputs"
></ng-container> ></ng-container>
</div>
</ng-template> </ng-template>
</e-panel> </e-panel>
</e-panels> </e-panels>
</ejs-dashboardlayout> </ejs-dashboardlayout>
</div> </div>
</div>
</div>
</div>
</div> </div>
import { Component, Inject, OnInit, OnDestroy, AfterViewInit, ViewChild, ViewContainerRef, ComponentRef } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatDialogModule } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog';
...@@ -10,7 +10,6 @@ import { MatIconModule } from '@angular/material/icon'; ...@@ -10,7 +10,6 @@ import { MatIconModule } from '@angular/material/icon';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { WidgetConfigGeneratorService } from '../services/widget-config-generator.service'; import { WidgetConfigGeneratorService } from '../services/widget-config-generator.service';
import { WidgetConfigRegistryService } from './services/widget-config-registry.service';
import { WidgetModel } from '../models/widgets.model'; import { WidgetModel } from '../models/widgets.model';
export interface WidgetConfigDialogData { export interface WidgetConfigDialogData {
...@@ -36,20 +35,16 @@ export interface WidgetConfigDialogData { ...@@ -36,20 +35,16 @@ export interface WidgetConfigDialogData {
templateUrl: './widget-config.component.html', templateUrl: './widget-config.component.html',
styleUrls: ['./widget-config.component.scss'] styleUrls: ['./widget-config.component.scss']
}) })
export class WidgetConfigComponent implements OnInit, AfterViewInit, OnDestroy { export class WidgetConfigComponent implements OnInit {
@ViewChild('configContainer', { read: ViewContainerRef }) configContainer!: ViewContainerRef;
currentConfig: any; currentConfig: any;
availableColumns: string[]; availableColumns: string[];
widgetType: string; widgetType: string;
comboChartTypes: string[] = ['Line', 'Column', 'Area', 'Spline']; comboChartTypes: string[] = ['Line', 'Column', 'Area', 'Spline'];
private configComponentRef: ComponentRef<any> | null = null;
constructor( constructor(
public dialogRef: MatDialogRef<WidgetConfigComponent>, public dialogRef: MatDialogRef<WidgetConfigComponent>,
@Inject(MAT_DIALOG_DATA) public data: WidgetConfigDialogData, @Inject(MAT_DIALOG_DATA) public data: WidgetConfigDialogData,
private widgetConfigGenerator: WidgetConfigGeneratorService, private widgetConfigGenerator: WidgetConfigGeneratorService
public widgetConfigRegistry: WidgetConfigRegistryService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
...@@ -72,13 +67,6 @@ export class WidgetConfigComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -72,13 +67,6 @@ export class WidgetConfigComponent implements OnInit, AfterViewInit, OnDestroy {
} }
} }
// Use fallback config if no config is available
if (!this.currentConfig || Object.keys(this.currentConfig).length === 0) {
this.currentConfig = this.widgetConfigRegistry.getFallbackConfig(this.widgetType);
}
// Load dynamic config component will be called in ngAfterViewInit
const gridLikeWidgets = ['SyncfusionDatagridWidgetComponent', 'NewDataTableWidget', 'MatrixWidgetComponent']; const gridLikeWidgets = ['SyncfusionDatagridWidgetComponent', 'NewDataTableWidget', 'MatrixWidgetComponent'];
if (gridLikeWidgets.includes(this.widgetType) && !this.currentConfig.columns) { if (gridLikeWidgets.includes(this.widgetType) && !this.currentConfig.columns) {
this.currentConfig.columns = []; this.currentConfig.columns = [];
...@@ -285,45 +273,12 @@ export class WidgetConfigComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -285,45 +273,12 @@ export class WidgetConfigComponent implements OnInit, AfterViewInit, OnDestroy {
addPivotFilter() { this.currentConfig.filters.push({ name: '' }); } addPivotFilter() { this.currentConfig.filters.push({ name: '' }); }
removePivotFilter(index: number) { this.currentConfig.filters.splice(index, 1); } removePivotFilter(index: number) { this.currentConfig.filters.splice(index, 1); }
ngAfterViewInit(): void {
// Load dynamic config component after view is initialized
this.loadConfigComponent();
}
private loadConfigComponent(): void {
const configComponentType = this.widgetConfigRegistry.getConfigComponent(this.widgetType);
if (configComponentType) {
// Load the specific config component
this.configComponentRef = this.configContainer.createComponent(configComponentType);
this.configComponentRef.instance.currentConfig = this.currentConfig;
this.configComponentRef.instance.availableColumns = this.availableColumns;
// Subscribe to config changes
if (this.configComponentRef.instance.configChange) {
this.configComponentRef.instance.configChange.subscribe((config: any) => {
this.currentConfig = config;
});
}
}
// If no specific config component is found, the template will show the fallback config
}
onSave(): void { onSave(): void {
// Get the latest config from the dynamic component if it exists
if (this.configComponentRef && this.configComponentRef.instance.currentConfig) {
this.currentConfig = this.configComponentRef.instance.currentConfig;
}
this.dialogRef.close(this.currentConfig); this.dialogRef.close(this.currentConfig);
} }
onCancel(): void { onCancel(): void {
this.dialogRef.close(); this.dialogRef.close();
} }
ngOnDestroy(): void {
if (this.configComponentRef) {
this.configComponentRef.destroy();
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment