Newer
Older
import { logoutKeycloak } from './authentication/script.js';//qui lo script si prende il token
import RequestToDomain from './authentication/requests-to-domain.js';
import Antifurto from "./antifurto.js";
import Scenari from "./scenari.js";
import Luci from './luci.js';
const logout = document.getElementById("button-logout");
logout.addEventListener('click', () => {
logoutKeycloak();
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
});
// ask domain to know which service should be used
const servicesArray = await RequestToDomain.getUsedServices();
new Sensori();
const boolArray = [false,false,false];
for(const service of servicesArray) {
if(service === 'antifurto') {
boolArray[0] = true;
}
else if(service === 'scenari') {
boolArray[1] = true;
}
else if(service === 'luci') {
boolArray[2] = true;
}
}
// launch each class
const antifurtobtn = document.getElementById("antifurto-btn");
if(boolArray[0])
new Antifurto();
else {
antifurtobtn.classList.add('invisible');
}
const scenariBtn = document.getElementById("scenari-btn");
if(boolArray[1])
new Scenari();
else {
scenariBtn.classList.add('invisible');
}
const luciBtn = document.getElementById("luci-btn");
if(boolArray[2])
new Luci();
else {
luciBtn.classList.add('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');
}