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">
</div> <!-- Dashboard Title with Icon -->
</div> <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>
</div> </div>
/* Dashboard Viewer Styles - Clean and Responsive */ /* Enhanced Dashboard Management Styles */
/* Background */ /* Background */
.dashboard-background { .dashboard-background {
background: linear-gradient(to bottom right, #f8fafc, #e0e7ff); 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 */ /* Layout Classes */
...@@ -59,7 +20,8 @@ ...@@ -59,7 +20,8 @@
.dashboard-header-container { .dashboard-header-container {
background: white; 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; border-bottom: 1px solid #e5e7eb;
position: sticky; position: sticky;
top: 0; top: 0;
...@@ -162,65 +124,18 @@ ...@@ -162,65 +124,18 @@
flex-shrink: 0; flex-shrink: 0;
} }
/* Dashboard Content Area - Full Width and Responsive */ /* Content Area */
.dashboard-content-area { .dashboard-content-area {
width: 100%; max-width: 80rem;
min-height: 100vh; margin: 0 auto;
padding: 0; padding: 1.5rem 1rem;
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;
}
} }
.dashboard-content-card { .dashboard-content-card {
background: white; background: white;
border-radius: 0.75rem; 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; border: 1px solid #e5e7eb;
min-height: 600px; min-height: 600px;
} }
...@@ -282,7 +197,8 @@ ...@@ -282,7 +197,8 @@
&:hover { &:hover {
transform: translateY(-1px); 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 { i {
...@@ -372,15 +288,20 @@ ...@@ -372,15 +288,20 @@
.dashboard-layout { .dashboard-layout {
.e-panel { .e-panel {
border-radius: 12px; 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; border: 1px solid #e5e7eb;
transition: all 0.3s ease; transition: all 0.3s ease;
position: relative; position: relative;
max-width: 100%; max-width: 100%;
overflow: hidden; overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
&:hover { &: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); transform: translateY(-2px);
} }
} }
...@@ -392,41 +313,58 @@ ...@@ -392,41 +313,58 @@
padding: 12px 16px; padding: 12px 16px;
font-weight: 600; font-weight: 600;
position: relative; position: relative;
flex-shrink: 0;
min-height: 48px;
display: flex;
align-items: center;
} }
.e-panel-content { .e-panel-content {
border-radius: 0 0 12px 12px; border-radius: unset !important;
background: transparent !important;
overflow: hidden; overflow: hidden;
position: relative; 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 { ::ng-deep {
#dashboard_default.e-dashboardlayout { #dashboard_default.e-dashboardlayout {
width: 100% !important; width: 100% !important;
height: auto !important; height: auto !important;
min-height: calc(100vh - 2rem) !important; max-height: calc(100vh - 300px) !important;
max-height: none !important; overflow: auto !important;
overflow: visible !important;
position: relative !important; position: relative !important;
background: transparent !important;
padding: 0 !important;
margin: 0 !important;
.e-panel { .e-panel {
max-width: 100% !important; max-width: 100% !important;
overflow: hidden !important; overflow: hidden !important;
position: relative !important; position: relative !important;
background: white !important; box-sizing: border-box !important;
border: 1px solid #e5e7eb !important; display: flex !important;
border-radius: 12px !important; flex-direction: column !important;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important; height: 100% !important;
margin: 0 !important;
/* Ensure panel respects grid boundaries */
min-width: 0 !important;
min-height: 0 !important;
} }
.e-panel-header { .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 { .e-panel-content {
...@@ -434,28 +372,110 @@ ...@@ -434,28 +372,110 @@
max-width: 100% !important; max-width: 100% !important;
width: 100% !important; width: 100% !important;
height: 100% !important; height: 100% !important;
box-sizing: border-box !important;
padding: 0 !important; padding: 0 !important;
margin: 0 !important; margin: 0 !important;
background: white !important; flex: 1 !important;
border-radius: 12px !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 { .e-panel .e-panel-container {
width: 100% !important; width: 100% !important;
height: 100% !important; height: 100% !important;
overflow: hidden !important; overflow: hidden !important;
position: relative !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 { .e-panel .e-panel-container .content {
width: 100% !important; width: 100% !important;
height: 100% !important; height: 100% !important;
overflow: hidden !important; overflow: hidden !important;
position: relative !important; position: relative !important;
box-sizing: border-box !important;
display: flex !important;
flex-direction: column !important;
padding: 0 !important; padding: 0 !important;
margin: 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 @@ ...@@ -471,7 +491,8 @@
&:hover { &:hover {
border-color: #3b82f6; 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 @@ ...@@ -484,94 +505,188 @@
} }
@keyframes shimmer { @keyframes shimmer {
0% { background-position: -200% 0; } 0% {
100% { background-position: 200% 0; } background-position: -200% 0;
}
100% {
background-position: 200% 0;
}
} }
/* Responsive Design for Dashboard Viewer */ /* Responsive Design */
@media (max-width: 1200px) { @media (max-width: 1024px) {
.dashboard-layout-container { .header-content {
padding: 0.75rem; padding: 0 0.75rem;
} }
::ng-deep { .header-left {
#dashboard_default.e-dashboardlayout { gap: 1rem;
min-height: calc(100vh - 1.5rem) !important;
}
} }
}
@media (max-width: 1024px) { .header-controls {
.dashboard-layout-container { gap: 1rem;
padding: 0.5rem;
} }
.dashboard-layout { .dashboard-selector {
.e-panel { flex-direction: column;
margin: 0.25rem; 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 { ::ng-deep {
#dashboard_default.e-dashboardlayout { #dashboard_default.e-dashboardlayout {
min-height: calc(100vh - 1rem) !important; .e-resize-handle {
width: 6px !important;
height: 6px !important;
}
.e-panel { .e-panel {
border-radius: 8px !important; min-height: 120px !important;
}
.e-panel-content {
min-height: 80px !important;
} }
} }
} }
} }
@media (max-width: 768px) { @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 { .dashboard-layout-container {
padding: 0.25rem; max-height: calc(100vh - 200px);
} }
.dashboard-layout { .dashboard-layout {
.e-panel { .e-panel {
margin: 0.125rem; margin: 8px;
border-radius: 8px;
} }
} }
// Syncfusion overrides for mobile
::ng-deep { ::ng-deep {
#dashboard_default.e-dashboardlayout { #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 { .e-panel {
border-radius: 8px !important; min-width: 100px !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-height: 100px !important;
}
.e-panel-content {
min-height: 60px !important;
}
.e-panel .e-panel-container .content > * {
min-height: 60px !important;
} }
} }
} }
} }
@media (max-width: 480px) { @media (max-width: 480px) {
.dashboard-layout-container { .header-content {
padding: 0.125rem; padding: 0 0.5rem;
} }
.dashboard-layout { .title-content h1 {
.e-panel { font-size: 1.25rem;
margin: 0.0625rem; }
border-radius: 6px;
} .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 { ::ng-deep {
#dashboard_default.e-dashboardlayout { #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 { .e-panel {
border-radius: 6px !important; min-width: 80px !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-height: 80px !important;
}
.e-panel-content {
min-height: 40px !important;
}
.e-panel .e-panel-container .content > * {
min-height: 40px !important;
} }
} }
} }
} }
.dashboard-container { .dashboard-container {
display: flex; display: flex;
height: 100vh; height: 100vh;
...@@ -583,7 +698,8 @@ ...@@ -583,7 +698,8 @@
background-color: #ffffff; /* bg-white */ background-color: #ffffff; /* bg-white */
padding: 1rem; /* p-4 */ padding: 1rem; /* p-4 */
overflow-y: auto; 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 */ border-right: 1px solid #e5e7eb; /* border-r border-gray-200 */
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -606,7 +722,8 @@ ...@@ -606,7 +722,8 @@
&:hover { &:hover {
background-color: #e0e7ff; /* hover:bg-indigo-50 */ background-color: #e0e7ff; /* hover:bg-indigo-50 */
border-color: #c7d2fe; /* hover:border-indigo-100 */ 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 @@ ...@@ -636,7 +753,8 @@
font-weight: bold; font-weight: bold;
padding: 0.5rem 1rem; /* py-2 px-4 */ padding: 0.5rem 1rem; /* py-2 px-4 */
border-radius: 0.5rem; /* rounded-lg */ 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 */ transition: transform 0.2s ease-in-out; /* transition-transform */
transform: scale(1); /* transform */ transform: scale(1); /* transform */
...@@ -700,3 +818,10 @@ ...@@ -700,3 +818,10 @@
// text-align: center; // text-align: center;
// line-height: 90px; // 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 { ...@@ -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