Bonjour,
voici 2 nouveaux widgets pour IPX800 V5, permettant la modification des codes d’accès, sans avoir à ouvrir la configuration de l’objet ACCESS CONTROL.
Ces widgets seront donc à réserver sur des dashboards protégés (admin, root,)
Modification d’un code d’accès :
Dans le code suivant, renseignez l’id de la variable str32 à modifier en ligne 1 du code.
Dans les variables str32 (page collection), recherchez la variable nommée strPoolCode_id x correspondant à votre objet access control. X de 1 à 6 correspond au numéro du code.
<script>
var idStr32a=524321;//id de la variable Str32
window.GCE_Refresh.push(function(data) { //IMPORTANT: binding refresh function to the WebSocket
switch (data['_id'])
{
case idStr32a:
document.getElementById('CodeA').value=data.value;
break;
}
})
function init1() {
GCE_API.get("/api/core/str/" + idStr32a.toString()).then((ret) => {
document.getElementById("CodeA").value=ret.value;
})
}
function MajSTR1() {
let v=document.getElementById('CodeA').value;
GCE_API.put("/api/core/str/" + idStr32a.toString(),{value: v});
}
init1()
</script>
<style>
.input1 {
width: 80%;
padding: 3px;
margin-bottom: 3px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 12px;
}
.label1 {
font-size: 12px;
margin-bottom: 3px;
display: block;
}
.button1 {
padding: 5px 10px;
font-size: 14px;
border: none;
border-radius: 4px;
cursor: pointer;
background-color: #007bff;
color: #fff;
}
.button1:hover {
background-color: #0056b3;
}
</style>
<label for="Code1" class="label1">Code client :</label>
<input class="input1" type="text" id="CodeA" name="CodeA">
<button class="button1" onclick="MajSTR1()">Envoi</button>
Modification des 6 codes d’accès
Dans les variables str32 (page collection), recherchez la variable nommée strPoolCode_id 1 correspondant à votre objet access control puis renseignez son id en ligne 1 du code ci-dessous.
<script>
var idStr32 = 524321; // id de la 1ère variable Str32
window.GCE_Refresh.push(function(data) { //IMPORTANT: binding refresh function to the WebSocket
switch (data['_id']) {
case idStr32 :
document.getElementById('Code1').value = data.value;
break;
case idStr32 + 1:
document.getElementById('Code2').value = data.value;
break;
case idStr32 + 2:
document.getElementById('Code3').value = data.value;
break;
case idStr32 + 3:
document.getElementById('Code4').value = data.value;
break;
case idStr32 + 4:
document.getElementById('Code5').value = data.value;
break;
case idStr32 + 5:
document.getElementById('Code6').value = data.value;
break;
}
});
function init2() {
GCE_API.get("/api/core/str/" + (idStr32 + 0).toString()).then((ret) => {
document.getElementById("Code1").value = ret.value;
});
GCE_API.get("/api/core/str/" + (idStr32 + 1).toString()).then((ret) => {
document.getElementById("Code2").value = ret.value;
});
GCE_API.get("/api/core/str/" + (idStr32 + 2).toString()).then((ret) => {
document.getElementById("Code3").value = ret.value;
});
GCE_API.get("/api/core/str/" + (idStr32 + 3).toString()).then((ret) => {
document.getElementById("Code4").value = ret.value;
});
GCE_API.get("/api/core/str/" + (idStr32 + 4).toString()).then((ret) => {
document.getElementById("Code5").value = ret.value;
});
GCE_API.get("/api/core/str/" + (idStr32 + 5).toString()).then((ret) => {
document.getElementById("Code6").value = ret.value;
});
}
function MajSTR() {
let v = document.getElementById('Code1').value;
GCE_API.put("/api/core/str/" + (idStr32).toString(), { value: v });
v = document.getElementById('Code2').value;
GCE_API.put("/api/core/str/" + (idStr32 + 1).toString(), { value: v });
v = document.getElementById('Code3').value;
GCE_API.put("/api/core/str/" + (idStr32 + 2).toString(), { value: v });
v = document.getElementById('Code4').value;
GCE_API.put("/api/core/str/" + (idStr32 + 3).toString(), { value: v });
v = document.getElementById('Code5').value;
GCE_API.put("/api/core/str/" + (idStr32 + 4).toString(), { value: v });
v = document.getElementById('Code6').value;
GCE_API.put("/api/core/str/" + (idStr32 + 5).toString(), { value: v });
}
init2();
</script>
<style>
.container2 {
background-color: #fff;
padding: 3px;
text-align: center;
width: 100%;
}
.label2 {
font-size: 12px;
margin-top: 3px;
display: inline-block;
width: 25%;
text-align: left;
color: #000;
}
.input2 {
width: 50%;
padding: 1px;
margin-top: 1px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
display: inline-block;
color: #333;
}
.button2 {
padding: 5px 10px;
font-size: 14px;
border: none;
border-radius: 4px;
cursor: pointer;
background-color: #007bff;
color: #fff;
}
.button2:hover {
background-color: #0056b3;
}
</style>
<div class="container2">
<div>
<label for="Code1" class="label2">Code 1 :</label>
<input class="input2" type="text" id="Code1" name="Code1">
</div>
<div>
<label for="Code2" class="label2">Code 2 :</label>
<input class="input2" type="text" id="Code2" name="Code2">
</div>
<div>
<label for="Code3" class="label2">Code 3 :</label>
<input class="input2" type="text" id="Code3" name="Code3">
</div>
<div>
<label for="Code4" class="label2">Code 4 :</label>
<input class="input2" type="text" id="Code4" name="Code4">
</div>
<div>
<label for="Code5" class="label2">Code 5 :</label>
<input class="input2" type="text" id="Code5" name="Code5">
</div>
<div>
<label for="Code6" class="label2">Code 6 :</label>
<input class="input2" type="text" id="Code6" name="Code6">
</div>
<button class="button2" onclick="MajSTR()">Envoi</button>
</div>
Bonne journée