Compare commits
2 Commits
68bad8d8d7
...
213945b2e9
| Author | SHA1 | Date | |
|---|---|---|---|
| 213945b2e9 | |||
| c52b22a1ee |
@ -1,5 +1,6 @@
|
||||
const { app, BrowserWindow, screen, ipcMain } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let mainWindow;
|
||||
let screenWindow;
|
||||
@ -20,7 +21,7 @@ function createWindows() {
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.loadURL('http://10.83.77.61:4200/login');
|
||||
mainWindow.loadURL('http://10.74.231.124:4200/login');
|
||||
|
||||
screenWindow = new BrowserWindow({
|
||||
x: secondary.bounds.x,
|
||||
@ -35,10 +36,23 @@ function createWindows() {
|
||||
}
|
||||
});
|
||||
|
||||
screenWindow.loadURL('http://10.83.77.61:4200/shared-display');
|
||||
screenWindow.loadURL('http://10.74.231.124:4200/shared-display');
|
||||
|
||||
ipcMain.on('open-second-screen', () => screenWindow.show());
|
||||
ipcMain.on('close-second-screen', () => screenWindow.hide());
|
||||
|
||||
// ✅ IPC to return BTID
|
||||
ipcMain.handle('get-btid', () => {
|
||||
try {
|
||||
const filePath = path.join(process.env.HOME || process.env.USERPROFILE, 'BTID', 'betting.txt');
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
const match = content.match(/Btid\s*=\s*(\d+)/i);
|
||||
return match ? match[1] : null;
|
||||
} catch (err) {
|
||||
console.error('Error reading betting.txt:', err);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindows);
|
||||
|
||||
@ -3,4 +3,7 @@ const { contextBridge, ipcRenderer } = require('electron');
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
openSecondScreen: () => ipcRenderer.send('open-second-screen'),
|
||||
closeSecondScreen: () => ipcRenderer.send('close-second-screen'),
|
||||
|
||||
// ✅ Ask main process for Btid
|
||||
getBtid: () => ipcRenderer.invoke('get-btid')
|
||||
});
|
||||
@ -583,7 +583,11 @@
|
||||
.btno-label {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: #fff; /* Or match whatever text color you use */
|
||||
color: #fff;
|
||||
}
|
||||
/* Extra spacing between the two */
|
||||
.btno-space {
|
||||
margin-right: 2rem; /* increase or decrease as needed */
|
||||
}
|
||||
.date-time {
|
||||
font-weight: bold;
|
||||
|
||||
@ -7,12 +7,12 @@
|
||||
class="d-flex align-items-center text-light small justify-content-end flex-grow-1"
|
||||
>
|
||||
|
||||
<span class="btno-label me-2">
|
||||
<span class="btno-label btno-space">
|
||||
<b>Operator:</b> {{ userName }}
|
||||
</span>
|
||||
|
||||
<span class="btno-label me-3">
|
||||
<b>B.T.No: 1111</b>
|
||||
<b>B.T.No: </b> {{ btid }}
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
||||
screenWidth: number = window.innerWidth;
|
||||
private subscription!: Subscription;
|
||||
userName: string = '';
|
||||
btid: string | null = null;
|
||||
|
||||
liveStatusOk: boolean = true;
|
||||
|
||||
@ -76,6 +77,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
this.userName = localStorage.getItem('userName') || '';
|
||||
this.btid = localStorage.getItem('btid');
|
||||
// Use NgZone to run setInterval outside Angular's change detection
|
||||
this.zone.runOutsideAngular(() => {
|
||||
setInterval(() => {
|
||||
|
||||
@ -215,16 +215,17 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
|
||||
|
||||
|
||||
onSubmit(): void {
|
||||
// ✅ Updated onSubmit with BTID
|
||||
async onSubmit(): Promise<void> {
|
||||
if (this.loginForm.invalid) {
|
||||
this.loginForm.markAllAsTouched();
|
||||
return;
|
||||
}
|
||||
|
||||
const { email, password } = this.loginForm.value;
|
||||
|
||||
this.btcService.userLogin(email, password).subscribe({
|
||||
next: (response) => {
|
||||
next: async (response) => {
|
||||
const employee = response.body;
|
||||
console.log('🧠 Raw employee response:', employee);
|
||||
|
||||
@ -236,49 +237,53 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.passwordStatus = true;
|
||||
|
||||
// ✅ Fetch BTID from Electron preload
|
||||
const btid = await (window as any).electronAPI?.getBtid?.();
|
||||
console.log("📦 BTID from file:", btid);
|
||||
|
||||
// Prepare print data
|
||||
const printData = {
|
||||
name: userName,
|
||||
employeeId: employeeId,
|
||||
action: 'login',
|
||||
type: 'login' // ← ADD THIS
|
||||
type: 'login'
|
||||
};
|
||||
|
||||
|
||||
// Store in localStorage
|
||||
// ✅ Store in localStorage
|
||||
localStorage.setItem('userName', userName);
|
||||
localStorage.setItem('employeeId', employeeId);
|
||||
localStorage.setItem('password', password);
|
||||
localStorage.setItem('btid', btid || "unknown");
|
||||
|
||||
// Optional print logic
|
||||
fetch('http://localhost:9100/print', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(printData),
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error('Print failed');
|
||||
console.log('🖨️ Print successful');
|
||||
// ✅ Optional second screen + navigate
|
||||
// fetch('http://localhost:9100/print', {
|
||||
// method: 'POST',
|
||||
// headers: { 'Content-Type': 'application/json' },
|
||||
// body: JSON.stringify(printData),
|
||||
// })
|
||||
// .then((res) => {
|
||||
// if (!res.ok) throw new Error('Print failed');
|
||||
// console.log('🖨️ Print successful');
|
||||
// Open second screen
|
||||
(window as any).electronAPI?.openSecondScreen?.();
|
||||
|
||||
// // Navigate to home
|
||||
this.router.navigate(['/home']);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('‼️ Print failed', err);
|
||||
this.loginError = 'Login OK, but printing failed.';
|
||||
});
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.error('‼️ Print failed', err);
|
||||
// this.loginError = 'Login OK, but printing failed.';
|
||||
// });
|
||||
|
||||
|
||||
},
|
||||
|
||||
error: () => {
|
||||
this.loginError = 'Invalid login credentials';
|
||||
// },
|
||||
// error: () => {
|
||||
// this.loginError = 'Invalid login credentials';
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
showConfirmModal : boolean = false;
|
||||
|
||||
confirmShutdown() : void{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user