fixed : auto fetched the btid from system in login time also

This commit is contained in:
Sibin Sabu 2025-08-18 12:50:11 +05:30
parent 54f2ff8381
commit 72b00c71eb
4 changed files with 229 additions and 84 deletions

View File

@ -1,6 +1,5 @@
/* 🔲 Base Styles */ /* 🔲 Base Styles */
.touch-pad-container { .touch-pad-container {
/*background-color: #cc0f0f;*/
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 1rem; padding: 1rem;
border-radius: 8px; border-radius: 8px;
@ -100,6 +99,7 @@ button {
background-color: #1f5664 !important; background-color: #1f5664 !important;
color: white; color: white;
} }
/* ✅ Responsive Tablet/Mobile Styles */ /* ✅ Responsive Tablet/Mobile Styles */
@media (max-width: 800px) { @media (max-width: 800px) {
.container-fluid { .container-fluid {
@ -171,8 +171,56 @@ button {
} }
} }
@media (min-width: 801px) { /* ✅ Tablet View (800px to 1030px) */
/* Remove container padding on desktop to align buttons edge-to-edge */ @media (min-width: 801px) and (max-width: 1045px) {
.touch-pad-container .container-fluid.mb-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex {
flex-direction: row;
justify-content: space-between;
gap: 1rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.first {
flex: 0 0 50%;
justify-content: flex-start;
gap: 0.5rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.second {
flex: 0 0 50%;
justify-content: flex-end;
gap: 0.5rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.first button {
min-width: 90px;
font-size: 0.9rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.second button {
min-width: 90px;
font-size: 0.9rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.second button:nth-child(1) {
margin-left: 0;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.second button:nth-child(2) {
margin-left: 0.5rem;
}
.touch-pad-container .container-fluid.mb-2 > .d-flex > div.second button:nth-child(3) {
margin-left: 0.5rem;
}
}
/* ✅ Desktop View */
@media (min-width: 1045px) {
.touch-pad-container .container-fluid.mb-2 { .touch-pad-container .container-fluid.mb-2 {
padding-left: 0; padding-left: 0;
padding-right: 0; padding-right: 0;
@ -315,9 +363,11 @@ button {
/* background-color: blue; */ /* background-color: blue; */
height: 8%; height: 8%;
} }
.container-fluid { .container-fluid {
height: 90%; height: 90%;
} }
.wrapper { .wrapper {
height: 95%; height: 95%;
} }
@ -332,6 +382,7 @@ button {
.wrapper-pad { .wrapper-pad {
height: 98%; height: 98%;
} }
.custom-touchpad { .custom-touchpad {
height: 95%; height: 95%;
} }
@ -418,6 +469,7 @@ button {
grid-column: span 2; grid-column: span 2;
background-color: #0077b6; background-color: #0077b6;
} }
.calc-backspace-btn { .calc-backspace-btn {
margin-right: -120px; margin-right: -120px;
background-color: #0077b6; background-color: #0077b6;
@ -477,6 +529,7 @@ button.ready-to-print {
background-color: #f8d7da !important; background-color: #f8d7da !important;
color: #721c24; color: #721c24;
} }
/* 🟦 FIELD Modal Overlay */ /* 🟦 FIELD Modal Overlay */
.field-modal { .field-modal {
display: none; display: none;
@ -510,12 +563,6 @@ button.ready-to-print {
margin-right: 47%; margin-right: 47%;
} }
.field-modal-header h5 {
margin: 0;
font-weight: bold;
color: #007bff;
}
/* ❌ Close Button */ /* ❌ Close Button */
.close-btn { .close-btn {
/* font-size: 1.5rem; */ /* font-size: 1.5rem; */
@ -578,7 +625,6 @@ button.ready-to-print {
font-weight: bold; font-weight: bold;
} }
/* 🟦 Custom FIELD Button */ /* 🟦 Custom FIELD Button */
.btn-field { .btn-field {
background-color: #2772af; /* Bootstrap secondary base */ background-color: #2772af; /* Bootstrap secondary base */
@ -601,10 +647,7 @@ button.ready-to-print {
background-color: #757373; background-color: #757373;
/* border-color: #b1b1b1; */ /* border-color: #b1b1b1; */
} }
.btn-bkp {
min-width: 60px;
font-weight: bold;
}
/* BOX Button Styling */ /* BOX Button Styling */
.btn.three { .btn.three {
background-color: #165d9b; /* Bootstrap secondary */ background-color: #165d9b; /* Bootstrap secondary */
@ -680,10 +723,13 @@ button.ready-to-print {
justify-content: center; justify-content: center;
gap: 50px; gap: 50px;
} }
.pool-replace-btn { .pool-replace-btn {
background-color: #125cac; background-color: #125cac;
color: white; color: white;
} }
/* Limit Popup Modal */
.limit-overlay { .limit-overlay {
position: fixed; position: fixed;
top: 0; top: 0;
@ -735,9 +781,15 @@ button.ready-to-print {
.limit-button:hover { .limit-button:hover {
background-color: #0056b3; background-color: #0056b3;
} }
.number-button button[disabled] { .number-button button[disabled] {
background-color: #cccccc; /* Gray background for disabled */ background-color: #cccccc;
color: #666666; /* Darker text for contrast */ color: #666666;
cursor: not-allowed; /* Cursor indicates disabled state */ cursor: not-allowed;
opacity: 0.6; /* Slightly transparent */ opacity: 0.6;
}
.btn-bkp {
min-width: 60px;
font-weight: bold;
} }

View File

@ -212,10 +212,7 @@ export class LoginComponent implements OnInit, OnDestroy {
resetUserPassMessage() { resetUserPassMessage() {
this.passwordStatus = true; this.passwordStatus = true;
} }
//--------------------------------------NEW LOGIN LOGIC ----------------------------------------//
// ✅ Updated onSubmit with BTID
async onSubmit(): Promise<void> { async onSubmit(): Promise<void> {
if (this.loginForm.invalid) { if (this.loginForm.invalid) {
this.loginForm.markAllAsTouched(); this.loginForm.markAllAsTouched();
@ -224,8 +221,9 @@ export class LoginComponent implements OnInit, OnDestroy {
const { email, password } = this.loginForm.value; const { email, password } = this.loginForm.value;
this.btcService.userLogin(email, password).subscribe({ // ✅ Await service (since its async)
next: async (response) => { (await this.btcService.userLogin(email, password)).subscribe({
next: (response) => {
const employee = response.body; const employee = response.body;
console.log('🧠 Raw employee response:', employee); console.log('🧠 Raw employee response:', employee);
@ -237,25 +235,31 @@ export class LoginComponent implements OnInit, OnDestroy {
this.passwordStatus = true; this.passwordStatus = true;
// ✅ Fetch BTID from Electron preload // ✅ Get the BTID the service fetched
const btid = await (window as any).electronAPI?.getBtid?.(); const btid = this.btcService.btid;
console.log("📦 BTID from file:", btid); console.log("📦 BTID from file (via service):", btid);
// Prepare print data // Prepare print data
const printData = { const printData = {
name: userName, name: userName,
employeeId: employeeId, employeeId: employeeId,
// btid: btid || "unknown",
action: 'login', action: 'login',
type: 'login' type: 'login'
}; };
console.log(printData.name);
console.log(printData.employeeId);
//console.log(printData.btid);
console.log(btid);
// ✅ Store in localStorage // ✅ Store in localStorage
localStorage.setItem('userName', userName); localStorage.setItem('userName', userName);
localStorage.setItem('employeeId', employeeId); localStorage.setItem('employeeId', employeeId);
localStorage.setItem('password', password); localStorage.setItem('password', password);
localStorage.setItem('btid', btid || "unknown"); localStorage.setItem('btid', btid || "unknown");
// ✅ Optional second screen + navigate // ✅ Print first — login only if printing succeeds
// fetch('http://localhost:9100/print', { // fetch('http://localhost:9100/print', {
// method: 'POST', // method: 'POST',
// headers: { 'Content-Type': 'application/json' }, // headers: { 'Content-Type': 'application/json' },
@ -264,25 +268,74 @@ export class LoginComponent implements OnInit, OnDestroy {
// .then((res) => { // .then((res) => {
// if (!res.ok) throw new Error('Print failed'); // if (!res.ok) throw new Error('Print failed');
// console.log('🖨️ Print successful'); // console.log('🖨️ Print successful');
// Open second screen
(window as any).electronAPI?.openSecondScreen?.();
// // Navigate to home // ✅ Only here we allow login
(window as any).electronAPI?.openSecondScreen?.();
this.router.navigate(['/home']); this.router.navigate(['/home']);
// }) // })
// .catch((err) => { // .catch((err) => {
// console.error('‼️ Print failed', err); // console.error('‼️ Print failed', err);
// this.loginError = 'Login OK, but printing failed.'; // this.loginError = 'Login failed: printing service unavailable.';
// this.passwordStatus = false; // reset status
// }); // });
},
error: () => {
this.loginError = 'Invalid login credentials';
}
});
}
//-------------------------NEW LOGIN ENDS HERE -------------------------------------------------//
// async onSubmit(): Promise<void> {
// if (this.loginForm.invalid) {
// this.loginForm.markAllAsTouched();
// return;
// }
// const { email, password } = this.loginForm.value;
// // ✅ Await service (since its async)
// (await this.btcService.userLogin(email, password)).subscribe({
// next: (response) => {
// const employee = response.body;
// console.log('🧠 Raw employee response:', employee);
// const userName = employee?.userName || 'Unknown User';
// const employeeId = employee?.userIdNumber || email;
// console.log('✅ Parsed name:', userName);
// console.log('✅ Parsed ID:', employeeId);
// this.passwordStatus = true;
// // ✅ Get the BTID the service fetched
// const btid = this.btcService.btid;
// console.log("📦 BTID from file (via service):", btid);
// // Prepare print data
// const printData = {
// name: userName,
// employeeId: employeeId,
// action: 'login',
// type: 'login'
// };
// // ✅ Store in localStorage
// localStorage.setItem('userName', userName);
// localStorage.setItem('employeeId', employeeId);
// localStorage.setItem('password', password);
// localStorage.setItem('btid', btid || "unknown");
// // ✅ Open second screen + navigate
// (window as any).electronAPI?.openSecondScreen?.();
// this.router.navigate(['/home']);
// }, // },
// error: () => { // error: () => {
// this.loginError = 'Invalid login credentials'; // this.loginError = 'Invalid login credentials';
}, // }
}); // });
} // }
showConfirmModal : boolean = false; showConfirmModal : boolean = false;

View File

@ -5,13 +5,53 @@ import { ApplicationHttpRouts } from '../constants/http-routs';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
// export class BtcService {
// constructor(private http: HttpClient) {}
// btid: string | null = null;
// //user login
// public userLogin(employeeId: string, password: string) {
// console.log('Login route ' + ApplicationHttpRouts.LOG_IN);
// this.btid = localStorage.getItem('btid');
// if (this.btid) {
// employeeId += "," + this.btid;
// } else {
// employeeId += ",null"; // or just "," if you dont want "null"
// }
// return this.http.get<any>(ApplicationHttpRouts.LOG_IN, {
// headers: this.basicAuthCredentialsBuilder(employeeId, password),
// withCredentials: true,
// observe: 'response',
// });
// }
export class BtcService { export class BtcService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
btid: string | null = null;
// user login // user login
public userLogin(employeeId: string, password: string) { public async userLogin(employeeId: string, password: string) {
console.log('Login route ' + ApplicationHttpRouts.LOG_IN); console.log('Login route ' + ApplicationHttpRouts.LOG_IN);
try {
if ((window as any).electronAPI?.getBtid) {
this.btid = await (window as any).electronAPI.getBtid();
} else {
console.warn('Electron API not available — fallback to null');
this.btid = null;
}
} catch (err) {
console.error('Error fetching BTID:', err);
this.btid = null;
}
// Append BTID after comma
if (this.btid) {
employeeId += ',' + this.btid;
} else {
employeeId += ',null';
}
return this.http.get<any>(ApplicationHttpRouts.LOG_IN, { return this.http.get<any>(ApplicationHttpRouts.LOG_IN, {
headers: this.basicAuthCredentialsBuilder(employeeId, password), headers: this.basicAuthCredentialsBuilder(employeeId, password),
withCredentials: true, withCredentials: true,

View File

@ -31,7 +31,7 @@ services:
spring: spring:
#image: mathewfrancisv/spring_back_postgres:v1.0.0 #image: mathewfrancisv/spring_back_postgres:v1.0.0
image: mathewfrancisv/btc_cezen_backend:v1.0.2 image: mathewfrancisv/btc_cezen_backend:v1.1.6
container_name: spring_app container_name: spring_app
ports: ports:
- "8083:8080" - "8083:8080"
@ -41,7 +41,7 @@ services:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/horse SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/horse
SPRING_DATASOURCE_USERNAME: postgres # Ensure this matches POSTGRES_USER SPRING_DATASOURCE_USERNAME: postgres # Ensure this matches POSTGRES_USER
SPRING_DATASOURCE_PASSWORD: root # Ensure this matches POSTGRES_PASSWORD SPRING_DATASOURCE_PASSWORD: root # Ensure this matches POSTGRES_PASSWORD
SPRING_DATASOURCE_CORSIP: http://10.83.77.61:4200 SPRING_DATASOURCE_CORSIP: http://10.74.231.61:4200
#network_mode: host #network_mode: host
networks: networks:
- app_network - app_network