Commit 89f905e7 by Ooh-Ao

view

parent 7682af35
<!-- Error Message --> <div class="min-h-screen dashboard-background">
<div *ngIf="errorMessage" class="error-message"> <!-- Enhanced Dashboard Header -->
<div class="error-message-content"> <div class="dashboard-header-container">
<i class="bi bi-exclamation-triangle-fill error-icon"></i> <div class="header-content">
<span class="error-text">Error:</span> <div class="header-flex">
<span class="error-description">{{ errorMessage }}</span> <div class="header-left">
<!-- 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>Dashboard Management</h1>
<p>Create and manage your dashboards</p>
</div>
</div> </div>
</div>
<!-- Dashboard Viewer Container - Clean Layout -->
<div *ngIf="dashboardData" class="dashboard-content-area"> </div>
<!-- Dashboard Content Only -->
<div class="dashboard-layout-container">
</div>
</div>
<!-- Enhanced Dashboard Content Area -->
<div class="dashboard-content-area">
<!-- View Dashboard Button -->
<!-- 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>
<!-- Dashboard Layout -->
<div *ngIf="panels.length > 0" class="dashboard-layout-container">
<ejs-dashboardlayout <ejs-dashboardlayout
id="dashboard_default" id="dashboard_default"
#editLayout [columns]="columns"
[cellSpacing]="cellSpacing" [cellSpacing]="cellSpacing"
[panels]="panels" [panels]="panels"
[columns]="columns" #editLayout
[allowResizing]="false" [allowResizing]="false"
[allowDragging]="false" [allowDragging]="false"
[allowFloating]="allowFloating"
[enableRtl]="false"
[enablePersistence]="false"
[cellAspectRatio]="cellAspectRatio"
[mediaQuery]='mediaQuery'
class="dashboard-layout" class="dashboard-layout"
> >
<e-panels> <e-panels>
<e-panel <e-panel
*ngFor="let panel of panels" *ngFor="let panel of panels"
[zIndex]="999" [id]="panel.id"
[row]="panel.row"
[col]="panel.col"
[sizeX]="panel.sizeX" [sizeX]="panel.sizeX"
[sizeY]="panel.sizeY" [sizeY]="panel.sizeY"
[id]="panel.id" [row]="panel.row"
[col]="panel.col"
[minSizeX]="panel.minSizeX"
[minSizeY]="panel.minSizeY"
[maxSizeX]="panel.maxSizeX"
[maxSizeY]="panel.maxSizeY"
[zIndex]="999"
> >
<ng-template #header>
<!-- No header -->
</ng-template>
<ng-template #content> <ng-template #content>
<ng-container <ng-container
[ngComponentOutlet]="panel.componentType" [ngComponentOutlet]="panel.componentType"
...@@ -44,4 +82,9 @@ ...@@ -44,4 +82,9 @@
</e-panels> </e-panels>
</ejs-dashboardlayout> </ejs-dashboardlayout>
</div> </div>
</div>
</div>
</div>
</div> </div>
...@@ -63,13 +63,15 @@ export interface DashboardPanel extends PanelModel { ...@@ -63,13 +63,15 @@ export interface DashboardPanel extends PanelModel {
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class DashboardViewerComponent implements OnInit, OnDestroy { export class DashboardViewerComponent implements OnInit, OnDestroy {
public panels: DashboardPanel[] = []; public panels: DashboardPanel[] = [];
public cellSpacing: number[] = [8, 8]; public cellSpacing: number[] = [8, 8];
public mediaQuery: string = 'max-width: 700px';
public columns: number = 6; public columns: number = 6;
public dashboardData: DashboardModel | null = null; public dashboardData: DashboardModel | null = null;
public errorMessage: string | null = null; public errorMessage: string | null = null;
public isFullscreen: boolean = true;
public allowFloating: boolean = false;
public cellAspectRatio: number = 100 / 75;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private dashboardDataService: DashboardDataService, private dashboardDataService: DashboardDataService,
...@@ -78,17 +80,11 @@ export class DashboardViewerComponent implements OnInit, OnDestroy { ...@@ -78,17 +80,11 @@ export class DashboardViewerComponent implements OnInit, OnDestroy {
) { } ) { }
goBack(): void { goBack(): void {
window.history.back(); window.history.back();
} }
ngOnInit(): void { ngOnInit(): void {
// Set responsive columns based on screen size
this.setResponsiveColumns();
// Listen for window resize events
window.addEventListener('resize', () => {
this.setResponsiveColumns();
});
this.route.paramMap.pipe( this.route.paramMap.pipe(
map(params => params.get('dashboardId')), map(params => params.get('dashboardId')),
...@@ -137,30 +133,17 @@ export class DashboardViewerComponent implements OnInit, OnDestroy { ...@@ -137,30 +133,17 @@ export class DashboardViewerComponent implements OnInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
// Clean up event listener // Clean up fullscreen mode
window.removeEventListener('resize', () => {
this.setResponsiveColumns();
});
} }
private setResponsiveColumns(): void { private setViewportMeta(): void {
const width = window.innerWidth; let viewport = document.querySelector('meta[name="viewport"]');
if (width <= 480) { if (!viewport) {
this.columns = 2; viewport = document.createElement('meta');
this.cellSpacing = [4, 4]; viewport.setAttribute('name', 'viewport');
} else if (width <= 768) { document.head.appendChild(viewport);
this.columns = 3;
this.cellSpacing = [6, 6];
} else if (width <= 1024) {
this.columns = 4;
this.cellSpacing = [8, 8];
} else if (width <= 1200) {
this.columns = 5;
this.cellSpacing = [8, 8];
} else {
this.columns = 6;
this.cellSpacing = [8, 8];
} }
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no');
} }
mapWidgetsToPanels(widgets: any[]): DashboardPanel[] { mapWidgetsToPanels(widgets: any[]): DashboardPanel[] {
...@@ -183,10 +166,10 @@ export class DashboardViewerComponent implements OnInit, OnDestroy { ...@@ -183,10 +166,10 @@ export class DashboardViewerComponent implements OnInit, OnDestroy {
return { return {
id: `${(widget as any).instanceId}-${widget.y}-${widget.x}`, id: `${(widget as any).instanceId}-${widget.y}-${widget.x}`,
header: widget.thName, header: widget.thName,
sizeX: widget.cols, sizeX: widget.cols || 4, // Default size if not specified
sizeY: widget.rows, sizeY: widget.rows || 3, // Default size if not specified
row: widget.y, row: widget.y || 0,
col: widget.x, col: widget.x || 0,
componentType: componentType, componentType: componentType,
componentInputs: { componentInputs: {
config: JSON.stringify(configObject), config: JSON.stringify(configObject),
......
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