diff --git a/domainManager/Domain/DBPissirDomain.db b/domainManager/Domain/DBPissirDomain.db index 67fd95713eba1c06f1ad515715a22437def76f14..dbeb8858400454bbff0580994bf4151500f2f4f4 100644 Binary files a/domainManager/Domain/DBPissirDomain.db and b/domainManager/Domain/DBPissirDomain.db differ diff --git a/domainManager/Domain/bin/code/Domain.class b/domainManager/Domain/bin/code/Domain.class index d16ed102ae0246ca342220f09fc2d349244a5684..4eaaa810bd027dd436456bb3b41b6ae53c2b05e5 100644 Binary files a/domainManager/Domain/bin/code/Domain.class and b/domainManager/Domain/bin/code/Domain.class differ diff --git a/domainManager/Domain/bin/code/ServicesHandler.class b/domainManager/Domain/bin/code/ServicesHandler.class index dfc99fc528af6cb09f2e5cf5ebcb63f1592a225a..e2272c0dc4eec585dd87c5711b7d282d8e28c8c6 100644 Binary files a/domainManager/Domain/bin/code/ServicesHandler.class and b/domainManager/Domain/bin/code/ServicesHandler.class differ diff --git a/domainManager/Domain/src/code/Domain.java b/domainManager/Domain/src/code/Domain.java index b921fb8ad228a942110da5a7385cf0626dbb2501..d6d11b77e5874112762301cc4dcd06970a515005 100644 --- a/domainManager/Domain/src/code/Domain.java +++ b/domainManager/Domain/src/code/Domain.java @@ -137,7 +137,7 @@ public class Domain { server.createContext("/secured/priviledges", new PriviledgesHandler()); server.start(); - System.out.println("Domain in ascolto su localhost:"+port); + System.out.println("Domain in ascolto su http://localhost:"+port); } } diff --git a/domainManager/Domain/src/code/ServicesHandler.java b/domainManager/Domain/src/code/ServicesHandler.java index f3163399a389570aa9d67f4884b2c2400c9a31e1..107459c8aea6a63232c1fd9903cabdce8e41e2c1 100644 --- a/domainManager/Domain/src/code/ServicesHandler.java +++ b/domainManager/Domain/src/code/ServicesHandler.java @@ -28,8 +28,8 @@ public class ServicesHandler implements HttpHandler{ return; } - String user; - if((user = Helper.checkTokenGetUser(he)) == null) { + + if(Helper.checkTokenGetUser(he) == null) { Helper.sendCors(he, 401); return; } diff --git a/keycloak-19.0.1/data/h2/keycloakdb.trace.db b/keycloak-19.0.1/data/h2/keycloakdb.trace.db index de54447f51604d9916d7b5f7fb230807e93a1dda..de938763137aab3ffde715460364c7da36735ed7 100644 --- a/keycloak-19.0.1/data/h2/keycloakdb.trace.db +++ b/keycloak-19.0.1/data/h2/keycloakdb.trace.db @@ -1345,3 +1345,34 @@ org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic c at io.quarkus.runtime.Application.stop(Application.java:203) at io.quarkus.runtime.Application.stop(Application.java:155) at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:420) +2022-09-14 19:40:43 jdbc[3]: exception +org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-197] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) + at org.h2.message.DbException.get(DbException.java:179) + at org.h2.message.DbException.get(DbException.java:155) + at org.h2.message.DbException.get(DbException.java:144) + at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1526) + at org.h2.jdbcx.JdbcXAConnection$PooledJdbcConnection.checkClosed(JdbcXAConnection.java:470) + at org.h2.jdbc.JdbcConnection.checkClosedForWrite(JdbcConnection.java:1512) + at org.h2.jdbc.JdbcConnection.rollback(JdbcConnection.java:516) + at org.h2.jdbcx.JdbcXAConnection$PooledJdbcConnection.close(JdbcXAConnection.java:450) + at org.h2.jdbcx.JdbcXAConnection.close(JdbcXAConnection.java:78) + at io.agroal.pool.ConnectionHandler.closeConnection(ConnectionHandler.java:185) + at io.agroal.pool.ConnectionPool$DestroyConnectionTask.run(ConnectionPool.java:768) + at io.agroal.pool.ConnectionPool.close(ConnectionPool.java:189) + at io.agroal.pool.DataSource.close(DataSource.java:79) + at io.quarkus.agroal.runtime.DataSources.stop(DataSources.java:381) + at io.quarkus.agroal.runtime.DataSources_Bean.destroy(Unknown Source) + at io.quarkus.agroal.runtime.DataSources_Bean.destroy(Unknown Source) + at io.quarkus.arc.impl.AbstractInstanceHandle.destroyInternal(AbstractInstanceHandle.java:80) + at io.quarkus.arc.impl.ContextInstanceHandleImpl.destroy(ContextInstanceHandleImpl.java:20) + at io.quarkus.arc.impl.AbstractSharedContext.destroy(AbstractSharedContext.java:94) + at io.quarkus.arc.impl.ArcContainerImpl.shutdown(ArcContainerImpl.java:369) + at io.quarkus.arc.Arc.shutdown(Arc.java:52) + at io.quarkus.arc.runtime.ArcRecorder$1.run(ArcRecorder.java:44) + at io.quarkus.runtime.StartupContext.runAllInReverseOrder(StartupContext.java:84) + at io.quarkus.runtime.StartupContext.close(StartupContext.java:73) + at io.quarkus.runner.ApplicationImpl.doStop(Unknown Source) + at io.quarkus.runtime.Application.stop(Application.java:203) + at io.quarkus.runtime.Application.stop(Application.java:155) + at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:420) diff --git a/webapp/public/css/style.css b/webapp/public/css/style.css index da1bc4599b51d304085dc9bec23cc592f32ce2b7..08f68275405435a08bad62104bd01da8b78854b0 100644 --- a/webapp/public/css/style.css +++ b/webapp/public/css/style.css @@ -51,4 +51,8 @@ .no-padding-left { padding-left: 0; +} + +#no-services { + box-shadow: 0px 0px 10px; } \ No newline at end of file diff --git a/webapp/public/index.html b/webapp/public/index.html index d5a07dbe480b8d823bcd34e438e6d72f6b2fc277..6dbe9f23918df258e45e7d18c94a747c76f21a9e 100644 --- a/webapp/public/index.html +++ b/webapp/public/index.html @@ -33,7 +33,7 @@ </head> <body id="body-id"> - <h1>Pissir SmartHome ${nomeCasa o nomeProprio}</h1> + <h1>Pissir SmartHome</h1> <div id="alert-message" role="alert" class="alert invisible"> <!-- <div class="d-flex justify-content-around container-fluid"> <i class="fa-solid fa-exclamation-circle fa-4x" aria-hidden="true"></i> @@ -46,17 +46,21 @@ <!-- alert-danger --> <!-- alert-success --> </div> + <div id="no-services" class="invisible d-col position-absolute top-50 start-50 translate-middle"> + <h1 style="width: 50%; margin: 0 auto;">Non hai servizi</h1> + <h3 style="width: 90%; margin: 10px auto;">Non hai scelto nessun nostro servizio attivo. Questa pagina rimane vuota.</h3> + </div> <button class="btn btn-primary position-absolute bottom-0 end-0" id="button-logout">Logout</button> <!-- container of the top buttons to change what is seen --> <div id="mainButtonContainer" class="d-flex flex-row justify-content-around"> - <button class="btn-12 btn btn-dark" id="luci-btn"> + <button class="btn-12 btn btn-dark invisible" id="luci-btn"> <span>Luci</span> </button> - <button class="btn-12 btn btn-dark" id="scenari-btn"> + <button class="btn-12 btn btn-dark invisible" id="scenari-btn"> <span>Scenari</span> </button> - <button class="btn-12 btn btn-dark" id="antifurto-btn"> + <button class="btn-12 btn btn-dark invisible" id="antifurto-btn"> <span>Antifurto</span> </button> </div> diff --git a/webapp/public/js/mqtt/mqtthat.js b/webapp/public/js/mqtt/mqtthat.js index f5b25b8f81fbf24acde029a3e71a4c065497eab3..c188125242fe8a01d49f1130b4f7a89060dc7ca9 100644 --- a/webapp/public/js/mqtt/mqtthat.js +++ b/webapp/public/js/mqtt/mqtthat.js @@ -24,6 +24,8 @@ client.connect({ onSuccess: onConnect, userName: "gruppo2", password: "funziona", + useSSL: true, + cleanSession: false, }); let isConnected = false; diff --git a/webapp/public/js/scriptIndex.js b/webapp/public/js/scriptIndex.js index 6895400a1526e86d5bf5cf561798a4c330a54ab2..a4576b839322faf6afee7236bb584b73b98f68ad 100644 --- a/webapp/public/js/scriptIndex.js +++ b/webapp/public/js/scriptIndex.js @@ -1,11 +1,11 @@ "use strict"; import { logoutKeycloak } from './authentication/script.js';//qui lo script si prende il token import RequestToDomain from './authentication/requests-to-domain.js'; -import Sensori from './sensori.js'; -import Antifurto from "./antifurto.js"; -import Scenari from "./scenari.js"; -import Luci from './luci.js'; -import Admin from './adminControls.js'; +// import Sensori from './sensori.js'; +// import Antifurto from "./antifurto.js"; +// import Scenari from "./scenari.js"; +// import Luci from './luci.js'; +// import Admin from './adminControls.js'; const logout = document.getElementById("button-logout"); logout.addEventListener('click', () => { @@ -13,12 +13,12 @@ logout.addEventListener('click', () => { }); // ask domain to know which service should be used -const domain = sessionStorage.getItem('domain') +const domain = sessionStorage.getItem('domain'); +document.querySelector('body > h1').innerHTML = `Pissir SmartHome @${domain}`; // map all elements in servicesArray to be lower case const servicesArray = (await RequestToDomain.getUsedServices(domain)).map(s => s.toLowerCase());// ["luci", "antifurto", ...] const userPriviledges = await RequestToDomain.getUserPriviledges(domain);// "admin" or "user" -new Sensori(); const boolArray = [false, false, false]; let atLeastOneOfOurServices = false; for (const service of servicesArray) { @@ -35,41 +35,47 @@ for (const service of servicesArray) { atLeastOneOfOurServices = true; } } -if (!atLeastOneOfOurServices) { - document.getElementById('no-services').classList.remove('invisible');//TODO creare questo elemento -} -// launch each class -const antifurtobtn = document.getElementById("antifurto-btn"); -if (boolArray[0]) - new Antifurto(); -else { - antifurtobtn.classList.add('invisible'); -} +const antifurtoBtn = document.getElementById("antifurto-btn"); +const scenariBtn = document.getElementById("scenari-btn"); +const luciBtn = document.getElementById("luci-btn"); +if (!atLeastOneOfOurServices) { + document.getElementById('no-services').classList.remove('invisible'); +} else { + const sensori = await import('./sensori.js'); + new sensori.default(); -const scenariBtn = document.getElementById("scenari-btn"); -if (boolArray[1]) - new Scenari(); -else { - scenariBtn.classList.add('invisible'); -} + // launch each class + if (boolArray[0]){ + const antifurto = await import("./antifurto.js"); + new antifurto.default(); + antifurtoBtn.classList.remove('invisible'); + } -const luciBtn = document.getElementById("luci-btn"); -if (boolArray[2]) - new Luci(); -else { - luciBtn.classList.add('invisible'); -} + if (boolArray[1]){ + const scenari = await import("./scenari.js"); + new scenari.default(); + scenariBtn.classList.remove('invisible'); + } -// if there is only one service, click the related button -// search if there's only one true in the boolArray -if (servicesArray.length === 1) { - const btn = document.getElementById(`${servicesArray[0]}-btn`); - btn.click(); - // btn.classList.add('invisible'); -} + if (boolArray[2]){ + const luci = await import('./luci.js'); + new luci.default(); + luciBtn.classList.remove('invisible'); + } + + // if there is only one service, click the related button + // search if there's only one true in the boolArray + if (servicesArray.length === 1) { + const btn = document.getElementById(`${servicesArray[0]}-btn`); + btn.click(); + // btn.classList.add('invisible'); + } -// if the user is an admin, show the admin panel -if (userPriviledges.toLowerCase() === 'admin') - new Admin(); \ No newline at end of file + // if the user is an admin, show the admin panel + if (userPriviledges.toLowerCase() === 'admin'){ + const admin = await import('./adminControls.js'); + new admin.default(); + } +} \ No newline at end of file