Skip to content

Commit

Permalink
Config page: post check if WIFI addr is there for WIFI type
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Oct 20, 2023
1 parent 8a2b26f commit 7c04028
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
12 changes: 12 additions & 0 deletions core/ajax/Abeille.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,18 @@ function sendToCmd($topic, $payload = '') {
ajax::success(json_encode(array('status' => $status, 'error' => $error)));
}

// Returns 'config' DB content
if (init('action') == 'getConfig') {
$status = 0;
$error = "";

$config = AbeilleTools::getConfig();
$configJson = json_encode($config);
logDebug('configJson='.$configJson);

ajax::success(json_encode(array('status' => $status, 'error' => $error, 'config' => $configJson)));
}

/* WARNING: ajax::error DOES NOT trig 'error' callback on client side.
Instead 'success' callback is used. This means that
- take care of error code returned
Expand Down
1 change: 1 addition & 0 deletions docs/fr_FR/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ChangeLog
- Sirene iAlarm: Mises-à-jour du modèle (2629).
- Moniteur: Amélioration interne pour support gros messages.
- Moes télécommande universelle IR: Mise-à-jour du code pour ce support particulier (2607).
- Page de config: Vérification adresse IP remplie si type WIFI.

231012-BETA-1
-------------
Expand Down
47 changes: 43 additions & 4 deletions plugin_info/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
fclose($file);

echo '<script>var js_wifiLink = "'.wifiLink.'";</script>'; // PHP to JS
echo '<script>var js_maxZigates = "'.maxNbOfZigate.'";</script>'; // PHP to JS

/* Returns current cmd value identified by its Jeedom logical ID name */
function getCmdValueByLogicId($eqId, $logicId) {
Expand Down Expand Up @@ -1393,10 +1394,48 @@ function cleanUp() {
});
}

// Tcharp38: Might be useful. Seems to be called when plugin config has been saved
// function Abeille_postSaveConfiguration() {
// console.log("Abeille_postSaveConfiguration()");
// }
// Called when Abeille plugin config has been saved
function Abeille_postSaveConfiguration() {
console.log("Abeille_postSaveConfiguration()");

$.ajax({
type: 'POST',
url: 'plugins/Abeille/core/ajax/Abeille.ajax.php',
data: {
action: 'getConfig'
},
dataType: 'json',
global: false,
error: function (request, status, error) {
console.log("Ajax error: status=", status);
},
success: function (json_res) {
// console.log("json_res=", json_res);
res = JSON.parse(json_res.result);
// Assuming status 0
config = JSON.parse(res.config);
// console.log("config=", config);

errors = '';
for (zgId = 1; zgId < js_maxZigates; zgId++) {
if (config['ab::zgEnabled'+zgId] != 'Y')
continue; // Disabled

zgType = config['ab::zgType'+zgId];
// console.log("Zigate "+zgId+" type "+zgType);

if (zgType == 'WIFI') {
if (config['ab::zgIpAddr'+zgId] == '') {
errors += "Zigate "+zgId+": {{- Adresse IP manquante}}";
}
}
// TODO: Check type choice vs FW version
}
if (errors != '')
window.alert(errors);
}
});
}

function statusChange(zgId) {
console.log("statusChange("+zgId+")")
Expand Down

0 comments on commit 7c04028

Please sign in to comment.