From 1cfe2fd97053542ae3b0d71714d7420b254f8c6c Mon Sep 17 00:00:00 2001 From: karthik Date: Thu, 18 Sep 2025 12:27:47 +0530 Subject: [PATCH] feat : stop message sync with 2nd screen also --- btc-UI/electron/main.js | 12 ++- btc-UI/electron/preload.js | 6 +- .../components/navbar/navbar.component.css | 25 +++++++ .../components/navbar/navbar.component.html | 75 +++---------------- .../app/components/navbar/navbar.component.ts | 73 +++++++++++++----- .../shared-table/shared-table.component.css | 24 +++++- .../shared-table/shared-table.component.html | 13 ++-- .../shared-table/shared-table.component.ts | 27 ++++--- btc-UI/src/electron.d.ts | 4 +- 9 files changed, 153 insertions(+), 106 deletions(-) diff --git a/btc-UI/electron/main.js b/btc-UI/electron/main.js index d745384..88ae035 100644 --- a/btc-UI/electron/main.js +++ b/btc-UI/electron/main.js @@ -1,4 +1,3 @@ -// main.js const { app, BrowserWindow, screen, ipcMain } = require('electron'); const path = require('path'); const fs = require('fs'); @@ -23,7 +22,7 @@ function createWindows() { }, }); - mainWindow.loadURL('http://10.74.231.124:4200/login'); + mainWindow.loadURL('http://10.150.40.124:4200/login'); screenWindow = new BrowserWindow({ x: secondary.bounds.x, @@ -38,7 +37,7 @@ function createWindows() { }, }); - screenWindow.loadURL('http://10.74.231.124:4200/shared-display'); + screenWindow.loadURL('http://10.150.40.124:4200/shared-display'); // Handle opening second screen and send initial data ipcMain.on('open-second-screen', () => { @@ -58,6 +57,13 @@ function createWindows() { } }); + // Add this new handler + ipcMain.on('sync-stop-message', (event, message) => { + if (screenWindow && screenWindow.webContents) { + screenWindow.webContents.send('update-stop-message', message); + } + }); + // Handle BTID request ipcMain.handle('get-btid', () => { try { diff --git a/btc-UI/electron/preload.js b/btc-UI/electron/preload.js index 3d1c198..767cc37 100644 --- a/btc-UI/electron/preload.js +++ b/btc-UI/electron/preload.js @@ -1,12 +1,12 @@ -// preload.js const { contextBridge, ipcRenderer } = require('electron'); contextBridge.exposeInMainWorld('electronAPI', { openSecondScreen: () => ipcRenderer.send('open-second-screen'), closeSecondScreen: () => ipcRenderer.send('close-second-screen'), getBtid: () => ipcRenderer.invoke('get-btid'), - // New: Send data to main process syncSharedData: (data) => ipcRenderer.send('sync-shared-data', data), - // New: Receive data in second window onUpdateSharedData: (callback) => ipcRenderer.on('update-shared-data', (event, data) => callback(data)), + // Add these new lines + syncStopMessage: (message) => ipcRenderer.send('sync-stop-message', message), + onUpdateStopMessage: (callback) => ipcRenderer.on('update-stop-message', (event, message) => callback(message)), }); \ No newline at end of file diff --git a/btc-UI/src/app/components/navbar/navbar.component.css b/btc-UI/src/app/components/navbar/navbar.component.css index 3de3bbd..fd24891 100755 --- a/btc-UI/src/app/components/navbar/navbar.component.css +++ b/btc-UI/src/app/components/navbar/navbar.component.css @@ -668,3 +668,28 @@ border-radius: 4px; cursor: pointer; } + + +/* Style for the scrolling stop message */ +.stop-message { + background-color: red; + color: white; + font-weight: bold; + padding: 2px 5px; + margin: 0 10px; + border-radius: 4px; + display: inline-block; + max-width: 50%; + overflow: hidden; +} + +.stop-message marquee { + font-size: 14px; + line-height: 20px; +} + +/* Existing styles for other elements */ +.text-light { + color: white !important; +} +/* Add other existing styles as needed */ \ No newline at end of file diff --git a/btc-UI/src/app/components/navbar/navbar.component.html b/btc-UI/src/app/components/navbar/navbar.component.html index f60719f..f19831b 100755 --- a/btc-UI/src/app/components/navbar/navbar.component.html +++ b/btc-UI/src/app/components/navbar/navbar.component.html @@ -3,27 +3,28 @@
{{ dateTime }}
+
+
+ {{ stopMessage }} +
+
- - Operator: {{ userName }} + Operator: {{ userName }} - - B.T.No: {{ btid }} + B.T.No: {{ btid }} - -
- @if( liveStatusOk){ - LIVE + @if (liveStatusOk) { + LIVE } @else { - OFF-LINE + OFF-LINE }
@@ -106,7 +107,6 @@ > Race No. | {{ selectedRace }} -
\ No newline at end of file diff --git a/btc-UI/src/app/components/shared-table/shared-table.component.ts b/btc-UI/src/app/components/shared-table/shared-table.component.ts index 19506b0..8c4e9b0 100644 --- a/btc-UI/src/app/components/shared-table/shared-table.component.ts +++ b/btc-UI/src/app/components/shared-table/shared-table.component.ts @@ -1,4 +1,3 @@ -// shared-table.component.ts import { Component, Input, OnInit } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SelectionData } from '../selection.service/selection.service'; @@ -19,18 +18,28 @@ export class SharedTableComponent implements OnInit { message = ''; isConnected = false; + // Add this new property + stopMessage: string = ''; constructor(private websocketService: WebsocketService) {} ngOnInit() { - this.websocketService.message$.subscribe((msg) => { - this.message = msg; - console.log('[SHARED TABLE] WebSocket message:', msg); - }); + // this.websocketService.message$.subscribe((msg) => { + // this.message = msg; + // console.log('[SHARED TABLE] WebSocket message:', msg); + // }); - this.websocketService.isConnected$.subscribe((status) => { - this.isConnected = status; - console.log('[SHARED TABLE] WebSocket connection status:', status); - }); + // this.websocketService.isConnected$.subscribe((status) => { + // this.isConnected = status; + // console.log('[SHARED TABLE] WebSocket connection status:', status); + // }); + + // Add this: Listen for stop message updates + if (window.electronAPI) { + window.electronAPI.onUpdateStopMessage((message: string) => { + this.stopMessage = message; + console.log('[SHARED TABLE] Received stop message:', message); + }); + } } } \ No newline at end of file diff --git a/btc-UI/src/electron.d.ts b/btc-UI/src/electron.d.ts index 36ebac7..902899b 100644 --- a/btc-UI/src/electron.d.ts +++ b/btc-UI/src/electron.d.ts @@ -1,10 +1,12 @@ -// src/electron.d.ts interface ElectronAPI { openSecondScreen: () => void; closeSecondScreen: () => void; getBtid: () => Promise; syncSharedData: (data: SharedData) => void; onUpdateSharedData: (callback: (data: SharedData) => void) => void; + // Add these new lines + syncStopMessage: (message: string) => void; + onUpdateStopMessage: (callback: (message: string) => void) => void; } interface SharedData {