Compare commits
108 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07074c2519 | |||
| a06337d9b5 | |||
| d5026535d0 | |||
| 60be3f7890 | |||
| 278bfe80ec | |||
| d6b171a0a7 | |||
| 9a5c174fc5 | |||
| 1b6ef14c10 | |||
| 6c52de4762 | |||
| 374e25f7ee | |||
| 9136619628 | |||
|
|
f332f8b6e2 | ||
|
|
40e682e5d8 | ||
|
|
07d49d87cf | ||
|
|
f0f3392dbb | ||
|
|
07c19bd46a | ||
|
|
185227b12e | ||
|
|
11018ae49d | ||
|
|
4db7ddaba2 | ||
|
|
b8c6512f8a | ||
|
|
012d590f40 | ||
| 8e47a11ace | |||
| 87cac22db5 | |||
|
|
214ad672f0 | ||
|
|
e4e6dfc64a | ||
|
|
7204d54538 | ||
|
|
fe78631347 | ||
|
|
97fef61d8d | ||
| 14f54eddd3 | |||
| 591d89aa61 | |||
|
|
9e4af33493 | ||
|
|
368f2ef5e6 | ||
| 4c39683348 | |||
| 291485f7b7 | |||
| 4278a54726 | |||
| 252997510e | |||
| b5213b7d44 | |||
|
|
27c04e5f28 | ||
|
|
1b8241f30c | ||
| bcaf213d24 | |||
|
|
861f3f033b | ||
|
|
149b6128a7 | ||
|
|
6669399b7e | ||
|
|
0d43286d84 | ||
|
|
43ed6c0c55 | ||
|
|
5f68d3fa51 | ||
| f68f76373c | |||
| 19a5245536 | |||
| 811d7b14b8 | |||
| b1f9c48bd8 | |||
| a34714388f | |||
|
|
809e2e16bb | ||
|
|
3ebfd37400 | ||
|
|
f0336a5ead | ||
|
|
8cedef205a | ||
|
|
45259f7b8d | ||
| 1c7729ab99 | |||
|
|
10aac6060b | ||
| 651a120e2b | |||
| 14e7223974 | |||
| ff95446e07 | |||
| 3bb798c39e | |||
|
|
9db43971ce | ||
| 1d2d593eee | |||
| 5a16152a46 | |||
| 3e0dae41f0 | |||
| ebb1f2e0d6 | |||
| a7906c6a34 | |||
| 1406d36d72 | |||
| 87571f8332 | |||
| 856b6b41a8 | |||
| 9a05e78fc5 | |||
| de73c8d68f | |||
| cd6e0595a9 | |||
| 39457af479 | |||
| 0c05d9eadf | |||
| 1847bf5d65 | |||
| 290f5cae6a | |||
| 6ef1afb7f3 | |||
| 538ee11053 | |||
| 5b3bc79199 | |||
| 15308ababa | |||
| 213fd197ef | |||
| 6da86b74a9 | |||
| 21007f7bbc | |||
| a475265764 | |||
| 2e07e728dd | |||
| 304ed9294c | |||
| 9b0edccde5 | |||
|
|
6e96c686a2 | ||
|
|
c4c19e96b6 | ||
| 1f3c33b78c | |||
| 5ce012b558 | |||
| 4b3e52ff43 | |||
| 8f9159a330 | |||
|
|
ccab40852c | ||
| 60662d88d4 | |||
| ee72ef6676 | |||
| 7b441c3600 | |||
| 139167be8a | |||
| 80edb10361 | |||
| 3cc4a4a632 | |||
| f27389da29 | |||
| 1664be0c8b | |||
| b3fa94f904 | |||
| 37ca45701b | |||
| 78ce686f97 | |||
| f25488370a |
55
.gitea/workflows/build-image.yml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
name: Build Docker Image
|
||||||
|
run-name: Build Docker Image
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build Docker Image:
|
||||||
|
runs-on: ubuntu-node
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install project dependencies
|
||||||
|
run: |
|
||||||
|
(
|
||||||
|
cd accounting-ng-nuttakit
|
||||||
|
npm install --force --legacy-peer-deps --include=dev
|
||||||
|
npm install -g @angular/cli
|
||||||
|
)
|
||||||
|
(
|
||||||
|
cd ng-ttc-frontend
|
||||||
|
npm install --force --legacy-peer-deps --include=dev
|
||||||
|
npm install -g @angular/cli
|
||||||
|
)
|
||||||
|
- name: Build webapp
|
||||||
|
run: |
|
||||||
|
(
|
||||||
|
cd accounting-ng-nuttakit
|
||||||
|
# temporary change api url for development
|
||||||
|
#sed -i 's@https://api.nuttakit.work@http://10.9.0.0:8080@g' src/environments/environment.ts
|
||||||
|
ng build
|
||||||
|
)
|
||||||
|
(
|
||||||
|
cd ng-ttc-frontend
|
||||||
|
# temporary change api url for development
|
||||||
|
#sed -i 's@https://api.nuttakit.work@http://10.9.0.0:8080@g' src/environments/environment.ts
|
||||||
|
ng build
|
||||||
|
)
|
||||||
|
- name: Build docker image
|
||||||
|
run: |
|
||||||
|
set +e
|
||||||
|
docker rm $(docker stop $(docker ps -a -q --filter ancestor=accounting-frontend:latest --format="{{.ID}}"))
|
||||||
|
docker rm $(docker stop $(docker ps -a -q --filter ancestor=ttc-frontend:latest --format="{{.ID}}"))
|
||||||
|
set -e
|
||||||
|
docker image rm -f accounting-frontend:latest
|
||||||
|
docker build . -t accounting-frontend:latest
|
||||||
|
docker image rm -f ttc-frontend:latest
|
||||||
|
docker build . -f Dockerfile-TTC -t ttc-frontend:latest
|
||||||
|
|
||||||
|
Restart Docker Compose:
|
||||||
|
runs-on: host
|
||||||
|
steps:
|
||||||
|
- name: Restart compose project
|
||||||
|
run: |
|
||||||
|
echo '(cd frontend-development-kickstarter && ddd && ddd && ddud)' > /hostpipe
|
||||||
|
|
||||||
|
|
||||||
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
ADD accounting-ng-nuttakit/dist/accounting-ng-nuttakit/browser /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
10
Dockerfile-TTC
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
ADD ng-ttc-frontend/dist/ng-ttc-frontend/browser /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -37,12 +37,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"node_modules/bootstrap/dist/css/bootstrap.min.css",
|
|
||||||
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
||||||
"src/styles.css"
|
"src/styles.css"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
@@ -86,7 +84,7 @@
|
|||||||
"builder": "@angular/build:dev-server",
|
"builder": "@angular/build:dev-server",
|
||||||
"options": {
|
"options": {
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"allowedHosts": ["accounting.nuttakit.work", "localhost"]
|
"allowedHosts": ["accounting.nuttakit.work", "localhost", "meal-demand-virtual-referrals.trycloudflare.com"]
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
@@ -116,12 +114,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"node_modules/bootstrap/dist/css/bootstrap.min.css",
|
|
||||||
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
||||||
"src/styles.css"
|
"src/styles.css"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,9 +58,9 @@
|
|||||||
"@fortawesome/free-regular-svg-icons": "^7.1.0",
|
"@fortawesome/free-regular-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
"@tailwindcss/postcss": "^4.1.16",
|
"@tailwindcss/postcss": "^4.1.16",
|
||||||
"bootstrap": "^5.3.8",
|
|
||||||
"chart.js": "^4.5.1",
|
"chart.js": "^4.5.1",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
"ng2-charts": "^6.0.1",
|
"ng2-charts": "^6.0.1",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
@@ -73,6 +73,7 @@
|
|||||||
"@angular/cli": "^20.3.9",
|
"@angular/cli": "^20.3.9",
|
||||||
"@angular/compiler-cli": "^20.3.10",
|
"@angular/compiler-cli": "^20.3.10",
|
||||||
"@capacitor/cli": "latest",
|
"@capacitor/cli": "latest",
|
||||||
|
"@types/jasmine": "~5.1.0",
|
||||||
"cross-env": "^10.1.0",
|
"cross-env": "^10.1.0",
|
||||||
"electron": "^39.0.0",
|
"electron": "^39.0.0",
|
||||||
"electron-builder": "^26.0.12",
|
"electron-builder": "^26.0.12",
|
||||||
@@ -84,7 +85,6 @@
|
|||||||
"karma-jasmine-html-reporter": "~2.1.0",
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
"ngx-toastr": "^19.1.0",
|
"ngx-toastr": "^19.1.0",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"typescript": "~5.9.3",
|
"typescript": "~5.9.3"
|
||||||
"@types/jasmine": "~5.1.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ const routes: Routes = [
|
|||||||
|
|
||||||
{ path: 'login', loadChildren: () => import('./controls/login-control/login-control.module').then(m => m.LoginControlModule) },
|
{ path: 'login', loadChildren: () => import('./controls/login-control/login-control.module').then(m => m.LoginControlModule) },
|
||||||
|
|
||||||
{ path: 'c', component: LicensePrivacyTermsComponent},
|
{ path: 'license', component: LicensePrivacyTermsComponent},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: 'main',
|
path: 'main',
|
||||||
@@ -22,9 +22,18 @@ const routes: Routes = [
|
|||||||
(m) => m.MainControlModule
|
(m) => m.MainControlModule
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// path: 'report',
|
||||||
|
// loadChildren: () =>
|
||||||
|
// import('./controls/report-control/report-control.module').then(
|
||||||
|
// (m) => m.ReportControlModule
|
||||||
|
// ),
|
||||||
|
// },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// {path: 'license' , component: LicensePrivacyTermsComponent}
|
||||||
|
|
||||||
{ path: '', redirectTo: 'login', pathMatch: 'full' },
|
{ path: '', redirectTo: 'login', pathMatch: 'full' },
|
||||||
|
|
||||||
{ path: '**', redirectTo: 'login' }
|
{ path: '**', redirectTo: 'login' }
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ import { LicensePrivacyTermsComponent } from './component/license-privacy-terms/
|
|||||||
// import { LoginPageComponent } from './component/login-page/login-page.component';
|
// import { LoginPageComponent } from './component/login-page/login-page.component';
|
||||||
// import { LoginContentComponent } from './content/login-content/login-content.component';
|
// import { LoginContentComponent } from './content/login-content/login-content.component';
|
||||||
|
|
||||||
|
|
||||||
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
||||||
|
import { LoginRegisterComponent } from './component/login-register/login-register.component';
|
||||||
|
// import { AccDateFormatPipe } from './pipe/dtmtodatetime.pipe';
|
||||||
|
// import { DtmtodatetimePipe } from './dtmtodatetime.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -30,6 +34,9 @@ import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
|||||||
SidebarContentComponent,
|
SidebarContentComponent,
|
||||||
SidebarComponent,
|
SidebarComponent,
|
||||||
LicensePrivacyTermsComponent,
|
LicensePrivacyTermsComponent,
|
||||||
|
// LoginRegisterComponent,
|
||||||
|
// AccDateFormatPipe
|
||||||
|
// DtmtodatetimePipe,
|
||||||
// MainDashboardContentComponent,
|
// MainDashboardContentComponent,
|
||||||
// MainDashboardComponent,
|
// MainDashboardComponent,
|
||||||
// LoginForgotComponent,
|
// LoginForgotComponent,
|
||||||
@@ -51,6 +58,9 @@ import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
|||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
FontAwesomeModule
|
FontAwesomeModule
|
||||||
],
|
],
|
||||||
|
exports: [
|
||||||
|
// AccDateFormatPipe
|
||||||
|
],
|
||||||
providers: [provideCharts(withDefaultRegisterables())],
|
providers: [provideCharts(withDefaultRegisterables())],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
--radius: 8px;
|
--radius: 8px;
|
||||||
--shadow: 0 10px 30px rgba(11,26,43,0.08);
|
--shadow: 0 10px 30px rgba(11,26,43,0.08);
|
||||||
--glass: rgba(255,255,255,0.6);
|
--glass: rgba(255,255,255,0.6);
|
||||||
|
--success-color: #10b981; /* Green for success/confirm */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Page layout */
|
/* Page layout (unchanged) */
|
||||||
.login-widget {
|
.login-widget {
|
||||||
/* Fill the viewport and center the card. Do not let the page itself
|
|
||||||
scroll; the card gets an internal max-height instead. */
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -24,8 +23,7 @@
|
|||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Card (unchanged) */
|
||||||
/* Card */
|
|
||||||
.login-widget .card{
|
.login-widget .card{
|
||||||
width: 380px;
|
width: 380px;
|
||||||
max-width: calc(100% - 40px);
|
max-width: calc(100% - 40px);
|
||||||
@@ -37,16 +35,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
/* Constrain the card so it never forces the page to scroll. If content
|
|
||||||
grows, the card will scroll internally. */
|
|
||||||
max-height: calc(100vh - 56px);
|
max-height: calc(100vh - 56px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modal/backdrop styles */
|
/* Modal/backdrop styles (unchanged) */
|
||||||
.login-backdrop{
|
.login-backdrop{
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0; /* top:0; right:0; bottom:0; left:0; */
|
inset: 0;
|
||||||
background: rgba(0,0,0,0.38);
|
background: rgba(0,0,0,0.38);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -54,43 +50,19 @@
|
|||||||
z-index: 1040;
|
z-index: 1040;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-modal{ width: 480px; max-width: 480px; }
|
.login-modal{ width: 480px; max-width: 480px; }
|
||||||
|
|
||||||
.modal-card{
|
.modal-card{
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 0; /* card children control internal padding */
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 20px 50px rgba(2,6,23,0.4);
|
box-shadow: 0 20px 50px rgba(2,6,23,0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Slightly larger brand area inside modal */
|
/* Brand area (unchanged) */
|
||||||
.modal-card .brand{ padding: 18px; }
|
|
||||||
|
|
||||||
/* Make the primary button pill-shaped and slightly larger */
|
|
||||||
button.primary{
|
|
||||||
color: #000;
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 10px 18px;
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make biometric and other action buttons visually lighter */
|
|
||||||
.biometric{
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* On small screens reduce modal padding and width to avoid overflow */
|
|
||||||
@media (max-width: 420px){
|
|
||||||
.login-backdrop{ padding: 12px; }
|
|
||||||
.login-modal{ max-width: 100%; }
|
|
||||||
.modal-card .brand{ padding: 12px; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Brand area */
|
|
||||||
.brand{
|
.brand{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
padding: 18px;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
border-bottom: 1px solid #eef2f5;
|
border-bottom: 1px solid #eef2f5;
|
||||||
}
|
}
|
||||||
@@ -116,16 +88,13 @@ button.primary{
|
|||||||
|
|
||||||
/* Form area */
|
/* Form area */
|
||||||
.form{
|
.form{
|
||||||
/* keep compact spacing inside the card */
|
|
||||||
/* width: 410px; */
|
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 6px 0 2px;
|
padding: 6px 22px 22px 22px;
|
||||||
}
|
}
|
||||||
|
/* Field label wrapper (unchanged) */
|
||||||
/* Field label wrapper */
|
|
||||||
.field{
|
.field{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -135,11 +104,11 @@ button.primary{
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
|
/* Inputs (class 'input-field' added to HTML) */
|
||||||
/* Inputs */
|
|
||||||
input[type="email"],
|
input[type="email"],
|
||||||
input[type="password"],
|
input[type="password"],
|
||||||
input[type="text"]{
|
input[type="text"],
|
||||||
|
.input-field { /* เพิ่ม class input-field เพื่อให้สไตล์ถูกใช้กับ input ที่กำหนด */
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
@@ -163,31 +132,30 @@ input:focus{
|
|||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checkbox / stay signed */
|
|
||||||
.stay-signed{
|
|
||||||
display: inline-flex;
|
|
||||||
gap: 8px;
|
|
||||||
align-items: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--muted);
|
|
||||||
}
|
|
||||||
.stay-signed input[type="checkbox"]{
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
accent-color: var(--primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Actions row */
|
/* Actions row */
|
||||||
.actions{
|
.actions{
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
|
flex-direction: row-reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Custom class for justify-end when using flex-row-reverse */
|
||||||
|
.actions.justify-end-custom {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom class for lift hover effect (used for 'เปิด Modal' button) */
|
||||||
|
.hover-lift:hover {
|
||||||
|
transform: translateY(-2.5px);
|
||||||
|
transition: transform .2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PRIMARY BUTTON - แก้ไขสีข้อความให้เป็นสีดำ */
|
||||||
button.primary{
|
button.primary{
|
||||||
background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
|
background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
|
||||||
color: #000000;
|
color: #000000; /* ⬅️ แก้ไขเป็นสีดำตามคำขอ */
|
||||||
border: none;
|
border: none;
|
||||||
padding: 10px 14px;
|
padding: 10px 14px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
@@ -197,6 +165,7 @@ button.primary{
|
|||||||
box-shadow: 0 6px 18px rgba(0,120,212,0.12);
|
box-shadow: 0 6px 18px rgba(0,120,212,0.12);
|
||||||
transition: transform .06s ease, box-shadow .12s ease, opacity .12s ease;
|
transition: transform .06s ease, box-shadow .12s ease, opacity .12s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.primary:hover:not(:disabled){
|
button.primary:hover:not(:disabled){
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
box-shadow: 0 10px 24px rgba(0,120,212,0.14);
|
box-shadow: 0 10px 24px rgba(0,120,212,0.14);
|
||||||
@@ -207,45 +176,26 @@ button.primary:active{
|
|||||||
button.primary:disabled{
|
button.primary:disabled{
|
||||||
opacity: 0.55;
|
opacity: 0.55;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
color: #000000; /* ข้อความ disabled ก็เป็นสีดำ */
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Alternative options */
|
/* Secondary Button Style (สำหรับปุ่ม 'เปิด Modal', 'ส่งอีกครั้ง') */
|
||||||
.alt-options{
|
.primary.secondary-button {
|
||||||
display: flex;
|
background: transparent;
|
||||||
align-items: center;
|
color: var(--primary);
|
||||||
gap: 12px;
|
border: 1px solid var(--primary);
|
||||||
margin-top: 6px;
|
box-shadow: none;
|
||||||
flex-wrap: wrap;
|
transition: background-color .14s ease;
|
||||||
}
|
}
|
||||||
.biometric{
|
.primary.secondary-button:hover {
|
||||||
display: inline-flex;
|
background: rgba(0, 120, 212, 0.05);
|
||||||
align-items: center;
|
transform: none;
|
||||||
gap: 10px;
|
box-shadow: none;
|
||||||
padding: 8px 10px;
|
|
||||||
background: transparent;
|
|
||||||
color: var(--primary);
|
|
||||||
border: 1px solid rgba(0,120,212,0.14);
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.biometric svg{ display: block; opacity: .95; }
|
|
||||||
.biometric:hover{
|
|
||||||
background: rgba(0,120,212,0.04);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Help link */
|
|
||||||
.help-link{
|
|
||||||
margin-left: auto;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--primary);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.help-link:hover{ text-decoration: underline; }
|
|
||||||
|
|
||||||
/* Footer */
|
/* Footer (unchanged) */
|
||||||
.footer{
|
.footer{
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -262,13 +212,9 @@ button.primary:disabled{
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.footer a:hover{ text-decoration: underline; }
|
|
||||||
.divider{ color: #d0d6db; }
|
|
||||||
|
|
||||||
/* Focus styles for keyboard users */
|
/* Focus styles (unchanged) */
|
||||||
:focus{
|
:focus{ outline: none; }
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
:focus-visible{
|
:focus-visible{
|
||||||
outline: 3px solid rgba(0,120,212,0.12);
|
outline: 3px solid rgba(0,120,212,0.12);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
@@ -277,14 +223,13 @@ button.primary:disabled{
|
|||||||
|
|
||||||
/* Small screens */
|
/* Small screens */
|
||||||
@media (max-width:420px){
|
@media (max-width:420px){
|
||||||
|
.login-backdrop{ padding: 12px; }
|
||||||
|
.login-modal{ max-width: 100%; }
|
||||||
|
.modal-card .brand{ padding: 12px; }
|
||||||
.login-widget .card{
|
.login-widget .card{
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.brand h1{ font-size: 18px; }
|
.brand h1{ font-size: 18px; }
|
||||||
.brand .subtitle{
|
|
||||||
font-family: "Kanit";
|
|
||||||
font-weight: 1000;
|
|
||||||
font-style: normal; }
|
|
||||||
.biometric span, .primary{ font-size: 13px; }
|
.biometric span, .primary{ font-size: 13px; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,105 +1,120 @@
|
|||||||
<div class="login-backdrop">
|
<div class="min-h-screen flex items-center justify-center p-4 sm:p-6 bg-linear-to-br from-red-50 via-white to-red-100 relative overflow-hidden">
|
||||||
<div class="login-modal d-flex align-items-center justify-content-center ">
|
<div class="login-modal d-flex align-items-center justify-content-center bg-white rounded-2xl">
|
||||||
<div class="card modal-card" role="dialog" aria-labelledby="signin-title" aria-modal="true">
|
<div class="card modal-card" role="dialog" aria-labelledby="signin-title" aria-modal="true">
|
||||||
<div class="brand">
|
|
||||||
<!-- <img src="assets/logo.png" alt="Company logo" class="logo" /> -->
|
|
||||||
<img src="logo.png" alt="Company logo" class="logo mb-2"/>
|
|
||||||
<h1 id="signin-title" class='kanit-bold'>ลืมรหัสผ่าน</h1>
|
|
||||||
<p class="subtitle">โปรดกรอก Email ของท่าน</p>
|
|
||||||
</div>
|
|
||||||
<form [formGroup]="forgotFrm" class="form px-3 pb-3 login-mobile">
|
|
||||||
<label class="field">
|
|
||||||
<span class="label-text ">อีเมล์</span>
|
|
||||||
<input type="email" formControlName="email" class="px-2 " id="englishInput" autocomplete="username" placeholder="nuttakit@gmail.com" aria-label="Email address" required />
|
|
||||||
</label>
|
|
||||||
|
|
||||||
@if (isSendOtp === true) {
|
<div class="brand">
|
||||||
<label class="field">
|
<img src="logo.png" alt="Company logo" class="logo mb-2"/>
|
||||||
<span class="label-text">รหัสยืนยัน OTP</span>
|
<h1 id="signin-title" class="kanit-bold">ลืมรหัสผ่าน</h1>
|
||||||
<input type="email" formControlName="otp" autocomplete="otp" placeholder="123456" alt required/>
|
<p class="subtitle">โปรดกรอก Email ของท่าน</p>
|
||||||
</label>
|
|
||||||
}
|
|
||||||
<!-- <div class="justify-end flex"> -->
|
|
||||||
<!-- <label class="stay-signed">
|
|
||||||
<input type="checkbox" formControlName="remember" />
|
|
||||||
<span>จดจำรหัสผ่าน</span>
|
|
||||||
</label> -->
|
|
||||||
<div class="flex flex-row gap-2 mt-4 justify-end">
|
|
||||||
<div class="flex-row hover:-translate-y-2.5 transform transition-all">
|
|
||||||
<button class="bg-[linear-gradient(180deg,var(--primary)_0%,var(--primary-600)_100%)]
|
|
||||||
text-black
|
|
||||||
border-0
|
|
||||||
px-3.5 py-2.5
|
|
||||||
rounded-md
|
|
||||||
font-semibold
|
|
||||||
cursor-pointer
|
|
||||||
text-[14px]
|
|
||||||
shadow-[0_6px_18px_var(--color-blue-500)]
|
|
||||||
transition
|
|
||||||
ease-in-out
|
|
||||||
duration-100
|
|
||||||
hover:scale-[1.02]
|
|
||||||
active:opacity-90" (click)="isModalOpen = true">
|
|
||||||
เปิด Modal
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
@if (isSendOtp === false) {
|
|
||||||
<div class="flex justify-end">
|
|
||||||
@if (isLoading === true) {
|
|
||||||
<button type="submit" class="primary cursor-progress!" disabled>
|
|
||||||
กำลังส่ง...
|
|
||||||
</button>
|
|
||||||
} @else {
|
|
||||||
<button type="submit" class="primary" (click)="onSubmin()">
|
|
||||||
{{ 'ยืนยันส่ง OTP รีเซ็ตรหัสผ่าน' }}
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
} @else if(isSendOtp === true) {
|
|
||||||
<div class="flex justify-end gap-2">
|
|
||||||
<button type="button" class="primary" (click)="onSubmin()">
|
|
||||||
{{ 'ส่งอีกครั้ง' }}
|
|
||||||
</button>
|
|
||||||
<button type="submit" class="primary" (click)="onVerifySubmit()">
|
|
||||||
{{ 'รีเซ็ตรหัสผ่าน' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
<!-- <button mat-raised-button color="primary" [disabled]="isLoading">
|
|
||||||
{{ isLoading ? 'กำลังส่ง...' : 'ส่งรหัส OTP' }}
|
<form [formGroup]="forgotFrm" class="form">
|
||||||
</button> -->
|
<label class="field">
|
||||||
<!-- } -->
|
<span class="label-text">อีเมล์</span>
|
||||||
<!-- </div> -->
|
<input type="email" formControlName="email" class="input-field" id="englishInput" autocomplete="username" placeholder="nuttakit@gmail.com" aria-label="Email address" required />
|
||||||
</form>
|
</label>
|
||||||
@if(isModalOpen){
|
|
||||||
<div class="fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-50" [formGroup]="forgotFrm">
|
@if (isSendOtp === true) {
|
||||||
<div class="bg-white p-6 rounded-lg shadow-lg max-w-sm w-fit">
|
<label class="field">
|
||||||
<h2 class="text-xl font-bold mb-4">เปลี่ยนรหัสผ่าน</h2>
|
<span class="label-text">รหัสยืนยัน OTP</span>
|
||||||
<hr class="w-full h-1 bg-gray-300 rounded-sm shadow-neutral-400 md:my-1">
|
<input type="text" formControlName="otp" class="input-field" autocomplete="one-time-code" placeholder="123456" alt required/>
|
||||||
<div class="mb-4">
|
</label>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-1">รหัสผ่านใหม่</label>
|
}
|
||||||
<input type="password" id="newPassword" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500" formControlName="newPassword" placeholder="กรอกรหัสผ่านใหม่">
|
|
||||||
|
<div class="actions justify-end-custom mt-4">
|
||||||
|
|
||||||
|
<div class="flex-row hover-lift">
|
||||||
|
<button class="primary secondary-button" type="button" (click)="isModalOpen = true">
|
||||||
|
เปิด Modal
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (isSendOtp === false) {
|
||||||
|
<div class="flex justify-end">
|
||||||
|
@if (isLoading === true) {
|
||||||
|
<button type="submit" class="primary" disabled>
|
||||||
|
กำลังส่ง...
|
||||||
|
</button>
|
||||||
|
} @else {
|
||||||
|
<button type="submit" class="primary" (click)="onSubmin()">
|
||||||
|
{{ 'ยืนยันส่ง OTP รีเซ็ตรหัสผ่าน' }}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
} @else if(isSendOtp === true) {
|
||||||
|
<div class="flex justify-end gap-2">
|
||||||
|
<button type="button" class="primary secondary-button" (click)="onSubmin()">
|
||||||
|
{{ 'ส่งอีกครั้ง' }}
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="primary" (click)="onVerifySubmit()">
|
||||||
|
{{ 'รีเซ็ตรหัสผ่าน' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@if(isModalOpen){
|
||||||
|
<div class="fixed inset-0 z-50 overflow-y-auto" role="dialog" aria-modal="true" [formGroup]="forgotFrm">
|
||||||
|
|
||||||
|
<div class="fixed inset-0 bg-black/60 backdrop-blur-sm transition-opacity" aria-hidden="true"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||||
|
|
||||||
|
<div class="relative transform overflow-hidden rounded-2xl bg-white text-left shadow-2xl transition-all sm:my-8 sm:w-full sm:max-w-md md:max-w-lg">
|
||||||
|
|
||||||
|
<div class="bg-red-900 h-2 w-full"></div>
|
||||||
|
|
||||||
|
<div class="px-8 pt-6 pb-8">
|
||||||
|
<div class="sm:flex sm:items-start mb-6">
|
||||||
|
<div class="mx-auto flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 text-red-900">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left">
|
||||||
|
<h3 class="text-xl font-bold leading-6 text-gray-900" id="modal-title">เปลี่ยนรหัสผ่าน</h3>
|
||||||
|
<p class="text-sm text-gray-500 mt-1">กรุณากรอกรหัสผ่านใหม่ของคุณด้านล่าง</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="space-y-5">
|
||||||
|
<div>
|
||||||
|
<label for="newPassword" class="block text-sm font-semibold text-gray-700 mb-2">รหัสผ่านใหม่</label>
|
||||||
|
<input type="password" id="newPassword" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all shadow-sm" formControlName="newPassword" placeholder="········">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="confirmPassword" class="block text-sm font-semibold text-gray-700 mb-2">ยืนยันรหัสผ่านใหม่</label>
|
||||||
|
<input type="password" id="confirmPassword" class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all shadow-sm" formControlName="confirmPassword" placeholder="········">
|
||||||
|
|
||||||
|
@if ( this.forgotFrm.get('confirmPassword')!.touched && this.forgotFrm.get('newPassword')?.value !== this.forgotFrm.get('confirmPassword')?.value ){
|
||||||
|
<div class="flex items-center text-red-600 text-sm mt-2 transition-all">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-4 h-4 mr-1">
|
||||||
|
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
<span>รหัสผ่านไม่ตรงกัน</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
|
||||||
<label for="confirmPassword" class="block text-sm font-medium text-gray-700 mb-1">ยืนยันรหัสผ่านใหม่</label>
|
<div class="bg-gray-50 px-6 py-4 sm:flex sm:flex-row-reverse sm:px-8 rounded-b-2xl">
|
||||||
<input type="password" id="confirmPassword" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500" formControlName="confirmPassword" placeholder="กรอกยืนยันรหัสผ่านใหม่">
|
<button type="button" class="inline-flex w-full justify-center rounded-xl bg-red-900 px-5 py-3 text-sm font-semibold text-white shadow-sm hover:bg-red-950 sm:ml-3 sm:w-auto transition-colors" (click)="onSetNewPassword()">
|
||||||
@if ( this.forgotFrm.get('confirmPassword')!.touched && this.forgotFrm.get('newPassword')?.value !== this.forgotFrm.get('confirmPassword')?.value ){
|
ยืนยันการเปลี่ยนแปลง
|
||||||
<span class="text-red-600 md">รหัสผ่านไม่ตรงกัน</span>
|
</button>
|
||||||
}
|
<button type="button" class="mt-3 inline-flex w-full justify-center rounded-xl bg-white px-5 py-3 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto transition-colors" (click)="isModalOpen = false">
|
||||||
</div>
|
ยกเลิก
|
||||||
<!-- <hr class="w-full h-[] bg-gray-100 border-0 rounded-sm md:my-1 dark:bg-gray-700"> -->
|
</button>
|
||||||
<div class="flex justify-end gap-2">
|
|
||||||
<button class="bg-red-500 text-white px-4 py-2 rounded" (click)="isModalOpen = false">
|
|
||||||
ปิด
|
|
||||||
</button>
|
|
||||||
<button class="bg-green-500 text-white px-4 py-2 rounded shadow-[0_1px_18px_var(--color-green-300)] hover:-translate-y-1.5 hover:shadow-[0_6px_18px_var(--color-green-500)] transition-all duration-500 ease-in-out" (click)="onSetNewPassword()">
|
|
||||||
ยืนยัน
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
/* Page layout */
|
/* Page layout */
|
||||||
.login-widget {
|
.login-widget {
|
||||||
/* Fill the viewport and center the card. Do not let the page itself
|
|
||||||
scroll; the card gets an internal max-height instead. */
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -37,8 +35,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
/* Constrain the card so it never forces the page to scroll. If content
|
|
||||||
grows, the card will scroll internally. */
|
|
||||||
max-height: calc(100vh - 56px);
|
max-height: calc(100vh - 56px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
@@ -46,7 +42,7 @@
|
|||||||
/* Modal/backdrop styles */
|
/* Modal/backdrop styles */
|
||||||
.login-backdrop{
|
.login-backdrop{
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0; /* top:0; right:0; bottom:0; left:0; */
|
inset: 0;
|
||||||
background: rgba(0,0,0,0.38);
|
background: rgba(0,0,0,0.38);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -64,33 +60,10 @@
|
|||||||
box-shadow: 0 20px 50px rgba(2,6,23,0.4);
|
box-shadow: 0 20px 50px rgba(2,6,23,0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Slightly larger brand area inside modal */
|
|
||||||
.modal-card .brand{ padding: 18px; }
|
|
||||||
|
|
||||||
/* Make the primary button pill-shaped and slightly larger */
|
|
||||||
button.primary{
|
|
||||||
color: #000;
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 10px 18px;
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make biometric and other action buttons visually lighter */
|
|
||||||
.biometric{
|
|
||||||
border-radius: 999px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* On small screens reduce modal padding and width to avoid overflow */
|
|
||||||
@media (max-width: 420px){
|
|
||||||
.login-backdrop{ padding: 12px; }
|
|
||||||
.login-modal{ max-width: 100%; }
|
|
||||||
.modal-card .brand{ padding: 12px; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Brand area */
|
/* Brand area */
|
||||||
.brand{
|
.brand{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
padding: 18px; /* Use padding from modal-card .brand */
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
border-bottom: 1px solid #eef2f5;
|
border-bottom: 1px solid #eef2f5;
|
||||||
}
|
}
|
||||||
@@ -116,12 +89,11 @@ button.primary{
|
|||||||
|
|
||||||
/* Form area */
|
/* Form area */
|
||||||
.form{
|
.form{
|
||||||
/* keep compact spacing inside the card */
|
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 6px 0 2px;
|
padding: 6px 22px 2px 22px; /* Adjusted padding to match card padding */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Field label wrapper */
|
/* Field label wrapper */
|
||||||
@@ -185,8 +157,9 @@ input:focus{
|
|||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
button.primary{
|
button.primary{
|
||||||
background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
|
/* ⭐️ แก้ไขตรงนี้: เปลี่ยนสีข้อความเป็นสีดำตามคำขอ */
|
||||||
color: #000000;
|
color: #000000;
|
||||||
|
background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
|
||||||
border: none;
|
border: none;
|
||||||
padding: 10px 14px;
|
padding: 10px 14px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
@@ -196,6 +169,7 @@ button.primary{
|
|||||||
box-shadow: 0 6px 18px rgba(0,120,212,0.12);
|
box-shadow: 0 6px 18px rgba(0,120,212,0.12);
|
||||||
transition: transform .06s ease, box-shadow .12s ease, opacity .12s ease;
|
transition: transform .06s ease, box-shadow .12s ease, opacity .12s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.primary:hover:not(:disabled){
|
button.primary:hover:not(:disabled){
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
box-shadow: 0 10px 24px rgba(0,120,212,0.14);
|
box-shadow: 0 10px 24px rgba(0,120,212,0.14);
|
||||||
@@ -206,6 +180,7 @@ button.primary:active{
|
|||||||
button.primary:disabled{
|
button.primary:disabled{
|
||||||
opacity: 0.55;
|
opacity: 0.55;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
color: #000000; /* ข้อความ Disabled ก็ยังเป็นสีดำ */
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +205,7 @@ button.primary:disabled{
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.biometric svg{ display: block; opacity: .95; }
|
.biometric svg{ display: block; opacity: .95; }
|
||||||
.biometric:hover{
|
.biometric:hover{
|
||||||
background: rgba(0,120,212,0.04);
|
background: rgba(0,120,212,0.04);
|
||||||
@@ -276,14 +252,14 @@ button.primary:disabled{
|
|||||||
|
|
||||||
/* Small screens */
|
/* Small screens */
|
||||||
@media (max-width:420px){
|
@media (max-width:420px){
|
||||||
|
.login-backdrop{ padding: 12px; }
|
||||||
|
.login-modal{ max-width: 100%; }
|
||||||
|
.modal-card .brand{ padding: 12px; }
|
||||||
|
|
||||||
.login-widget .card{
|
.login-widget .card{
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.brand h1{ font-size: 18px; }
|
.brand h1{ font-size: 18px; }
|
||||||
.brand .subtitle{
|
|
||||||
font-family: "Kanit";
|
|
||||||
font-weight: 1000;
|
|
||||||
font-style: normal; }
|
|
||||||
.biometric span, .primary{ font-size: 13px; }
|
.biometric span, .primary{ font-size: 13px; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,55 @@
|
|||||||
<!-- Modal-like backdrop that covers the viewport -->
|
<div class="min-h-screen flex items-center justify-center p-4 sm:p-6 bg-linear-to-br from-red-50 via-white to-red-100 relative overflow-hidden">
|
||||||
<div class="login-backdrop">
|
<div class="login-modal d-flex align-items-center justify-content-center bg-white rounded-2xl">
|
||||||
<div class="login-modal d-flex align-items-center justify-content-center">
|
|
||||||
<div class="card modal-card" role="dialog" aria-labelledby="signin-title" aria-modal="true">
|
<div class="card modal-card" role="dialog" aria-labelledby="signin-title" aria-modal="true">
|
||||||
<div class="brand">
|
|
||||||
<!-- <img src="assets/logo.png" alt="Company logo" class="logo" /> -->
|
|
||||||
<img src="logo.png" alt="Company logo" class="logo mb-2"/>
|
|
||||||
<h1 id="signin-title" class='kanit-bold'>เข้าสู่ระบบ</h1>
|
|
||||||
<p class="subtitle">บัญชีโปรแกรมจัดการบัญชีของคุณ</p>
|
|
||||||
</div>
|
|
||||||
<form [formGroup]="loginForm" (ngSubmit)="signIn()" class="form px-3 pb-3">
|
|
||||||
<label class="field">
|
|
||||||
<span class="label-text">อีเมล์</span>
|
|
||||||
<input type="email" formControlName="username" autocomplete="username" placeholder="nuttakit@gmail.com" required />
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label class="field">
|
<div class="brand">
|
||||||
<span class="label-text">รหัสผ่าน</span>
|
<img src="/logo.png" alt="Company logo" class="logo"/>
|
||||||
<input type="password" formControlName="password" autocomplete="current-password" required />
|
<h1 id="signin-title" class="kanit-bold">เข้าสู่ระบบ</h1>
|
||||||
</label>
|
<p class="subtitle">บัญชีโปรแกรมจัดการบัญชีของท่าน</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<form [formGroup]="loginForm" (ngSubmit)="signIn()" class="form">
|
||||||
<label class="stay-signed">
|
|
||||||
<input type="checkbox" formControlName="remember" />
|
<label class="field">
|
||||||
<span>จดจำรหัสผ่าน</span>
|
<span class="label-text">อีเมล์</span>
|
||||||
|
<input type="email" formControlName="username" autocomplete="username" placeholder="nuttakit@gmail.com" required class="input-field" />
|
||||||
</label>
|
</label>
|
||||||
<!-- <fa-icon [icon]="faCoffee" /> -->
|
|
||||||
<button type="submit" class="primary" [disabled]="!(loginForm.get('username')?.valid && loginForm.get('password')?.value)">
|
|
||||||
เข้าสู่ระบบ
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</div>
|
<label class="field mt-3">
|
||||||
|
<span class="label-text">รหัสผ่าน</span>
|
||||||
|
<input type="password" formControlName="password" autocomplete="current-password" required class="input-field" />
|
||||||
|
</label>
|
||||||
|
|
||||||
<div class="alt-options">
|
<div class="actions d-flex justify-content-between align-items-center mt-4">
|
||||||
<button type="button" class="biometric" (click)="useBiometric()">
|
<label class="stay-signed">
|
||||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
<input type="checkbox" formControlName="remember" />
|
||||||
<path d="M12 11a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" fill="currentColor" opacity=".9"/>
|
<span>จดจำรหัสผ่าน</span>
|
||||||
<path d="M6.2 10.9A6 6 0 0 1 12 6a6 6 0 0 1 5.8 4.9M12 22v-2" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
</label>
|
||||||
<path d="M4 12a8 8 0 0 1 16 0v1" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
<button type="submit" class="primary login-button"
|
||||||
</svg>
|
[disabled]="!(loginForm.get('username')?.valid && loginForm.get('password')?.value)">
|
||||||
|
เข้าสู่ระบบ
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="alt-options mt-4 text-center">
|
||||||
|
<button type="button" class="biometric btn-icon" (click)="useBiometric()">
|
||||||
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" class="icon-svg">
|
||||||
|
<path d="M12 11a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" fill="currentColor" opacity=".9"/>
|
||||||
|
<path d="M6.2 10.9A6 6 0 0 1 12 6a6 6 0 0 1 5.8 4.9M12 22v-2" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M4 12a8 8 0 0 1 16 0v1" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
<span>เข้าสู่ระบบด้วย Windows Hello / Touch ID</span>
|
<span>เข้าสู่ระบบด้วย Windows Hello / Touch ID</span>
|
||||||
</button>
|
</button>
|
||||||
|
<a class="help-link mt-2" href="#" (click)="$event.preventDefault(); forgotPassword()">ลืมรหัส ใช่ หรือ ไม่?</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<a class="help-link" href="#" (click)="$event.preventDefault(); forgotPassword()">ลืมรหัส ใช่ หรือ ไม่?</a>
|
<div class="footer mt-5 text-center">
|
||||||
</div>
|
<a href="#" (click)="$event.preventDefault(); createAccount()">สร้างบัญชี</a>
|
||||||
|
<span class="divider mx-2">•</span>
|
||||||
|
<a href="#" (click)="$event.preventDefault(); privacy()">Privacy & terms</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<a href="#" (click)="$event.preventDefault(); createAccount()">สร้างบัญชี</a>
|
|
||||||
<span class="divider">•</span>
|
|
||||||
<a href="#" (click)="$event.preventDefault(); privacy()">Privacy & terms</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export class LoginPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createAccount(): void {
|
createAccount(): void {
|
||||||
|
this.router.navigate(['/login/register']);
|
||||||
this.message = 'Create account flow not implemented.';
|
this.message = 'Create account flow not implemented.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
/* Custom animation for blobs */
|
||||||
|
@keyframes blob {
|
||||||
|
0% { transform: translate(0px, 0px) scale(1); }
|
||||||
|
33% { transform: translate(30px, -50px) scale(1.1); }
|
||||||
|
66% { transform: translate(-20px, 20px) scale(0.9); }
|
||||||
|
100% { transform: translate(0px, 0px) scale(1); }
|
||||||
|
}
|
||||||
|
.animate-blob {
|
||||||
|
animation: blob 7s infinite;
|
||||||
|
}
|
||||||
|
.animation-delay-2000 {
|
||||||
|
animation-delay: 2s;
|
||||||
|
}
|
||||||
|
.animation-delay-4000 {
|
||||||
|
animation-delay: 4s;
|
||||||
|
}
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
<body class="bg-gray-50">
|
||||||
|
|
||||||
|
<div class="min-h-screen w-full flex flex-col justify-center py-12 px-4 sm:px-6 lg:px-8 bg-linear-to-br from-red-50 via-white to-red-100 relative overflow-hidden">
|
||||||
|
|
||||||
|
<!-- Decorative Blobs -->
|
||||||
|
<div class="absolute top-0 left-0 w-72 h-72 bg-red-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob"></div>
|
||||||
|
<div class="absolute top-0 right-0 w-72 h-72 bg-orange-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob animation-delay-2000"></div>
|
||||||
|
<div class="absolute -bottom-8 left-20 w-72 h-72 bg-rose-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob animation-delay-4000"></div>
|
||||||
|
|
||||||
|
<!-- Card Container -->
|
||||||
|
<div class="bg-white/80 backdrop-blur-lg px-6 py-8 sm:p-10 rounded-3xl shadow-2xl w-full max-w-lg border border-white/50 relative z-10 mx-auto flex flex-col min-h-[500px]">
|
||||||
|
|
||||||
|
<!-- Header & Stepper Progress -->
|
||||||
|
<div class="mb-6">
|
||||||
|
<div class="text-center mb-6">
|
||||||
|
<h1 class="text-3xl font-bold text-red-950 tracking-tight">สร้างบัญชีใหม่</h1>
|
||||||
|
<p class="text-gray-500 mt-1 text-sm">ขั้นตอนที่ {{ currentStep }} จาก 3</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Progress Bar -->
|
||||||
|
<div class="relative h-2 bg-gray-200 rounded-full overflow-hidden">
|
||||||
|
<div class="absolute top-0 left-0 h-full bg-red-900 transition-all duration-500 ease-out rounded-full"
|
||||||
|
[style.width.%]="(currentStep / 3) * 100"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Step Labels (Optional visual aid) -->
|
||||||
|
<div class="flex justify-between text-xs text-gray-400 mt-2 font-medium px-1">
|
||||||
|
<span [class.text-red-900]="currentStep >= 1">ข้อมูลส่วนตัว</span>
|
||||||
|
<span [class.text-red-900]="currentStep >= 2">ตั้งรหัสผ่าน</span>
|
||||||
|
<span [class.text-red-900]="currentStep >= 3">ยืนยัน</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Form Bindings -->
|
||||||
|
<form [formGroup]="registerFrm" (ngSubmit)="onSubmit()" class="flex-1 flex flex-col justify-between">
|
||||||
|
|
||||||
|
<!-- STEP 1: Personal Info -->
|
||||||
|
@if (currentStep === 1) {
|
||||||
|
<div class="space-y-5 step-content">
|
||||||
|
<div>
|
||||||
|
<label for="username" class="block text-sm font-semibold text-gray-700 mb-1.5">ชื่อจริง</label>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||||
|
<svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd" /></svg>
|
||||||
|
</div>
|
||||||
|
<input type="text" id="username" formControlName="username"
|
||||||
|
class="w-full pl-10 pr-4 py-3 bg-gray-50 border border-gray-200 rounded-xl focus:bg-white focus:ring-2 focus:ring-red-900 focus:border-transparent outline-none transition-all shadow-sm placeholder-gray-400"
|
||||||
|
[class.border-red-500]="registerFrm.get('username')?.invalid && (registerFrm.get('username')?.dirty || registerFrm.get('username')?.touched)"
|
||||||
|
placeholder="สมชาย">
|
||||||
|
</div>
|
||||||
|
@if (registerFrm.get('username')?.invalid && (registerFrm.get('username')?.dirty || registerFrm.get('username')?.touched)) {
|
||||||
|
<div class="text-red-600 text-xs mt-1.5 ml-1">กรุณาระบุชื่อจริง</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="userlastname" class="block text-sm font-semibold text-gray-700 mb-1.5">นามสกุล</label>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||||
|
<svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd" /></svg>
|
||||||
|
</div>
|
||||||
|
<input type="text" id="userlastname" formControlName="userlastname"
|
||||||
|
class="w-full pl-10 pr-4 py-3 bg-gray-50 border border-gray-200 rounded-xl focus:bg-white focus:ring-2 focus:ring-red-900 focus:border-transparent outline-none transition-all shadow-sm placeholder-gray-400"
|
||||||
|
[class.border-red-500]="registerFrm.get('userlastname')?.invalid && (registerFrm.get('userlastname')?.dirty || registerFrm.get('userlastname')?.touched)"
|
||||||
|
placeholder="ใจดี">
|
||||||
|
</div>
|
||||||
|
@if (registerFrm.get('userlastname')?.invalid && (registerFrm.get('userlastname')?.dirty || registerFrm.get('userlastname')?.touched)) {
|
||||||
|
<div class="text-red-600 text-xs mt-1.5 ml-1">กรุณาระบุนามสกุล</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- STEP 2: Account Info -->
|
||||||
|
@if (currentStep === 2) {
|
||||||
|
<div class="space-y-5 step-content">
|
||||||
|
<div>
|
||||||
|
<label for="email" class="block text-sm font-semibold text-gray-700 mb-1.5">อีเมล</label>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||||
|
<svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z" /><path d="M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z" /></svg>
|
||||||
|
</div>
|
||||||
|
<input type="email" id="email" formControlName="email"
|
||||||
|
class="w-full pl-10 pr-4 py-3 bg-gray-50 border border-gray-200 rounded-xl focus:bg-white focus:ring-2 focus:ring-red-900 focus:border-transparent outline-none transition-all shadow-sm placeholder-gray-400"
|
||||||
|
[class.border-red-500]="registerFrm.get('email')?.invalid && (registerFrm.get('email')?.dirty || registerFrm.get('email')?.touched)"
|
||||||
|
placeholder="you@example.com">
|
||||||
|
</div>
|
||||||
|
@if (registerFrm.get('email')?.invalid && (registerFrm.get('email')?.dirty || registerFrm.get('email')?.touched)) {
|
||||||
|
<div class="text-red-600 text-xs mt-1.5 ml-1">กรุณาระบุอีเมลที่ถูกต้อง</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="password" class="block text-sm font-semibold text-gray-700 mb-1.5">รหัสผ่าน</label>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||||
|
<svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd" /></svg>
|
||||||
|
</div>
|
||||||
|
<input type="password" id="password" formControlName="password"
|
||||||
|
class="w-full pl-10 pr-4 py-3 bg-gray-50 border border-gray-200 rounded-xl focus:bg-white focus:ring-2 focus:ring-red-900 focus:border-transparent outline-none transition-all shadow-sm placeholder-gray-400"
|
||||||
|
[class.border-red-500]="registerFrm.get('password')?.invalid && (registerFrm.get('password')?.dirty || registerFrm.get('password')?.touched)"
|
||||||
|
placeholder="••••••••">
|
||||||
|
</div>
|
||||||
|
@if (registerFrm.get('password')?.invalid && (registerFrm.get('password')?.dirty || registerFrm.get('password')?.touched)) {
|
||||||
|
<div class="text-red-600 text-xs mt-1.5 ml-1">กรุณาระบุรหัสผ่าน</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="confirmPassword" class="block text-sm font-semibold text-gray-700 mb-1.5">ยืนยันรหัสผ่าน</label>
|
||||||
|
<div class="relative">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||||
|
<svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd" /></svg>
|
||||||
|
</div>
|
||||||
|
<input type="password" id="confirmPassword" formControlName="confirmPassword"
|
||||||
|
class="w-full pl-10 pr-4 py-3 bg-gray-50 border border-gray-200 rounded-xl focus:bg-white focus:ring-2 focus:ring-red-900 focus:border-transparent outline-none transition-all shadow-sm placeholder-gray-400"
|
||||||
|
[class.border-red-500]="(registerFrm.get('confirmPassword')?.invalid || registerFrm.get('password')?.value !== registerFrm.get('confirmPassword')?.value) && (registerFrm.get('confirmPassword')?.dirty || registerFrm.get('confirmPassword')?.touched)"
|
||||||
|
placeholder="••••••••">
|
||||||
|
</div>
|
||||||
|
@if (registerFrm.get('confirmPassword')?.dirty && registerFrm.get('password')?.value !== registerFrm.get('confirmPassword')?.value) {
|
||||||
|
<div class="text-red-600 text-xs mt-1.5 ml-1">รหัสผ่านไม่ตรงกัน</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- STEP 3: Confirmation -->
|
||||||
|
@if (currentStep === 3) {
|
||||||
|
<div class="step-content flex flex-col justify-center items-center h-full space-y-6 text-center">
|
||||||
|
|
||||||
|
<div class="w-20 h-20 bg-red-50 rounded-full flex items-center justify-center mb-2">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-10 h-10 text-red-900">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xl font-bold text-gray-900">เกือบเสร็จแล้ว!</h3>
|
||||||
|
<p class="text-gray-500 text-sm mt-1">กรุณายอมรับเงื่อนไขเพื่อสร้างบัญชีของคุณ</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-gray-50 p-4 rounded-xl w-full text-left border border-gray-100">
|
||||||
|
<p class="text-sm text-gray-600 font-medium mb-2">สรุปข้อมูล:</p>
|
||||||
|
<div class="text-sm text-gray-800 flex items-center gap-2">
|
||||||
|
<svg class="w-4 h-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" /></svg>
|
||||||
|
{{ registerFrm.get('username')?.value }} {{ registerFrm.get('userlastname')?.value }}
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-gray-800 flex items-center gap-2 mt-1">
|
||||||
|
<svg class="w-4 h-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" /></svg>
|
||||||
|
{{ registerFrm.get('email')?.value }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w-full">
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<input type="checkbox" id="terms" formControlName="terms"
|
||||||
|
class="h-5 w-5 text-red-900 border-gray-300 rounded focus:ring-red-900 cursor-pointer transition-all">
|
||||||
|
<label for="terms" class="ml-2 block text-sm text-gray-600 cursor-pointer select-none">
|
||||||
|
ฉันยอมรับ <a href="/license" class="font-semibold text-red-900 hover:text-red-700 underline decoration-2 decoration-transparent hover:decoration-red-700 transition-all">ข้อตกลงและเงื่อนไข</a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@if (registerFrm.get('terms')?.invalid && (registerFrm.get('terms')?.dirty || registerFrm.get('terms')?.touched)) {
|
||||||
|
<div class="text-red-600 text-xs mt-2">กรุณายอมรับเงื่อนไข</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- Navigation Buttons -->
|
||||||
|
<div class="pt-6 mt-auto flex gap-3">
|
||||||
|
<!-- Back Button (Hide on step 1) -->
|
||||||
|
@if (currentStep > 1) {
|
||||||
|
<button type="button" (click)="currentStep = currentStep - 1"
|
||||||
|
class="w-1/3 py-3.5 px-4 bg-gray-100 hover:bg-gray-200 text-gray-700 font-bold rounded-xl transition-colors">
|
||||||
|
ย้อนกลับ
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- Next Button (Step 1 & 2) -->
|
||||||
|
@if (currentStep < 3) {
|
||||||
|
<button type="button" (click)="currentStep = currentStep + 1"
|
||||||
|
[disabled]="(currentStep === 1 && (registerFrm.get('username')?.invalid || registerFrm.get('userlastname')?.invalid)) ||
|
||||||
|
(currentStep === 2 && (registerFrm.get('email')?.invalid || registerFrm.get('password')?.invalid || registerFrm.get('confirmPassword')?.invalid || registerFrm.get('password')?.value !== registerFrm.get('confirmPassword')?.value))"
|
||||||
|
class="flex-1 py-3.5 px-4 bg-red-900 hover:bg-red-950 text-white font-bold rounded-xl shadow-lg shadow-red-900/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
||||||
|
ถัดไป
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- Submit Button (Step 3 Only) -->
|
||||||
|
@if (currentStep === 3) {
|
||||||
|
<button type="submit"
|
||||||
|
[disabled]="registerFrm.invalid"
|
||||||
|
class="flex-1 py-3.5 px-4 bg-red-900 hover:bg-red-950 text-white font-bold rounded-xl shadow-lg shadow-red-900/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
||||||
|
สมัครสมาชิก
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Footer Link -->
|
||||||
|
@if (currentStep === 1) {
|
||||||
|
<p class="mt-6 text-center text-sm text-gray-500">
|
||||||
|
เป็นสมาชิกอยู่แล้วใช่ไหม?
|
||||||
|
<a href="#" class="font-bold text-red-900 hover:text-red-950 hover:underline transition-all">
|
||||||
|
เข้าสู่ระบบ
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||||
|
import { GeneralService } from '../../services/generalservice';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-login-register',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './login-register.component.html',
|
||||||
|
styleUrl: './login-register.component.css',
|
||||||
|
})
|
||||||
|
export class LoginRegisterComponent implements OnInit {
|
||||||
|
@Output() registeredEventSubmit = new EventEmitter<any>();
|
||||||
|
registerFrm!: FormGroup;
|
||||||
|
currentStep = 1;
|
||||||
|
|
||||||
|
constructor(){}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.setupFormControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFormControl(): void {
|
||||||
|
this.registerFrm = new FormGroup({
|
||||||
|
username: new FormControl('',[Validators.required, Validators.maxLength(100)]),
|
||||||
|
userlastname: new FormControl('',[Validators.required, Validators.maxLength(100)]),
|
||||||
|
email: new FormControl('',[Validators.required, Validators.email, Validators.maxLength(100)]),
|
||||||
|
password: new FormControl('',[Validators.required, Validators.maxLength(50)]),
|
||||||
|
confirmPassword: new FormControl('',[Validators.required, Validators.maxLength(50)]),
|
||||||
|
terms: new FormControl(false, [Validators.requiredTrue])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(){
|
||||||
|
let data = {
|
||||||
|
username: this.registerFrm.get('username')?.value,
|
||||||
|
userlastname: this.registerFrm.get('userlastname')?.value,
|
||||||
|
email: this.registerFrm.get('email')?.value,
|
||||||
|
password: this.registerFrm.get('password')?.value
|
||||||
|
}
|
||||||
|
this.RegisteredEventSubmit(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisteredEventSubmit(event: any){
|
||||||
|
this.registeredEventSubmit.emit(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -281,6 +281,23 @@
|
|||||||
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quick-log__form select,
|
||||||
|
.quick-log__form textarea {
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-log__form select:focus,
|
||||||
|
.quick-log__form textarea:focus {
|
||||||
|
border-color: #0ea5e9;
|
||||||
|
box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.quick-log__form input:focus,
|
.quick-log__form input:focus,
|
||||||
.quick-log__form textarea:focus {
|
.quick-log__form textarea:focus {
|
||||||
border-color: #0ea5e9;
|
border-color: #0ea5e9;
|
||||||
@@ -627,3 +644,20 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quick-log__form select {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
|
||||||
|
background-position: right 0.5rem center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 1.5em 1.5em;
|
||||||
|
padding-right: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ledger-table.is-scrollable {
|
||||||
|
max-height: 25rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,7 +13,36 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section class="dashboard__periods">
|
<!-- Summary Cards -->
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-3 gap-6 mb-8">
|
||||||
|
|
||||||
|
<div class="bg-white border border-gray-200 rounded-2xl p-5 shadow-sm hover:shadow-md transition">
|
||||||
|
<div class="text-gray-500 text-sm">รายรับทั้งหมด</div>
|
||||||
|
<div class="text-3xl font-bold text-green-600 mt-1">
|
||||||
|
{{ myActSumData.summary.totalIncome || 0 | number:'1.0-2' }} บาท
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white border border-gray-200 rounded-2xl p-5 shadow-sm hover:shadow-md transition">
|
||||||
|
<div class="text-gray-500 text-sm">รายจ่ายทั้งหมด</div>
|
||||||
|
<div class="text-3xl font-bold text-red-600 mt-1">
|
||||||
|
{{ myActSumData.summary.totalExpense || 0 | number:'1.0-2' }} บาท
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white border border-gray-200 rounded-2xl p-5 shadow-sm hover:shadow-md transition">
|
||||||
|
<div class="text-gray-500 text-sm">คงเหลือ</div>
|
||||||
|
<div
|
||||||
|
class="text-3xl font-bold mt-1"
|
||||||
|
[ngClass]="myActSumData.summary.netProfit >= 0 ? 'text-blue-600' : 'text-red-600'"
|
||||||
|
>
|
||||||
|
{{ myActSumData.summary.netProfit | number:'1.0-2' }} บาท
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <section class="dashboard__periods">
|
||||||
<article class="period-card" *ngFor="let summary of periodSummaries">
|
<article class="period-card" *ngFor="let summary of periodSummaries">
|
||||||
<header class="period-card__header">
|
<header class="period-card__header">
|
||||||
<span class="period-card__badge" [ngClass]="'period-card__badge--' + summary.badge">
|
<span class="period-card__badge" [ngClass]="'period-card__badge--' + summary.badge">
|
||||||
@@ -39,9 +68,9 @@
|
|||||||
<span class="trend-chip">แนวโน้ม {{ summary.trend }}</span>
|
<span class="trend-chip">แนวโน้ม {{ summary.trend }}</span>
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section> -->
|
||||||
|
|
||||||
<section class="dashboard__stats">
|
<!-- <section class="dashboard__stats">
|
||||||
<article class="stat-card" *ngFor="let card of kpiCards">
|
<article class="stat-card" *ngFor="let card of kpiCards">
|
||||||
<div class="stat-card__icon" [ngClass]="'accent-' + card.accent"></div>
|
<div class="stat-card__icon" [ngClass]="'accent-' + card.accent"></div>
|
||||||
<div class="stat-card__body">
|
<div class="stat-card__body">
|
||||||
@@ -50,47 +79,131 @@
|
|||||||
<p class="stat-card__trend">{{ card.trend }} · {{ card.context }}</p>
|
<p class="stat-card__trend">{{ card.trend }} · {{ card.context }}</p>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section> -->
|
||||||
|
|
||||||
<section class="ledger-grid">
|
<div class="ledger-grid" [formGroup]="saveFrm">
|
||||||
<article class="panel quick-log">
|
<form class="panel quick-log" [formGroup]="saveFrm">
|
||||||
<div class="panel__header">
|
<div class="panel__header">
|
||||||
<div>
|
<div>
|
||||||
<h2>บันทึกรายการแบบรวดเร็ว</h2>
|
<h2>บันทึกรายการแบบรวดเร็ว</h2>
|
||||||
<p>จดรายรับรายจ่ายภายในไม่กี่คลิก</p>
|
<p>จดรายรับรายจ่ายภายในไม่กี่คลิก</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- เปลี่ยน form ด้านในเป็น div แทน เพื่อไม่ให้ form ซ้อน form -->
|
||||||
|
<div class="quick-log__form">
|
||||||
|
|
||||||
|
<!-- 1. ส่วนเลือกประเภท (รายรับ/รายจ่าย) -->
|
||||||
|
<label>
|
||||||
|
<span>ประเภท</span>
|
||||||
|
<div class="quick-log__toggle">
|
||||||
|
<button type="button" class="toggle-btn" [ngClass]="{ 'is-active': mode == 'i' }" (click)="mode = 'i'; saveFrm.get('actcat')?.reset('')">รายรับ</button>
|
||||||
|
<button type="button" class="toggle-btn" [ngClass]="{ 'is-active': mode == 'e' }" (click)="mode = 'e'; saveFrm.get('actcat')?.reset('')">รายจ่าย</button>
|
||||||
</div>
|
</div>
|
||||||
<form class="quick-log__form">
|
</label>
|
||||||
<label>
|
|
||||||
<span>ประเภท</span>
|
|
||||||
<div class="quick-log__toggle">
|
|
||||||
<button type="button" class="toggle-btn" [ngClass]="{ 'is-active': mode == 'i' }" (click)="mode = 'i'">รายรับ</button>
|
|
||||||
<button type="button" class="toggle-btn" [ngClass]="{ 'is-active': mode == 'e' }" (click)="mode = 'e'">รายจ่าย</button>
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<span>วันที่</span>
|
|
||||||
<!-- <input type="text" disabled placeholder="10/04/2025 เวลา 12:00"/> -->
|
|
||||||
|
|
||||||
<input type="datetime-local"/>
|
<!-- 2. ส่วนวันที่ -->
|
||||||
</label>
|
<div class="mb-2">
|
||||||
<div class="quick-log__grid">
|
|
||||||
<label>
|
|
||||||
<span>หมวดหมู่</span>
|
|
||||||
<input type="text" placeholder="เลือกหมวดหมู่" />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<span>ยอดเงิน (฿)</span>
|
|
||||||
<input type="number" placeholder="0.00" />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<label>
|
<label>
|
||||||
<span>บันทึกเพิ่มเติม</span>
|
<span>วันที่ <span class="text-red-500">*</span></span>
|
||||||
<textarea rows="3" placeholder="รายละเอียดการรับ/จ่าย"></textarea>
|
<input type="datetime-local" formControlName="actacpdtm"
|
||||||
|
[class.border-red-500]="saveFrm.get('actacpdtm')?.invalid && (saveFrm.get('actacpdtm')?.value || saveFrm.get('actacpdtm')?.touched)"/>
|
||||||
</label>
|
</label>
|
||||||
<button type="button" class="btn btn--primary">บันทึกรายการ</button>
|
|
||||||
</form>
|
<!-- Validate วันที่ -->
|
||||||
</article>
|
@if (saveFrm.get('actacpdtm')?.invalid && (saveFrm.get('actacpdtm')?.value || saveFrm.get('actacpdtm')?.touched)) {
|
||||||
|
<div class="flex items-center text-red-600 text-xs mt-1 transition-all">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-3 h-3 mr-1">
|
||||||
|
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
<span>กรุณาระบุวันที่</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="quick-log__grid">
|
||||||
|
<!-- 3. ส่วนหมวดหมู่ -->
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<label class="h-full">
|
||||||
|
<span>หมวดหมู่ <span class="text-red-500">*</span></span>
|
||||||
|
|
||||||
|
@if(mode == 'i'){
|
||||||
|
<select formControlName="actcat"
|
||||||
|
class="w-full h-auto px-4 py-2 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-100 focus:border-blue-50 transition-all bg-white"
|
||||||
|
[class.border-red-500]="saveFrm.get('actcat')?.invalid && (saveFrm.get('actcat')?.dirty || saveFrm.get('actcat')?.touched)">
|
||||||
|
<option value="" disabled>ไม่เลือก</option>
|
||||||
|
@for (item of myDropAct.income; track item.dtlcod) {
|
||||||
|
<option [value]="item.dtlcod">{{ item.dtlnam }}</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}@else if(mode == 'e'){
|
||||||
|
<select formControlName="actcat"
|
||||||
|
class="w-full h-auto px-4 py-2 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-100 focus:border-blue-50 transition-all bg-white"
|
||||||
|
[class.border-red-500]="saveFrm.get('actcat')?.invalid && (saveFrm.get('actcat')?.dirty || saveFrm.get('actcat')?.touched)">
|
||||||
|
<option value="" disabled>ไม่เลือก</option>
|
||||||
|
@for (item of myDropAct.expense; track item.dtlcod) {
|
||||||
|
<option [value]="item.dtlcod">{{ item.dtlnam }}</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<!-- Validate หมวดหมู่ -->
|
||||||
|
@if (saveFrm.get('actcat')?.invalid && (saveFrm.get('actcat')?.dirty || saveFrm.get('actcat')?.touched)) {
|
||||||
|
<div class="flex items-center text-red-600 text-xs mt-1 transition-all">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-3 h-3 mr-1">
|
||||||
|
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
<span>กรุณาเลือกหมวดหมู่</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 4. ส่วนยอดเงิน -->
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<label>
|
||||||
|
<span>ยอดเงิน (฿) <span class="text-red-500">*</span></span>
|
||||||
|
<input type="number" formControlName="actqty" placeholder="0.00"
|
||||||
|
[class.border-red-500]="saveFrm.get('actqty')?.invalid && (saveFrm.get('actqty')?.dirty || saveFrm.get('actqty')?.touched)"/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<!-- Validate ยอดเงิน -->
|
||||||
|
@if (saveFrm.get('actqty')?.invalid && (saveFrm.get('actqty')?.dirty || saveFrm.get('actqty')?.touched)) {
|
||||||
|
<div class="flex items-center text-red-600 text-xs mt-1 transition-all">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-3 h-3 mr-1">
|
||||||
|
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
<span>กรุณาระบุยอดเงิน</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 5. ส่วนบันทึกเพิ่มเติม -->
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>
|
||||||
|
<span>บันทึกเพิ่มเติม</span>
|
||||||
|
<textarea rows="3" formControlName="actcmt" placeholder="รายละเอียดการรับ/จ่าย"
|
||||||
|
[class.border-red-500]="saveFrm.get('actcmt')?.invalid"></textarea>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<!-- Validate ความยาวตัวอักษร (ถ้ามี) -->
|
||||||
|
@if (saveFrm.get('actcmt')?.hasError('maxlength')) {
|
||||||
|
<div class="flex items-center text-red-600 text-xs mt-1 transition-all">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-3 h-3 mr-1">
|
||||||
|
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
<span>พิมพ์ได้สูงสุด 200 ตัวอักษร</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn--primary" (click)="onSaveSubmit()">บันทึกรายการ</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<article class="panel ledger-panel">
|
<article class="panel ledger-panel">
|
||||||
<div class="panel__header">
|
<div class="panel__header">
|
||||||
@@ -100,32 +213,61 @@
|
|||||||
</div>
|
</div>
|
||||||
<button class="btn btn--ghost btn--compact">ดูทั้งหมด</button>
|
<button class="btn btn--ghost btn--compact">ดูทั้งหมด</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="ledger-table">
|
<div class="ledger-table" [class.is-scrollable]="myActData.length > 5">
|
||||||
<div class="ledger-row ledger-head">
|
<div class="ledger-row ledger-head">
|
||||||
<span>รายการ</span>
|
<span>รายการ</span>
|
||||||
<span>หมวดหมู่</span>
|
<span>หมวดหมู่</span>
|
||||||
<span>ยอดเงิน</span>
|
<span>ยอดเงิน</span>
|
||||||
<span>บันทึก</span>
|
<span>บันทึก</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="ledger-row" *ngFor="let idx of ledgerEntries; let i = index;">
|
<!-- @for (idx of myActData; track i; let i = $index) {
|
||||||
<div class="ledger-main">
|
<div class="ledger-row">
|
||||||
<span class="pill" [ngClass]="idx.type == 'i' ? 'pill--income' : 'pill--expense'">
|
<div class="ledger-main">
|
||||||
{{ idx.type == 'i' ? 'รับ' : 'จ่าย' }}
|
<span class="pill" [ngClass]="idx.acttyp === 'i' ? 'pill--income' : 'pill--expense'">
|
||||||
</span>
|
{{ idx.type === 'i' ? 'รับ' : 'จ่าย' }}
|
||||||
<div>
|
</span>
|
||||||
<p class="ledger-title">{{ idx.title }}</p>
|
|
||||||
<p class="ledger-date">{{ idx.date }}</p>
|
<div>
|
||||||
|
<p class="ledger-title">{{ idx.title }}</p>
|
||||||
|
<p class="ledger-date">{{ idx.date }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<span class="ledger-category">{{ idx.category }}</span>
|
||||||
|
|
||||||
|
<span class="ledger-amount" [ngClass]="idx.type === 'i' ? 'is-credit' : 'is-debit'">
|
||||||
|
{{ idx.amount }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="ledger-note">{{ idx.note }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="ledger-category">{{ idx.category }}</span>
|
} -->
|
||||||
<span class="ledger-amount" [ngClass]="idx.type == 'i' ? 'is-credit' : 'is-debit'">
|
@for (idx of myActData; track idx.actseq; let i = $index) {
|
||||||
{{ idx.amount }}
|
<div class="ledger-row">
|
||||||
</span>
|
|
||||||
<span class="ledger-note">{{ idx.note }}</span>
|
<div class="ledger-main">
|
||||||
</div>
|
<span class="pill" [ngClass]="idx.acttyp === 'i' ? 'pill--income' : 'pill--expense'">
|
||||||
|
{{ idx.acttyp === 'i' ? 'รับ' : 'จ่าย' }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p class="ledger-title">{{ idx.acttypnam }}</p>
|
||||||
|
<p class="ledger-date">{{ idx.actacpdtm ?? '' | dtmtodatetime}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="ledger-category">{{ idx.actcatnam }}</span>
|
||||||
|
|
||||||
|
<span class="ledger-amount" [ngClass]="idx.acttyp === 'i' ? 'is-credit' : 'is-debit'">
|
||||||
|
{{ idx.actqty | number:'1.0-2' }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="ledger-note">{{ idx.actcmt }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</div>
|
||||||
|
|
||||||
<section class="dashboard__grid">
|
<section class="dashboard__grid">
|
||||||
<!-- <article class="panel panel--main">
|
<!-- <article class="panel panel--main">
|
||||||
@@ -153,25 +295,26 @@
|
|||||||
<button class="btn btn--ghost btn--compact">จัดการหมวดหมู่</button>
|
<button class="btn btn--ghost btn--compact">จัดการหมวดหมู่</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="pie-panel__content">
|
<div class="pie-panel__content">
|
||||||
<div class="pie-chart" [style.background]="expenseGradient">
|
<div class="pie-chart" [style.background]="ActSumDataGradient">
|
||||||
<div class="pie-chart__center">
|
<div class="pie-chart__center">
|
||||||
<p>รวมเดือนนี้</p>
|
<p>รวมเดือนนี้</p>
|
||||||
<strong>฿732K</strong>
|
<strong>{{myActSumData.summary.totalExpense}}</strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="pie-legend">
|
<ul class="pie-legend">
|
||||||
<li class="pie-legend__item" *ngFor="let part of expenseBreakdown">
|
<li class="pie-legend__item" *ngFor="let idx of myActSumData.pie.expense">
|
||||||
<span class="swatch" [style.background]="part.color"></span>
|
<span class="swatch" [style.background]="idx.color"></span>
|
||||||
<div>
|
<div>
|
||||||
<p class="pie-legend__label">{{ part.label }}</p>
|
<p class="pie-legend__label">{{ idx.label }}</p>
|
||||||
<p class="pie-legend__value">{{ part.value }}%</p>
|
<p class="pie-legend__value">{{ idx.percent }}%</p>
|
||||||
|
<p class="pie-legend__value">{{ idx.value | number:'1.0-2'}} บาท</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<!-- ตัวเลขซ้อนทับกัน -->
|
<!-- ตัวเลขซ้อนทับกัน -->
|
||||||
<article class="panel panel--side">
|
<!-- <article class="panel panel--side">
|
||||||
<div class="panel__header">
|
<div class="panel__header">
|
||||||
<div>
|
<div>
|
||||||
<h2>สรุปสภาพคล่อง</h2>
|
<h2>สรุปสภาพคล่อง</h2>
|
||||||
@@ -188,9 +331,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article> -->
|
||||||
|
|
||||||
<article class="panel alerts-panel">
|
<article class="bg-white border border-gray-200 rounded-2xl p-5 shadow-sm">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-lg font-bold text-gray-800">สรุปสภาพคล่อง</h2>
|
||||||
|
<p class="text-xs text-gray-400">อัปเดตล่าสุดเมื่อสักครู่</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-3">
|
||||||
|
<div *ngFor="let ratio of quickRatios"
|
||||||
|
class="flex justify-between items-center p-2 hover:bg-gray-50 rounded-lg transition">
|
||||||
|
|
||||||
|
<p class="text-gray-600 text-sm font-medium flex-1 truncate">
|
||||||
|
{{ ratio.label }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<span class="text-base font-semibold" [ngClass]="ratio.colorClass">
|
||||||
|
<ng-container *ngIf="isNumber(ratio.value); else textVal">
|
||||||
|
{{ ratio.value | number:'1.2-2' }}
|
||||||
|
<span *ngIf="ratio.label !== 'อัตรากำไร'" class="text-xs font-normal text-gray-400">บาท</span>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-template #textVal>
|
||||||
|
{{ ratio.value }}
|
||||||
|
</ng-template>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<!-- <article class="panel alerts-panel">
|
||||||
<div class="panel__header">
|
<div class="panel__header">
|
||||||
<div>
|
<div>
|
||||||
<h2>การแจ้งเตือนสำคัญ</h2>
|
<h2>การแจ้งเตือนสำคัญ</h2>
|
||||||
@@ -204,9 +377,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="alert__tag">{{ alert.tag }}</span>
|
<span class="alert__tag">{{ alert.tag }}</span>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article> -->
|
||||||
|
|
||||||
<article class="panel tasks-panel">
|
<!-- <article class="panel tasks-panel">
|
||||||
<div class="panel__header">
|
<div class="panel__header">
|
||||||
<div>
|
<div>
|
||||||
<h2>รายการยอดค้างจ่าย</h2>
|
<h2>รายการยอดค้างจ่าย</h2>
|
||||||
@@ -223,7 +396,7 @@
|
|||||||
<span class="task__badge">{{ task.priority }}</span>
|
<span class="task__badge">{{ task.priority }}</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article> -->
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||||
import { GeneralService } from '../../services/generalservice';
|
import { GeneralService } from '../../services/generalservice';
|
||||||
|
import { IDropAct, IStateDrop, IStateResultResponse, IActData, IActSumData, QuickRatio} from '../../interfaces/dashboard.interface'
|
||||||
|
import { DashboardStateService } from '../../services/state/dashboard-state.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-main-dashboard',
|
selector: 'app-main-dashboard',
|
||||||
@@ -9,177 +11,124 @@ import { GeneralService } from '../../services/generalservice';
|
|||||||
styleUrl: './main-dashboard.component.css'
|
styleUrl: './main-dashboard.component.css'
|
||||||
})
|
})
|
||||||
export class MainDashboardComponent implements OnInit {
|
export class MainDashboardComponent implements OnInit {
|
||||||
|
@Output() saveEventSubmit = new EventEmitter<any>();
|
||||||
mode: string = 'i';
|
mode: string = 'i';
|
||||||
isModalOpen: boolean = false;
|
isModalOpen: boolean = false;
|
||||||
isSubmitting: boolean = false;
|
isSubmitting: boolean = false;
|
||||||
arrearsForm!: FormGroup;
|
arrearsForm!: FormGroup;
|
||||||
saveFrm!: FormGroup;
|
saveFrm!: FormGroup;
|
||||||
|
myActData: IActData[] = [];
|
||||||
|
quickRatios: QuickRatio[] = [];
|
||||||
readonly ownerName = 'Nuttakit';
|
// myDropAct: IStateDrop[] = [];
|
||||||
|
myDropAct: IStateDrop = { income: [], expense: [] };
|
||||||
readonly kpiCards = [
|
myActSumData: IActSumData = {
|
||||||
{
|
summary: {
|
||||||
label: 'รายรับรวม',
|
totalIncome: '',
|
||||||
value: '฿1.28M',
|
totalExpense: '',
|
||||||
trend: '+12.4%',
|
netProfit: 0,
|
||||||
context: 'เทียบกับเดือนก่อน',
|
profitRate: '',
|
||||||
accent: 'mint'
|
adjustedProfitRate: '',
|
||||||
|
period: ''
|
||||||
},
|
},
|
||||||
{
|
pie: {
|
||||||
label: 'รายจ่ายรวม',
|
income: [],
|
||||||
value: '฿732K',
|
expense: []
|
||||||
trend: '-4.1%',
|
|
||||||
context: 'จัดการได้ดีขึ้น',
|
|
||||||
accent: 'lavender'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'ยอดค้างชำระ',
|
|
||||||
value: '฿184K',
|
|
||||||
trend: '-2 ใบแจ้งหนี้',
|
|
||||||
context: 'รอติดตาม',
|
|
||||||
accent: 'amber'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'อัตรากำไร',
|
|
||||||
value: '37.8%',
|
|
||||||
trend: '+1.9 จุด',
|
|
||||||
context: 'ระยะ 30 วัน',
|
|
||||||
accent: 'teal'
|
|
||||||
}
|
}
|
||||||
];
|
};
|
||||||
|
|
||||||
readonly revenueTrend = [
|
ActSumDataGradient: any
|
||||||
{ label: 'ม.ค.', value: 52 },
|
|
||||||
{ label: 'ก.พ.', value: 61 },
|
|
||||||
{ label: 'มี.ค.', value: 73 },
|
|
||||||
{ label: 'เม.ย.', value: 68 },
|
|
||||||
{ label: 'พ.ค.', value: 82 },
|
|
||||||
{ label: 'มิ.ย.', value: 77 }
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly quickRatios = [
|
|
||||||
{ label: 'กระแสเงินสด', value: '+฿312K', status: 'positive' },
|
|
||||||
{ label: 'วงเงินคงเหลือ', value: '฿890K', status: 'neutral' },
|
|
||||||
{ label: 'ค่าใช้จ่ายเดือนนี้', value: '฿412K', status: 'warning' }
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly periodSummaries = [
|
ownerName = localStorage.getItem('username') || 'ชนกนันต์';
|
||||||
{
|
|
||||||
label: 'รายปี',
|
|
||||||
note: 'ปี 2567',
|
|
||||||
income: '฿9.6M',
|
|
||||||
expense: '฿5.1M',
|
|
||||||
net: '+฿4.5M',
|
|
||||||
trend: '+18%',
|
|
||||||
badge: 'year'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'รายเดือน',
|
|
||||||
note: 'มิถุนายน 2567',
|
|
||||||
income: '฿1.28M',
|
|
||||||
expense: '฿732K',
|
|
||||||
net: '+฿548K',
|
|
||||||
trend: '+6%',
|
|
||||||
badge: 'month'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'รายสัปดาห์',
|
|
||||||
note: 'สัปดาห์ที่ 24',
|
|
||||||
income: '฿312K',
|
|
||||||
expense: '฿188K',
|
|
||||||
net: '+฿124K',
|
|
||||||
trend: '+2%',
|
|
||||||
badge: 'week'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly alerts = [
|
constructor(
|
||||||
{
|
private dashboardStateService: DashboardStateService
|
||||||
title: 'ใบแจ้งหนี้ #INV-083 จะครบกำหนด',
|
){}
|
||||||
detail: 'ลูกค้า Metro Engineering',
|
|
||||||
tag: 'ภายใน 3 วัน'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'มีเอกสารที่ต้องอนุมัติ 2 รายการ',
|
|
||||||
detail: 'เบิกค่าใช้จ่ายฝ่ายการตลาด',
|
|
||||||
tag: 'รออนุมัติ'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'พบรายการใช้จ่ายผิดปกติ',
|
|
||||||
detail: 'ค่าใช้จ่ายเดินทางสูงกว่าค่าเฉลี่ย 28%',
|
|
||||||
tag: 'ตรวจสอบ'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly tasks = [
|
// readonly revenueTrend = [
|
||||||
{
|
// { label: 'ม.ค.', value: 52 },
|
||||||
title: 'กระทบยอดธนาคาร เดือน มิ.ย.',
|
// { label: 'ก.พ.', value: 61 },
|
||||||
due: 'วันนี้ 16:00',
|
// { label: 'มี.ค.', value: 73 },
|
||||||
priority: 'สูง'
|
// { label: 'เม.ย.', value: 68 },
|
||||||
},
|
// { label: 'พ.ค.', value: 82 },
|
||||||
{
|
// { label: 'มิ.ย.', value: 77 }
|
||||||
title: 'เตรียมรายงาน VAT',
|
// ];
|
||||||
due: 'พรุ่งนี้ 10:30',
|
|
||||||
priority: 'กลาง'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'ออกใบเสนอราคา โครงการใหม่',
|
|
||||||
due: 'ศุกร์ 14:00',
|
|
||||||
priority: 'ต่ำ'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly ledgerEntries = [
|
// readonly quickRatios = [
|
||||||
{
|
// { label: 'กระแสเงินสด', value: '+฿312K', status: 'positive' },
|
||||||
type: 'i',
|
// { label: 'วงเงินคงเหลือ', value: '฿890K', status: 'neutral' },
|
||||||
title: 'ค่าบริการที่ปรึกษา',
|
// { label: 'ค่าใช้จ่ายเดือนนี้', value: '฿412K', status: 'warning' }
|
||||||
category: 'บริการ',
|
// ];
|
||||||
amount: '+฿85,000',
|
// ฟังก์ชันนี้ควรเรียกหลังจากได้รับข้อมูล myActSumData แล้ว (เช่นใน subscribe หรือ ngOnChanges)
|
||||||
date: 'วันนี้ · 10:15',
|
|
||||||
note: 'โครงการ Warehouse Automation'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'e',
|
|
||||||
title: 'ค่าเช่าออฟฟิศ',
|
|
||||||
category: 'ค่าใช้จ่ายคงที่',
|
|
||||||
amount: '-฿48,000',
|
|
||||||
date: 'วันนี้ · 09:00',
|
|
||||||
note: 'สำนักงานพระราม 9'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'i',
|
|
||||||
title: 'รับเงินมัดจำ',
|
|
||||||
category: 'สัญญาใหม่',
|
|
||||||
amount: '+฿120,000',
|
|
||||||
date: 'เมื่อวาน',
|
|
||||||
note: 'ลูกค้า Urbane CoWorking'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'e',
|
|
||||||
title: 'ค่าวัตถุดิบ',
|
|
||||||
category: 'ต้นทุนโครงการ',
|
|
||||||
amount: '-฿27,500',
|
|
||||||
date: '12 มิ.ย.',
|
|
||||||
note: 'สั่งผ่าน Blue Supply'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly expenseBreakdown = [
|
|
||||||
{ label: 'ฝ่ายบริหาร', value: 32, color: '#0ea5e9' },
|
|
||||||
{ label: 'การตลาด', value: 18, color: '#f97316' },
|
|
||||||
{ label: 'ต้นทุนโครงการ', value: 27, color: '#10b981' },
|
|
||||||
{ label: 'บุคลากร', value: 15, color: '#a855f7' },
|
|
||||||
{ label: 'อื่นๆ', value: 8, color: '#e11d48' }
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly expenseGradient = this.buildExpenseGradient();
|
|
||||||
|
// เพิ่มใน Class Component
|
||||||
|
isNumber(val: any): boolean {
|
||||||
|
return typeof val === 'number';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// readonly ledgerEntries = [
|
||||||
|
// {
|
||||||
|
// type: 'i',
|
||||||
|
// title: 'ค่าบริการที่ปรึกษา',
|
||||||
|
// category: 'บริการ',
|
||||||
|
// amount: '+฿85,000',
|
||||||
|
// date: 'วันนี้ · 10:15',
|
||||||
|
// note: 'โครงการ Warehouse Automation'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// type: 'e',
|
||||||
|
// title: 'ค่าเช่าออฟฟิศ',
|
||||||
|
// category: 'ค่าใช้จ่ายคงที่',
|
||||||
|
// amount: '-฿48,000',
|
||||||
|
// date: 'วันนี้ · 09:00',
|
||||||
|
// note: 'สำนักงานพระราม 9'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// type: 'i',
|
||||||
|
// title: 'รับเงินมัดจำ',
|
||||||
|
// category: 'สัญญาใหม่',
|
||||||
|
// amount: '+฿120,000',
|
||||||
|
// date: 'เมื่อวาน',
|
||||||
|
// note: 'ลูกค้า Urbane CoWorking'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// type: 'e',
|
||||||
|
// title: 'ค่าวัตถุดิบ',
|
||||||
|
// category: 'ต้นทุนโครงการ',
|
||||||
|
// amount: '-฿27,500',
|
||||||
|
// date: '12 มิ.ย.',
|
||||||
|
// note: 'สั่งผ่าน Blue Supply'
|
||||||
|
// }
|
||||||
|
// ];
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.setupFormControl();
|
this.setupFormControl();
|
||||||
}
|
this.dashboardStateService.getStateResult().subscribe(data => {
|
||||||
|
if (data) {
|
||||||
|
this.myDropAct = data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// ผลลับท์ ของ รายการ
|
||||||
|
this.dashboardStateService.getStateAccountResult().subscribe(data => {
|
||||||
|
if (data) {
|
||||||
|
this.myActData = data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// ผลลัพการ คำนวณ ของ ปัญชี ต่างๆ
|
||||||
|
this.dashboardStateService.getStateSumResult().subscribe(data => {
|
||||||
|
if (data) {
|
||||||
|
this.myActSumData = data;
|
||||||
|
this.ActSumDataGradient = this.buildExpenseGradient()
|
||||||
|
this.updateQuickRatios();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
setupFormControl(){
|
setupFormControl(){
|
||||||
this.arrearsForm = new FormGroup({
|
this.arrearsForm = new FormGroup({
|
||||||
// email: new FormControl('',[Validators.required, Validators.email, Validators.maxLength(100)]),
|
// email: new FormControl('',[Validators.required, Validators.email, Validators.maxLength(100)]),
|
||||||
@@ -190,15 +139,66 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.saveFrm = new FormGroup({
|
this.saveFrm = new FormGroup({
|
||||||
actacpdtm: new FormControl('',[Validators.required, Validators.maxLength(12)]),
|
actacpdtm: new FormControl('',[Validators.required]),
|
||||||
actqty: new FormControl('',[Validators.required]),
|
actqty: new FormControl('',[Validators.required]),
|
||||||
actcat: new FormControl('',[Validators.required, Validators.maxLength(1)]),
|
actcat: new FormControl('',[Validators.required, Validators.maxLength(1)]),
|
||||||
actcmt: new FormControl('',[Validators.maxLength(200)])
|
actcmt: new FormControl('',[Validators.maxLength(200)])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSaveSubmit(){
|
updateQuickRatios() {
|
||||||
|
const summary = this.myActSumData.summary;
|
||||||
|
|
||||||
|
// แปลงค่า netProfit เป็นตัวเลขเพื่อเช็คเงื่อนไข (รองรับทั้ง string และ number)
|
||||||
|
const netProfitVal = parseFloat(String(summary.netProfit));
|
||||||
|
const profitRateVal = parseFloat(summary.profitRate.replace('%', '')); // ลบ % ออกก่อนเช็ค
|
||||||
|
|
||||||
|
this.quickRatios = [
|
||||||
|
{
|
||||||
|
label: 'รายรับรวม',
|
||||||
|
value: summary.totalIncome,
|
||||||
|
colorClass: 'text-green-600' // รายรับสีเขียวเสมอ (หรือจะใช้สีดำ text-gray-700 ก็ได้)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'รายจ่ายรวม',
|
||||||
|
value: summary.totalExpense,
|
||||||
|
colorClass: 'text-red-500' // รายจ่ายสีแดงอ่อน หรือสีปกติ
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'คงเหลือสุทธิ', // หรือ กำไรสุทธิ
|
||||||
|
value: netProfitVal, // ส่งเป็นตัวเลขไปให้ Pipe format
|
||||||
|
// ถ้า >= 0 สีน้ำเงิน, ถ้าติดลบ สีแดง
|
||||||
|
colorClass: netProfitVal >= 0 ? 'text-blue-600' : 'text-red-600 font-bold'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'อัตรากำไร',
|
||||||
|
value: summary.profitRate,
|
||||||
|
// เช็ค % ถ้าติดลบให้แดง
|
||||||
|
colorClass: profitRateVal >= 0 ? 'text-blue-600' : 'text-red-600'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'ระยะเวลา',
|
||||||
|
value: summary.period,
|
||||||
|
colorClass: 'text-gray-500'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
onSaveSubmit(){
|
||||||
|
const rawDate = this.saveFrm.get('actacpdtm')?.value; // ค่าดิบ: "2025-11-21T14:23"
|
||||||
|
let arysave = {
|
||||||
|
actacpdtm: rawDate ? rawDate.replace(/[-T:]/g, '') : '',
|
||||||
|
actqty: this.saveFrm.get('actqty')?.value,
|
||||||
|
actcat: this.saveFrm.get('actcat')?.value,
|
||||||
|
actcmt: this.saveFrm.get('actcmt')?.value,
|
||||||
|
acttyp: this.mode
|
||||||
|
}
|
||||||
|
this.SaveEventSubmit(arysave);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SaveEventSubmit(event: any){
|
||||||
|
this.saveEventSubmit.emit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
onArrearsSubmit(){
|
onArrearsSubmit(){
|
||||||
@@ -206,15 +206,19 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private buildExpenseGradient(): string {
|
private buildExpenseGradient(): string {
|
||||||
|
if (!this.myActSumData?.pie?.expense?.length) return '';
|
||||||
|
|
||||||
let current = 0;
|
let current = 0;
|
||||||
const segments = this.expenseBreakdown
|
const segments = this.myActSumData.pie.expense
|
||||||
.map(part => {
|
.map(part => {
|
||||||
const start = current;
|
const start = current;
|
||||||
const end = current + part.value;
|
const percent = parseFloat(part.percent); // แปลงจาก string → number
|
||||||
|
const end = current + percent;
|
||||||
current = end;
|
current = end;
|
||||||
return `${part.color} ${start}% ${end}%`;
|
return `${part.color} ${start}% ${end}%`;
|
||||||
})
|
})
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
return `conic-gradient(${segments})`;
|
return `conic-gradient(${segments})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,489 @@
|
|||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
padding: 2rem clamp(1rem, 4vw, 3rem);
|
||||||
|
background: #f8fafc;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report {
|
||||||
|
max-width: 1280px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.12em;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #94a3b8;
|
||||||
|
margin: 0 0 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report__header h1 {
|
||||||
|
margin: 0 0 0.25rem;
|
||||||
|
font-size: clamp(1.8rem, 4vw, 2.4rem);
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.muted {
|
||||||
|
margin: 0;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report__actions {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: none;
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.65rem 1.4rem;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn--primary {
|
||||||
|
background: linear-gradient(135deg, #22d3ee, #0ea5e9);
|
||||||
|
color: #0f172a;
|
||||||
|
box-shadow: 0 15px 30px rgba(14, 165, 233, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn--ghost {
|
||||||
|
background: #fff;
|
||||||
|
color: #0f172a;
|
||||||
|
border: 1px solid #cbd5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn--compact {
|
||||||
|
padding: 0.45rem 1.1rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card {
|
||||||
|
position: relative;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 1.25rem;
|
||||||
|
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card__label {
|
||||||
|
margin: 0;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card h2 {
|
||||||
|
margin: 0.4rem 0;
|
||||||
|
font-size: 1.6rem;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card__detail {
|
||||||
|
margin: 0;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card__tone {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border-radius: 20px;
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0.15;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tone-mint { background: linear-gradient(135deg, #a7f3d0, #34d399); }
|
||||||
|
.tone-amber { background: linear-gradient(135deg, #fde68a, #fbbf24); }
|
||||||
|
.tone-indigo { background: linear-gradient(135deg, #c4b5fd, #818cf8); }
|
||||||
|
.tone-slate { background: linear-gradient(135deg, #cbd5f5, #94a3b8); }
|
||||||
|
|
||||||
|
.report__content {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 24px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
box-shadow: 0 15px 45px rgba(15, 23, 42, 0.08);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel__header h2 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel__header p {
|
||||||
|
margin: 0;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table {
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
|
border-radius: 18px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table__head,
|
||||||
|
.table__row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1.2fr 1fr 1.6fr 1fr 0.8fr;
|
||||||
|
padding: 0.85rem 1rem;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table__head {
|
||||||
|
background: #f1f5f9;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table__row:nth-child(even) {
|
||||||
|
background: rgba(15, 23, 42, 0.015);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table__row strong {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table__row small {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mono {
|
||||||
|
font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.amount-col {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.income {
|
||||||
|
color: #16a34a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expense {
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- UPDATED PIE CHART SECTION (Donut Style) --- */
|
||||||
|
|
||||||
|
.pie-panel__content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 3rem; /* ระยะห่างระหว่างกราฟกับ Legend */
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-wrapper {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pie-chart {
|
||||||
|
width: 180px;
|
||||||
|
height: 180px;
|
||||||
|
border-radius: 50%;
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
/* Flex เพื่อจัดรูตรงกลาง */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pie-chart__center {
|
||||||
|
width: 75%; /* ความหนาของขอบ */
|
||||||
|
height: 75%;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: inset 0 2px 10px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-shadow {
|
||||||
|
position: absolute;
|
||||||
|
width: 160px;
|
||||||
|
height: 160px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(0,0,0,0.03);
|
||||||
|
filter: blur(20px);
|
||||||
|
z-index: 1;
|
||||||
|
top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-muted {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #9ca3af;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total-amount {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Legend Styles */
|
||||||
|
.pie-legend {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem; /* ระยะห่างแต่ละ item */
|
||||||
|
min-width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pie-legend__item {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.swatch {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-top: 6px; /* ดันลงมาให้ตรงกับ Text บรรทัดแรก */
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-label {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #374151;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-percent {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-value {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #6b7280;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- END UPDATED PIE CHART SECTION --- */
|
||||||
|
|
||||||
|
|
||||||
|
.preview-modal {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 120;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-modal__backdrop {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(15, 23, 42, 0.55);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-modal__content {
|
||||||
|
position: relative;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 24px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
width: min(1100px, 100%);
|
||||||
|
max-height: 90vh;
|
||||||
|
overflow: auto;
|
||||||
|
box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-modal__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-modal__actions {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-sheet {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-sheet__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-totals {
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-totals p {
|
||||||
|
margin: 0;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-totals strong {
|
||||||
|
display: block;
|
||||||
|
color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-pie {
|
||||||
|
margin: 1.5rem 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mini-pie {
|
||||||
|
width: 140px;
|
||||||
|
height: 140px;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: inset 0 0 20px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-pie ul {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-table th,
|
||||||
|
.preview-table td {
|
||||||
|
padding: 0.65rem 0.75rem;
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-table th {
|
||||||
|
background: #f1f5f9;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-table td:last-child {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.report__content {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table__head,
|
||||||
|
.table__row {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.amount-col {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pie-panel__content {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
:host {
|
||||||
|
padding: 1.5rem 1rem 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report__actions {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-modal {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
<div class="report">
|
||||||
|
<div class="report__header">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">สรุปรายงาน</p>
|
||||||
|
<h1>รายงานรายรับรายจ่าย</h1>
|
||||||
|
<!-- <p class="muted">ช่วงวันที่ {{ reportRange.start }} - {{ reportRange.end }}</p> -->
|
||||||
|
</div>
|
||||||
|
<div class="report__actions">
|
||||||
|
<!-- <button class="btn btn--ghost">ส่งออกเป็น Excel</button> -->
|
||||||
|
<button class="btn btn--primary" (click)="openPreview()">ปริ้นรายงาน</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
||||||
|
|
||||||
|
<div class="p-6 rounded-2xl bg-green-50 border border-green-100 shadow-sm hover:shadow-md transition duration-200">
|
||||||
|
<p class="text-sm font-medium text-green-800 opacity-70">รายรับรวม</p>
|
||||||
|
<h2 class="text-3xl font-bold text-gray-800 mt-2">{{ myActSumData.summary.totalIncome | number:'1.2-2' }}</h2>
|
||||||
|
<div class="mt-2 flex items-center text-sm font-medium text-green-600">
|
||||||
|
<!-- <span>+12.4% MoM</span> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-6 rounded-2xl bg-yellow-50 border border-yellow-100 shadow-sm hover:shadow-md transition duration-200">
|
||||||
|
<p class="text-sm font-medium text-yellow-800 opacity-70">รายจ่ายรวม</p>
|
||||||
|
<h2 class="text-3xl font-bold text-gray-800 mt-2">{{ myActSumData.summary.totalExpense | number:'1.2-2' }}</h2>
|
||||||
|
<div class="mt-2 flex items-center text-sm font-medium text-yellow-600">
|
||||||
|
<!-- <span>-4.1% MoM</span> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-6 rounded-2xl bg-purple-50 border border-purple-100 shadow-sm hover:shadow-md transition duration-200">
|
||||||
|
<p class="text-sm font-medium text-purple-800 opacity-70">กำไรสุทธิ</p>
|
||||||
|
<h2 class="text-3xl font-bold text-gray-800 mt-2">{{ myActSumData.summary.netProfit | number:'1.2-2' }}</h2>
|
||||||
|
<div class="mt-2 flex items-center text-sm font-medium text-purple-600">
|
||||||
|
<span>Margin {{ myActSumData.summary.profitRate }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-6 rounded-2xl bg-gray-50 border border-gray-100 shadow-sm hover:shadow-md transition duration-200">
|
||||||
|
<p class="text-sm font-medium text-gray-600 opacity-70">บันทึกรายการ</p>
|
||||||
|
<h2 class="text-3xl font-bold text-gray-800 mt-2">{{myActData.length}} รายการ</h2>
|
||||||
|
<div class="mt-2 flex items-center text-xs font-medium text-gray-500">
|
||||||
|
<!-- <span>32 รายรับ · 54 รายจ่าย</span> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="report__content">
|
||||||
|
<div class="panel">
|
||||||
|
<div class="panel__header">
|
||||||
|
<div>
|
||||||
|
<h2>สมุดรายวัน</h2>
|
||||||
|
<p>บันทึกรายรับรายจ่ายทั้งหมดในช่วงเวลา</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="table">
|
||||||
|
<div class="table__head">
|
||||||
|
<span>วันที่</span>
|
||||||
|
<span>เลขที่เอกสาร</span>
|
||||||
|
<span>หัวข้อ</span>
|
||||||
|
<span>หมวดหมู่</span>
|
||||||
|
<span class="amount-col">ยอดเงิน</span>
|
||||||
|
</div>
|
||||||
|
@for (idx of myActData; track idx.actseq) {
|
||||||
|
<div class="table__row">
|
||||||
|
<span>{{ idx.actacpdtm | date:'dd/MM/yyyy' }}</span>
|
||||||
|
<span class="mono">RCPT{{ idx.actseq }}</span>
|
||||||
|
<span>
|
||||||
|
<strong>{{ idx.actcatnam }}</strong>
|
||||||
|
<small class="muted">{{ idx.acttyp === 'i' ? 'รับ' : 'จ่าย' }}</small>
|
||||||
|
</span>
|
||||||
|
<span>{{ idx.actcatnam }}</span>
|
||||||
|
<span class="amount-col" [ngClass]="idx.acttyp === 'i' ? 'income' : 'expense' ">{{ idx.actqty | number:'1.2-2' }}</span>
|
||||||
|
</div>
|
||||||
|
} @empty {
|
||||||
|
<div class="p-4 text-center text-gray-400">ไม่มีข้อมูลรายการ</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel pie-panel">
|
||||||
|
<div class="panel__header">
|
||||||
|
<div>
|
||||||
|
<h2>สัดส่วนค่าใช้จ่าย</h2>
|
||||||
|
<p>เปรียบเทียบหมวดหลักของรายจ่ายเดือนนี้</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pie-panel__content">
|
||||||
|
<div class="chart-wrapper">
|
||||||
|
<div class="pie-chart" [style.background]="ActSumDataGradient">
|
||||||
|
<div class="pie-chart__center">
|
||||||
|
<p class="label-muted">รวมรายจ่าย</p>
|
||||||
|
<strong class="total-amount">{{ myActSumData.summary.totalExpense | number:'1.0-0' }}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="chart-shadow"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="pie-legend">
|
||||||
|
@for (part of myActSumData.pie.expense; track part.label) {
|
||||||
|
<li class="pie-legend__item">
|
||||||
|
<span class="swatch" [style.background]="part.color"></span>
|
||||||
|
<div class="legend-text">
|
||||||
|
<p class="item-label">{{ part.label }}</p>
|
||||||
|
<p class="item-percent">{{ part.percent }}%</p>
|
||||||
|
<p class="item-value">{{ part.value | number:'1.0-0' }} บาท</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- PRINT PREVIEW MODAL -->
|
||||||
|
@if(printPreviewOpen){
|
||||||
|
<div class="preview-modal">
|
||||||
|
<div class="preview-modal__backdrop" (click)="closePreview()"></div>
|
||||||
|
<div class="preview-modal__content">
|
||||||
|
<div class="preview-modal__header">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Print Preview</p>
|
||||||
|
<h2>รายงานรายรับรายจ่าย</h2>
|
||||||
|
</div>
|
||||||
|
<div class="preview-modal__actions">
|
||||||
|
<button class="btn btn--ghost" (click)="closePreview()">ปิด</button>
|
||||||
|
<!-- ACTION ADDED HERE -->
|
||||||
|
<button class="btn btn--primary" (click)="printReport()">พิมพ์</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="preview-sheet">
|
||||||
|
<div class="preview-sheet__header">
|
||||||
|
<div>
|
||||||
|
<h3>Accounting Summary</h3>
|
||||||
|
<p>Prepared on {{ reportRange.end }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="preview-pie">
|
||||||
|
<div class="mini-pie" [style.background]="ActSumDataGradient"></div>
|
||||||
|
<ul>
|
||||||
|
@for (part of myActSumData.pie.expense; track part.label) {
|
||||||
|
<li>
|
||||||
|
<span class="swatch" [style.background]="part.color"></span>
|
||||||
|
<span>{{ part.label }} · {{ part.percent }}%</span>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="preview-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>วันที่</th>
|
||||||
|
<th>เลขที่</th>
|
||||||
|
<th>หัวข้อ</th>
|
||||||
|
<th>หมวดหมู่</th>
|
||||||
|
<th>ยอดเงิน</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@for (idx of myActData; track idx.actseq) {
|
||||||
|
<tr>
|
||||||
|
<td>{{ idx.actacpdtm | date:'dd/MM/yyyy'}}</td>
|
||||||
|
<td>RCPT{{ idx.actseq }}</td>
|
||||||
|
<td>{{ idx.actcatnam }}</td>
|
||||||
|
<td>{{ idx.actcatnam }}</td>
|
||||||
|
<td [ngClass]="idx.acttyp === 'i' ? 'income' : 'expense' ">{{ idx.actqty | number:'1.2-2' }}</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- The rest of the dashboard HTML is excluded for brevity/focus on the core report logic -->
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { GeneralService } from './../../services/generalservice';
|
||||||
|
import { QuickRatio, IStateDrop, IActSumData } from './../../interfaces/dashboard.interface';
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { IActData } from '../../interfaces/dashboard.interface';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-main-report',
|
||||||
|
templateUrl: './main-report.component.html',
|
||||||
|
standalone: false,
|
||||||
|
styleUrls: ['./main-report.component.css']
|
||||||
|
})
|
||||||
|
export class MainReportComponent implements OnInit{
|
||||||
|
|
||||||
|
|
||||||
|
myActData: IActData[] = [];
|
||||||
|
quickRatios: QuickRatio[] = [];
|
||||||
|
// myDropAct: IStateDrop[] = [];
|
||||||
|
myDropAct: IStateDrop = { income: [], expense: [] };
|
||||||
|
myActSumData: IActSumData = {
|
||||||
|
summary: {
|
||||||
|
totalIncome: '',
|
||||||
|
totalExpense: '',
|
||||||
|
netProfit: 0,
|
||||||
|
profitRate: '',
|
||||||
|
adjustedProfitRate: '',
|
||||||
|
period: ''
|
||||||
|
},
|
||||||
|
pie: {
|
||||||
|
income: [],
|
||||||
|
expense: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ActSumDataGradient: any
|
||||||
|
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private generalService: GeneralService,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router
|
||||||
|
){}
|
||||||
|
readonly reportRange = {
|
||||||
|
start: '1 มิถุนายน 2567',
|
||||||
|
end: '30 มิถุนายน 2567'
|
||||||
|
};
|
||||||
|
|
||||||
|
readonly summaryCards = [
|
||||||
|
{ label: 'รายรับรวม', value: '฿1,284,500', detail: '+12.4% MoM', tone: 'mint' },
|
||||||
|
{ label: 'รายจ่ายรวม', value: '฿732,800', detail: '-4.1% MoM', tone: 'amber' },
|
||||||
|
{ label: 'กำไรสุทธิ', value: '฿551,700', detail: 'Margin 42.9%', tone: 'indigo' },
|
||||||
|
{ label: 'บันทึกรายการ', value: '86 รายการ', detail: '32 รายรับ · 54 รายจ่าย', tone: 'slate' }
|
||||||
|
];
|
||||||
|
|
||||||
|
readonly ledgerRecords = [
|
||||||
|
{
|
||||||
|
date: '01 มิ.ย. 2567',
|
||||||
|
doc: 'RCPT-9101',
|
||||||
|
type: 'income',
|
||||||
|
topic: 'ค่าบริการที่ปรึกษา',
|
||||||
|
category: 'บริการ',
|
||||||
|
amount: 145000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '02 มิ.ย. 2567',
|
||||||
|
doc: 'EXP-4407',
|
||||||
|
type: 'expense',
|
||||||
|
topic: 'ค่าวัสดุโครงการ A',
|
||||||
|
category: 'ต้นทุนโครงการ',
|
||||||
|
amount: -38900
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '06 มิ.ย. 2567',
|
||||||
|
doc: 'RCPT-9110',
|
||||||
|
type: 'income',
|
||||||
|
topic: 'รับเงินมัดจำโครงการ',
|
||||||
|
category: 'สัญญาใหม่',
|
||||||
|
amount: 220000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '09 มิ.ย. 2567',
|
||||||
|
doc: 'EXP-4412',
|
||||||
|
type: 'expense',
|
||||||
|
topic: 'เงินเดือนพนักงาน',
|
||||||
|
category: 'บุคลากร',
|
||||||
|
amount: -180000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '12 มิ.ย. 2567',
|
||||||
|
doc: 'EXP-4416',
|
||||||
|
type: 'expense',
|
||||||
|
topic: 'ค่าเช่าออฟฟิศ',
|
||||||
|
category: 'ค่าใช้จ่ายคงที่',
|
||||||
|
amount: -48000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '19 มิ.ย. 2567',
|
||||||
|
doc: 'RCPT-9122',
|
||||||
|
type: 'income',
|
||||||
|
topic: 'ค่าสัญญาบริการรายปี',
|
||||||
|
category: 'บริการ',
|
||||||
|
amount: 325000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '23 มิ.ย. 2567',
|
||||||
|
doc: 'EXP-4425',
|
||||||
|
type: 'expense',
|
||||||
|
topic: 'ค่าโฆษณาออนไลน์',
|
||||||
|
category: 'การตลาด',
|
||||||
|
amount: -72000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '28 มิ.ย. 2567',
|
||||||
|
doc: 'RCPT-9133',
|
||||||
|
type: 'income',
|
||||||
|
topic: 'รายรับจากคู่ค้าใหม่',
|
||||||
|
category: 'พันธมิตร',
|
||||||
|
amount: 210500
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
readonly expenseBreakdown = [
|
||||||
|
{ label: 'ต้นทุนโครงการ', value: 34, color: '#10b981' },
|
||||||
|
{ label: 'บุคลากร', value: 26, color: '#6366f1' },
|
||||||
|
{ label: 'การตลาด', value: 18, color: '#f97316' },
|
||||||
|
{ label: 'ค่าใช้จ่ายคงที่', value: 14, color: '#0ea5e9' },
|
||||||
|
{ label: 'อื่นๆ', value: 8, color: '#e11d48' }
|
||||||
|
];
|
||||||
|
|
||||||
|
readonly previewTotals = [
|
||||||
|
{ label: 'รายรับรวม', value: '฿1,284,500' },
|
||||||
|
{ label: 'รายจ่ายรวม', value: '฿732,800' },
|
||||||
|
{ label: 'กำไรสุทธิ', value: '฿551,700' }
|
||||||
|
];
|
||||||
|
|
||||||
|
printPreviewOpen = false;
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.OnSearchSum({}, false);
|
||||||
|
this.OnSearchAct({});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OnSearchAct(value: any): void {
|
||||||
|
const uri = '/api/web/accountingSearch';
|
||||||
|
let request = {
|
||||||
|
token: value
|
||||||
|
}
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
|
next: (result: any) => {
|
||||||
|
if (result.code === '200') {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
this.myActData = result.data;
|
||||||
|
}else{
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
this.generalService.trowApi(error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OnSearchSum(value: any, setupFirst: boolean): void {
|
||||||
|
const uri = '/api/web/accountingSum';
|
||||||
|
let request = {
|
||||||
|
token: value
|
||||||
|
}
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
|
next: (result: any) => {
|
||||||
|
if (result.code === '200') {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
this.myActSumData = result.data
|
||||||
|
this.ActSumDataGradient = this.buildExpenseGradient();
|
||||||
|
}else{
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
this.generalService.trowApi(error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get expenseGradient(): string {
|
||||||
|
let current = 0;
|
||||||
|
const segments = this.expenseBreakdown
|
||||||
|
.map(slice => {
|
||||||
|
const start = current;
|
||||||
|
const end = current + slice.value;
|
||||||
|
current = end;
|
||||||
|
return `${slice.color} ${start}% ${end}%`;
|
||||||
|
})
|
||||||
|
.join(', ');
|
||||||
|
return `conic-gradient(${segments})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private buildExpenseGradient(): string {
|
||||||
|
if (!this.myActSumData?.pie?.expense?.length) return '';
|
||||||
|
|
||||||
|
let current = 0;
|
||||||
|
const segments = this.myActSumData.pie.expense
|
||||||
|
.map(part => {
|
||||||
|
const start = current;
|
||||||
|
const percent = parseFloat(part.percent); // แปลงจาก string → number
|
||||||
|
const end = current + percent;
|
||||||
|
current = end;
|
||||||
|
return `${part.color} ${start}% ${end}%`;
|
||||||
|
})
|
||||||
|
.join(', ');
|
||||||
|
|
||||||
|
return `conic-gradient(${segments})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
get formattedRecords() {
|
||||||
|
return this.ledgerRecords.map(record => ({
|
||||||
|
...record,
|
||||||
|
displayAmount: this.formatCurrency(record.amount),
|
||||||
|
tone: record.type === 'income' ? 'income' : 'expense'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
printReport(): void {
|
||||||
|
window.print();
|
||||||
|
}
|
||||||
|
|
||||||
|
openPreview(): void {
|
||||||
|
this.printPreviewOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
closePreview(): void {
|
||||||
|
this.printPreviewOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private formatCurrency(amount: number): string {
|
||||||
|
const formatter = new Intl.NumberFormat('th-TH', { style: 'currency', currency: 'THB', maximumFractionDigits: 0 });
|
||||||
|
return formatter.format(amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +1,27 @@
|
|||||||
/* .sidebar {
|
.sidebar-container {
|
||||||
width: 220px;
|
width: 250px;
|
||||||
background: #222;
|
transition: width 0.3s ease-in-out;
|
||||||
color: white;
|
flex-shrink: 0; /* Prevent the sidebar from shrinking in the flex container */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-container.is-collapsed {
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-container.is-mobile {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
padding: 20px;
|
width: 250px; /* Width when shown on mobile */
|
||||||
} */
|
z-index: 40;
|
||||||
/* .sidebar ul {
|
transform: translateX(-100%);
|
||||||
list-style: none;
|
transition: transform 0.3s ease-in-out;
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
.sidebar li {
|
|
||||||
margin: 10px 0;
|
.sidebar-container.is-mobile.is-open {
|
||||||
cursor: pointer;
|
transform: translateX(0);
|
||||||
transition: 0.2s;
|
|
||||||
}
|
}
|
||||||
.sidebar li:hover {
|
|
||||||
color: #00bcd4;
|
|
||||||
} */
|
|
||||||
|
|
||||||
@keyframes spin-slow {
|
@keyframes spin-slow {
|
||||||
0% { transform: rotate(0deg); }
|
0% { transform: rotate(0deg); }
|
||||||
@@ -25,15 +30,3 @@
|
|||||||
.animate-spin-slow {
|
.animate-spin-slow {
|
||||||
animation: spin-slow 8s linear infinite;
|
animation: spin-slow 8s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.sidebar {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 50;
|
|
||||||
transform: translateX(-100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar.expanded {
|
|
||||||
transform: translateX(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
<div
|
<div
|
||||||
class="h-screen bg-linear-to-b from-amber-950 to-amber-900 text-gray-100 shadow-2xl flex flex-col relative transition-all duration-300 ease-in-out"
|
[class.is-mobile]="isMobile"
|
||||||
[@sidebarState]="isOpen ? 'expanded' : 'collapsed'">
|
[class.is-open]="isOpen"
|
||||||
|
[class.is-collapsed]="!isOpen && !isMobile"
|
||||||
|
class="sidebar-container h-full bg-linear-to-b from-amber-950 to-amber-900 text-gray-100 shadow-2xl flex flex-col relative">
|
||||||
|
|
||||||
<button
|
<button
|
||||||
(click)="toggleSidebar()"
|
(click)="toggleSidebar()"
|
||||||
|
[class.hidden]="isMobile"
|
||||||
class="absolute -right-3 top-6 bg-amber-700 hover:bg-amber-600 text-white rounded-full p-2 shadow-md transition-all duration-300">
|
class="absolute -right-3 top-6 bg-amber-700 hover:bg-amber-600 text-white rounded-full p-2 shadow-md transition-all duration-300">
|
||||||
<i class="fas" [ngClass]="isOpen ? 'fa-angle-left' : 'fa-angle-right'"></i>
|
<i class="fas" [ngClass]="isOpen ? 'fa-angle-left' : 'fa-angle-right'"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="flex items-center gap-3 p-5">
|
<div class="flex items-center gap-3 p-5">
|
||||||
<h3 *ngIf="isOpen" class="text-2xl font-bold transition-all duration-300">
|
<h3 *ngIf="isOpen" class="text-2xl font-bold transition-all duration-300">
|
||||||
Global Sidebar
|
<img src="logo.png" alt="">
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="border-t border-amber-700 mx-4 my-4 opacity-70">
|
<hr class="border-t border-amber-700 mx-4 my-4 opacity-70">
|
||||||
|
|
||||||
<ul class="flex flex-col gap-2 px-2 grow">
|
<ul class="flex flex-col gap-2 px-2 flex-1 overflow-y-auto">
|
||||||
|
|
||||||
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
||||||
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
||||||
@@ -24,13 +27,13 @@
|
|||||||
<i class="fas fa-tachometer-alt text-xl group-hover:scale-110 transition-transform"></i>
|
<i class="fas fa-tachometer-alt text-xl group-hover:scale-110 transition-transform"></i>
|
||||||
<span *ngIf="isOpen" class="text-lg font-medium">Dashboard</span>
|
<span *ngIf="isOpen" class="text-lg font-medium">Dashboard</span>
|
||||||
</li>
|
</li>
|
||||||
|
<!--
|
||||||
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
||||||
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
||||||
(click)="navigate('/main/profile')">
|
(click)="navigate('/main/profile')">
|
||||||
<i class="fas fa-user-circle text-xl group-hover:scale-110 transition-transform"></i>
|
<i class="fas fa-user-circle text-xl group-hover:scale-110 transition-transform"></i>
|
||||||
<span *ngIf="isOpen" class="text-lg font-medium">Profile</span>
|
<span *ngIf="isOpen" class="text-lg font-medium">Profile</span>
|
||||||
</li>
|
</li> -->
|
||||||
|
|
||||||
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
||||||
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
hover:bg-amber-800 hover:shadow-lg transition-all duration-300 ease-in-out"
|
||||||
@@ -38,28 +41,16 @@
|
|||||||
<i class="fas fa-chart-bar text-xl group-hover:scale-110 transition-transform"></i>
|
<i class="fas fa-chart-bar text-xl group-hover:scale-110 transition-transform"></i>
|
||||||
<span *ngIf="isOpen" class="text-lg font-medium">Report</span>
|
<span *ngIf="isOpen" class="text-lg font-medium">Report</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer mt-auto
|
|
||||||
hover:bg-red-700 hover:shadow-lg transition-all duration-300 ease-in-out"
|
|
||||||
(click)="logout()">
|
|
||||||
<i class="fas fa-sign-out-alt text-xl group-hover:scale-110 transition-transform"></i>
|
|
||||||
<span *ngIf="isOpen" class="text-lg font-medium text-red-200">Logout</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<div class="mt-auto p-2">
|
||||||
|
<ul class="flex flex-col">
|
||||||
|
<li class="group flex items-center gap-3 p-3 rounded-lg cursor-pointer
|
||||||
|
hover:bg-red-700 hover:shadow-lg transition-all duration-300 ease-in-out"
|
||||||
|
(click)="logout()">
|
||||||
|
<i class="fas fa-sign-out-alt text-xl group-hover:scale-110 transition-transform"></i>
|
||||||
|
<span *ngIf="isOpen" class="text-lg font-medium text-red-200">Logout</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
|
||||||
*ngIf="isMobile && showOverlay"
|
|
||||||
class="fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300"
|
|
||||||
(click)="toggleSidebar()">
|
|
||||||
</div>
|
|
||||||
<!--
|
|
||||||
|
|
||||||
<div class="flex-1 bg-gray-100 text-gray-900 overflow-y-auto">
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,15 @@
|
|||||||
import { Component, HostListener, OnInit } from '@angular/core';
|
import { Component, HostListener, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sidebar',
|
selector: 'app-sidebar',
|
||||||
standalone: false,
|
standalone: false,
|
||||||
templateUrl: './sidebar.component.html',
|
templateUrl: './sidebar.component.html',
|
||||||
styleUrls: ['./sidebar.component.css'],
|
styleUrls: ['./sidebar.component.css']
|
||||||
animations: [
|
|
||||||
trigger('sidebarState', [
|
|
||||||
state('expanded', style({
|
|
||||||
width: '220px',
|
|
||||||
opacity: 1
|
|
||||||
})),
|
|
||||||
state('collapsed', style({
|
|
||||||
width: '70px',
|
|
||||||
opacity: 0.95
|
|
||||||
})),
|
|
||||||
transition('expanded <=> collapsed', [
|
|
||||||
animate('300ms ease-in-out')
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class SidebarComponent implements OnInit {
|
export class SidebarComponent implements OnInit {
|
||||||
isOpen = true; // ขยายไหม
|
isOpen = true;
|
||||||
isMobile = false; // ตรวจอุปกรณ์
|
isMobile = false;
|
||||||
showOverlay = false; // สำหรับ mobile overlay
|
|
||||||
|
|
||||||
constructor(private router: Router) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
@@ -39,24 +22,21 @@ export class SidebarComponent implements OnInit {
|
|||||||
checkDevice() {
|
checkDevice() {
|
||||||
this.isMobile = window.innerWidth <= 768;
|
this.isMobile = window.innerWidth <= 768;
|
||||||
if (this.isMobile) {
|
if (this.isMobile) {
|
||||||
this.isOpen = false; // ซ่อน sidebar ตอนเข้า mobile
|
this.isOpen = false;
|
||||||
} else {
|
} else {
|
||||||
this.isOpen = true; // เปิดไว้ตลอดใน desktop
|
this.isOpen = true;
|
||||||
this.showOverlay = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSidebar() {
|
toggleSidebar() {
|
||||||
if (this.isMobile) {
|
this.isOpen = !this.isOpen;
|
||||||
this.showOverlay = !this.showOverlay;
|
|
||||||
this.isOpen = this.showOverlay;
|
|
||||||
} else {
|
|
||||||
this.isOpen = !this.isOpen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(path: string) {
|
navigate(path: string) {
|
||||||
this.router.navigate([path]);
|
this.router.navigate([path]);
|
||||||
|
if (this.isMobile) {
|
||||||
|
this.isOpen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|||||||
12
accounting-ng-nuttakit/src/app/config/caching.config.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export const CACHEABLE_URLS = {
|
||||||
|
GET: [
|
||||||
|
// Add GET URIs here that you want to cache
|
||||||
|
// e.g., '/api/data'
|
||||||
|
],
|
||||||
|
POST: [
|
||||||
|
'/api/web/accountingSetup',
|
||||||
|
'/api/nigga'
|
||||||
|
// Add POST URIs here that you want to cache
|
||||||
|
// e.g., '/api/search'
|
||||||
|
]
|
||||||
|
};
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
} @else if(mode == "forgot-password"){
|
} @else if(mode == "forgot-password"){
|
||||||
<app-login-forgot (otpEventSubmit)="onOtpSendSubmit($event)" (otpVerifyEventSubmit)="onVerifySubmit($event)"></app-login-forgot>
|
<app-login-forgot (otpEventSubmit)="onOtpSendSubmit($event)" (otpVerifyEventSubmit)="onVerifySubmit($event)"></app-login-forgot>
|
||||||
}
|
}
|
||||||
<!-- @else {
|
@else if(mode == "register"){
|
||||||
|
<app-login-register (registeredEventSubmit)="onRegisterSubmit($event)"></app-login-register>
|
||||||
} -->
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { finalize } from 'rxjs/operators';
|
|||||||
export class LoginContentComponent implements OnInit {
|
export class LoginContentComponent implements OnInit {
|
||||||
@ViewChild(LoginForgotComponent) loginForgotComponent!: LoginForgotComponent;
|
@ViewChild(LoginForgotComponent) loginForgotComponent!: LoginForgotComponent;
|
||||||
@ViewChild(LoginPageComponent) loginPageComponent!: LoginPageComponent;
|
@ViewChild(LoginPageComponent) loginPageComponent!: LoginPageComponent;
|
||||||
mode: 'forgot-password' | 'default' = 'default';
|
mode: 'forgot-password' | 'register' | 'default' = 'default';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private generalService: GeneralService,
|
private generalService: GeneralService,
|
||||||
@@ -27,6 +27,8 @@ export class LoginContentComponent implements OnInit {
|
|||||||
|
|
||||||
if (param === 'forgot-password') {
|
if (param === 'forgot-password') {
|
||||||
this.mode = 'forgot-password';
|
this.mode = 'forgot-password';
|
||||||
|
}else if(param === 'register'){
|
||||||
|
this.mode = 'register';
|
||||||
} else {
|
} else {
|
||||||
// this.router.navigate(['/login']); // This can cause navigation loops
|
// this.router.navigate(['/login']); // This can cause navigation loops
|
||||||
this.mode = 'default';
|
this.mode = 'default';
|
||||||
@@ -57,6 +59,7 @@ export class LoginContentComponent implements OnInit {
|
|||||||
if (result.code === '200' && result.data?.token) {
|
if (result.code === '200' && result.data?.token) {
|
||||||
this.generalService.trowApi(result);
|
this.generalService.trowApi(result);
|
||||||
localStorage.setItem('access_token', result.data.token);
|
localStorage.setItem('access_token', result.data.token);
|
||||||
|
localStorage.setItem('username', result.data.usrthinam);
|
||||||
this.router.navigate(['main/dashboard']);
|
this.router.navigate(['main/dashboard']);
|
||||||
} else {
|
} else {
|
||||||
const errorMessage = result.message_th || result.message || 'Sign-in failed.';
|
const errorMessage = result.message_th || result.message || 'Sign-in failed.';
|
||||||
@@ -71,11 +74,38 @@ export class LoginContentComponent implements OnInit {
|
|||||||
if (this.loginPageComponent) {
|
if (this.loginPageComponent) {
|
||||||
this.loginPageComponent.message = errorMessage;
|
this.loginPageComponent.message = errorMessage;
|
||||||
}
|
}
|
||||||
this.generalService.trowApi(error.error || { message_th: 'เกิดข้อผิดพลาดไม่ทราบสาเหตุ' });
|
this.generalService.trowApi(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRegisterSubmit(value: any){
|
||||||
|
const uri = '/api/login/register';
|
||||||
|
const request = {
|
||||||
|
firstname: value.username,
|
||||||
|
lastname: value.userlastname,
|
||||||
|
password: value.password,
|
||||||
|
email: value.email,
|
||||||
|
organization: 'accpj'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
|
next: (result: any) => {
|
||||||
|
if (result.code === '200') {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
this.generalService.trowApi(error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.router.navigate(['/login']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onOtpSendSubmit(value: any){
|
onOtpSendSubmit(value: any){
|
||||||
let uri = '/api/login/otp/send';
|
let uri = '/api/login/otp/send';
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<app-main-dashboard></app-main-dashboard>
|
<app-main-dashboard (saveEventSubmit)="OnSaveSubmit($event)"></app-main-dashboard>
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import { DashboardStateService } from './../../services/state/dashboard-state.service';
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ChartConfiguration, ChartOptions } from 'chart.js';
|
import { ChartConfiguration, ChartOptions } from 'chart.js';
|
||||||
import { BaseChartDirective } from 'ng2-charts';
|
import { BaseChartDirective } from 'ng2-charts';
|
||||||
import { GeneralService } from '../../services/generalservice';
|
import { GeneralService } from '../../services/generalservice';
|
||||||
|
import { IDropAct, IStateDrop, IActData, IActSumData } from '../../interfaces/dashboard.interface';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-main-dashboard-content',
|
selector: 'app-main-dashboard-content',
|
||||||
@@ -11,85 +14,169 @@ import { GeneralService } from '../../services/generalservice';
|
|||||||
})
|
})
|
||||||
export class MainDashboardContentComponent implements OnInit {
|
export class MainDashboardContentComponent implements OnInit {
|
||||||
@ViewChild(BaseChartDirective) chart?: BaseChartDirective;
|
@ViewChild(BaseChartDirective) chart?: BaseChartDirective;
|
||||||
|
myDropAct!: IStateDrop;
|
||||||
public lineChartData: ChartConfiguration<'line'>['data'] = {
|
myActData: IActData[] = [];
|
||||||
labels: [],
|
myActSumData: IActSumData = {
|
||||||
datasets: [
|
summary: {
|
||||||
{
|
totalIncome: '',
|
||||||
data: [],
|
totalExpense: '',
|
||||||
label: 'Revenue',
|
netProfit: 0,
|
||||||
fill: true,
|
profitRate: '',
|
||||||
tension: 0.5,
|
adjustedProfitRate: '',
|
||||||
borderColor: 'rgba(75,192,192,1)',
|
period: ''
|
||||||
backgroundColor: 'rgba(75,192,192,0.2)'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
public lineChartOptions: ChartOptions<'line'> = {
|
|
||||||
responsive: true,
|
|
||||||
scales: {
|
|
||||||
y: {
|
|
||||||
beginAtZero: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
plugins: {
|
pie: {
|
||||||
legend: {
|
income: [],
|
||||||
display: true,
|
expense: []
|
||||||
},
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: 'Revenue Summary - Last 6 Months'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private generalService: GeneralService) {}
|
constructor(
|
||||||
|
private generalService: GeneralService,
|
||||||
|
private dashboardStateService: DashboardStateService
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.fetchChartData();
|
let token = localStorage.getItem('access_token')
|
||||||
|
this.OnSearchAct(token, true);
|
||||||
|
this.OnSetupDashboard(token, true);
|
||||||
|
this.OnSearchSum(token, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchChartData(): void {
|
OnSearchAct(value: any, setupFirst: boolean): void {
|
||||||
// NOTE: Using a placeholder endpoint as the actual one was not provided.
|
const uri = '/api/web/accountingSearch';
|
||||||
const uri = '/api/dashboard/summary-last-6-months';
|
let request = {
|
||||||
|
token: value
|
||||||
this.generalService.getRequest(uri).subscribe({
|
}
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
next: (result: any) => {
|
next: (result: any) => {
|
||||||
if (result.code === '200' && result.data) {
|
if (result.code === '200') {
|
||||||
this.processChartData(result.data);
|
this.generalService.trowApi(result);
|
||||||
} else {
|
this.myActData = result.data;
|
||||||
console.warn('Could not fetch chart data:', result.message_th);
|
this.dashboardStateService.setStateAccountResult(this.myActData);
|
||||||
// Optionally, display placeholder data or an error message
|
}else{
|
||||||
this.setupPlaceholderData();
|
this.generalService.trowApi(result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
console.error('Error fetching chart data:', error);
|
this.generalService.trowApi(error);
|
||||||
// Display placeholder data on error to show the graph structure
|
},
|
||||||
this.setupPlaceholderData();
|
complete: () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
processChartData(data: any[]): void {
|
OnSaveSubmit(value: any){
|
||||||
const labels = data.map(item => item.month);
|
const uri = '/api/web/accountingAdd';
|
||||||
const revenues = data.map(item => item.revenue);
|
let request = value
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
this.lineChartData.labels = labels;
|
next: (result: any) => {
|
||||||
this.lineChartData.datasets[0].data = revenues;
|
if (result.code === '200') {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
this.chart?.update();
|
// this.myActData = result.data;
|
||||||
|
// this.dashboardStateService.setStateAccountResult(this.myActData);
|
||||||
|
}else{
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
this.generalService.trowApi(error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.ngOnInit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPlaceholderData(): void {
|
OnSetupDashboard(value: any, setupFirst: boolean): void {
|
||||||
// This function is called if the API fails, to show a sample graph.
|
const uri = '/api/web/accountingSetup';
|
||||||
const labels = ['January', 'February', 'March', 'April', 'May', 'June'];
|
let request = {
|
||||||
const revenues = [1200, 1900, 3000, 5000, 2300, 3200]; // Sample data
|
token: value
|
||||||
|
}
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
|
next: (result: any) => {
|
||||||
|
if (result.code === '200') {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
this.myDropAct = result.data
|
||||||
|
this.dashboardStateService.setStateResult(this.myDropAct)
|
||||||
|
}else{
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
this.generalService.trowApi(error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
|
||||||
this.lineChartData.labels = labels;
|
}
|
||||||
this.lineChartData.datasets[0].data = revenues;
|
});
|
||||||
|
|
||||||
this.chart?.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnSearchSum(value: any, setupFirst: boolean): void {
|
||||||
|
const uri = '/api/web/accountingSum';
|
||||||
|
let request = {
|
||||||
|
token: value
|
||||||
|
}
|
||||||
|
this.generalService.postRequest(uri, request).subscribe({
|
||||||
|
next: (result: any) => {
|
||||||
|
if (result.code === '200') {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
this.myActSumData = result.data
|
||||||
|
this.dashboardStateService.setStateSumResult(this.myActSumData);
|
||||||
|
}else{
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
this.generalService.trowApi(error);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchChartData(): void {
|
||||||
|
// // NOTE: Using a placeholder endpoint as the actual one was not provided.
|
||||||
|
// const uri = '/api/dashboard/summary-last-6-months';
|
||||||
|
|
||||||
|
// this.generalService.getRequest(uri).subscribe({
|
||||||
|
// next: (result: any) => {
|
||||||
|
// if (result.code === '200' && result.data) {
|
||||||
|
// this.processChartData(result.data);
|
||||||
|
// } else {
|
||||||
|
// console.warn('Could not fetch chart data:', result.message_th);
|
||||||
|
// // Optionally, display placeholder data or an error message
|
||||||
|
// this.setupPlaceholderData();
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// error: (error: any) => {
|
||||||
|
// console.error('Error fetching chart data:', error);
|
||||||
|
// // Display placeholder data on error to show the graph structure
|
||||||
|
// this.setupPlaceholderData();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// processChartData(data: any[]): void {
|
||||||
|
// const labels = data.map(item => item.month);
|
||||||
|
// const revenues = data.map(item => item.revenue);
|
||||||
|
|
||||||
|
// this.lineChartData.labels = labels;
|
||||||
|
// this.lineChartData.datasets[0].data = revenues;
|
||||||
|
|
||||||
|
// this.chart?.update();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setupPlaceholderData(): void {
|
||||||
|
// // This function is called if the API fails, to show a sample graph.
|
||||||
|
// const labels = ['January', 'February', 'March', 'April', 'May', 'June'];
|
||||||
|
// const revenues = [1200, 1900, 3000, 5000, 2300, 3200]; // Sample data
|
||||||
|
|
||||||
|
// this.lineChartData.labels = labels;
|
||||||
|
// this.lineChartData.datasets[0].data = revenues;
|
||||||
|
|
||||||
|
// this.chart?.update();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
<div class="flex h-screen overflow-hidden">
|
<!-- Mobile Header -->
|
||||||
<!-- Sidebar (เฉพาะ main) -->
|
<div class="md:hidden flex items-center justify-between bg-white text-gray-800 p-4 shadow-md relative z-50">
|
||||||
<app-sidebar></app-sidebar>
|
<button (click)="sidebar.toggleSidebar()" class="p-2">
|
||||||
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-4 6h10"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex h-screen bg-gray-50">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<app-sidebar #sidebar></app-sidebar>
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<div class="flex-1 overflow-y-auto bg-gray-50 text-gray-900">
|
<div class="flex-1 overflow-y-auto overflow-x-hidden text-gray-900">
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ import { LoginPageComponent } from '../../component/login-page/login-page.compon
|
|||||||
import { ReactiveFormsModule } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||||
import { LoginForgotComponent } from '../../component/login-forgot/login-forgot.component';
|
import { LoginForgotComponent } from '../../component/login-forgot/login-forgot.component';
|
||||||
|
import { LoginRegisterComponent } from '../../component/login-register/login-register.component';
|
||||||
// import { AppModule } from '../../app.module';
|
// import { AppModule } from '../../app.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
LoginContentComponent,
|
LoginContentComponent,
|
||||||
LoginPageComponent,
|
LoginPageComponent,
|
||||||
LoginForgotComponent
|
LoginForgotComponent,
|
||||||
|
LoginRegisterComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
import { MainDashboardContentComponent } from '../../content/main-dashboard-content/main-dashboard-content.component';
|
import { MainDashboardContentComponent } from '../../content/main-dashboard-content/main-dashboard-content.component';
|
||||||
|
import { MainReportComponent } from '../../component/main-report/main-report.component';
|
||||||
// import { MainReportComponent } from '../../component/main-report/main-report.component';
|
// import { MainReportComponent } from '../../component/main-report/main-report.component';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: 'dashboard', component: MainDashboardContentComponent },
|
{ path: 'dashboard', component: MainDashboardContentComponent },
|
||||||
|
{ path: 'report', component: MainReportComponent },
|
||||||
// children: [
|
// children: [
|
||||||
// {
|
// {
|
||||||
// path: 'dashboard',
|
// path: 'dashboard',
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { ReactiveFormsModule } from '@angular/forms';
|
|||||||
|
|
||||||
import { MainDashboardComponent } from '../../component/main-dashboard/main-dashboard.component';
|
import { MainDashboardComponent } from '../../component/main-dashboard/main-dashboard.component';
|
||||||
import { MainDashboardContentComponent } from '../../content/main-dashboard-content/main-dashboard-content.component';
|
import { MainDashboardContentComponent } from '../../content/main-dashboard-content/main-dashboard-content.component';
|
||||||
|
import { AccDateFormatPipe } from '../../pipe/dtmtodatetime.pipe';
|
||||||
|
import { MainReportComponent } from '../../component/main-report/main-report.component';
|
||||||
|
|
||||||
// import { MainReportComponent } from '../../component/main-report/main-report.component';
|
// import { MainReportComponent } from '../../component/main-report/main-report.component';
|
||||||
|
|
||||||
@@ -16,7 +18,9 @@ import { MainDashboardContentComponent } from '../../content/main-dashboard-cont
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
MainDashboardComponent,
|
MainDashboardComponent,
|
||||||
MainDashboardContentComponent
|
MainDashboardContentComponent,
|
||||||
|
MainReportComponent,
|
||||||
|
AccDateFormatPipe
|
||||||
// MainReportComponent
|
// MainReportComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
@@ -24,6 +28,9 @@ import { MainDashboardContentComponent } from '../../content/main-dashboard-cont
|
|||||||
MainControlRoutingModule,
|
MainControlRoutingModule,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
// BrowserAnimationsModule
|
// BrowserAnimationsModule
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
AccDateFormatPipe
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class MainControlModule { }
|
export class MainControlModule { }
|
||||||
|
|||||||
102
accounting-ng-nuttakit/src/app/interfaces/dashboard.interface.ts
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
export interface IStateDrop {
|
||||||
|
income: IDropAct[];
|
||||||
|
expense: IDropAct[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDropAct {
|
||||||
|
dtlnam?: string,
|
||||||
|
dtlcod?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IActData {
|
||||||
|
actseq?: number,
|
||||||
|
actnum?: number,
|
||||||
|
acttyp?: string,
|
||||||
|
acttypnam?: string,
|
||||||
|
actcatnam?: string,
|
||||||
|
actqty?: number,
|
||||||
|
actcmt?: string,
|
||||||
|
actacpdtm?: string
|
||||||
|
}
|
||||||
|
export interface IStateResultResponse {
|
||||||
|
data: IStateDrop;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IStateResultResponse {
|
||||||
|
data: IStateDrop;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface IActSumData {
|
||||||
|
summary: IActSummary;
|
||||||
|
pie: IActPie;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IActSummary {
|
||||||
|
totalIncome: string;
|
||||||
|
totalExpense: string;
|
||||||
|
netProfit: number;
|
||||||
|
profitRate: string;
|
||||||
|
adjustedProfitRate: string;
|
||||||
|
period: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IActPie {
|
||||||
|
expense: IActCategory[];
|
||||||
|
income: IActCategory[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IActCategory {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
percent: string;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface QuickRatio {
|
||||||
|
label: string;
|
||||||
|
value: string | number;
|
||||||
|
colorClass: string; // ตัวเก็บชื่อ class สี
|
||||||
|
}
|
||||||
|
|
||||||
|
// export
|
||||||
|
// ข้อมูลสินค้าหลัก
|
||||||
|
// export interface IProduct {
|
||||||
|
// id: string;
|
||||||
|
// name: string;
|
||||||
|
// price: number;
|
||||||
|
// category: string;
|
||||||
|
// inStock: boolean;
|
||||||
|
// description?: string; // optional
|
||||||
|
// imageUrl?: string;
|
||||||
|
// tags: string[];
|
||||||
|
// createdAt: Date;
|
||||||
|
// updatedAt: Date;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // ข้อมูลสินค้าแบบย่อ (ใช้ในรายการ)
|
||||||
|
// export interface IProductSummary {
|
||||||
|
// id: string;
|
||||||
|
// name: string;
|
||||||
|
// price: number;
|
||||||
|
// imageUrl?: string;
|
||||||
|
// inStock: boolean;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // ข้อมูลสำหรับฟอร์ม
|
||||||
|
// export interface IProductForm {
|
||||||
|
// name: string;
|
||||||
|
// price: number;
|
||||||
|
// category: string;
|
||||||
|
// description?: string;
|
||||||
|
// inStock: boolean;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // ข้อมูลการจัดหมวดหมู่
|
||||||
|
// export interface IProductCategory {
|
||||||
|
// id: string;
|
||||||
|
// name: string;
|
||||||
|
// parentId?: string;
|
||||||
|
// productCount: number;
|
||||||
|
// }
|
||||||
24
accounting-ng-nuttakit/src/app/pipe/dtmtodatetime.pipe.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'dtmtodatetime',
|
||||||
|
standalone: false
|
||||||
|
})
|
||||||
|
export class AccDateFormatPipe implements PipeTransform {
|
||||||
|
|
||||||
|
transform(value: string | number): string {
|
||||||
|
if (value === null || value === undefined) return '';
|
||||||
|
|
||||||
|
const str = value.toString();
|
||||||
|
if (str.length !== 12) return str;
|
||||||
|
|
||||||
|
const yyyy = str.slice(0, 4);
|
||||||
|
const mm = str.slice(4, 6);
|
||||||
|
const dd = str.slice(6, 8);
|
||||||
|
const hh = str.slice(8, 10);
|
||||||
|
const min = str.slice(10, 12);
|
||||||
|
|
||||||
|
return `${dd}/${mm}/${yyyy} ${hh}:${min}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,12 +1,30 @@
|
|||||||
import { inject } from '@angular/core';
|
import { inject } from '@angular/core';
|
||||||
import { CanActivateFn, Router } from '@angular/router';
|
import { CanActivateFn, Router } from '@angular/router';
|
||||||
|
import { jwtDecode } from 'jwt-decode';
|
||||||
|
|
||||||
export const authGuard: CanActivateFn = (route, state) => {
|
export const authGuard: CanActivateFn = (route, state) => {
|
||||||
const router = inject(Router);
|
const router = inject(Router);
|
||||||
const accessToken = localStorage.getItem('access_token');
|
const accessToken = localStorage.getItem('access_token');
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
return true;
|
try {
|
||||||
|
const decodedToken: any = jwtDecode(accessToken);
|
||||||
|
const currentTime = Date.now() / 1000;
|
||||||
|
|
||||||
|
if (decodedToken.exp < currentTime) {
|
||||||
|
// Token expired
|
||||||
|
localStorage.removeItem('access_token');
|
||||||
|
router.navigate(['/login']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
// Error decoding token
|
||||||
|
localStorage.removeItem('access_token');
|
||||||
|
router.navigate(['/login']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
router.navigate(['/login']);
|
router.navigate(['/login']);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import {
|
||||||
|
HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse
|
||||||
|
} from '@angular/common/http';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { tap } from 'rxjs/operators';
|
||||||
|
import { CachingService } from './caching.service';
|
||||||
|
import { CACHEABLE_URLS } from '../config/caching.config';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CachingInterceptor implements HttpInterceptor {
|
||||||
|
|
||||||
|
constructor(private cache: CachingService) {}
|
||||||
|
|
||||||
|
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
|
if (!this.isCacheable(req)) {
|
||||||
|
return next.handle(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
const cachedResponse = this.cache.get(this.getCacheKey(req));
|
||||||
|
if (cachedResponse) {
|
||||||
|
return of(cachedResponse.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
return next.handle(req).pipe(
|
||||||
|
tap(event => {
|
||||||
|
if (event instanceof HttpResponse) {
|
||||||
|
this.cache.put(this.getCacheKey(req), event.clone());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private isCacheable(req: HttpRequest<any>): boolean {
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
return CACHEABLE_URLS.GET.some(url => req.urlWithParams.includes(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
return CACHEABLE_URLS.POST.some(url => req.urlWithParams.includes(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getCacheKey(req: HttpRequest<any>): string {
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
return req.urlWithParams + JSON.stringify(req.body);
|
||||||
|
}
|
||||||
|
return req.urlWithParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
41
accounting-ng-nuttakit/src/app/services/caching.service.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpResponse } from '@angular/common/http';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CachingService {
|
||||||
|
private cache = new Map<string, [Date, HttpResponse<any>]>();
|
||||||
|
private cacheDurationInMs = 600000; // 5 minutes
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
get(key: string): HttpResponse<any> | null {
|
||||||
|
const tuple = this.cache.get(key);
|
||||||
|
if (!tuple) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const expires = tuple[0];
|
||||||
|
const httpResponse = tuple[1];
|
||||||
|
|
||||||
|
// Don't observe expired keys
|
||||||
|
const now = new Date();
|
||||||
|
if (expires && expires.getTime() < now.getTime()) {
|
||||||
|
this.cache.delete(key);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
put(key: string, value: HttpResponse<any>): void {
|
||||||
|
const expires = new Date();
|
||||||
|
expires.setMilliseconds(expires.getMilliseconds() + this.cacheDurationInMs);
|
||||||
|
this.cache.set(key, [expires, value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.cache.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,8 +54,14 @@ export class GeneralService {
|
|||||||
return this.http.post(fullUrl, payload, this.getHttpOptions()).pipe(
|
return this.http.post(fullUrl, payload, this.getHttpOptions()).pipe(
|
||||||
map((res: any) => res),
|
map((res: any) => res),
|
||||||
catchError((error: any) => {
|
catchError((error: any) => {
|
||||||
|
const response = error?.error;
|
||||||
console.error('❌ [POST Request Error]:', error);
|
console.error('❌ [POST Request Error]:', error);
|
||||||
return throwError(() => error);
|
return throwError(() => ({
|
||||||
|
status: error.status,
|
||||||
|
code: response?.code ?? '500',
|
||||||
|
message: response?.message ?? 'Internal Server Error',
|
||||||
|
message_th: response?.message_th ?? 'เกิดข้อผิดพลาดภายในเซิร์ฟเวอร์'
|
||||||
|
}));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -66,9 +72,14 @@ export class GeneralService {
|
|||||||
return this.http.get(fullUrl, this.getHttpOptions()).pipe(
|
return this.http.get(fullUrl, this.getHttpOptions()).pipe(
|
||||||
map((res: any) => res),
|
map((res: any) => res),
|
||||||
catchError((error: any) => {
|
catchError((error: any) => {
|
||||||
|
const response = error?.error;
|
||||||
console.error('❌ [GET Request Error]:', error);
|
console.error('❌ [GET Request Error]:', error);
|
||||||
return throwError(() => error);
|
return throwError(() => ({
|
||||||
})
|
status: error.status,
|
||||||
|
code: response?.code ?? '500',
|
||||||
|
message: response?.message ?? 'Internal Server Error',
|
||||||
|
message_th: response?.message_th ?? 'เกิดข้อผิดพลาดภายในเซิร์ฟเวอร์'
|
||||||
|
})); })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
|
import { IDropAct, IStateDrop, IActData, IActSumData } from '../../interfaces/dashboard.interface';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class DashboardStateService {
|
||||||
|
// ประกาศ BehaviorSubject ด้วย Interface
|
||||||
|
private dashboardState = new BehaviorSubject<IStateDrop | null>(null);
|
||||||
|
private accounttingState = new BehaviorSubject<IActData[] | null>(null);
|
||||||
|
private actsumState = new BehaviorSubject<IActSumData | null>(null);
|
||||||
|
|
||||||
|
// ส่ง Observable ไปให้ components subscribe
|
||||||
|
getStateResult(): Observable<IStateDrop | null> {
|
||||||
|
return this.dashboardState.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// เซ็ท state
|
||||||
|
setStateResult(dashboard: IStateDrop): void {
|
||||||
|
this.dashboardState.next(dashboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setStateAccountResult(dashboard: IActData[]): void {
|
||||||
|
this.accounttingState.next(dashboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setStateSumResult(sumResult: IActSumData): void {
|
||||||
|
this.actsumState.next(sumResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
// เคลียร์ state
|
||||||
|
clearState(): void {
|
||||||
|
this.dashboardState.next(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
getStateAccountResult(): Observable<IActData[] | null> {
|
||||||
|
return this.accounttingState.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
getStateSumResult(): Observable<IActSumData | null> {
|
||||||
|
return this.actsumState.asObservable();
|
||||||
|
}
|
||||||
|
// ดึงค่า current state (ไม่ใช่ observable)
|
||||||
|
// getCurrentState(): IDropAct | null {
|
||||||
|
// return this.dashboardState.value;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
|
// apiBaseUrl: 'https://bread-leader-move-created.trycloudflare.com'
|
||||||
|
|
||||||
|
|
||||||
apiBaseUrl: 'http://localhost:8000'
|
apiBaseUrl: 'http://localhost:8000'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: true,
|
||||||
apiBaseUrl: 'https://api.nuttakit.work'
|
apiBaseUrl: 'https://api.nuttakit.work'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>AccountingNgNuttakit</title>
|
<title>SmartAccount</title>
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
|
|||||||
@@ -12,10 +12,15 @@
|
|||||||
z-index: 999999 !important;
|
z-index: 999999 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input::placeholder{
|
||||||
|
color: #9aa3ad;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure the page and app root occupy full height so 100vh aligns */
|
/* Make sure the page and app root occupy full height so 100vh aligns */
|
||||||
html, body, app-root {
|
html, body, app-root {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
/* เริ่มต้น: สำหรับ Desktop */
|
/* เริ่มต้น: สำหรับ Desktop */
|
||||||
.login-mobile {
|
.login-mobile {
|
||||||
|
|||||||
553
comunicate-demo/index.html
Normal file
@@ -0,0 +1,553 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>TTC Communication Client</title>
|
||||||
|
|
||||||
|
<!-- Tailwind CSS -->
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
|
||||||
|
<!-- Socket.io Client -->
|
||||||
|
<script src="https://cdn.socket.io/4.7.4/socket.io.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Icons -->
|
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
tailwind.config = {
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
primary: '#4F46E5', // Indigo 600
|
||||||
|
secondary: '#10B981', // Emerald 500
|
||||||
|
danger: '#EF4444', // Red 500
|
||||||
|
dark: '#1F2937' // Gray 800
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
/* Custom Scrollbar */
|
||||||
|
::-webkit-scrollbar { width: 8px; }
|
||||||
|
::-webkit-scrollbar-track { background: #f1f1f1; }
|
||||||
|
::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
|
||||||
|
::-webkit-scrollbar-thumb:hover { background: #555; }
|
||||||
|
|
||||||
|
.video-container {
|
||||||
|
transform: scaleX(-1); /* Mirror effect for self view */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="bg-gray-100 min-h-screen text-gray-800 font-sans">
|
||||||
|
|
||||||
|
<!-- Navbar -->
|
||||||
|
<nav class="bg-white shadow-sm border-b border-gray-200 px-6 py-4 flex justify-between items-center">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="bg-primary text-white p-2 rounded-lg">
|
||||||
|
<i class="fa-solid fa-network-wired"></i>
|
||||||
|
</div>
|
||||||
|
<h1 class="font-bold text-xl text-gray-700">TTC Microservice <span class="text-xs font-normal bg-gray-200 px-2 py-0.5 rounded text-gray-500">Demo Client</span></h1>
|
||||||
|
</div>
|
||||||
|
<div id="connectionStatus" class="flex items-center gap-2 text-sm text-red-500 font-medium">
|
||||||
|
<div class="w-2 h-2 rounded-full bg-red-500 animate-pulse"></div>
|
||||||
|
Disconnected
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container mx-auto p-6 max-w-6xl grid grid-cols-1 lg:grid-cols-12 gap-6">
|
||||||
|
|
||||||
|
<!-- LEFT PANEL: Config & Notify -->
|
||||||
|
<div class="lg:col-span-4 space-y-6">
|
||||||
|
|
||||||
|
<!-- 1. Authentication -->
|
||||||
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-5">
|
||||||
|
<h2 class="text-lg font-bold mb-4 flex items-center gap-2 text-gray-700">
|
||||||
|
<i class="fa-solid fa-key text-primary"></i> Authentication
|
||||||
|
</h2>
|
||||||
|
<div class="space-y-3">
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase">Server URL</label>
|
||||||
|
<!-- [FIX] เปลี่ยนค่าเริ่มต้นให้ว่างไว้ เดี๋ยว Script จะเติมให้เองตาม Context -->
|
||||||
|
<input type="text" id="serverUrl"
|
||||||
|
class="w-full mt-1 p-2 bg-gray-50 border border-gray-300 rounded focus:ring-2 focus:ring-primary focus:outline-none transition-all"
|
||||||
|
placeholder="Auto-detected..." value=" https://entrepreneur-faced-browsing-gateway.trycloudflare.com">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase">JWT Token</label>
|
||||||
|
<textarea id="jwtToken" rows="2" class="w-full mt-1 p-2 bg-gray-50 border border-gray-300 rounded focus:ring-2 focus:ring-primary focus:outline-none text-xs font-mono" placeholder="Paste your Bearer token here..."></textarea>
|
||||||
|
</div>
|
||||||
|
<button id="btnConnect" class="w-full bg-primary hover:bg-indigo-700 text-white font-medium py-2 rounded transition-colors shadow-sm flex justify-center items-center gap-2">
|
||||||
|
<i class="fa-solid fa-link"></i> Connect Socket
|
||||||
|
</button>
|
||||||
|
<div id="userInfoDisplay" class="hidden mt-2 p-2 bg-indigo-50 text-indigo-700 text-xs rounded border border-indigo-100">
|
||||||
|
<!-- User info will show here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 2. Notification System -->
|
||||||
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-5 flex flex-col h-[500px]">
|
||||||
|
<h2 class="text-lg font-bold mb-4 flex items-center gap-2 text-gray-700">
|
||||||
|
<i class="fa-solid fa-bell text-secondary"></i> Notification
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<!-- Notify Form -->
|
||||||
|
<div class="space-y-3 mb-4 p-3 bg-gray-50 rounded-lg border border-gray-200">
|
||||||
|
<input type="text" id="notifyTargetId" class="w-full p-2 text-sm border border-gray-300 rounded" placeholder="Target User ID (seq)">
|
||||||
|
<input type="text" id="notifyTitle" class="w-full p-2 text-sm border border-gray-300 rounded" placeholder="Topic / Title">
|
||||||
|
<input type="text" id="notifyMessage" class="w-full p-2 text-sm border border-gray-300 rounded" placeholder="Message body...">
|
||||||
|
<button id="btnSendNotify" class="w-full bg-secondary hover:bg-emerald-600 text-white text-sm font-medium py-2 rounded transition-colors">
|
||||||
|
Send Realtime Notify
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Notify Logs -->
|
||||||
|
<div class="flex-1 overflow-y-auto space-y-2 pr-1" id="notifyLogs">
|
||||||
|
<div class="text-center text-gray-400 text-xs mt-10">No notifications yet</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- RIGHT PANEL: VoIP -->
|
||||||
|
<div class="lg:col-span-8">
|
||||||
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-5 h-full flex flex-col">
|
||||||
|
<h2 class="text-lg font-bold mb-4 flex items-center gap-2 text-gray-700 border-b pb-3">
|
||||||
|
<i class="fa-solid fa-video text-pink-500"></i> Video Conference / VoIP
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<!-- Control Bar -->
|
||||||
|
<div class="flex flex-wrap gap-3 mb-4 items-end bg-gray-50 p-3 rounded-lg">
|
||||||
|
<div class="flex-1">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase">Call To (User ID)</label>
|
||||||
|
<div class="flex gap-2 mt-1">
|
||||||
|
<input type="text" id="callTargetId" class="flex-1 p-2 border border-gray-300 rounded focus:ring-2 focus:ring-pink-500 focus:outline-none" placeholder="User ID...">
|
||||||
|
<button id="btnCall" class="bg-pink-500 hover:bg-pink-600 text-white px-4 py-2 rounded shadow-sm flex items-center gap-2 transition-colors">
|
||||||
|
<i class="fa-solid fa-phone"></i> Call
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button id="btnHangup" class="hidden bg-red-500 hover:bg-red-600 text-white px-6 py-2 rounded shadow-sm flex items-center gap-2 transition-colors">
|
||||||
|
<i class="fa-solid fa-phone-slash"></i> Hangup
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Incoming Call Alert (Modal-ish) -->
|
||||||
|
<div id="incomingCallAlert" class="hidden mb-4 bg-yellow-50 border border-yellow-200 rounded-lg p-4 flex justify-between items-center shadow-sm animate-bounce">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="bg-yellow-100 p-2 rounded-full text-yellow-600">
|
||||||
|
<i class="fa-solid fa-phone-volume fa-lg"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-bold text-gray-800">Incoming Call...</h3>
|
||||||
|
<p class="text-sm text-gray-500">From User: <span id="callerNameDisplay" class="font-mono text-black">Unknown</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<button id="btnAccept" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded shadow text-sm font-bold">
|
||||||
|
Accept
|
||||||
|
</button>
|
||||||
|
<button id="btnReject" class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded shadow text-sm font-bold">
|
||||||
|
Reject
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Video Area -->
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 flex-1 min-h-[400px]">
|
||||||
|
<!-- Local -->
|
||||||
|
<div class="relative bg-gray-900 rounded-xl overflow-hidden shadow-inner group">
|
||||||
|
<video id="localVideo" autoplay playsinline muted class="w-full h-full object-cover video-container opacity-50"></video>
|
||||||
|
<div class="absolute bottom-4 left-4 text-white text-xs bg-black/50 px-2 py-1 rounded backdrop-blur-sm">
|
||||||
|
You (Local)
|
||||||
|
</div>
|
||||||
|
<div class="absolute inset-0 flex items-center justify-center text-gray-500 group-hover:hidden" id="localPlaceholder">
|
||||||
|
<div class="text-center">
|
||||||
|
<i class="fa-solid fa-camera-slash fa-2x mb-2"></i>
|
||||||
|
<p class="text-xs">Camera Off</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Remote -->
|
||||||
|
<div class="relative bg-gray-900 rounded-xl overflow-hidden shadow-inner">
|
||||||
|
<video id="remoteVideo" autoplay playsinline class="w-full h-full object-cover"></video>
|
||||||
|
<div class="absolute bottom-4 left-4 text-white text-xs bg-black/50 px-2 py-1 rounded backdrop-blur-sm">
|
||||||
|
Remote User
|
||||||
|
</div>
|
||||||
|
<div class="absolute inset-0 flex items-center justify-center text-gray-600" id="remotePlaceholder">
|
||||||
|
<div class="text-center">
|
||||||
|
<i class="fa-solid fa-user-slash fa-2x mb-2"></i>
|
||||||
|
<p class="text-xs">Waiting for connection...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- MAIN SCRIPT -->
|
||||||
|
<script type="module">
|
||||||
|
/** * TTC Client Logic
|
||||||
|
* Implements Socket.io & WebRTC Standard
|
||||||
|
*/
|
||||||
|
|
||||||
|
// --- State ---
|
||||||
|
let socket = null;
|
||||||
|
let myStream = null;
|
||||||
|
let peerConnection = null;
|
||||||
|
let incomingSignal = null; // Store offer temporarily
|
||||||
|
let activeCallUser = null;
|
||||||
|
let myUserId = null;
|
||||||
|
|
||||||
|
// --- Config ---
|
||||||
|
const rtcConfig = {
|
||||||
|
iceServers: [
|
||||||
|
{ urls: 'stun:stun.l.google.com:19302' },
|
||||||
|
// { urls: 'stun:global.stun.twilio.com:3478' }
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- DOM Elements ---
|
||||||
|
const els = {
|
||||||
|
serverUrl: document.getElementById('serverUrl'),
|
||||||
|
jwtToken: document.getElementById('jwtToken'),
|
||||||
|
btnConnect: document.getElementById('btnConnect'),
|
||||||
|
status: document.getElementById('connectionStatus'),
|
||||||
|
userInfo: document.getElementById('userInfoDisplay'),
|
||||||
|
|
||||||
|
// Notify
|
||||||
|
notifyTarget: document.getElementById('notifyTargetId'),
|
||||||
|
notifyTitle: document.getElementById('notifyTitle'),
|
||||||
|
notifyMsg: document.getElementById('notifyMessage'),
|
||||||
|
btnSendNotify: document.getElementById('btnSendNotify'),
|
||||||
|
notifyLogs: document.getElementById('notifyLogs'),
|
||||||
|
|
||||||
|
// VoIP
|
||||||
|
callTarget: document.getElementById('callTargetId'),
|
||||||
|
btnCall: document.getElementById('btnCall'),
|
||||||
|
btnHangup: document.getElementById('btnHangup'),
|
||||||
|
incomingAlert: document.getElementById('incomingCallAlert'),
|
||||||
|
callerName: document.getElementById('callerNameDisplay'),
|
||||||
|
btnAccept: document.getElementById('btnAccept'),
|
||||||
|
btnReject: document.getElementById('btnReject'),
|
||||||
|
|
||||||
|
localVideo: document.getElementById('localVideo'),
|
||||||
|
remoteVideo: document.getElementById('remoteVideo'),
|
||||||
|
localPlace: document.getElementById('localPlaceholder'),
|
||||||
|
remotePlace: document.getElementById('remotePlaceholder'),
|
||||||
|
};
|
||||||
|
|
||||||
|
// [FIX] Auto-populate Server URL to avoid Mixed Content Error
|
||||||
|
// ถ้าเข้าผ่าน https (ngrok) มันจะใช้ https ตามอัตโนมัติ
|
||||||
|
// window.onload = () => {
|
||||||
|
// els.serverUrl.value = window.location.origin;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// --- 1. Connection Logic ---
|
||||||
|
els.btnConnect.addEventListener('click', () => {
|
||||||
|
const url = els.serverUrl.value;
|
||||||
|
const token = els.jwtToken.value.trim();
|
||||||
|
|
||||||
|
//if (!token) return alert('Please enter a JWT Token');
|
||||||
|
|
||||||
|
// [FIX] Initialize Socket with Secure Options
|
||||||
|
// window.location.origin จะแก้ปัญหา Mixed Content เพราะมันจะใช้ protocol เดียวกับหน้าเว็บ
|
||||||
|
socket = io(url, {
|
||||||
|
auth: { token: token },
|
||||||
|
transports: ['websocket', 'polling'], // เพิ่ม polling เพื่อความชัวร์ในบาง network
|
||||||
|
secure: true, // Force secure connection
|
||||||
|
rejectUnauthorized: false // ยอมรับ Self-signed cert กรณีเทส local
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle Connection Events
|
||||||
|
socket.on('connect', () => {
|
||||||
|
updateStatus(true);
|
||||||
|
console.log('✅ Connected:', socket.id);
|
||||||
|
// Decode token roughly to show ID (Optional)
|
||||||
|
try {
|
||||||
|
const payload = JSON.parse(atob(token.split('.')[1]));
|
||||||
|
myUserId = payload.id;
|
||||||
|
els.userInfo.innerHTML = `Signed in as: <b>${payload.usrnam}</b> (ID: ${payload.id})`;
|
||||||
|
els.userInfo.classList.remove('hidden');
|
||||||
|
} catch(e) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('disconnect', () => {
|
||||||
|
updateStatus(false);
|
||||||
|
console.log('❌ Disconnected');
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('connect_error', (err) => {
|
||||||
|
updateStatus(false);
|
||||||
|
console.error('Socket Error:', err);
|
||||||
|
alert('Connection Failed: ' + err.message + '\n(Check Mixed Content/CORS in Console)');
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Register Listeners ---
|
||||||
|
setupNotificationListeners();
|
||||||
|
setupVoIPListeners();
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateStatus(isConnected) {
|
||||||
|
if(isConnected) {
|
||||||
|
els.status.innerHTML = `<div class="w-2 h-2 rounded-full bg-green-500"></div> Connected`;
|
||||||
|
els.status.className = "flex items-center gap-2 text-sm text-green-600 font-bold";
|
||||||
|
els.btnConnect.disabled = true;
|
||||||
|
els.btnConnect.innerText = "Connected";
|
||||||
|
els.btnConnect.classList.add('bg-gray-400', 'cursor-not-allowed');
|
||||||
|
} else {
|
||||||
|
els.status.innerHTML = `<div class="w-2 h-2 rounded-full bg-red-500 animate-pulse"></div> Disconnected`;
|
||||||
|
els.status.className = "flex items-center gap-2 text-sm text-red-500 font-medium";
|
||||||
|
els.btnConnect.disabled = false;
|
||||||
|
els.btnConnect.innerText = "Connect Socket";
|
||||||
|
els.btnConnect.classList.remove('bg-gray-400', 'cursor-not-allowed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 2. Notification Logic ---
|
||||||
|
function setupNotificationListeners() {
|
||||||
|
// Sending
|
||||||
|
els.btnSendNotify.addEventListener('click', () => {
|
||||||
|
if(!socket) return alert("Not connected");
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
targetUserId: els.notifyTarget.value,
|
||||||
|
title: els.notifyTitle.value,
|
||||||
|
message: els.notifyMsg.value,
|
||||||
|
type: 'info'
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.emit('send_notification', data);
|
||||||
|
addNotifyLog('outgoing', `To ${data.targetUserId}: ${data.title}`);
|
||||||
|
els.notifyMsg.value = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Receiving
|
||||||
|
socket.on('receive_notification', (data) => {
|
||||||
|
addNotifyLog('incoming', `From ${data.from}: ${data.title} - ${data.message}`);
|
||||||
|
// Play sound if needed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addNotifyLog(type, text) {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
const time = new Date().toLocaleTimeString('th-TH', { hour: '2-digit', minute:'2-digit'});
|
||||||
|
|
||||||
|
if(type === 'incoming') {
|
||||||
|
div.className = "bg-white border-l-4 border-secondary p-3 rounded shadow-sm text-sm";
|
||||||
|
div.innerHTML = `<div class="flex justify-between text-xs text-gray-400 mb-1"><span>Incoming</span> <span>${time}</span></div>
|
||||||
|
<div class="text-gray-700">${text}</div>`;
|
||||||
|
} else {
|
||||||
|
div.className = "bg-gray-50 border-l-4 border-gray-300 p-3 rounded text-sm";
|
||||||
|
div.innerHTML = `<div class="flex justify-between text-xs text-gray-400 mb-1"><span>Sent</span> <span>${time}</span></div>
|
||||||
|
<div class="text-gray-600">${text}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
els.notifyLogs.prepend(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 3. VoIP / WebRTC Logic ---
|
||||||
|
async function getLocalStream() {
|
||||||
|
try {
|
||||||
|
// [FIX] ใช้ constraints แบบง่าย เพื่อลดโอกาสเกิด OverconstrainedError
|
||||||
|
const stream = await navigator.mediaDevices.getUserMedia({
|
||||||
|
video: true,
|
||||||
|
audio: { echoCancellation: true, noiseSuppression: true }
|
||||||
|
});
|
||||||
|
myStream = stream;
|
||||||
|
els.localVideo.srcObject = stream;
|
||||||
|
els.localVideo.classList.remove('opacity-50');
|
||||||
|
els.localPlace.classList.add('hidden');
|
||||||
|
return stream;
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Media Error:", err);
|
||||||
|
|
||||||
|
let msg = "Cannot access Camera/Microphone.";
|
||||||
|
if(location.protocol !== 'https:' && location.hostname !== 'localhost') {
|
||||||
|
msg += " (Browser requires HTTPS or Localhost)";
|
||||||
|
} else {
|
||||||
|
msg += " " + err.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
alert(msg);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPeerConnection(targetId) {
|
||||||
|
const pc = new RTCPeerConnection(rtcConfig);
|
||||||
|
|
||||||
|
// Add local tracks
|
||||||
|
if(myStream) {
|
||||||
|
myStream.getTracks().forEach(track => pc.addTrack(track, myStream));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle ICE Candidates
|
||||||
|
pc.onicecandidate = (event) => {
|
||||||
|
if (event.candidate) {
|
||||||
|
socket.emit('send_ice_candidate', {
|
||||||
|
targetUserId: targetId,
|
||||||
|
candidate: event.candidate
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle Remote Stream
|
||||||
|
pc.ontrack = (event) => {
|
||||||
|
const [remoteStream] = event.streams;
|
||||||
|
els.remoteVideo.srcObject = remoteStream;
|
||||||
|
els.remotePlace.classList.add('hidden');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Connection State Changes
|
||||||
|
pc.onconnectionstatechange = () => {
|
||||||
|
console.log("Peer State:", pc.connectionState);
|
||||||
|
if(pc.connectionState === 'disconnected' || pc.connectionState === 'failed') {
|
||||||
|
hangupUI();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupVoIPListeners() {
|
||||||
|
|
||||||
|
// --- A. Caller Logic ---
|
||||||
|
els.btnCall.addEventListener('click', async () => {
|
||||||
|
const target = els.callTarget.value;
|
||||||
|
if(!target || !socket) return;
|
||||||
|
|
||||||
|
activeCallUser = target;
|
||||||
|
|
||||||
|
// 1. Get Media
|
||||||
|
const stream = await getLocalStream();
|
||||||
|
if (!stream) return; // Exit if media failed
|
||||||
|
|
||||||
|
// 2. Create PC
|
||||||
|
peerConnection = createPeerConnection(target);
|
||||||
|
|
||||||
|
// 3. Create Offer
|
||||||
|
const offer = await peerConnection.createOffer();
|
||||||
|
await peerConnection.setLocalDescription(offer);
|
||||||
|
|
||||||
|
// 4. Send Signal
|
||||||
|
socket.emit('call_user', {
|
||||||
|
userToCall: target,
|
||||||
|
signalData: offer
|
||||||
|
});
|
||||||
|
|
||||||
|
uiCallingState();
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- B. Callee Logic (Incoming) ---
|
||||||
|
socket.on('call_incoming', (data) => {
|
||||||
|
incomingSignal = data.signal;
|
||||||
|
activeCallUser = data.from; // Store who is calling
|
||||||
|
els.callerName.innerText = `ID: ${data.from}`;
|
||||||
|
|
||||||
|
els.incomingAlert.classList.remove('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
els.btnAccept.addEventListener('click', async () => {
|
||||||
|
els.incomingAlert.classList.add('hidden');
|
||||||
|
|
||||||
|
// 1. Get Media
|
||||||
|
const stream = await getLocalStream();
|
||||||
|
if (!stream) return;
|
||||||
|
|
||||||
|
// 2. Create PC
|
||||||
|
peerConnection = createPeerConnection(activeCallUser);
|
||||||
|
|
||||||
|
// 3. Set Remote Desc (Offer)
|
||||||
|
await peerConnection.setRemoteDescription(incomingSignal);
|
||||||
|
|
||||||
|
// 4. Create Answer
|
||||||
|
const answer = await peerConnection.createAnswer();
|
||||||
|
await peerConnection.setLocalDescription(answer);
|
||||||
|
|
||||||
|
// 5. Send Answer
|
||||||
|
socket.emit('answer_call', {
|
||||||
|
to: activeCallUser,
|
||||||
|
signal: answer
|
||||||
|
});
|
||||||
|
|
||||||
|
uiConnectedState();
|
||||||
|
});
|
||||||
|
|
||||||
|
els.btnReject.addEventListener('click', () => {
|
||||||
|
els.incomingAlert.classList.add('hidden');
|
||||||
|
// Optional: Send reject signal
|
||||||
|
hangupUI();
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- C. Connection Establishment ---
|
||||||
|
socket.on('call_accepted', async (data) => {
|
||||||
|
// Caller receives Answer
|
||||||
|
await peerConnection.setRemoteDescription(data.signal);
|
||||||
|
uiConnectedState();
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('receive_ice_candidate', async (data) => {
|
||||||
|
if(peerConnection) {
|
||||||
|
try {
|
||||||
|
await peerConnection.addIceCandidate(data.candidate);
|
||||||
|
} catch(e) {
|
||||||
|
console.warn("ICE Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- D. Hangup ---
|
||||||
|
els.btnHangup.addEventListener('click', () => {
|
||||||
|
socket.emit('end_call', { targetUserId: activeCallUser });
|
||||||
|
hangupUI();
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('call_ended', () => {
|
||||||
|
alert("Call Ended by remote user");
|
||||||
|
hangupUI();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- UI Helpers ---
|
||||||
|
function uiCallingState() {
|
||||||
|
els.btnCall.disabled = true;
|
||||||
|
els.btnCall.innerHTML = `<i class="fa-solid fa-spinner fa-spin"></i> Calling...`;
|
||||||
|
els.btnHangup.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function uiConnectedState() {
|
||||||
|
els.btnCall.classList.add('hidden');
|
||||||
|
els.btnHangup.classList.remove('hidden');
|
||||||
|
els.incomingAlert.classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hangupUI() {
|
||||||
|
if(peerConnection) peerConnection.close();
|
||||||
|
if(myStream) myStream.getTracks().forEach(t => t.stop());
|
||||||
|
|
||||||
|
peerConnection = null;
|
||||||
|
myStream = null;
|
||||||
|
activeCallUser = null;
|
||||||
|
incomingSignal = null;
|
||||||
|
|
||||||
|
els.localVideo.srcObject = null;
|
||||||
|
els.remoteVideo.srcObject = null;
|
||||||
|
els.localPlace.classList.remove('hidden');
|
||||||
|
els.remotePlace.classList.remove('hidden');
|
||||||
|
|
||||||
|
els.btnCall.disabled = false;
|
||||||
|
els.btnCall.classList.remove('hidden');
|
||||||
|
els.btnCall.innerHTML = `<i class="fa-solid fa-phone"></i> Call`;
|
||||||
|
els.btnHangup.classList.add('hidden');
|
||||||
|
els.incomingAlert.classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
26
comunicate-demo/index.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// 1. สร้างไฟล์นี้ในโฟลเดอร์เดียวกับ index.html
|
||||||
|
// 2. รันคำสั่ง: npm install express (ถ้ายังไม่มี)
|
||||||
|
// 3. สตาร์ทเซิร์ฟเวอร์: node server_frontend.js
|
||||||
|
|
||||||
|
const express = require('express');
|
||||||
|
const path = require('path');
|
||||||
|
const app = express();
|
||||||
|
const PORT = 80; // พอร์ตสำหรับหน้าเว็บ (แยกกับ API 1011)
|
||||||
|
|
||||||
|
// ให้บริการไฟล์ Static ในโฟลเดอร์ปัจจุบัน
|
||||||
|
app.use(express.static(path.join(__dirname)));
|
||||||
|
|
||||||
|
// Route หลักส่ง index.html
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.sendFile(path.join(__dirname, 'index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// สั่งให้ Listen ทุก IP ในเครื่อง (0.0.0.0)
|
||||||
|
app.listen(PORT, '0.0.0.0', () => {
|
||||||
|
console.log('---------------------------------------------------');
|
||||||
|
console.log(`🚀 Frontend Server running!`);
|
||||||
|
console.log(`🏠 Local: http://localhost:${PORT}`);
|
||||||
|
console.log(`📡 Network: http://<YOUR_IP_ADDRESS>:${PORT}`);
|
||||||
|
console.log('---------------------------------------------------');
|
||||||
|
console.log('To find your IP: Run "ipconfig" (Windows) or "ifconfig" (Mac/Linux)');
|
||||||
|
});
|
||||||
17
comunicate-demo/package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "comunicate-demo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"type": "commonjs",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^5.1.0",
|
||||||
|
"path": "^0.12.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
listen-pipe.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
trap "rm -f $HOME/execpipe" EXIT
|
||||||
|
trap "rm -f $HOME/execpipe" ERR
|
||||||
|
|
||||||
|
mkfifo $HOME/execpipe
|
||||||
|
while true; do eval "$(cat $HOME/execpipe)"; done
|
||||||
17
ng-ttc-frontend/.editorconfig
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Editor configuration, see https://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.ts]
|
||||||
|
quote_type = single
|
||||||
|
ij_typescript_use_double_quotes = false
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
||||||
43
ng-ttc-frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
|
||||||
|
|
||||||
|
# Compiled output
|
||||||
|
/dist
|
||||||
|
/tmp
|
||||||
|
/out-tsc
|
||||||
|
/bazel-out
|
||||||
|
/.angular
|
||||||
|
|
||||||
|
# Node
|
||||||
|
/node_moduless
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
.idea/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.history/*
|
||||||
|
|
||||||
|
# Miscellaneous
|
||||||
|
/.angular/cache
|
||||||
|
.sass-cache/
|
||||||
|
/connect.lock
|
||||||
|
/coverage
|
||||||
|
/libpeerconnection.log
|
||||||
|
testem.log
|
||||||
|
/typings
|
||||||
|
|
||||||
|
# System files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
5
ng-ttc-frontend/.postcssrc.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"@tailwindcss/postcss": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
ng-ttc-frontend/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
|
||||||
|
"recommendations": ["angular.ng-template"]
|
||||||
|
}
|
||||||
33
ng-ttc-frontend/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// {
|
||||||
|
// // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
// "version": "0.2.0",
|
||||||
|
// "configurations": [
|
||||||
|
// {
|
||||||
|
// "name": "ng serve",
|
||||||
|
// "type": "chrome",
|
||||||
|
// "request": "launch",
|
||||||
|
// "preLaunchTask": "npm: start",
|
||||||
|
// "url": "http://localhost:4200/"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "name": "ng test",
|
||||||
|
// "type": "chrome",
|
||||||
|
// "request": "launch",
|
||||||
|
// "preLaunchTask": "npm: test",
|
||||||
|
// "url": "http://localhost:9876/debug.html"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Launch Chrome against localhost",
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"url": "http://localhost:4200",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
42
ng-ttc-frontend/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "start",
|
||||||
|
"isBackground": true,
|
||||||
|
"problemMatcher": {
|
||||||
|
"owner": "typescript",
|
||||||
|
"pattern": "$tsc",
|
||||||
|
"background": {
|
||||||
|
"activeOnStart": true,
|
||||||
|
"beginsPattern": {
|
||||||
|
"regexp": "(.*?)"
|
||||||
|
},
|
||||||
|
"endsPattern": {
|
||||||
|
"regexp": "bundle generation complete"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "test",
|
||||||
|
"isBackground": true,
|
||||||
|
"problemMatcher": {
|
||||||
|
"owner": "typescript",
|
||||||
|
"pattern": "$tsc",
|
||||||
|
"background": {
|
||||||
|
"activeOnStart": true,
|
||||||
|
"beginsPattern": {
|
||||||
|
"regexp": "(.*?)"
|
||||||
|
},
|
||||||
|
"endsPattern": {
|
||||||
|
"regexp": "bundle generation complete"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
59
ng-ttc-frontend/README.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# NgTtcFrontend
|
||||||
|
|
||||||
|
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.7.
|
||||||
|
|
||||||
|
## Development server
|
||||||
|
|
||||||
|
To start a local development server, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng serve
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
|
||||||
|
|
||||||
|
## Code scaffolding
|
||||||
|
|
||||||
|
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng generate component component-name
|
||||||
|
```
|
||||||
|
|
||||||
|
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng generate --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
To build the project run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng build
|
||||||
|
```
|
||||||
|
|
||||||
|
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running end-to-end tests
|
||||||
|
|
||||||
|
For end-to-end (e2e) testing, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng e2e
|
||||||
|
```
|
||||||
|
|
||||||
|
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
||||||
130
ng-ttc-frontend/angular.json
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"version": 1,
|
||||||
|
"newProjectRoot": "projects",
|
||||||
|
"projects": {
|
||||||
|
"ng-ttc-frontend": {
|
||||||
|
"projectType": "application",
|
||||||
|
"schematics": {
|
||||||
|
"@schematics/angular:component": {
|
||||||
|
"standalone": false
|
||||||
|
},
|
||||||
|
"@schematics/angular:directive": {
|
||||||
|
"standalone": false
|
||||||
|
},
|
||||||
|
"@schematics/angular:pipe": {
|
||||||
|
"standalone": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"prefix": "app",
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular/build:application",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "dist/ng-ttc-frontend",
|
||||||
|
"index": "src/index.html",
|
||||||
|
"browser": "src/main.ts",
|
||||||
|
"polyfills": [
|
||||||
|
"zone.js"
|
||||||
|
],
|
||||||
|
"tsConfig": "tsconfig.app.json",
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
||||||
|
"src/styles.css"
|
||||||
|
],
|
||||||
|
"scripts": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.development.ts",
|
||||||
|
"with": "src/environments/environment.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "1MB",
|
||||||
|
"maximumError": "2MB"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kB",
|
||||||
|
"maximumError": "10kB"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputHashing": "all"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"optimization": false,
|
||||||
|
"extractLicenses": false,
|
||||||
|
"sourceMap": true,
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.development.ts"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultConfiguration": "production"
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"builder": "@angular/build:dev-server",
|
||||||
|
"options": {
|
||||||
|
"host": "0.0.0.0",
|
||||||
|
"allowedHosts": ["localhost"]
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"buildTarget": "ng-ttc-frontend:build:production"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"buildTarget": "ng-ttc-frontend:build:development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultConfiguration": "development"
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular/build:extract-i18n"
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular/build:karma",
|
||||||
|
"options": {
|
||||||
|
"polyfills": [
|
||||||
|
"zone.js",
|
||||||
|
"zone.js/testing"
|
||||||
|
],
|
||||||
|
"tsConfig": "tsconfig.spec.json",
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
|
||||||
|
"src/styles.css"
|
||||||
|
],
|
||||||
|
"scripts": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cli": {
|
||||||
|
"analytics": false
|
||||||
|
}
|
||||||
|
}
|
||||||
21238
ng-ttc-frontend/package-lock.json
generated
Normal file
91
ng-ttc-frontend/package.json
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"name": "ng-ttc-frontend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "electron/main.js",
|
||||||
|
"author": "Nuttakit",
|
||||||
|
"scripts": {
|
||||||
|
"ng": "ng",
|
||||||
|
"start": "ng serve",
|
||||||
|
"build": "ng build",
|
||||||
|
"watch": "ng build --watch --configuration development",
|
||||||
|
"test": "ng test",
|
||||||
|
"electron": "ng build --base-href ./ && electron .",
|
||||||
|
"dist": "ng build --configuration production && electron-builder"
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"appId": "accounting.nuttakit.work",
|
||||||
|
"productName": "accounting-nuttakit",
|
||||||
|
"asar": false,
|
||||||
|
"directories": {
|
||||||
|
"output": "dist_electron"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist/ng-ttc-frontend/browser/**/*",
|
||||||
|
"electron/**/*",
|
||||||
|
"!node_modules/@capacitor/android/**/*"
|
||||||
|
],
|
||||||
|
"win": {
|
||||||
|
"target": [
|
||||||
|
"nsis",
|
||||||
|
"msi"
|
||||||
|
],
|
||||||
|
"icon": "public/favicon.ico"
|
||||||
|
},
|
||||||
|
"nsis": {
|
||||||
|
"oneClick": false,
|
||||||
|
"perMachine": true,
|
||||||
|
"allowElevation": true,
|
||||||
|
"runAfterFinish": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/animations": "^20.3.10",
|
||||||
|
"@angular/common": "^20.3.10",
|
||||||
|
"@angular/compiler": "^20.3.10",
|
||||||
|
"@angular/core": "^20.3.10",
|
||||||
|
"@angular/forms": "^20.3.10",
|
||||||
|
"@angular/platform-browser": "^20.3.10",
|
||||||
|
"@angular/platform-browser-dynamic": "^20.3.10",
|
||||||
|
"@angular/router": "^20.3.10",
|
||||||
|
"@capacitor/android": "^7.4.4",
|
||||||
|
"@capacitor/angular": "^2.0.3",
|
||||||
|
"@capacitor/core": "latest",
|
||||||
|
"@fortawesome/angular-fontawesome": "^3.0.0",
|
||||||
|
"@fortawesome/fontawesome-free": "^7.1.0",
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^7.1.0",
|
||||||
|
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||||
|
"@fortawesome/free-regular-svg-icons": "^7.1.0",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
|
"@tailwindcss/postcss": "^4.1.17",
|
||||||
|
"chart.js": "^4.5.1",
|
||||||
|
"dotenv": "^17.2.3",
|
||||||
|
"jose": "^6.1.2",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
|
"ng2-charts": "^6.0.1",
|
||||||
|
"rxjs": "~7.8.0",
|
||||||
|
"tailwindcss": "^4.1.17",
|
||||||
|
"tslib": "^2.3.0",
|
||||||
|
"zone.js": "~0.15.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular-devkit/build-angular": "^20.3.10",
|
||||||
|
"@angular/build": "^20.3.9",
|
||||||
|
"@angular/cli": "^20.3.9",
|
||||||
|
"@angular/compiler-cli": "^20.3.10",
|
||||||
|
"@capacitor/cli": "latest",
|
||||||
|
"@types/jasmine": "~5.1.0",
|
||||||
|
"cross-env": "^10.1.0",
|
||||||
|
"electron": "^39.0.0",
|
||||||
|
"electron-builder": "^26.0.12",
|
||||||
|
"jasmine-core": "~5.6.0",
|
||||||
|
"karma": "~6.4.0",
|
||||||
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
|
"karma-coverage": "~2.2.0",
|
||||||
|
"karma-jasmine": "~5.1.0",
|
||||||
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
|
"ngx-toastr": "^19.1.0",
|
||||||
|
"postcss": "^8.5.6",
|
||||||
|
"typescript": "~5.9.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
ng-ttc-frontend/public/ballot_0.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
ng-ttc-frontend/public/bell_0.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
ng-ttc-frontend/public/calendar_0.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
ng-ttc-frontend/public/chart-histogram_0.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
ng-ttc-frontend/public/chart-simple.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
ng-ttc-frontend/public/check_0.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
ng-ttc-frontend/public/coins_0.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
ng-ttc-frontend/public/exclamation_0.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
ng-ttc-frontend/public/exit_0.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
ng-ttc-frontend/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
ng-ttc-frontend/public/form_0.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
ng-ttc-frontend/public/home (1)_0.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
ng-ttc-frontend/public/home_0.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
ng-ttc-frontend/public/icons8-home-384.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
ng-ttc-frontend/public/interrogation.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
ng-ttc-frontend/public/interrogation_0.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
ng-ttc-frontend/public/locked-computer_0.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
ng-ttc-frontend/public/logo.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
BIN
ng-ttc-frontend/public/menu-burger_0.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
ng-ttc-frontend/public/pencil_0.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
ng-ttc-frontend/public/plus-small_0.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
ng-ttc-frontend/public/search_0.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
ng-ttc-frontend/public/settings (1)_0.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
ng-ttc-frontend/public/stamp_0.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
ng-ttc-frontend/public/user_0.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
49
ng-ttc-frontend/src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { SidebarContentComponent } from './content/sidebar-content/sidebar-content.component';
|
||||||
|
import { LicensePrivacyTermsComponent } from './component/license-privacy-terms/license-privacy-terms.component';
|
||||||
|
import { authGuard } from './services/auth.guard';
|
||||||
|
import { loginGuard } from './services/login.guard';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
|
||||||
|
{ path: 'login', loadChildren: () => import('./controls/login-control/login-control.module').then(m => m.LoginControlModule), canActivate: [loginGuard] },
|
||||||
|
|
||||||
|
{ path: 'license', component: LicensePrivacyTermsComponent},
|
||||||
|
|
||||||
|
{
|
||||||
|
path: 'main',
|
||||||
|
component: SidebarContentComponent,
|
||||||
|
canActivate: [
|
||||||
|
authGuard
|
||||||
|
],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
loadChildren: () =>
|
||||||
|
import('./controls/main-control/main-control.module').then(
|
||||||
|
(m) => m.MainControlModule
|
||||||
|
),
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// path: 'report',
|
||||||
|
// loadChildren: () =>
|
||||||
|
// import('./controls/report-control/report-control.module').then(
|
||||||
|
// (m) => m.ReportControlModule
|
||||||
|
// ),
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// {path: 'license' , component: LicensePrivacyTermsComponent}
|
||||||
|
|
||||||
|
{ path: '', redirectTo: 'login', pathMatch: 'full' },
|
||||||
|
|
||||||
|
{ path: '**', redirectTo: 'login' }
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forRoot(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class AppRoutingModule {}
|
||||||
0
ng-ttc-frontend/src/app/app.component.css
Normal file
1
ng-ttc-frontend/src/app/app.component.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<router-outlet />
|
||||||
19
ng-ttc-frontend/src/app/app.component.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ThemeService } from './services/theme.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-root',
|
||||||
|
templateUrl: './app.component.html',
|
||||||
|
standalone: false,
|
||||||
|
styleUrl: './app.component.css'
|
||||||
|
})
|
||||||
|
export class AppComponent implements OnInit {
|
||||||
|
constructor(private themeService: ThemeService) {}
|
||||||
|
title = 'ng-ttc-frontend';
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
// โหลดธีมเมื่อคอมโพเนนต์เริ่มต้นทำงาน
|
||||||
|
this.themeService.getCurrentTheme();
|
||||||
|
}
|
||||||
|
}
|
||||||
85
ng-ttc-frontend/src/app/app.module.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { NgModule, Component } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
|
||||||
|
import { ToastrModule } from 'ngx-toastr';
|
||||||
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
// import { RouterModule } from '@angular/router';
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
|
|
||||||
|
// import { LayoutComponent } from './content/content/layout/layout.component';
|
||||||
|
import { SidebarContentComponent } from './content/sidebar-content/sidebar-content.component';
|
||||||
|
import { SidebarComponent } from './component/sidebar/sidebar.component';
|
||||||
|
// import { ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||||
|
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||||
|
import { LicensePrivacyTermsComponent } from './component/license-privacy-terms/license-privacy-terms.component';
|
||||||
|
import { TokenTimerComponent } from './component/token-timer/token-timer.component';
|
||||||
|
// import { MainDashboardContentComponent } from './content/main-dashboard-content/main-dashboard-content.component';
|
||||||
|
// import { MainDashboardComponent } from './component/main-dashboard/main-dashboard.component';
|
||||||
|
// import { LoginForgotComponent } from './component/login-forgot/login-forgot.component';
|
||||||
|
// import { LoginPageComponent } from './component/login-page/login-page.component';
|
||||||
|
// import { LoginContentComponent } from './content/login-content/login-content.component';
|
||||||
|
|
||||||
|
|
||||||
|
import { provideCharts, withDefaultRegisterables } from 'ng2-charts';
|
||||||
|
import { CachingInterceptor } from './services/caching.interceptor';
|
||||||
|
import { MainProject } from './component/main-project/main-project';
|
||||||
|
import { MainProjectContent } from './content/main-project-content/main-project-content';
|
||||||
|
import { MainProjectAdd } from './component/main-project-add/main-project-add';
|
||||||
|
import { BudgetAprovalContent } from './content/budget-aproval-content/budget-aproval-content';
|
||||||
|
import { ThemeSwitcherComponent } from './component/theme-switcher/theme-switcher';
|
||||||
|
import { ChatWidgetComponent } from './component/chat-widget-component/chat-widget-component';
|
||||||
|
// import { BudgetAproval } from './component/budget-aproval/budget-aproval';
|
||||||
|
// import { AccDateFormatPipe } from './pipe/dtmtodatetime.pipe';
|
||||||
|
// import { DtmtodatetimePipe } from './dtmtodatetime.pipe';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
AppComponent,
|
||||||
|
// LayoutComponent,
|
||||||
|
SidebarContentComponent,
|
||||||
|
SidebarComponent,
|
||||||
|
LicensePrivacyTermsComponent,
|
||||||
|
TokenTimerComponent,
|
||||||
|
// ChatWidgetComponent,
|
||||||
|
// ThemeSwitcherComponent,
|
||||||
|
// BudgetAprovalContent
|
||||||
|
// MainProjectAdd,
|
||||||
|
// MainProject,
|
||||||
|
// MainProjectContent,
|
||||||
|
// BudgetAproval,
|
||||||
|
// AccDateFormatPipe
|
||||||
|
// DtmtodatetimePipe,
|
||||||
|
// MainDashboardContentComponent,
|
||||||
|
// MainDashboardComponent,
|
||||||
|
// LoginForgotComponent,
|
||||||
|
// LoginPageComponent,
|
||||||
|
// LoginPageComponentComponent,
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
BrowserModule,
|
||||||
|
CommonModule,
|
||||||
|
ToastrModule.forRoot({
|
||||||
|
positionClass:'toast-top-right',
|
||||||
|
preventDuplicates: true,
|
||||||
|
maxOpened: 3,
|
||||||
|
autoDismiss: true
|
||||||
|
}),
|
||||||
|
// ReactiveFormsModule,
|
||||||
|
BrowserAnimationsModule,
|
||||||
|
AppRoutingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
FontAwesomeModule
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
// AccDateFormatPipe
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
provideCharts(withDefaultRegisterables()),
|
||||||
|
{ provide: HTTP_INTERCEPTORS, useClass: CachingInterceptor, multi: true }
|
||||||
|
],
|
||||||
|
bootstrap: [AppComponent]
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
.animate-fade-in-down { animation: fadeInDown 0.3s ease-out; }
|
||||||
|
.animate-fade-in { animation: fadeIn 0.2s ease-out; }
|
||||||
|
|
||||||
|
@keyframes fadeInDown {
|
||||||
|
from { opacity: 0; transform: translateY(-10px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; }
|
||||||
|
to { opacity: 1; }
|
||||||
|
}
|
||||||
|
input[type=number]::-webkit-inner-spin-button,
|
||||||
|
input[type=number]::-webkit-outer-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,338 @@
|
|||||||
|
|
||||||
|
<div class="w-full p-6 space-y-8 bg-gray-50 min-h-screen font-sans text-gray-800">
|
||||||
|
|
||||||
|
<!-- 1. Header Section -->
|
||||||
|
<div class="flex flex-col md:flex-row md:justify-between md:items-end gap-4 border-b border-gray-200 pb-4">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-2xl font-bold text-gray-800 flex items-center gap-3">
|
||||||
|
<!-- <span class="bg-red-100 text-red-800 p-2 rounded-lg text-xl">💸</span> -->
|
||||||
|
<span>จัดสรรงบประมาณ</span>
|
||||||
|
</h2>
|
||||||
|
<p class="text-gray-500 mt-1 ml-1 text-sm">โครงการ: <span class="font-medium text-red-900">{{projectTitle || prjnam}}</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-gray-500 bg-white px-4 py-2 rounded-full shadow-sm border border-gray-100">
|
||||||
|
รายการทั้งหมด: <span class="font-bold text-red-800">{{ myTrnMst.length }}</span> รายการ
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 2. Add/Edit Budget Form (Collapsible) -->
|
||||||
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden transition-all duration-300">
|
||||||
|
<!-- Toggle Header -->
|
||||||
|
<div
|
||||||
|
class="flex justify-between items-center p-4 bg-gray-50 cursor-pointer hover:bg-gray-100 transition select-none border-b border-gray-100"
|
||||||
|
(click)="toggleFormCollapse()"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2 font-bold text-gray-700">
|
||||||
|
<!-- <span class="bg-red-600 text-white w-6 h-6 flex items-center justify-center rounded-full text-xs shadow-sm">
|
||||||
|
{{ isEditMode ? '✎' : '✚' }}
|
||||||
|
</span> -->
|
||||||
|
<span class="w-1 h-6 bg-red-900 rounded-full mr-1"></span>{{ isEditMode ? 'แก้ไขรายการ' : 'เพิ่มรายการงบประมาณ' }}
|
||||||
|
</div>
|
||||||
|
<button class="text-gray-400 transition-transform duration-300" [ngClass]="{'rotate-180': isFormExpanded}">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Form Content -->
|
||||||
|
@if(isFormExpanded){
|
||||||
|
<div class="p-6 bg-white animate-fade-in-down">
|
||||||
|
<form [formGroup]="budgetForm">
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-12 gap-6 items-start">
|
||||||
|
|
||||||
|
<!-- Dropdown หมวดงบ -->
|
||||||
|
<div class="md:col-span-5 space-y-1">
|
||||||
|
<label class="block text-xs font-bold text-gray-500 uppercase">
|
||||||
|
หมวดงบประมาณ <span class="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<select formControlName="bdgcod"
|
||||||
|
class="w-full p-3 border border-gray-200 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent bg-gray-50 transition cursor-pointer"
|
||||||
|
[class.border-red-500]="budgetForm.get('bdgcod')?.invalid && budgetForm.get('bdgcod')?.touched">
|
||||||
|
<option value="">-- กรุณาเลือก --</option>
|
||||||
|
@for (item of myDropBdg; track item.bdgcod) {
|
||||||
|
<option [value]="item.bdgcod">{{ item.bdgnam }}</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
<!-- Error Message -->
|
||||||
|
@if (budgetForm.get('bdgcod')?.invalid && budgetForm.get('bdgcod')?.touched) {
|
||||||
|
<div class="text-red-500 text-xs flex items-center gap-1">
|
||||||
|
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||||
|
กรุณาเลือกหมวดงบ
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Input จำนวนเงิน -->
|
||||||
|
<div class="md:col-span-5 space-y-1">
|
||||||
|
<label class="block text-xs font-bold text-gray-500 uppercase">
|
||||||
|
จำนวนเงิน <span class="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<div class="relative">
|
||||||
|
<input type="number" formControlName="amount" placeholder="0.00"
|
||||||
|
class="w-full p-3 pr-12 border border-gray-200 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent bg-gray-50 text-right font-mono text-gray-800 transition"
|
||||||
|
[class.border-red-500]="budgetForm.get('amount')?.invalid && budgetForm.get('amount')?.touched">
|
||||||
|
<span class="absolute right-4 top-3 text-gray-400 text-sm font-medium pointer-events-none">THB</span>
|
||||||
|
</div>
|
||||||
|
<!-- Error Message -->
|
||||||
|
@if (budgetForm.get('amount')?.invalid && budgetForm.get('amount')?.touched) {
|
||||||
|
<div class="text-red-500 text-xs flex items-center gap-1">
|
||||||
|
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||||
|
ระบุจำนวนเงินที่ถูกต้อง
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="md:col-span-2 flex gap-2 pt-6">
|
||||||
|
<button type="button" (click)="onSaveSubmit()"
|
||||||
|
class="flex-1 bg-red-800 hover:bg-red-900 text-white font-bold py-3 px-4 rounded-lg shadow-md hover:shadow-lg transition active:scale-95 flex justify-center items-center gap-2">
|
||||||
|
<span>{{ isEditMode ? 'บันทึกแก้ไข' : 'เพิ่ม' }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@if(isEditMode) {
|
||||||
|
<button type="button" (click)="cancelEdit()"
|
||||||
|
class="bg-gray-200 hover:bg-gray-300 text-gray-600 font-bold py-3 px-4 rounded-lg transition active:scale-95">
|
||||||
|
ยกเลิก
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 3. Budget Table -->
|
||||||
|
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="min-w-full text-left border-collapse">
|
||||||
|
<thead>
|
||||||
|
<tr class="bg-red-900 text-white text-sm uppercase tracking-wider">
|
||||||
|
<th class="py-4 px-6 font-semibold w-16 text-center">#</th>
|
||||||
|
<th class="py-4 px-6 font-semibold">รายการ / หมวดงบ</th>
|
||||||
|
<th class="py-4 px-6 font-semibold text-right w-48">จำนวนเงิน (บาท)</th>
|
||||||
|
<th class="py-4 px-6 font-semibold text-center w-32">จัดการ</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-100 text-sm">
|
||||||
|
@for (idx of myTrnMst; track idx.trnseq; let i = $index) {
|
||||||
|
<tr class="hover:bg-red-50/40 transition group">
|
||||||
|
<td class="py-4 px-6 text-center text-gray-500 font-mono">{{ i + 1 }}</td>
|
||||||
|
|
||||||
|
<td class="py-4 px-6">
|
||||||
|
<div class="font-bold text-gray-800">{{ idx.trnbdgnam }}</div>
|
||||||
|
<div class="text-xs text-gray-400 font-mono mt-0.5">{{ idx.trnbdgcod }}</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="py-4 px-6 text-right font-mono font-medium text-gray-700">
|
||||||
|
{{ idx.trnexpbdg | number:'1.2-2' }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="py-4 px-6 text-center">
|
||||||
|
<div class="flex justify-center items-center gap-2">
|
||||||
|
<button (click)="editItem(i)" class="p-2 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded-lg transition" title="แก้ไข">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button (click)="removeItem(i)" class="p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition" title="ลบ">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
} @empty {
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="py-12 text-center text-gray-400 bg-gray-50/30">
|
||||||
|
<div class="text-4xl mb-2 opacity-50">📭</div>
|
||||||
|
<p>ยังไม่มีรายการงบประมาณ</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
<!-- Footer Total & Action Buttons -->
|
||||||
|
<tfoot class="bg-gray-50 border-t-2 border-red-200">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="py-4 px-6 text-right font-bold text-gray-600 uppercase text-xs tracking-wider">รวมยอดสุทธิ</td>
|
||||||
|
<td class="py-4 px-6 text-right">
|
||||||
|
<span class="text-xl font-extrabold text-red-900">{{ getTotalAmount() | number:'1.2-2' }}</span>
|
||||||
|
<span class="text-xs text-gray-500 ml-1 font-medium">THB</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-4 px-6 text-center">
|
||||||
|
<div class="flex items-center justify-center gap-3">
|
||||||
|
<!-- 🟢 ปุ่มย้อนกลับ (Icon Arrow) -->
|
||||||
|
<button (click)="goBack()" class="p-2.5 bg-white border border-gray-200 rounded-lg text-gray-500 hover:text-red-700 hover:border-red-200 hover:bg-red-50 hover:shadow-sm transition active:scale-95 group" title="ย้อนกลับ">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 group-hover:-translate-x-1 transition-transform duration-200" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- 🟢 ปุ่มยืนยันบันทึกทั้งหมด -->
|
||||||
|
<button (click)="openConfirmModal()"
|
||||||
|
class="bg-green-600 hover:bg-green-700 text-white text-xs font-bold py-2.5 px-5 rounded-lg shadow transition active:scale-95 flex items-center gap-2">
|
||||||
|
<span>✓</span> บันทึก
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if(showConfirmModal) {
|
||||||
|
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm animate-fade-in">
|
||||||
|
<div class="bg-white rounded-2xl shadow-2xl w-96 overflow-hidden transform transition-all scale-100">
|
||||||
|
|
||||||
|
<!-- 🟢 Dynamic Header Color -->
|
||||||
|
<div class="p-4 text-white flex justify-between items-center"
|
||||||
|
[ngClass]="myTrnMst.length === 0 ? 'bg-red-600' : 'bg-red-900'">
|
||||||
|
<h3 class="font-bold text-lg flex items-center gap-2">
|
||||||
|
<span>{{ myTrnMst.length === 0 ? '⚠️' : '💾' }}</span>
|
||||||
|
{{ myTrnMst.length === 0 ? 'ยืนยันการยกเลิก' : 'ยืนยันการบันทึก' }}
|
||||||
|
</h3>
|
||||||
|
<button (click)="closeConfirmModal()" class="text-white/70 hover:text-white">✕</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-6 text-center space-y-4">
|
||||||
|
<!-- 🟢 Dynamic Icon -->
|
||||||
|
<div class="w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-2"
|
||||||
|
[ngClass]="myTrnMst.length === 0 ? 'bg-red-50 text-red-600' : 'bg-red-50 text-red-600'">
|
||||||
|
<span class="text-3xl">{{ myTrnMst.length === 0 ? '🗑️' : '📝' }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 🟢 Dynamic Message -->
|
||||||
|
<p class="text-gray-600">
|
||||||
|
@if(myTrnMst.length === 0) {
|
||||||
|
คุณต้องการ <b>ยกเลิกการจัดสรรงบประมาณ</b> <br>ของโครงการนี้ใช่หรือไม่?
|
||||||
|
} @else {
|
||||||
|
คุณต้องการ <b>บันทึกข้อมูลการจัดสรรงบประมาณ</b> <br>ของโครงการนี้ใช่หรือไม่?
|
||||||
|
}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Summary Info -->
|
||||||
|
<div class="bg-gray-50 p-3 rounded-lg border border-gray-100 text-sm">
|
||||||
|
<div class="flex justify-between mb-1">
|
||||||
|
<span class="text-gray-500">จำนวนรายการ:</span>
|
||||||
|
<span class="font-bold text-gray-800">{{ myTrnMst.length }} รายการ</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-between">
|
||||||
|
<span class="text-gray-500">ยอดรวม:</span>
|
||||||
|
<span class="font-bold text-red-800">{{ getTotalAmount() | number:'1.2-2' }} บาท</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 🟢 List of Items (บอกรายการ) -->
|
||||||
|
<div class="text-xs text-gray-500 mt-2 text-left max-h-32 overflow-y-auto border-t border-gray-200 pt-2">
|
||||||
|
<div class="font-semibold mb-1">รายการ:</div>
|
||||||
|
@if(myTrnMst.length > 0) {
|
||||||
|
<ul class="list-disc pl-4 space-y-1">
|
||||||
|
@for(item of myTrnMst; track $index) {
|
||||||
|
<li>{{ item.trnbdgnam }} ({{ item.trnexpbdg | number }})</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
} @else {
|
||||||
|
<p class="text-red-500 italic">- ไม่พบรายการคงเหลือ (ลบทั้งหมด) -</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Footer -->
|
||||||
|
<div class="p-4 bg-gray-50 flex gap-3 border-t border-gray-100">
|
||||||
|
<button (click)="closeConfirmModal()" class="flex-1 py-2.5 px-4 bg-white border border-gray-300 text-gray-700 font-bold rounded-xl hover:bg-gray-50 transition">
|
||||||
|
ยกเลิก
|
||||||
|
</button>
|
||||||
|
<!-- 🟢 Dynamic Button Color -->
|
||||||
|
<button (click)="confirmSave()"
|
||||||
|
class="flex-1 py-2.5 px-4 text-white font-bold rounded-xl shadow-md hover:shadow-lg transition"
|
||||||
|
[ngClass]="myTrnMst.length === 0 ? 'bg-red-600 hover:bg-red-700' : 'bg-red-800 hover:bg-red-900'">
|
||||||
|
{{ myTrnMst.length === 0 ? 'ยืนยันการยกเลิก' : 'ยืนยัน' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- 🟢 Modal Confirmation
|
||||||
|
@if(showConfirmModal) {
|
||||||
|
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm animate-fade-in">
|
||||||
|
<div class="bg-white rounded-2xl shadow-2xl w-96 overflow-hidden transform transition-all scale-100">
|
||||||
|
|
||||||
|
Modal Header
|
||||||
|
<div class="bg-red-900 p-4 text-white flex justify-between items-center">
|
||||||
|
<h3 class="font-bold text-lg flex items-center gap-2">
|
||||||
|
<span>💾</span> ยืนยันการบันทึก
|
||||||
|
</h3>
|
||||||
|
<button (click)="closeConfirmModal()" class="text-white/70 hover:text-white">✕</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Modal Body
|
||||||
|
<div class="p-6 text-center space-y-4">
|
||||||
|
<div class="w-16 h-16 bg-red-50 rounded-full flex items-center justify-center mx-auto mb-2">
|
||||||
|
<span class="text-3xl">📝</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-gray-600">คุณต้องการบันทึกข้อมูลการจัดสรรงบประมาณใช่หรือไม่?</p>
|
||||||
|
|
||||||
|
<div class="bg-gray-50 p-3 rounded-lg border border-gray-100 text-sm">
|
||||||
|
<div class="flex justify-between mb-1">
|
||||||
|
<span class="text-gray-500">จำนวนรายการ:</span>
|
||||||
|
<span class="font-bold text-gray-800">{{ myTrnMst.length }} รายการ</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-between">
|
||||||
|
<span class="text-gray-500">ยอดรวม:</span>
|
||||||
|
<span class="font-bold text-red-800">{{ getTotalAmount() | number:'1.2-2' }} บาท</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Modal Footer
|
||||||
|
<div class="p-4 bg-gray-50 flex gap-3 border-t border-gray-100">
|
||||||
|
<button (click)="closeConfirmModal()" class="flex-1 py-2.5 px-4 bg-white border border-gray-300 text-gray-700 font-bold rounded-xl hover:bg-gray-50 transition">
|
||||||
|
ยกเลิก
|
||||||
|
</button>
|
||||||
|
<button (click)="confirmSave()" class="flex-1 py-2.5 px-4 bg-red-800 text-white font-bold rounded-xl hover:bg-red-900 shadow-md hover:shadow-lg transition">
|
||||||
|
ยืนยัน
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
} -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 🔴 Modal Confirmation (Delete) -->
|
||||||
|
@if(showDeleteModal) {
|
||||||
|
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm animate-fade-in">
|
||||||
|
<div class="bg-white rounded-2xl shadow-2xl w-96 overflow-hidden transform transition-all scale-100">
|
||||||
|
|
||||||
|
<div class="bg-red-600 p-4 text-white flex justify-between items-center">
|
||||||
|
<h3 class="font-bold text-lg flex items-center gap-2">
|
||||||
|
<span>🗑️</span> ยืนยันการลบ
|
||||||
|
</h3>
|
||||||
|
<button (click)="closeDeleteModal()" class="text-white/70 hover:text-white">✕</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-6 text-center space-y-4">
|
||||||
|
<div class="w-16 h-16 bg-red-50 rounded-full flex items-center justify-center mx-auto mb-2">
|
||||||
|
<span class="text-3xl">⚠️</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-gray-600">คุณต้องการลบรายการนี้ใช่หรือไม่?</p>
|
||||||
|
<p class="text-sm text-gray-500">การกระทำนี้ไม่สามารถย้อนกลับได้ (ในหน้าจอนี้)</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-4 bg-gray-50 flex gap-3 border-t border-gray-100">
|
||||||
|
<button (click)="closeDeleteModal()" class="flex-1 py-2.5 px-4 bg-white border border-gray-300 text-gray-700 font-bold rounded-xl hover:bg-gray-50 transition">
|
||||||
|
ยกเลิก
|
||||||
|
</button>
|
||||||
|
<button (click)="confirmDelete()" class="flex-1 py-2.5 px-4 bg-red-600 text-white font-bold rounded-xl hover:bg-red-700 shadow-md hover:shadow-lg transition">
|
||||||
|
ลบรายการ
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
import { TransactionStateService } from './../../services/state/transaction-state.service';
|
||||||
|
import { ITrnmst, IDropBdg } from './../../interfaces/main.interface';
|
||||||
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||||
|
import { GeneralService } from '../../services/generalservice';
|
||||||
|
import { DashboardStateService } from '../../services/state/dashboard-state.service';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { Location } from '@angular/common';
|
||||||
|
import { ToastrService } from 'ngx-toastr';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-budget-aproval',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './budget-aproval.html',
|
||||||
|
styleUrl: './budget-aproval.css',
|
||||||
|
})
|
||||||
|
export class BudgetAproval implements OnInit {
|
||||||
|
@Output() ExpenseEventSubmit = new EventEmitter<any>();
|
||||||
|
@Input() prjnam!: string;
|
||||||
|
@Input() prjseq!: string;
|
||||||
|
|
||||||
|
budgetForm!: FormGroup;
|
||||||
|
isFormExpanded = true;
|
||||||
|
isEditMode = false;
|
||||||
|
editingIndex: number = -1;
|
||||||
|
showConfirmModal = false;
|
||||||
|
myTrnMst: ITrnmst[]=[];
|
||||||
|
myDropBdg: IDropBdg[]=[];
|
||||||
|
param:string = '';
|
||||||
|
// State สำหรับการลบ
|
||||||
|
showDeleteModal = false;
|
||||||
|
deleteIndex: number = -1;
|
||||||
|
|
||||||
|
// budgetCategoriesDrop = [
|
||||||
|
// { dtlcod: 'EXP01', dtlnam: 'ค่าวัสดุอุปกรณ์ (EXP01)' },
|
||||||
|
// { dtlcod: 'EXP02', dtlnam: 'ค่าจ้างเหมาแรงงาน (EXP02)' },
|
||||||
|
// { dtlcod: 'EXP03', dtlnam: 'ค่าครุภัณฑ์ (EXP03)' }
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// budgetItems: IBudgetItem[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private location: Location,
|
||||||
|
private toastr: ToastrService,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private transactionStateService: TransactionStateService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.param = this.route.snapshot.paramMap.get('seq') ?? '';
|
||||||
|
this.setupFormControl();
|
||||||
|
this.transactionStateService.getTransactionState().subscribe(data => {
|
||||||
|
this.myTrnMst = data || []
|
||||||
|
});
|
||||||
|
this.transactionStateService.getBudgetDrop().subscribe(data => {
|
||||||
|
this.myDropBdg = data ?? []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFormControl() {
|
||||||
|
this.budgetForm = new FormGroup({
|
||||||
|
bdgcod: new FormControl('', [Validators.required]),
|
||||||
|
amount: new FormControl('', [Validators.required, Validators.min(1)])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleFormCollapse() {
|
||||||
|
this.isFormExpanded = !this.isFormExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
// onSaveSubmit() {
|
||||||
|
// if (this.budgetForm.invalid) {
|
||||||
|
// this.budgetForm.markAllAsTouched();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const formValue = this.budgetForm.value;
|
||||||
|
// const selectedCode = formValue.bdgcod;
|
||||||
|
|
||||||
|
// // Validation: เช็คว่าหมวดงบซ้ำหรือไม่
|
||||||
|
// const duplicateIndex = this.myTrnMst.findIndex(idx => idx.trnbdgcod === selectedCode);
|
||||||
|
|
||||||
|
// if (duplicateIndex !== -1) {
|
||||||
|
// // กรณีเพิ่มใหม่ (เจอซ้ำ = ห้าม) หรือ กรณีแก้ไข (เจอซ้ำกับแถวอื่นที่ไม่ใช่ตัวเอง = ห้าม)
|
||||||
|
// if (!this.isEditMode || (this.isEditMode && duplicateIndex !== this.editingIndex)) {
|
||||||
|
// this.toastr.error(`หมวดงบประมาณนี้ มีอยู่ในตารางแล้ว`, 'ไม่สามารถเพิ่มซ้ำได้', {
|
||||||
|
// positionClass: 'toast-top-right',
|
||||||
|
// timeOut: 3500,
|
||||||
|
// progressBar: true,
|
||||||
|
// progressAnimation: 'decreasing',
|
||||||
|
// toastClass:
|
||||||
|
// 'ngx-toastr error-toast bg-white bg-opacity-90 text-red-700 shadow-lg'
|
||||||
|
// })
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const category = this.myDropBdg.find(c => c.bdgcod === selectedCode);
|
||||||
|
|
||||||
|
// const newItem: ITrnmst = {
|
||||||
|
// trnbdgcod: formValue.bdgcod,
|
||||||
|
// trnbdgnam: category ? category.bdgcod : formValue.bdgcod,
|
||||||
|
// trnexpbdg: Number(formValue.amount)
|
||||||
|
// };
|
||||||
|
|
||||||
|
// if (this.isEditMode && this.editingIndex > -1) {
|
||||||
|
// this.myTrnMst[this.editingIndex] = newItem;
|
||||||
|
// this.cancelEdit();
|
||||||
|
// } else {
|
||||||
|
// this.myTrnMst.push(newItem);
|
||||||
|
// this.budgetForm.reset();
|
||||||
|
// this.budgetForm.get('bdgcod')?.setValue('');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
onSaveSubmit() {
|
||||||
|
if (this.budgetForm.invalid) {
|
||||||
|
this.budgetForm.markAllAsTouched();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formValue = this.budgetForm.value;
|
||||||
|
const selectedCode = formValue.bdgcod;
|
||||||
|
|
||||||
|
// 1. Validation: เช็คว่าหมวดงบซ้ำหรือไม่
|
||||||
|
const duplicateIndex = this.myTrnMst.findIndex(idx => idx.trnbdgcod === selectedCode);
|
||||||
|
|
||||||
|
if (duplicateIndex !== -1) {
|
||||||
|
// ถ้าไม่ใช่โหมดแก้ไข หรือ แก้ไขแต่ไปซ้ำกับคนอื่น
|
||||||
|
if (!this.isEditMode || (this.isEditMode && duplicateIndex !== this.editingIndex)) {
|
||||||
|
this.toastr.error(`หมวดงบประมาณนี้ (${selectedCode}) มีอยู่ในตารางแล้ว`, 'ไม่สามารถเพิ่มซ้ำได้', {
|
||||||
|
timeOut: 3500,
|
||||||
|
progressBar: true
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ 2. ค้นหาชื่อหมวดงบ (Name) จาก Dropdown โดยใช้ Code ที่เลือก
|
||||||
|
const category = this.myDropBdg.find(c => c.bdgcod === selectedCode);
|
||||||
|
|
||||||
|
// ✅ 3. สร้าง Object ใหม่ โดยใส่ชื่อ (trnbdgnam) ที่ค้นหาได้ลงไป
|
||||||
|
const newItem: ITrnmst = {
|
||||||
|
trnbdgcod: selectedCode,
|
||||||
|
// ถ้าเจอชื่อให้ใส่ชื่อ ถ้าไม่เจอให้ใส่รหัสแทน (กันเหนียว)
|
||||||
|
trnbdgnam: category ? category.bdgnam : selectedCode,
|
||||||
|
trnexpbdg: Number(formValue.amount),
|
||||||
|
trnprjnam: this.projectTitle // คงชื่อโครงการเดิมไว้
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.isEditMode && this.editingIndex > -1) {
|
||||||
|
// กรณีแก้ไข: Merge ข้อมูลใหม่ทับของเดิม (เพื่อรักษา field อื่นๆ เช่น trnseq ไว้ถ้ามี)
|
||||||
|
this.myTrnMst[this.editingIndex] = {
|
||||||
|
...this.myTrnMst[this.editingIndex],
|
||||||
|
...newItem
|
||||||
|
};
|
||||||
|
this.cancelEdit();
|
||||||
|
} else {
|
||||||
|
// กรณีเพิ่มใหม่
|
||||||
|
this.myTrnMst.push(newItem);
|
||||||
|
this.budgetForm.reset();
|
||||||
|
this.budgetForm.get('bdgcod')?.setValue('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editItem(index: number) {
|
||||||
|
const item = this.myTrnMst[index];
|
||||||
|
this.isEditMode = true;
|
||||||
|
this.editingIndex = index;
|
||||||
|
this.isFormExpanded = true;
|
||||||
|
this.budgetForm.patchValue({
|
||||||
|
bdgcod: item.trnbdgcod,
|
||||||
|
amount: item.trnexpbdg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelEdit() {
|
||||||
|
this.isEditMode = false;
|
||||||
|
this.editingIndex = -1;
|
||||||
|
this.budgetForm.reset();
|
||||||
|
this.budgetForm.get('bdgcod')?.setValue('');
|
||||||
|
}
|
||||||
|
|
||||||
|
removeItem(index: number) {
|
||||||
|
// // if(confirm('ต้องการลบรายการนี้หรือไม่?')) {
|
||||||
|
// this.myTrnMst.splice(index, 1);
|
||||||
|
// if (this.isEditMode && this.editingIndex === index) {
|
||||||
|
// this.cancelEdit();
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
this.deleteIndex = index;
|
||||||
|
this.showDeleteModal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmDelete() {
|
||||||
|
if (this.deleteIndex > -1) {
|
||||||
|
this.myTrnMst.splice(this.deleteIndex, 1);
|
||||||
|
|
||||||
|
// ถ้าลบตัวที่กำลังแก้อยู่ ให้เคลียร์ฟอร์ม
|
||||||
|
if (this.isEditMode && this.editingIndex === this.deleteIndex) {
|
||||||
|
this.cancelEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toastr.success('ลบรายการเรียบร้อย', 'สำเร็จ');
|
||||||
|
}
|
||||||
|
this.closeDeleteModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDeleteModal() {
|
||||||
|
this.showDeleteModal = false;
|
||||||
|
this.deleteIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTotalAmount() {
|
||||||
|
return this.myTrnMst.reduce((sum, item) => sum + Number(item.trnexpbdg || 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
openConfirmModal() {
|
||||||
|
this.showConfirmModal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeConfirmModal() {
|
||||||
|
this.showConfirmModal = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmSave() {
|
||||||
|
const expenseList = this.myTrnMst.map(item => ({
|
||||||
|
bdgcod: item.trnbdgcod,
|
||||||
|
amount: Number(item.trnexpbdg)
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
prjseq: this.prjseq,
|
||||||
|
expenseList: expenseList
|
||||||
|
};
|
||||||
|
|
||||||
|
this.expenseEventSubmit(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
expenseEventSubmit(event: any){
|
||||||
|
this.ExpenseEventSubmit.emit(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
goBack() {
|
||||||
|
this.location.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
get projectTitle(): string {
|
||||||
|
return this.myTrnMst?.[0]?.trnprjnam ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
/* Custom Scrollbar */
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background: #cbd5e1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.animate-fade-in-up {
|
||||||
|
animation: fadeInUp 0.3s ease-out forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeInUp {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(20px) scale(0.95);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
|
||||||
|
<!-- Container หลัก: Fixed มุมขวาล่าง -->
|
||||||
|
<div class="fixed bottom-5 right-5 z-50 flex flex-col items-end space-y-4 font-sans">
|
||||||
|
|
||||||
|
<!-- หน้าต่างแชท -->
|
||||||
|
<div *ngIf="isOpen"
|
||||||
|
[style.width.px]="isMaximized ? 600 : chatWidth"
|
||||||
|
[style.height.px]="isMaximized ? 800 : chatHeight"
|
||||||
|
class="bg-white rounded-xl shadow-2xl flex flex-col overflow-hidden border border-gray-200 animate-fade-in-up relative transition-all duration-100 ease-out"
|
||||||
|
[class.max-w-[90vw]]="isMaximized"
|
||||||
|
[class.max-h-[80vh]]="isMaximized">
|
||||||
|
|
||||||
|
<!-- 1. ส่วนจุดดึงขยาย (Resize Handle) -->
|
||||||
|
<div *ngIf="!isMaximized"
|
||||||
|
(mousedown)="startResizing($event)"
|
||||||
|
class="absolute top-0 left-0 w-6 h-6 z-50 cursor-nw-resize flex items-start justify-start p-1 opacity-0 hover:opacity-100 transition-opacity group">
|
||||||
|
<div class="w-2 h-2 border-t-2 border-l-2 border-red-400 rounded-tl-sm"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="bg-red-800 p-3 flex justify-between items-center text-white shadow-md shrink-0 cursor-default select-none">
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<div class="relative">
|
||||||
|
<div class="w-8 h-8 bg-red-700 rounded-full flex items-center justify-center text-xs font-bold border border-red-600">
|
||||||
|
AI
|
||||||
|
</div>
|
||||||
|
<div class="absolute bottom-0 right-0 w-2.5 h-2.5 bg-green-400 border-2 border-red-800 rounded-full"></div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col leading-tight">
|
||||||
|
<span class="font-bold text-sm">ผู้ช่วยวิเคราะห์ข้อมูล</span>
|
||||||
|
<span class="text-xs text-red-100">ตอบกลับทันที</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center space-x-1">
|
||||||
|
<button (click)="toggleMaximize()" class="hover:bg-red-700 p-1 rounded transition text-red-100 hover:text-white" title="ขยาย/ย่อ">
|
||||||
|
<svg *ngIf="!isMaximized" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
|
||||||
|
</svg>
|
||||||
|
<svg *ngIf="isMaximized" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9l-6-6M15 9V4.5M15 9h4.5M15 9l6-6M9 15v4.5M9 15H4.5M9 15l-6 6M15 15v4.5M15 15h4.5M15 15l6 6" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button (click)="toggleChat()" class="hover:bg-red-700 p-1 rounded transition text-red-100 hover:text-white">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Chat Body -->
|
||||||
|
<div class="flex-1 p-4 overflow-y-auto bg-slate-50 space-y-3" #scrollContainer>
|
||||||
|
<div *ngFor="let msg of messages"
|
||||||
|
class="flex w-full"
|
||||||
|
[ngClass]="{'justify-end': msg.isUser, 'justify-start': !msg.isUser}">
|
||||||
|
|
||||||
|
<div *ngIf="!msg.isUser" class="w-6 h-6 bg-red-100 rounded-full shrink-0 mr-2 flex items-center justify-center text-xs text-red-800 font-bold self-end mb-1">
|
||||||
|
AI
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div [ngClass]="{
|
||||||
|
'bg-red-800 text-white rounded-tl-2xl rounded-tr-2xl rounded-bl-2xl': msg.isUser,
|
||||||
|
'bg-white text-gray-800 border border-gray-200 rounded-tl-2xl rounded-tr-2xl rounded-br-2xl': !msg.isUser
|
||||||
|
}"
|
||||||
|
class="max-w-[85%] px-4 py-2 text-sm shadow-sm wrap-break-words relative group">
|
||||||
|
{{ msg.text }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Footer / Input [Reactive Form] -->
|
||||||
|
<!-- Bind [formGroup] ที่ div นี้เพื่อให้ input ใช้งาน formControlName ได้ -->
|
||||||
|
<div class="p-3 bg-white border-t border-gray-200 flex items-center space-x-2 shrink-0" [formGroup]="chatForm">
|
||||||
|
<button class="text-gray-400 hover:text-red-800 transition">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- ใช้ formControlName แทน ngModel -->
|
||||||
|
<input type="text"
|
||||||
|
formControlName="message"
|
||||||
|
(keyup.enter)="sendMessage()"
|
||||||
|
placeholder="พิมพ์ข้อความ..."
|
||||||
|
class="flex-1 bg-gray-100 rounded-full px-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-red-500 focus:bg-white transition text-gray-700 placeholder-gray-400">
|
||||||
|
|
||||||
|
<!-- ใช้ chatForm.invalid ในการ disable ปุ่ม -->
|
||||||
|
<button (click)="sendMessage()"
|
||||||
|
[disabled]="chatForm.invalid"
|
||||||
|
class="text-red-950 hover:text-red-800 p-2 transition disabled:opacity-50 disabled:cursor-not-allowed">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Launcher Button -->
|
||||||
|
<button (click)="toggleChat()"
|
||||||
|
class="group w-14 h-14 bg-red-800 hover:bg-red-700 text-white rounded-full shadow-lg shadow-red-800/30 flex items-center justify-center transition-all transform hover:scale-110 focus:outline-none ring-4 ring-red-50 hover:ring-red-100 active:scale-95">
|
||||||
|
|
||||||
|
<svg *ngIf="isOpen" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<svg *ngIf="!isOpen" xmlns="http://www.w3.org/2000/svg" class="h-7 w-7 transition-transform group-hover:-rotate-12" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Overlay กันกดส่วนอื่นตอนกำลังลาก -->
|
||||||
|
<div *ngIf="isResizing" class="fixed inset-0 z-60 cursor-nw-resize"></div>
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
import { GeneralService } from './../../services/generalservice';
|
||||||
|
import { ReactiveFormsModule, FormGroup, FormControl, Validators } from '@angular/forms';
|
||||||
|
import { IChat } from '../../interfaces/main.interface';
|
||||||
|
import { Component, HostListener, OnDestroy } from '@angular/core';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-chat-widget-component',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './chat-widget-component.html',
|
||||||
|
styleUrl: './chat-widget-component.css',
|
||||||
|
})
|
||||||
|
export class ChatWidgetComponent implements OnDestroy {
|
||||||
|
// --- State ---
|
||||||
|
isOpen = false;
|
||||||
|
isMaximized = false;
|
||||||
|
isLoading = false; // Added to track API state
|
||||||
|
first = true;
|
||||||
|
|
||||||
|
// --- Form & Data ---
|
||||||
|
chatForm!: FormGroup;
|
||||||
|
messages: IChat[] = [];
|
||||||
|
private subscriptions: Subscription = new Subscription();
|
||||||
|
|
||||||
|
// --- Resize State ---
|
||||||
|
chatWidth = 320;
|
||||||
|
chatHeight = 384;
|
||||||
|
isResizing = false;
|
||||||
|
private startX = 0;
|
||||||
|
private startY = 0;
|
||||||
|
private startWidth = 0;
|
||||||
|
private startHeight = 0;
|
||||||
|
|
||||||
|
constructor(private generalService: GeneralService) {
|
||||||
|
this.setupFormControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
// Best Practice: Unsubscribe to prevent memory leaks
|
||||||
|
this.subscriptions.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFormControl() {
|
||||||
|
this.chatForm = new FormGroup({
|
||||||
|
message: new FormControl('', [Validators.required]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleChat() {
|
||||||
|
this.isOpen = !this.isOpen;
|
||||||
|
this.isMaximized = false;
|
||||||
|
|
||||||
|
// Only trigger welcome message logic if opening
|
||||||
|
if (this.isOpen) {
|
||||||
|
if (this.first) {
|
||||||
|
// Initial handshake with AI
|
||||||
|
this.OnAiChat({ methods: 'ind' });
|
||||||
|
|
||||||
|
// Add "Waiting" message only if it doesn't exist
|
||||||
|
const isAlreadyHave = this.messages.some((sub) => sub.text === 'รอAi ประมวณผลสักครู่');
|
||||||
|
if (!isAlreadyHave) {
|
||||||
|
this.messages.push({
|
||||||
|
text: 'รอAi ประมวณผลสักครู่',
|
||||||
|
isUser: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleMaximize() {
|
||||||
|
this.isMaximized = !this.isMaximized;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage() {
|
||||||
|
if (this.chatForm.invalid) return;
|
||||||
|
|
||||||
|
const messageText = this.chatForm.get('message')?.value;
|
||||||
|
|
||||||
|
if (messageText && messageText.trim()) {
|
||||||
|
// 1. Add User Message to UI
|
||||||
|
this.messages.push({ text: messageText, isUser: true });
|
||||||
|
|
||||||
|
// 2. Clear the form input
|
||||||
|
this.chatForm.reset();
|
||||||
|
|
||||||
|
// 3. Set loading state
|
||||||
|
this.isLoading = true;
|
||||||
|
|
||||||
|
// 4. Send to API
|
||||||
|
this.OnAiChat({ methods: 'cht', message: messageText });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OnAiChat(value: { methods: string; message?: string }) {
|
||||||
|
// Best Practice: Move URL to environment.ts in the future
|
||||||
|
const url = 'https://n8n.nuttakit.work/webhook/Ai';
|
||||||
|
|
||||||
|
const request = {
|
||||||
|
methods: value.methods || 'cht',
|
||||||
|
message: value.message ?? '',
|
||||||
|
};
|
||||||
|
|
||||||
|
const sub = this.generalService.postUrl(url, request).subscribe({
|
||||||
|
next: (result: any) => {
|
||||||
|
if (result.code === 200) {
|
||||||
|
// Push AI response
|
||||||
|
this.messages.push(result.data);
|
||||||
|
this.first = false;
|
||||||
|
} else {
|
||||||
|
// Handle API logic errors
|
||||||
|
// specific check for the method if it exists
|
||||||
|
if(this.generalService['trowApi']) {
|
||||||
|
this.generalService.trowApi(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
console.error('Chat Error:', error);
|
||||||
|
this.messages.push({ text: 'ขออภัย เกิดข้อผิดพลาดในการเชื่อมต่อ', isUser: false });
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
this.isLoading = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.subscriptions.add(sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Resize Logic (Preserved) ---
|
||||||
|
|
||||||
|
startResizing(event: MouseEvent) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.isResizing = true;
|
||||||
|
this.startX = event.clientX;
|
||||||
|
this.startY = event.clientY;
|
||||||
|
this.startWidth = this.chatWidth;
|
||||||
|
this.startHeight = this.chatHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:mousemove', ['$event'])
|
||||||
|
onMouseMove(event: MouseEvent) {
|
||||||
|
if (!this.isResizing) return;
|
||||||
|
|
||||||
|
// Logic assumes resizing from Top-Left corner (expanding Up and Left)
|
||||||
|
const deltaX = this.startX - event.clientX;
|
||||||
|
const deltaY = this.startY - event.clientY;
|
||||||
|
|
||||||
|
this.chatWidth = Math.max(300, this.startWidth + deltaX);
|
||||||
|
this.chatHeight = Math.max(350, this.startHeight + deltaY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:mouseup')
|
||||||
|
stopResizing() {
|
||||||
|
this.isResizing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
.policy-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-start;
|
||||||
|
background: linear-gradient(135deg, #f3f6f9 0%, #e9eff5 100%);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 40px 20px;
|
||||||
|
color: #1a1f36;
|
||||||
|
font-family: "Sarabun", "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: white;
|
||||||
|
max-width: 800px;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 16px;
|
||||||
|
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
|
||||||
|
padding: 40px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b737a;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 20px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #0b1a2b;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 15px;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0078d4;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-text {
|
||||||
|
color: #6b737a;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<div class="policy-container">
|
||||||
|
<div class="card">
|
||||||
|
<h1 class="page-title">ข้อตกลงสิทธิ์การใช้งาน นโยบายความเป็นส่วนตัว และเงื่อนไขการให้บริการ</h1>
|
||||||
|
<p class="subtitle">ปรับปรุงล่าสุด: 27 ตุลาคม 2025</p>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>1. ข้อตกลงสิทธิ์การใช้งาน (License Agreement)</h2>
|
||||||
|
<p>
|
||||||
|
ซอร์สโค้ด ส่วนประกอบ และทรัพย์สินการออกแบบทั้งหมดภายใต้โครงการ Nuttakit Software
|
||||||
|
อยู่ภายใต้สัญญาอนุญาตแบบ <strong>MIT License</strong> เว้นแต่จะมีการระบุเป็นอย่างอื่นโดยเฉพาะ
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
ท่านได้รับสิทธิ์ในการใช้งาน คัดลอก แก้ไข รวม รวมเข้ากับซอฟต์แวร์อื่น เผยแพร่ หรือแจกจ่ายซอฟต์แวร์นี้
|
||||||
|
เพื่อวัตถุประสงค์ส่วนตัวหรือเชิงพาณิชย์ได้
|
||||||
|
โดยต้องคงไว้ซึ่งข้อความลิขสิทธิ์และข้อความอนุญาตนี้ในสำเนาทั้งหมดของซอฟต์แวร์
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
ซอฟต์แวร์นี้ถูกจัดให้ “ตามสภาพ” (AS IS)
|
||||||
|
โดยไม่มีการรับประกันใด ๆ ไม่ว่าจะโดยชัดแจ้งหรือโดยนัย
|
||||||
|
รวมถึงแต่ไม่จำกัดเฉพาะการรับประกันความเหมาะสมในการใช้งานหรือความถูกต้องของข้อมูล
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>2. นโยบายความเป็นส่วนตัว (Privacy Policy)</h2>
|
||||||
|
<p>
|
||||||
|
NuttakitSoftwareให้ความสำคัญกับความเป็นส่วนตัวของผู้ใช้งาน
|
||||||
|
แอปพลิเคชันของเราจะเก็บข้อมูลเพียงบางส่วนเท่านั้น เช่น รหัสอุปกรณ์
|
||||||
|
บันทึกการทำงาน หรือสถิติการใช้งาน
|
||||||
|
เพื่อใช้ในการวิเคราะห์ ปรับปรุง และพัฒนาประสิทธิภาพของระบบ
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
ข้อมูลส่วนบุคคล (Personal Identifiable Information — PII)
|
||||||
|
จะไม่ถูกขาย แบ่งปัน หรือโอนไปยังบุคคลที่สามโดยไม่ได้รับความยินยอมจากท่านอย่างชัดเจน
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
เราใช้มาตรฐานการเข้ารหัสระดับอุตสาหกรรม (AES-CBC)
|
||||||
|
เพื่อรักษาความปลอดภัยในการส่งข้อมูลระหว่างแอปพลิเคชัน เซิร์ฟเวอร์ และ API
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
ผู้ใช้สามารถร้องขอให้ลบหรือขอรับสำเนาข้อมูลของตนเองได้ตลอดเวลา
|
||||||
|
โดยติดต่อทีมสนับสนุนของเรา
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>3. เงื่อนไขการให้บริการ (Terms of Service)</h2>
|
||||||
|
<p>
|
||||||
|
เมื่อท่านใช้งานซอฟต์แวร์หรือบริการของเรา ถือว่าท่านยอมรับและปฏิบัติตามกฎหมายและข้อบังคับที่เกี่ยวข้องทั้งหมด
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
ท่านจะต้องไม่ใช้ซอฟต์แวร์ของเราในทางที่ผิด
|
||||||
|
ไม่พยายามถอดรหัส แก้ไข ดัดแปลง หรือแสวงหาประโยชน์จากช่องโหว่ในระบบโดยไม่ได้รับอนุญาต
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Nuttakit ขอสงวนสิทธิ์ในการแก้ไขหรือยุติการให้บริการโดยไม่ต้องแจ้งให้ทราบล่วงหน้า
|
||||||
|
หากตรวจพบการละเมิดความปลอดภัยหรือการใช้งานที่ไม่เหมาะสม
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
ทีมพัฒนา Nuttakit และผู้ร่วมพัฒนาไม่รับผิดชอบต่อความเสียหายใด ๆ
|
||||||
|
ที่อาจเกิดจากการใช้งานหรือไม่สามารถใช้งานซอฟต์แวร์นี้ได้
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>4. ช่องทางการติดต่อ (Contact)</h2>
|
||||||
|
<p>
|
||||||
|
หากท่านมีข้อสงสัยหรือข้อกังวลเกี่ยวกับข้อมูลส่วนบุคคลหรือเงื่อนไขการให้บริการ
|
||||||
|
สามารถติดต่อเราได้ที่:
|
||||||
|
<br />
|
||||||
|
<strong>อีเมล:</strong> support@nuttakit.work<br />
|
||||||
|
<strong>เว็บไซต์:</strong>
|
||||||
|
<a href="https://nuttakit.work" target="_blank">https://nuttakit.work</a>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<hr />
|
||||||
|
<p class="footer-text">© 2025 Nuttakit Software. สงวนลิขสิทธิ์ทั้งหมด</p>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-license-privacy-terms',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './license-privacy-terms.component.html',
|
||||||
|
styleUrl: './license-privacy-terms.component.css'
|
||||||
|
})
|
||||||
|
export class LicensePrivacyTermsComponent {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
:root {
|
||||||
|
--bg-1: #f3f6f9;
|
||||||
|
--card-bg: #ffffff;
|
||||||
|
--muted: #6b737a;
|
||||||
|
--text: #0b1a2b;
|
||||||
|
--primary: #0078d4;
|
||||||
|
--primary-600: #0065b8;
|
||||||
|
--radius: 8px;
|
||||||
|
--shadow: 0 10px 30px rgba(11,26,43,0.08);
|
||||||
|
--glass: rgba(255,255,255,0.6);
|
||||||
|
--success-color: #10b981; /* Green for success/confirm */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Page layout (unchanged) */
|
||||||
|
.login-widget {
|
||||||
|
min-height: 100vh;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 28px 18px;
|
||||||
|
background: linear-gradient(180deg, #f7f9fb 0%, var(--bg-1) 100%);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Card (unchanged) */
|
||||||
|
.login-widget .card{
|
||||||
|
width: 380px;
|
||||||
|
max-width: calc(100% - 40px);
|
||||||
|
background: var(--card-bg);
|
||||||
|
border-radius: calc(var(--radius) + 2px);
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
padding: 22px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
max-height: calc(100vh - 56px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Modal/backdrop styles (unchanged) */
|
||||||
|
.login-backdrop{
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0,0,0,0.38);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1040;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
.login-modal{ width: 480px; max-width: 480px; }
|
||||||
|
|
||||||
|
.modal-card{
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 20px 50px rgba(2,6,23,0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brand area (unchanged) */
|
||||||
|
.brand{
|
||||||
|
text-align: center;
|
||||||
|
padding: 18px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
border-bottom: 1px solid #eef2f5;
|
||||||
|
}
|
||||||
|
.brand .logo{
|
||||||
|
height: 44px;
|
||||||
|
width: 44px;
|
||||||
|
object-fit: contain;
|
||||||
|
display: inline-block;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.brand h1{
|
||||||
|
margin: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.2px;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
.brand .subtitle{
|
||||||
|
margin: 6px 0 12px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form area */
|
||||||
|
.form{
|
||||||
|
margin-top: 6px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 6px 22px 22px 22px;
|
||||||
|
}
|
||||||
|
/* Field label wrapper (unchanged) */
|
||||||
|
.field{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.field .label-text{
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
/* Inputs (class 'input-field' added to HTML) */
|
||||||
|
input[type="email"],
|
||||||
|
input[type="password"],
|
||||||
|
input[type="text"],
|
||||||
|
.input-field { /* เพิ่ม class input-field เพื่อให้สไตล์ถูกใช้กับ input ที่กำหนด */
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: var(--text);
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #d8dee6;
|
||||||
|
border-radius: 6px;
|
||||||
|
outline: none;
|
||||||
|
transition: box-shadow .14s ease, border-color .14s ease, transform .06s ease;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::placeholder{
|
||||||
|
color: #9aa3ad;
|
||||||
|
}
|
||||||
|
input:focus{
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: 0 6px 20px rgba(0,120,212,0.10);
|
||||||
|
transform: translateZ(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Actions row */
|
||||||
|
.actions{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 4px;
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom class for justify-end when using flex-row-reverse */
|
||||||
|
.actions.justify-end-custom {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom class for lift hover effect (used for 'เปิด Modal' button) */
|
||||||
|
.hover-lift:hover {
|
||||||
|
transform: translateY(-2.5px);
|
||||||
|
transition: transform .2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PRIMARY BUTTON - แก้ไขสีข้อความให้เป็นสีดำ */
|
||||||
|
button.primary{
|
||||||
|
background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%);
|
||||||
|
color: #000000; /* ⬅️ แก้ไขเป็นสีดำตามคำขอ */
|
||||||
|
border: none;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
box-shadow: 0 6px 18px rgba(0,120,212,0.12);
|
||||||
|
transition: transform .06s ease, box-shadow .12s ease, opacity .12s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary:hover:not(:disabled){
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 10px 24px rgba(0,120,212,0.14);
|
||||||
|
}
|
||||||
|
button.primary:active{
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
button.primary:disabled{
|
||||||
|
opacity: 0.55;
|
||||||
|
cursor: not-allowed;
|
||||||
|
color: #000000; /* ข้อความ disabled ก็เป็นสีดำ */
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Secondary Button Style (สำหรับปุ่ม 'เปิด Modal', 'ส่งอีกครั้ง') */
|
||||||
|
.primary.secondary-button {
|
||||||
|
background: transparent;
|
||||||
|
color: var(--primary);
|
||||||
|
border: 1px solid var(--primary);
|
||||||
|
box-shadow: none;
|
||||||
|
transition: background-color .14s ease;
|
||||||
|
}
|
||||||
|
.primary.secondary-button:hover {
|
||||||
|
background: rgba(0, 120, 212, 0.05);
|
||||||
|
transform: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Footer (unchanged) */
|
||||||
|
.footer{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 6px;
|
||||||
|
padding-top: 10px;
|
||||||
|
border-top: 1px solid #eef2f5;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
.footer a{
|
||||||
|
color: var(--primary);
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Focus styles (unchanged) */
|
||||||
|
:focus{ outline: none; }
|
||||||
|
:focus-visible{
|
||||||
|
outline: 3px solid rgba(0,120,212,0.12);
|
||||||
|
outline-offset: 2px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Small screens */
|
||||||
|
@media (max-width:420px){
|
||||||
|
.login-backdrop{ padding: 12px; }
|
||||||
|
.login-modal{ max-width: 100%; }
|
||||||
|
.modal-card .brand{ padding: 12px; }
|
||||||
|
.login-widget .card{
|
||||||
|
padding: 18px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.brand h1{ font-size: 18px; }
|
||||||
|
.biometric span, .primary{ font-size: 13px; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<div class="login-backdrop">
|
||||||
|
<div class="login-modal d-flex align-items-center justify-content-center bg-white rounded-2xl">
|
||||||
|
<div class="card modal-card" role="dialog" aria-labelledby="signin-title" aria-modal="true">
|
||||||
|
|
||||||
|
<div class="brand">
|
||||||
|
<img src="logo.png" alt="Company logo" class="logo mb-2"/>
|
||||||
|
<h1 id="signin-title" class="kanit-bold">ลืมรหัสผ่าน</h1>
|
||||||
|
<p class="subtitle">โปรดกรอก Email ของท่าน</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form [formGroup]="forgotFrm" class="form">
|
||||||
|
<label class="field">
|
||||||
|
<span class="label-text">อีเมล์</span>
|
||||||
|
<input type="email" formControlName="email" class="input-field" id="englishInput" autocomplete="username" placeholder="nuttakit@gmail.com" aria-label="Email address" required />
|
||||||
|
</label>
|
||||||
|
|
||||||
|
@if (isSendOtp === true) {
|
||||||
|
<label class="field">
|
||||||
|
<span class="label-text">รหัสยืนยัน OTP</span>
|
||||||
|
<input type="text" formControlName="otp" class="input-field" autocomplete="one-time-code" placeholder="123456" alt required/>
|
||||||
|
</label>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="actions justify-end-custom mt-4">
|
||||||
|
|
||||||
|
<div class="flex-row hover-lift">
|
||||||
|
<button class="primary secondary-button" type="button" (click)="isModalOpen = true">
|
||||||
|
เปิด Modal
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (isSendOtp === false) {
|
||||||
|
<div class="flex justify-end">
|
||||||
|
@if (isLoading === true) {
|
||||||
|
<button type="submit" class="primary" disabled>
|
||||||
|
กำลังส่ง...
|
||||||
|
</button>
|
||||||
|
} @else {
|
||||||
|
<button type="submit" class="primary" (click)="onSubmin()">
|
||||||
|
{{ 'ยืนยันส่ง OTP รีเซ็ตรหัสผ่าน' }}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
} @else if(isSendOtp === true) {
|
||||||
|
<div class="flex justify-end gap-2">
|
||||||
|
<button type="button" class="primary secondary-button" (click)="onSubmin()">
|
||||||
|
{{ 'ส่งอีกครั้ง' }}
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="primary" (click)="onVerifySubmit()">
|
||||||
|
{{ 'รีเซ็ตรหัสผ่าน' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@if(isModalOpen){
|
||||||
|
<div class="fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-50" [formGroup]="forgotFrm">
|
||||||
|
<div class="bg-white p-6 rounded-lg shadow-xl max-w-sm w-fit modal-reset-password">
|
||||||
|
<h2 class="text-xl font-bold mb-4 text-center">เปลี่ยนรหัสผ่าน</h2>
|
||||||
|
<hr class="w-full h-px bg-gray-200 border-0 my-3">
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-sm font-medium text-gray-700 mb-1">รหัสผ่านใหม่</label>
|
||||||
|
<input type="password" id="newPassword" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500" formControlName="newPassword" placeholder="กรอกรหัสผ่านใหม่">
|
||||||
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="confirmPassword" class="block text-sm font-medium text-gray-700 mb-1">ยืนยันรหัสผ่านใหม่</label>
|
||||||
|
<input type="password" id="confirmPassword" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500" formControlName="confirmPassword" placeholder="กรอกยืนยันรหัสผ่านใหม่">
|
||||||
|
@if ( this.forgotFrm.get('confirmPassword')!.touched && this.forgotFrm.get('newPassword')?.value !== this.forgotFrm.get('confirmPassword')?.value ){
|
||||||
|
<span class="text-red-600 text-xs mt-1 block">รหัสผ่านไม่ตรงกัน</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end gap-2 mt-5">
|
||||||
|
<button class="bg-gray-400 text-white px-4 py-2 rounded-lg transition-colors hover:bg-gray-500" (click)="isModalOpen = false">
|
||||||
|
ปิด
|
||||||
|
</button>
|
||||||
|
<button class="bg-green-600 text-white px-4 py-2 rounded-lg font-semibold shadow-md transition-all duration-300 ease-in-out hover:bg-green-700 hover:shadow-lg" (click)="onSetNewPassword()">
|
||||||
|
ยืนยัน
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||