Skip to content
Snippets Groups Projects
Commit 2821f9fa authored by Alfredo Chissotti's avatar Alfredo Chissotti
Browse files

wss inizio

parent 479d468e
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -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);
}
}
......@@ -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;
}
......
......@@ -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)
......@@ -51,4 +51,8 @@
.no-padding-left {
padding-left: 0;
}
#no-services {
box-shadow: 0px 0px 10px;
}
\ No newline at end of file
......@@ -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>
......
......@@ -24,6 +24,8 @@ client.connect({
onSuccess: onConnect,
userName: "gruppo2",
password: "funziona",
useSSL: true,
cleanSession: false,
});
let isConnected = false;
......
"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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment