From 5b0ff9e0996fecd233a7bd743326841818e6517e Mon Sep 17 00:00:00 2001 From: TypoMustakes Date: Thu, 9 May 2024 17:56:16 +0200 Subject: [PATCH] SignalR implemented --- .../wwwroot/customers/customers.html | 1 + .../wwwroot/customers/customers.js | 38 ++++++++ .../wwwroot/employees/employees.html | 1 + .../wwwroot/employees/employees.js | 38 ++++++++ .../maintainer_teams/maintainerteam.html | 1 + .../maintainer_teams/maintainerteam.js | 38 ++++++++ .../GetSubordinates/GetSubordinates.html | 1 + .../wwwroot/noncrud/GetSubordinates/script.js | 51 ++++++++++ .../WhoIsResponsibleForService.html | 1 + .../WhoIsResponsibleForService/script.js | 93 +++++++++++++++++++ .../WhoMaintainsService.html | 1 + .../noncrud/WhoMaintainsService/script.js | 72 ++++++++++++++ .../WhoUsesService/WhoUsesService.html | 1 + .../wwwroot/noncrud/WhoUsesService/script.js | 72 ++++++++++++++ .../WhoWorksInMaintainerTeam.html | 1 + .../WhoWorksInMaintainerTeam/script.js | 71 ++++++++++++++ .../wwwroot/services/services.html | 1 + .../wwwroot/services/services.js | 38 ++++++++ 18 files changed, 520 insertions(+) diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.html index 7f6b21a..ae0fd9d 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.html @@ -4,6 +4,7 @@ Customers + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.js index b65cdd3..e7cf524 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/customers/customers.js @@ -1,5 +1,41 @@ let customers = []; +let connection = null; getcustomers(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("CustomerCreated", (user, message) => { + getcustomers(); + }); + + connection.on("CustomerDeleted", (user, message) => { + getcustomers(); + }); + + connection.on("CustomerUpdated", (user, message) => { + getcustomers(); + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getcustomers() { @@ -14,6 +50,8 @@ async function getcustomers() function display() { + document.getElementById('saveresult').innerHTML = ''; + document.getElementById('forms').innerHTML = ''; document.getElementById('resultarea').innerHTML = ''; customers.forEach(t => { diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.html index 228ab1c..2aa813f 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.html @@ -4,6 +4,7 @@ Employees + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.js index e63874b..95381eb 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/employees/employees.js @@ -1,5 +1,41 @@ let employees = []; +let connection = null; getemployees(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("EmployeeCreated", (user, message) => { + getemployees(); + }); + + connection.on("EmployeeDeleted", (user, message) => { + getemployees(); + }); + + connection.on("EmployeeUpdated", (user, message) => { + getemployees(); + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getemployees() { @@ -14,6 +50,8 @@ async function getemployees() function display() { + document.getElementById('saveresult').innerHTML = ''; + document.getElementById('forms').innerHTML = ''; document.getElementById('resultarea').innerHTML = ''; employees.forEach(t => { diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.html index fd085e7..4ea513a 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.html @@ -4,6 +4,7 @@ Teams + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.js index 526abc2..718050e 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/maintainer_teams/maintainerteam.js @@ -1,5 +1,41 @@ let teams = []; +let connection = null; getteams(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("MaintainerTeamCreated", (user, message) => { + getteams(); + }); + + connection.on("MaintainerTeamDeleted", (user, message) => { + getteams(); + }); + + connection.on("MaintainerTeamUpdated", (user, message) => { + getteams(); + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getteams() { @@ -14,6 +50,8 @@ async function getteams() function display() { + document.getElementById('saveresult').innerHTML = ''; + document.getElementById('forms').innerHTML = ''; document.getElementById('resultarea').innerHTML = ''; teams.forEach(t => { diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/GetSubordinates.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/GetSubordinates.html index a1b716d..1e3a9d8 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/GetSubordinates.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/GetSubordinates.html @@ -4,6 +4,7 @@ Get subordinates + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/script.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/script.js index 671e36b..0dfe853 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/script.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/GetSubordinates/script.js @@ -1,5 +1,54 @@ let employees = []; +let connection = null; +let selectedId = null; getEmployees(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("EmployeeCreated", (user, message) => { + getEmployees(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeDeleted", (user, message) => { + getEmployees(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeUpdated", (user, message) => { + getEmployees(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getEmployees() { @@ -15,6 +64,7 @@ async function getEmployees() function display() { document.getElementById('lines').innerHTML = ''; + document.getElementById('resultarea').innerHTML = ''; employees.forEach(t => { document.getElementById('lines').innerHTML += @@ -30,6 +80,7 @@ function display() async function runQuery(id) { + selectedId = id; let results = [] document.getElementById('resultarea').innerHTML = ''; diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/WhoIsResponsibleForService.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/WhoIsResponsibleForService.html index 23cb47f..f8136fc 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/WhoIsResponsibleForService.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/WhoIsResponsibleForService.html @@ -4,6 +4,7 @@ Get leader responsible for service + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/script.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/script.js index 1eb54ae..84739ac 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/script.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoIsResponsibleForService/script.js @@ -1,5 +1,96 @@ let services = []; +let connection = null; +let selectedId = null; getServices(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("ServiceCreated", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("ServiceDeleted", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("ServiceUpdated", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeCreated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeUpdated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeDeleted", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("MaintainerTeamCreated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("MaintainerTeamUpdated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("MaintainerTeamDeleted", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getServices() { @@ -15,6 +106,7 @@ async function getServices() function display() { document.getElementById('lines').innerHTML = ''; + document.getElementById('resultarea').innerHTML = ''; services.forEach(t => { document.getElementById('lines').innerHTML += @@ -30,6 +122,7 @@ function display() async function runQuery(id) { + selectedId = id; let result = null; document.getElementById('resultarea').innerHTML = ''; diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/WhoMaintainsService.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/WhoMaintainsService.html index 795199d..f3d3e28 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/WhoMaintainsService.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/WhoMaintainsService.html @@ -4,6 +4,7 @@ Who maintains a service + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/script.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/script.js index 221d9e8..a378887 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/script.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoMaintainsService/script.js @@ -1,5 +1,75 @@ let services = []; +let connection = null; +let selectedId = null; getServices(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("ServiceCreated", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("ServiceDeleted", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("ServiceUpdated", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeCreated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeUpdated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeDeleted", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getServices() { @@ -15,6 +85,7 @@ async function getServices() function display() { document.getElementById('lines').innerHTML = ''; + document.getElementById('resultarea').innerHTML = ''; services.forEach(t => { document.getElementById('lines').innerHTML += @@ -30,6 +101,7 @@ function display() async function runQuery(id) { + selectedId = id; let results = [] document.getElementById('resultarea').innerHTML = ''; diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/WhoUsesService.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/WhoUsesService.html index b43a6ee..91a4cdb 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/WhoUsesService.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/WhoUsesService.html @@ -4,6 +4,7 @@ Who uses service + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/script.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/script.js index 6d8eec8..7734fb1 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/script.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoUsesService/script.js @@ -1,5 +1,75 @@ let services = []; +let connection = null; +let selectedId = null; getServices(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("ServiceCreated", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("ServiceDeleted", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("ServiceUpdated", (user, message) => { + getServices(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("CustomerCreated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("CustomerDeleted", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("CustomerUpdated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getServices() { @@ -15,6 +85,7 @@ async function getServices() function display() { document.getElementById('lines').innerHTML = ''; + document.getElementById('resultarea').innerHTML = ''; services.forEach(t => { document.getElementById('lines').innerHTML += @@ -30,6 +101,7 @@ function display() async function runQuery(id) { + selectedId = id; let results = [] document.getElementById('resultarea').innerHTML = ''; diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/WhoWorksInMaintainerTeam.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/WhoWorksInMaintainerTeam.html index 77ec5ae..faf5871 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/WhoWorksInMaintainerTeam.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/WhoWorksInMaintainerTeam.html @@ -4,6 +4,7 @@ Who works in a team + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/script.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/script.js index 0c8d0ae..6c95dda 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/script.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/noncrud/WhoWorksInMaintainerTeam/script.js @@ -1,5 +1,75 @@ let teams = []; +let connection = null; +let selectedId = null; getTeams(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("MaintainerTeamCreated", (user, message) => { + getTeams(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("MaintainerTeamDeleted", (user, message) => { + getTeams(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("MaintainerTeamUpdated", (user, message) => { + getTeams(); + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeCreated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeDeleted", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.on("EmployeeUpdated", (user, message) => { + if (selectedId != null) + { + runQuery(selectedId); + } + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getTeams() { @@ -30,6 +100,7 @@ function display() async function runQuery(id) { + let selectedId = id; let results = [] document.getElementById('resultarea').innerHTML = ''; diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.html b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.html index 1d2a06a..7544154 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.html +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.html @@ -4,6 +4,7 @@ Services + diff --git a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.js b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.js index adb0a4c..4769827 100644 --- a/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.js +++ b/WD7UVN_SzTGUI_2023242.Client.JS/wwwroot/services/services.js @@ -1,5 +1,41 @@ let services = []; +let connection = null; getservices(); +setupSignalR(); + +function setupSignalR() { + connection = new signalR.HubConnectionBuilder() + .withUrl("https://localhost:5001/hub") + .configureLogging(signalR.LogLevel.Information) + .build(); + + connection.on("ServiceCreated", (user, message) => { + getservices(); + }); + + connection.on("ServiceDeleted", (user, message) => { + getservices(); + }); + + connection.on("ServiceUpdated", (user, message) => { + getservices(); + }); + + connection.onclose(async () => { + await start(); + }); + start(); +} + +async function start() { + try { + await connection.start(); + console.log("SignalR Connected."); + } catch (err) { + console.log(err); + setTimeout(start, 5000); + } +}; async function getservices() { @@ -14,6 +50,8 @@ async function getservices() function display() { + document.getElementById('saveresult').innerHTML = ''; + document.getElementById('forms').innerHTML = ''; document.getElementById('resultarea').innerHTML = ''; services.forEach(t => {