Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
portal-apps-manage
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angular
portal-apps-manage
Commits
244ac3e1
Commit
244ac3e1
authored
Sep 02, 2025
by
Ooh-Ao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widget
parent
7d32073b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
11 deletions
+97
-11
dashboard-management.component.ts
...ge/dashboard-management/dashboard-management.component.ts
+0
-0
widget-config.component.html
...ard-management/widget-config/widget-config.component.html
+1
-0
widget-config.component.ts
...board-management/widget-config/widget-config.component.ts
+14
-11
dashboard-viewer.component.ts
...tal-manage/dashboard-viewer/dashboard-viewer.component.ts
+16
-0
widget-config-generator.service.ts
...portal-manage/services/widget-config-generator.service.ts
+65
-0
index.html
src/index.html
+1
-0
No files found.
src/app/portal-manage/dashboard-management/dashboard-management.component.ts
View file @
244ac3e1
This diff is collapsed.
Click to expand it.
src/app/portal-manage/dashboard-management/widget-config/widget-config.component.html
View file @
244ac3e1
...
...
@@ -652,6 +652,7 @@
</mat-dialog-content>
<mat-dialog-actions
align=
"end"
>
<button
mat-stroked-button
(
click
)="
resetConfig
()"
class=
"mr-auto"
>
Reset to Default
</button>
<button
mat-button
(
click
)="
onCancel
()"
>
Cancel
</button>
<button
mat-raised-button
color=
"primary"
(
click
)="
onSave
()"
>
Save
</button>
</mat-dialog-actions>
src/app/portal-manage/dashboard-management/widget-config/widget-config.component.ts
View file @
244ac3e1
...
...
@@ -9,11 +9,12 @@ import { MatButtonModule } from '@angular/material/button';
import
{
MatIconModule
}
from
'@angular/material/icon'
;
import
{
MatCheckboxModule
}
from
'@angular/material/checkbox'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
WidgetConfigGeneratorService
}
from
'../../services/widget-config-generator.service'
;
import
{
WidgetModel
}
from
'../../models/widgets.model'
;
export
interface
WidgetConfigDialogData
{
config
:
any
;
widget
:
WidgetModel
;
availableColumns
:
string
[];
widgetType
:
string
;
}
@
Component
({
...
...
@@ -41,27 +42,26 @@ export class WidgetConfigComponent implements OnInit {
constructor
(
public
dialogRef
:
MatDialogRef
<
WidgetConfigComponent
>
,
@
Inject
(
MAT_DIALOG_DATA
)
public
data
:
WidgetConfigDialogData
@
Inject
(
MAT_DIALOG_DATA
)
public
data
:
WidgetConfigDialogData
,
private
widgetConfigGenerator
:
WidgetConfigGeneratorService
)
{
}
ngOnInit
():
void
{
this
.
availableColumns
=
this
.
data
.
availableColumns
;
this
.
widgetType
=
this
.
data
.
widget
Type
;
this
.
widgetType
=
this
.
data
.
widget
.
component
;
// Handle config whether it is a string or an object
try
{
if
(
typeof
this
.
data
.
config
===
'string'
)
{
this
.
currentConfig
=
JSON
.
parse
(
this
.
data
.
config
);
if
(
typeof
this
.
data
.
widget
.
config
===
'string'
)
{
this
.
currentConfig
=
JSON
.
parse
(
this
.
data
.
widget
.
config
);
}
else
{
// Deep copy config to avoid direct mutation of the original object
this
.
currentConfig
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
data
.
config
||
{}));
this
.
currentConfig
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
data
.
widget
.
config
||
{}));
}
}
catch
(
e
)
{
console
.
error
(
'Error parsing widget config:'
,
e
);
this
.
currentConfig
=
{};
// Default to empty object on error
this
.
currentConfig
=
{};
}
// Initialize arrays if they don't exist
const
gridLikeWidgets
=
[
'SyncfusionDatagridWidgetComponent'
,
'NewDataTableWidget'
,
'MatrixWidgetComponent'
];
if
(
gridLikeWidgets
.
includes
(
this
.
widgetType
)
&&
!
this
.
currentConfig
.
columns
)
{
this
.
currentConfig
.
columns
=
[];
...
...
@@ -81,6 +81,10 @@ export class WidgetConfigComponent implements OnInit {
}
}
resetConfig
():
void
{
this
.
currentConfig
=
this
.
widgetConfigGenerator
.
generateConfig
(
this
.
data
.
widget
,
this
.
data
.
availableColumns
);
}
// Methods for Grid-like Widgets
addGridColumn
()
{
this
.
currentConfig
.
columns
.
push
({
field
:
''
,
headerText
:
''
,
width
:
100
,
isPrimary
:
false
});
...
...
@@ -123,7 +127,6 @@ export class WidgetConfigComponent implements OnInit {
onSave
():
void
{
// No more JSON parsing needed for the refactored widgets
this
.
dialogRef
.
close
(
this
.
currentConfig
);
}
...
...
src/app/portal-manage/dashboard-viewer/dashboard-viewer.component.ts
View file @
244ac3e1
...
...
@@ -114,6 +114,22 @@ export class DashboardViewerComponent implements OnInit {
).
subscribe
({
next
:
dashboard
=>
{
if
(
dashboard
)
{
if
(
dashboard
.
widgets
)
{
dashboard
.
widgets
.
forEach
(
widget
=>
{
const
keysToProcess
:
Array
<
keyof
WidgetModel
>
=
[
'config'
,
'perspective'
,
'data'
];
keysToProcess
.
forEach
(
key
=>
{
if
((
widget
as
any
)[
key
]
&&
typeof
(
widget
as
any
)[
key
]
===
'string'
)
{
try
{
(
widget
as
any
)[
key
]
=
JSON
.
parse
((
widget
as
any
)[
key
]
as
string
);
}
catch
(
e
)
{
console
.
error
(
`Error parsing widget
${
key
}
string:`
,
(
widget
as
any
)[
key
],
e
);
(
widget
as
any
)[
key
]
=
{};
}
}
});
});
}
this
.
dashboardData
=
dashboard
;
this
.
panels
=
this
.
mapWidgetsToPanels
(
dashboard
.
widgets
||
[]);
if
(
dashboard
.
datasetId
)
{
...
...
src/app/portal-manage/services/widget-config-generator.service.ts
0 → 100644
View file @
244ac3e1
import
{
Injectable
}
from
'@angular/core'
;
import
{
WidgetModel
}
from
'../models/widgets.model'
;
@
Injectable
({
providedIn
:
'root'
})
export
class
WidgetConfigGeneratorService
{
constructor
()
{
}
public
generateConfig
(
widget
:
WidgetModel
,
columns
:
string
[]):
any
{
let
newConfig
:
any
;
// Handle config whether it is a string or an object
try
{
if
(
typeof
widget
.
config
===
'string'
)
{
newConfig
=
JSON
.
parse
(
widget
.
config
);
}
else
{
// Deep copy config to avoid direct mutation of the original object
newConfig
=
JSON
.
parse
(
JSON
.
stringify
(
widget
.
config
||
{}));
}
}
catch
(
e
)
{
console
.
error
(
'Error parsing widget config in generator service:'
,
e
);
newConfig
=
{};
// Default to empty object on error
}
const
col1
=
columns
.
length
>
0
?
columns
[
0
]
:
''
;
const
col2
=
columns
.
length
>
1
?
columns
[
1
]
:
col1
;
switch
(
widget
.
component
)
{
case
'SyncfusionDatagridWidgetComponent'
:
case
'MatrixWidgetComponent'
:
case
'SimpleTableWidgetComponent'
:
case
'NewDataTableWidget'
:
newConfig
.
title
=
widget
.
thName
;
newConfig
.
columns
=
columns
.
map
(
c
=>
({
field
:
c
,
headerText
:
c
,
width
:
150
}));
break
;
case
'BarChartWidgetComponent'
:
case
'AreaChartWidgetComponent'
:
case
'PieChartWidgetComponent'
:
case
'DoughnutChartWidgetComponent'
:
case
'WaterfallChartWidgetComponent'
:
newConfig
.
title
=
widget
.
thName
;
newConfig
.
xField
=
col1
;
newConfig
.
yField
=
col2
;
break
;
case
'SimpleKpiWidgetComponent'
:
case
'GaugeChartWidgetComponent'
:
newConfig
.
title
=
widget
.
thName
;
newConfig
.
valueField
=
col1
;
break
;
case
'SlicerWidgetComponent'
:
newConfig
.
title
=
widget
.
thName
;
newConfig
.
optionsField
=
col1
;
break
;
default
:
newConfig
.
title
=
widget
.
thName
;
break
;
}
return
newConfig
;
}
}
src/index.html
View file @
244ac3e1
...
...
@@ -14,6 +14,7 @@
<link
rel=
"icon"
type=
"image/x-icon"
href=
"./assets/images/brand-logos/favicon.ico"
>
<link
rel=
"stylesheet"
href=
"assets/JS/pace/themes/silver/pace-theme-flash.css"
/>
<link
href=
"https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@100..900&display=swap"
rel=
"stylesheet"
>
<link
href=
"https://fonts.googleapis.com/icon?family=Material+Icons"
rel=
"stylesheet"
>
<!-- <link
href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&display=swap"
rel="stylesheet"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment