Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
myjob-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
myjob-manage
Commits
f956c40e
Commit
f956c40e
authored
Jul 09, 2025
by
Natthaphat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix token myPortal
parent
b2561485
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
35 deletions
+50
-35
excel-report.service.ts
src/app/DPU/services/excel-report.service.ts
+14
-13
http-request.interceptor.ts
src/app/shared/services/http-request.interceptor.ts
+34
-22
environment.ts
src/environments/environment.ts
+2
-0
No files found.
src/app/DPU/services/excel-report.service.ts
View file @
f956c40e
...
...
@@ -18,19 +18,19 @@ export class ExcelReportService {
private
translateService
:
TranslateService
)
{
}
getExcelList
():
Observable
<
TemplateModel
[]
>
{
return
this
.
http
.
get
<
TemplateModel
[]
>
(
environment
.
baseUrl
+
"/
template/lists?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
)
return
this
.
http
.
get
<
TemplateModel
[]
>
(
environment
.
url
+
"
template/lists?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
)
}
getModuleList
():
Observable
<
ModuleModel
[]
>
{
return
this
.
http
.
get
<
ModuleModel
[]
>
(
environment
.
baseUrl
+
"/
template/lists/module?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
)
return
this
.
http
.
get
<
ModuleModel
[]
>
(
environment
.
url
+
"
template/lists/module?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
)
}
getExcelPortalList
():
Observable
<
ExcelPortalModel
[]
>
{
return
this
.
http
.
get
<
ExcelPortalModel
[]
>
(
environment
.
baseUrl
+
"/
excel-center/content/lists"
)
return
this
.
http
.
get
<
ExcelPortalModel
[]
>
(
environment
.
url
+
"
excel-center/content/lists"
)
}
getExcelPortalgGroupList
():
Observable
<
ExcelPortalGroupModel
[]
>
{
return
this
.
http
.
get
<
ExcelPortalGroupModel
[]
>
(
environment
.
baseUrl
+
"/
portal-group/lists"
)
return
this
.
http
.
get
<
ExcelPortalGroupModel
[]
>
(
environment
.
url
+
"
portal-group/lists"
)
}
getExcelPortalTagsList
():
Observable
<
ExcelPortalTagsModel
[]
>
{
return
this
.
http
.
get
<
ExcelPortalTagsModel
[]
>
(
environment
.
baseUrl
+
"/
tag/lists"
)
return
this
.
http
.
get
<
ExcelPortalTagsModel
[]
>
(
environment
.
url
+
"
tag/lists"
)
}
postTemplate
(
body
:
{
...
...
@@ -41,7 +41,7 @@ export class ExcelReportService {
edesc
:
string
,
module
:
string
})
{
return
this
.
http
.
post
(
environment
.
baseUrl
+
"/
template?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
body
)
return
this
.
http
.
post
(
environment
.
url
+
"
template?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
body
)
}
deleteTemplate
(
body
:
TemplateModel
):
Observable
<
AlertModel
>
{
let
option
=
{
...
...
@@ -50,10 +50,10 @@ export class ExcelReportService {
}),
body
:
body
}
return
this
.
http
.
delete
<
AlertModel
>
(
environment
.
baseUrl
+
"/
template?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
option
)
return
this
.
http
.
delete
<
AlertModel
>
(
environment
.
url
+
"
template?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
option
)
}
postTemplateFile
(
body
:
TemplateFileModel
):
Observable
<
AlertModel
>
{
return
this
.
http
.
post
<
AlertModel
>
(
environment
.
baseUrl
+
"/
template-file?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
body
)
return
this
.
http
.
post
<
AlertModel
>
(
environment
.
url
+
"
template-file?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
body
)
}
deleteTemplateFile
(
body
:
TemplateFileModel
):
Observable
<
AlertModel
>
{
let
option
=
{
...
...
@@ -62,22 +62,22 @@ export class ExcelReportService {
}),
body
:
body
}
return
this
.
http
.
delete
<
AlertModel
>
(
environment
.
baseUrl
+
"/
template-file?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
option
)
return
this
.
http
.
delete
<
AlertModel
>
(
environment
.
url
+
"
template-file?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
option
)
}
downloadTemplateFile
(
fileName
:
string
)
{
return
this
.
http
.
get
(
environment
.
baseUrl
+
"/
template-file/download/excel/"
+
fileName
+
"?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
{
responseType
:
'blob'
})
return
this
.
http
.
get
(
environment
.
url
+
"
template-file/download/excel/"
+
fileName
+
"?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
{
responseType
:
'blob'
})
}
printExcelReport
(
body
:
{
fileName
:
string
,
paramObj
:
string
})
{
return
this
.
http
.
post
(
environment
.
baseUrl
+
"/
template-file/export-to-excel?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
body
,
{
responseType
:
'blob'
})
return
this
.
http
.
post
(
environment
.
url
+
"
template-file/export-to-excel?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,
body
,
{
responseType
:
'blob'
})
}
getTemplateFile
(
templateid
:
string
,
filename
:
string
):
Observable
<
AlertModel
>
{
return
this
.
http
.
get
<
AlertModel
>
(
environment
.
baseUrl
+
"/
template-file/"
+
templateid
+
"/"
+
filename
+
"?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,)
return
this
.
http
.
get
<
AlertModel
>
(
environment
.
url
+
"
template-file/"
+
templateid
+
"/"
+
filename
+
"?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,)
}
getTemplateFileLists
():
Observable
<
TemplateFileMiniModel
[]
>
{
return
this
.
http
.
get
<
TemplateFileMiniModel
[]
>
(
environment
.
baseUrl
+
"/
template-file/menuitem/mini/lists?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,)
return
this
.
http
.
get
<
TemplateFileMiniModel
[]
>
(
environment
.
url
+
"
template-file/menuitem/mini/lists?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47"
,)
}
}
\ No newline at end of file
src/app/shared/services/http-request.interceptor.ts
View file @
f956c40e
...
...
@@ -18,34 +18,46 @@ export class HttpRequestInterceptor {
constructor
(
private
tokenService
:
TokenService
,
private
authService
:
AuthService
)
{
}
intercept
(
req
:
HttpRequest
<
any
>
,
next
:
HttpHandler
):
Observable
<
HttpEvent
<
any
>>
{
if
(
req
.
url
.
startsWith
(
"./"
))
{
if
(
req
.
url
.
startsWith
(
'./'
))
{
return
next
.
handle
(
req
);
}
else
{
let
authReq
=
req
;
const
fullUrl
=
req
.
url
.
startsWith
(
"http"
)
?
req
.
url
:
environment
.
baseUrl
+
req
.
url
;
const
token
=
this
.
tokenService
.
getToken
()
?
"Bearer "
+
this
.
tokenService
.
getToken
()
:
null
console
.
log
(
fullUrl
)
if
(
token
!=
null
)
{
authReq
=
this
.
addTokenHeader
(
req
,
token
,
fullUrl
);
}
else
{
const
overideReq
=
{
url
:
fullUrl
,
};
authReq
=
req
.
clone
(
overideReq
);
}
console
.
log
(
"full url : "
,
fullUrl
)
return
next
.
handle
(
authReq
).
pipe
(
catchError
(
error
=>
{
console
.
log
(
"error"
,
error
)
if
(
error
instanceof
HttpErrorResponse
&&
error
.
status
===
403
&&
!
fullUrl
.
includes
(
"login"
))
{
console
.
log
(
"error"
,
403
)
}
// จัดการ full URL
const
fullUrl
=
req
.
url
.
startsWith
(
'http'
)
?
req
.
url
:
`
${
environment
.
baseUrl
.
replace
(
/
\/
$/
,
''
)}
/
${
req
.
url
.
replace
(
/^
\/
/
,
''
)}
`
;
let
token
:
string
|
null
=
null
;
// ใช้ fixed token หาก url เป็น portal.myhr.co.th
if
(
fullUrl
.
startsWith
(
environment
.
url
))
{
token
=
`Bearer
${
environment
.
portalFixedToken
}
`
;
}
else
if
(
this
.
tokenService
.
getToken
())
{
token
=
`Bearer
${
this
.
tokenService
.
getToken
()}
`
;
}
let
authReq
=
req
.
clone
({
url
:
fullUrl
});
if
(
token
)
{
authReq
=
this
.
addTokenHeader
(
authReq
,
token
,
fullUrl
);
// ✅ 3 arguments
}
return
next
.
handle
(
authReq
).
pipe
(
catchError
(
error
=>
{
if
(
error
instanceof
HttpErrorResponse
&&
error
.
status
===
403
&&
!
fullUrl
.
includes
(
'login'
)
&&
!
fullUrl
.
startsWith
(
environment
.
url
)
// ไม่ refresh สำหรับ portal token
)
{
return
this
.
handle403Error
(
authReq
,
next
,
fullUrl
);
}
return
throwError
(
error
);
}));
}
})
);
}
private
handle403Error
(
request
:
HttpRequest
<
any
>
,
next
:
HttpHandler
,
fullUrl
:
string
)
{
if
(
!
this
.
isRefreshing
)
{
this
.
isRefreshing
=
true
;
...
...
src/environments/environment.ts
View file @
f956c40e
...
...
@@ -4,6 +4,8 @@
export
const
environment
=
{
production
:
false
,
baseUrl
:
'https://myjob.myhr.co.th/api'
,
url
:
'https://portal.myhr.co.th/api/'
,
portalFixedToken
:
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZSI6InVzZXIiLCJpc3MiOiJDb21wdXRlciBTY2llbmNlIENvcnBvcmF0aW9uIExpbWl0ZWQiLCJmdWxsTmFtZSI6InRlZXJhZGFjaCBrdWhhdGFuYXNhdGllbiIsIm1lbWJlcklkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0In0.FO7u8g7KfzkmZFTuuniBCEQxduPjcvzMbH7iug3DT90'
,
firebase
:
{
apiKey
:
"***************************************"
,
authDomain
:
"************************"
,
...
...
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