Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mySkill-x
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
mySkill-x
Commits
7a7d837a
Commit
7a7d837a
authored
Oct 21, 2025
by
sawit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get dashboardId for Widget
parent
0ede5a33
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
6 deletions
+88
-6
widget1.component.html
src/app/components/widget1/widget1.component.html
+14
-0
widget1.component.ts
src/app/components/widget1/widget1.component.ts
+27
-6
widget.model.ts
src/app/shared/model/widget.model.ts
+28
-0
widget.service.ts
src/app/shared/services/widget.service.ts
+19
-0
No files found.
src/app/components/widget1/widget1.component.html
View file @
7a7d837a
<!-- <iframe [src]="iframeUrl" style="width: 100%; height: 75vh; border: none;"></iframe> -->
<!-- Controls Section -->
<div
class=
"header-controls px-4 py-2"
>
<!-- Dashboard Selector -->
<div
class=
"dashboard-selector flex items-center space-x-4"
>
<label
class=
"selector-label text-lg font-medium text-gray-700"
>
Select Dashboard:
</label>
<select
(
change
)="
onDashboardChange
($
event
)"
class=
"block w-full max-w-xs px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
>
<option
[
disabled
]="
true
"
[
selected
]="
true
"
>
-- Select a Dashboard --
</option>
<option
*
ngFor=
"let dashboard of dashboards"
[
value
]="
dashboard
.
dashboardId
"
>
{{ dashboard.thName }}
</option>
</select>
</div>
</div>
<div
style=
"width: 100%; height: 80vh;"
>
<iframe
*
ngIf=
"dashboardUrl"
...
...
src/app/components/widget1/widget1.component.ts
View file @
7a7d837a
import
{
CommonModule
}
from
'@angular/common'
;
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
DomSanitizer
,
SafeResourceUrl
}
from
'@angular/platform-browser'
;
import
{
DashboardWidgetModel
}
from
'src/app/shared/model/widget.model'
;
import
{
WidgetService
}
from
'src/app/shared/services/widget.service'
;
@
Component
({
selector
:
'app-widget1'
,
...
...
@@ -11,16 +13,35 @@ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
})
export
class
Widget1Component
implements
OnInit
{
// iframeUrl!: SafeResourceUrl
;
dashboards
:
DashboardWidgetModel
[]
=
[]
;
dashboardUrl
:
SafeResourceUrl
|
null
=
null
;
private
dashboardId
=
'dash-1758608130166'
;
private
portalAppBaseUrl
=
'https://portal.myhr.co.th'
;
private
dashboardId
:
string
|
null
=
null
;
// private portalAppBaseUrl = 'https://portal.myhr.co.th';
private
portalAppBaseUrl
=
'http://localhost:4200'
;
constructor
(
private
sanitizer
:
DomSanitizer
)
{
}
constructor
(
private
sanitizer
:
DomSanitizer
,
private
widgetService
:
WidgetService
)
{
}
ngOnInit
()
{
const
url
=
`
${
this
.
portalAppBaseUrl
}
/#/embed/dashboard/
${
this
.
dashboardId
}
`
;
this
.
dashboardUrl
=
this
.
sanitizer
.
bypassSecurityTrustResourceUrl
(
url
);
this
.
loadDashboards
();
}
loadDashboards
():
void
{
this
.
widgetService
.
getDashboards
().
subscribe
(
dashboards
=>
{
this
.
dashboards
=
dashboards
;
});
}
onDashboardChange
(
event
:
Event
):
void
{
const
selectElement
=
event
.
target
as
HTMLSelectElement
;
this
.
dashboardId
=
selectElement
.
value
;
if
(
this
.
dashboardId
)
{
const
url
=
`
${
this
.
portalAppBaseUrl
}
/#/embed/dashboard/
${
this
.
dashboardId
}
`
;
this
.
dashboardUrl
=
this
.
sanitizer
.
bypassSecurityTrustResourceUrl
(
url
);
}
else
{
this
.
dashboardUrl
=
null
;
}
}
}
src/app/shared/model/widget.model.ts
0 → 100644
View file @
7a7d837a
export
interface
DashboardWidgetModel
{
dashboardId
:
string
companyId
:
string
thName
:
string
engName
:
string
application
:
string
module
:
string
description
:
string
datasetId
:
string
templateId
:
string
fileName
:
string
isActive
:
boolean
widgets
:
Widget
[]
}
export
interface
Widget
{
widgetId
:
string
thName
:
string
engName
:
string
component
:
string
cols
:
number
rows
:
number
x
:
number
y
:
number
data
:
string
config
:
string
perspective
:
string
}
src/app/shared/services/widget.service.ts
0 → 100644
View file @
7a7d837a
import
{
Injectable
}
from
'@angular/core'
;
import
{
environment
}
from
'src/environments/environment'
;
import
{
DashboardWidgetModel
}
from
'../model/widget.model'
;
import
{
Observable
}
from
'rxjs'
;
import
{
HttpClient
}
from
'@angular/common/http'
;
@
Injectable
({
providedIn
:
'root'
})
export
class
WidgetService
{
api
=
"/dashboard"
baseUrl
=
environment
.
portal
+
this
.
api
constructor
(
private
http
:
HttpClient
)
{
}
getDashboards
():
Observable
<
DashboardWidgetModel
[]
>
{
return
this
.
http
.
get
<
DashboardWidgetModel
[]
>
(
`
${
this
.
baseUrl
}
/lists/search?application=myskill-x`
);
}
}
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