Commit 89f905e7 by Ooh-Ao

view

parent 7682af35
<!-- Error Message -->
<div *ngIf="errorMessage" class="error-message">
<div class="error-message-content">
<i class="bi bi-exclamation-triangle-fill error-icon"></i>
<span class="error-text">Error:</span>
<span class="error-description">{{ errorMessage }}</span>
</div>
</div>
<div class="min-h-screen dashboard-background">
<!-- Enhanced Dashboard Header -->
<div class="dashboard-header-container">
<div class="header-content">
<div class="header-flex">
<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>
</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
id="dashboard_default"
[columns]="columns"
[cellSpacing]="cellSpacing"
[panels]="panels"
#editLayout
[allowResizing]="false"
[allowDragging]="false"
[allowFloating]="allowFloating"
[enableRtl]="false"
[enablePersistence]="false"
[cellAspectRatio]="cellAspectRatio"
[mediaQuery]='mediaQuery'
class="dashboard-layout"
>
<e-panels>
<e-panel
*ngFor="let panel of panels"
[id]="panel.id"
[sizeX]="panel.sizeX"
[sizeY]="panel.sizeY"
[row]="panel.row"
[col]="panel.col"
[minSizeX]="panel.minSizeX"
[minSizeY]="panel.minSizeY"
[maxSizeX]="panel.maxSizeX"
[maxSizeY]="panel.maxSizeY"
[zIndex]="999"
>
<ng-template #content>
<ng-container
[ngComponentOutlet]="panel.componentType"
[ngComponentOutletInputs]="panel.componentInputs"
></ng-container>
</ng-template>
</e-panel>
</e-panels>
</ejs-dashboardlayout>
</div>
</div>
</div>
<!-- Dashboard Viewer Container - Clean Layout -->
<div *ngIf="dashboardData" class="dashboard-content-area">
<!-- Dashboard Content Only -->
<div class="dashboard-layout-container">
<ejs-dashboardlayout
id="dashboard_default"
#editLayout
[cellSpacing]="cellSpacing"
[panels]="panels"
[columns]="columns"
[allowResizing]="false"
[allowDragging]="false"
class="dashboard-layout"
>
<e-panels>
<e-panel
*ngFor="let panel of panels"
[zIndex]="999"
[row]="panel.row"
[col]="panel.col"
[sizeX]="panel.sizeX"
[sizeY]="panel.sizeY"
[id]="panel.id"
>
<ng-template #header>
<!-- No header -->
</ng-template>
<ng-template #content>
<ng-container
[ngComponentOutlet]="panel.componentType"
[ngComponentOutletInputs]="panel.componentInputs"
></ng-container>
</ng-template>
</e-panel>
</e-panels>
</ejs-dashboardlayout>
</div>
</div>
/* Dashboard Viewer Styles - Clean and Responsive */
/* Enhanced Dashboard Management Styles */
/* Background */
.dashboard-background {
background: linear-gradient(to bottom right, #f8fafc, #e0e7ff);
min-height: 100vh;
}
/* Error Message */
.error-message {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(to bottom right, #f8fafc, #e0e7ff);
}
.error-message-content {
background: white;
padding: 2rem;
border-radius: 12px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
border: 1px solid #e5e7eb;
text-align: center;
max-width: 500px;
}
.error-icon {
font-size: 3rem;
color: #ef4444;
margin-bottom: 1rem;
}
.error-text {
font-size: 1.25rem;
font-weight: 600;
color: #374151;
display: block;
margin-bottom: 0.5rem;
}
.error-description {
color: #6b7280;
font-size: 1rem;
}
/* Layout Classes */
......@@ -59,7 +20,8 @@
.dashboard-header-container {
background: white;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05);
border-bottom: 1px solid #e5e7eb;
position: sticky;
top: 0;
......@@ -162,65 +124,18 @@
flex-shrink: 0;
}
/* Dashboard Content Area - Full Width and Responsive */
/* Content Area */
.dashboard-content-area {
width: 100%;
min-height: 100vh;
padding: 0;
margin: 0;
background: linear-gradient(to bottom right, #f8fafc, #e0e7ff);
}
/* Dashboard Layout Container - Clean and Responsive */
.dashboard-layout-container {
width: 100%;
min-height: 100vh;
padding: 1rem;
box-sizing: border-box;
}
/* Dashboard Layout - Responsive Grid */
.dashboard-layout {
width: 100% !important;
height: auto !important;
min-height: calc(100vh - 2rem);
background: transparent;
.e-panel {
border-radius: 12px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
border: 1px solid #e5e7eb;
background: white;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
margin: 0;
&:hover {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
transform: translateY(-2px);
}
}
.e-panel-header {
display: none !important; /* Hide panel headers in viewer mode */
}
.e-panel-content {
border-radius: 12px;
overflow: hidden;
position: relative;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
max-width: 80rem;
margin: 0 auto;
padding: 1.5rem 1rem;
}
.dashboard-content-card {
background: white;
border-radius: 0.75rem;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05);
border: 1px solid #e5e7eb;
min-height: 600px;
}
......@@ -282,7 +197,8 @@
&:hover {
transform: translateY(-1px);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
i {
......@@ -372,15 +288,20 @@
.dashboard-layout {
.e-panel {
border-radius: 12px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
border: 1px solid #e5e7eb;
transition: all 0.3s ease;
position: relative;
max-width: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
&:hover {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05);
transform: translateY(-2px);
}
}
......@@ -392,41 +313,58 @@
padding: 12px 16px;
font-weight: 600;
position: relative;
flex-shrink: 0;
min-height: 48px;
display: flex;
align-items: center;
}
.e-panel-content {
border-radius: 0 0 12px 12px;
border-radius: unset !important;
background: transparent !important;
overflow: hidden;
position: relative;
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
padding: 0 !important;
}
}
/* Syncfusion DashboardLayout Override for Viewer */
/* Syncfusion DashboardLayout Override */
::ng-deep {
#dashboard_default.e-dashboardlayout {
width: 100% !important;
height: auto !important;
min-height: calc(100vh - 2rem) !important;
max-height: none !important;
overflow: visible !important;
max-height: calc(100vh - 300px) !important;
overflow: auto !important;
position: relative !important;
background: transparent !important;
padding: 0 !important;
margin: 0 !important;
.e-panel {
max-width: 100% !important;
overflow: hidden !important;
position: relative !important;
background: white !important;
border: 1px solid #e5e7eb !important;
border-radius: 12px !important;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
margin: 0 !important;
box-sizing: border-box !important;
display: flex !important;
flex-direction: column !important;
height: 100% !important;
/* Ensure panel respects grid boundaries */
min-width: 0 !important;
min-height: 0 !important;
}
.e-panel-header {
display: none !important; /* Completely hide headers in viewer */
flex-shrink: 0 !important;
min-height: 48px !important;
display: flex !important;
align-items: center !important;
padding: 12px 16px !important;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
color: white !important;
border-radius: 12px 12px 0 0 !important;
font-weight: 600 !important;
}
.e-panel-content {
......@@ -434,28 +372,110 @@
max-width: 100% !important;
width: 100% !important;
height: 100% !important;
box-sizing: border-box !important;
padding: 0 !important;
margin: 0 !important;
background: white !important;
border-radius: 12px !important;
flex: 1 !important;
display: flex !important;
flex-direction: column !important;
min-height: 0 !important;
}
/* Ensure widgets don't overflow */
/* Widget content constraints */
.e-panel .e-panel-container {
width: 100% !important;
height: 100% !important;
overflow: hidden !important;
position: relative !important;
box-sizing: border-box !important;
padding: 0 !important;
margin: 0 !important;
flex: 1 !important;
display: flex !important;
flex-direction: column !important;
min-height: 0 !important;
}
/* Widget content styling */
.e-panel .e-panel-container .content {
width: 100% !important;
height: 100% !important;
overflow: hidden !important;
position: relative !important;
box-sizing: border-box !important;
display: flex !important;
flex-direction: column !important;
padding: 0 !important;
margin: 0 !important;
flex: 1 !important;
min-height: 0 !important;
}
/* Resize handle styling */
.e-resize-handle {
background: #3b82f6 !important;
opacity: 0.7 !important;
transition: opacity 0.2s ease !important;
z-index: 1000 !important;
}
.e-resize-handle:hover {
opacity: 1 !important;
background: #2563eb !important;
}
/* Resize handle positioning */
.e-resize-handle.e-resize-handle-right {
right: -2px !important;
width: 4px !important;
cursor: ew-resize !important;
}
.e-resize-handle.e-resize-handle-bottom {
bottom: -2px !important;
height: 4px !important;
cursor: ns-resize !important;
}
.e-resize-handle.e-resize-handle-corner {
width: 8px !important;
height: 8px !important;
cursor: nw-resize !important;
}
/* Ensure widgets don't exceed panel boundaries and fill full space */
.e-panel .e-panel-container .content > * {
max-width: 100% !important;
max-height: 100% !important;
width: 100% !important;
height: 100% !important;
overflow: hidden !important;
box-sizing: border-box !important;
flex: 1 !important;
display: flex !important;
flex-direction: column !important;
}
/* Specific widget component styling */
.e-panel .e-panel-container .content > * {
width: 100% !important;
height: 100% !important;
flex: 1 !important;
display: flex !important;
flex-direction: column !important;
min-height: 0 !important;
}
/* Ensure all child elements fill the space */
.e-panel .e-panel-container .content > * > * {
width: 100% !important;
height: 100% !important;
flex: 1 !important;
min-height: 0 !important;
}
/* Force all nested elements to use full space */
.e-panel .e-panel-container .content * {
box-sizing: border-box !important;
}
}
}
......@@ -471,7 +491,8 @@
&:hover {
border-color: #3b82f6;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
}
}
......@@ -484,94 +505,188 @@
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
0% {
background-position: -200% 0;
}
100% {
background-position: 200% 0;
}
}
/* Responsive Design for Dashboard Viewer */
@media (max-width: 1200px) {
.dashboard-layout-container {
padding: 0.75rem;
/* Responsive Design */
@media (max-width: 1024px) {
.header-content {
padding: 0 0.75rem;
}
::ng-deep {
#dashboard_default.e-dashboardlayout {
min-height: calc(100vh - 1.5rem) !important;
}
.header-left {
gap: 1rem;
}
}
@media (max-width: 1024px) {
.dashboard-layout-container {
padding: 0.5rem;
.header-controls {
gap: 1rem;
}
.dashboard-layout {
.e-panel {
margin: 0.25rem;
}
.dashboard-selector {
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.selector-label {
font-size: 0.8rem;
}
.dashboard-select {
min-width: 150px;
}
/* Adjust resize handles for smaller screens */
::ng-deep {
#dashboard_default.e-dashboardlayout {
min-height: calc(100vh - 1rem) !important;
.e-resize-handle {
width: 6px !important;
height: 6px !important;
}
.e-panel {
border-radius: 8px !important;
min-height: 120px !important;
}
.e-panel-content {
min-height: 80px !important;
}
}
}
}
@media (max-width: 768px) {
.header-flex {
flex-direction: column;
align-items: stretch;
gap: 1rem;
padding: 1rem 0;
}
.header-left {
flex-direction: column;
align-items: stretch;
gap: 1rem;
}
.header-title-section {
justify-content: center;
}
.header-controls {
flex-direction: column;
align-items: stretch;
gap: 1rem;
}
.dashboard-selector {
align-items: center;
}
.action-buttons {
justify-content: center;
gap: 0.5rem;
}
.custom-btn {
padding: 0.4rem 0.8rem;
font-size: 0.8rem;
}
.dashboard-content-card {
max-height: calc(100vh - 150px);
}
.dashboard-layout-container {
padding: 0.25rem;
max-height: calc(100vh - 200px);
}
.dashboard-layout {
.e-panel {
margin: 0.125rem;
border-radius: 8px;
margin: 8px;
}
}
// Syncfusion overrides for mobile
::ng-deep {
#dashboard_default.e-dashboardlayout {
min-height: calc(100vh - 0.5rem) !important;
max-height: calc(100vh - 250px) !important;
.e-resize-handle {
width: 8px !important;
height: 8px !important;
opacity: 0.8 !important;
}
.e-panel {
border-radius: 8px !important;
box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.06) !important;
min-width: 100px !important;
min-height: 100px !important;
}
.e-panel-content {
min-height: 60px !important;
}
.e-panel .e-panel-container .content > * {
min-height: 60px !important;
}
}
}
}
@media (max-width: 480px) {
.dashboard-layout-container {
padding: 0.125rem;
.header-content {
padding: 0 0.5rem;
}
.dashboard-layout {
.e-panel {
margin: 0.0625rem;
border-radius: 6px;
}
.title-content h1 {
font-size: 1.25rem;
}
.title-content p {
font-size: 0.75rem;
}
.action-buttons {
flex-direction: column;
gap: 0.5rem;
}
.custom-btn {
width: 100%;
justify-content: center;
}
// Syncfusion overrides for small mobile
::ng-deep {
#dashboard_default.e-dashboardlayout {
min-height: calc(100vh - 0.25rem) !important;
.e-resize-handle {
width: 10px !important;
height: 10px !important;
opacity: 0.9 !important;
}
.e-panel {
border-radius: 6px !important;
box-shadow: 0 1px 3px -1px rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.06) !important;
min-width: 80px !important;
min-height: 80px !important;
}
.e-panel-content {
min-height: 40px !important;
}
.e-panel .e-panel-container .content > * {
min-height: 40px !important;
}
}
}
}
.dashboard-container {
display: flex;
height: 100vh;
......@@ -583,7 +698,8 @@
background-color: #ffffff; /* bg-white */
padding: 1rem; /* p-4 */
overflow-y: auto;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-lg */
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-lg */
border-right: 1px solid #e5e7eb; /* border-r border-gray-200 */
display: flex;
flex-direction: column;
......@@ -606,7 +722,8 @@
&:hover {
background-color: #e0e7ff; /* hover:bg-indigo-50 */
border-color: #c7d2fe; /* hover:border-indigo-100 */
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* hover:shadow-md */
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05); /* hover:shadow-md */
}
}
......@@ -636,7 +753,8 @@
font-weight: bold;
padding: 0.5rem 1rem; /* py-2 px-4 */
border-radius: 0.5rem; /* rounded-lg */
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
transition: transform 0.2s ease-in-out; /* transition-transform */
transform: scale(1); /* transform */
......@@ -700,3 +818,10 @@
// text-align: center;
// line-height: 90px;
// }
.e-dashboardlayout.e-control .e-panel {
margin: 0 !important;
border-radius: 12px !important;
box-shadow: unset !important;
border: unset !important;
}
......@@ -63,13 +63,15 @@ export interface DashboardPanel extends PanelModel {
encapsulation: ViewEncapsulation.None
})
export class DashboardViewerComponent implements OnInit, OnDestroy {
public panels: DashboardPanel[] = [];
public cellSpacing: number[] = [8, 8];
public mediaQuery: string = 'max-width: 700px';
public columns: number = 6;
public dashboardData: DashboardModel | null = null;
public errorMessage: string | null = null;
public isFullscreen: boolean = true;
public allowFloating: boolean = false;
public cellAspectRatio: number = 100 / 75;
constructor(
private route: ActivatedRoute,
private dashboardDataService: DashboardDataService,
......@@ -78,17 +80,11 @@ export class DashboardViewerComponent implements OnInit, OnDestroy {
) { }
goBack(): void {
window.history.back();
}
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(
map(params => params.get('dashboardId')),
......@@ -137,30 +133,17 @@ export class DashboardViewerComponent implements OnInit, OnDestroy {
}
ngOnDestroy(): void {
// Clean up event listener
window.removeEventListener('resize', () => {
this.setResponsiveColumns();
});
// Clean up fullscreen mode
}
private setResponsiveColumns(): void {
const width = window.innerWidth;
if (width <= 480) {
this.columns = 2;
this.cellSpacing = [4, 4];
} else if (width <= 768) {
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];
private setViewportMeta(): void {
let viewport = document.querySelector('meta[name="viewport"]');
if (!viewport) {
viewport = document.createElement('meta');
viewport.setAttribute('name', 'viewport');
document.head.appendChild(viewport);
}
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no');
}
mapWidgetsToPanels(widgets: any[]): DashboardPanel[] {
......@@ -183,10 +166,10 @@ export class DashboardViewerComponent implements OnInit, OnDestroy {
return {
id: `${(widget as any).instanceId}-${widget.y}-${widget.x}`,
header: widget.thName,
sizeX: widget.cols,
sizeY: widget.rows,
row: widget.y,
col: widget.x,
sizeX: widget.cols || 4, // Default size if not specified
sizeY: widget.rows || 3, // Default size if not specified
row: widget.y || 0,
col: widget.x || 0,
componentType: componentType,
componentInputs: {
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