Skip to content

Commit

Permalink
save & show affect_user
Browse files Browse the repository at this point in the history
  • Loading branch information
Phpvarious authored Oct 9, 2024
1 parent c541de6 commit f439181
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
11 changes: 11 additions & 0 deletions core/ajax/mobile.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@
}
}

if (init('action') == 'getAffectUserByEqlogic') {
$eqLogic = mobile::byId(init('id'));
$return = '';
if (is_object($eqLogic)) {
if (is_object($user = user::byId($eqLogic->getConfiguration('affect_user')))) {
$return = $user->getLogin();
}
}
ajax::success($return);
}

throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));

} catch (Exception $e) {
Expand Down
4 changes: 4 additions & 0 deletions core/api/mobile.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ function saveMenuFromAppV2($menu, $mobile) {
log::add('mobile', 'debug', '| [NOTICE] Token vide ');
}
}
if (is_object($user = user::byHash($params['apikey']))) {
log::add('mobile', 'debug', '| [INFO] affect_user > ' . $user->getLogin() . ' (' . $user->getId() . ')');
$mobile->setConfiguration('affect_user', $user->getId());
}
$mobile->save();

/* moved to new method setCustomMenu
Expand Down
15 changes: 4 additions & 11 deletions desktop/js/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function printEqLogic(_eqLogic) {
type: "POST",
url: "plugins/mobile/core/ajax/mobile.ajax.php",
data: {
action: "getQrCode",
action: "getAffectUserByEqlogic",
id: _eqLogic.id,
},
dataType: "json",
Expand All @@ -57,16 +57,9 @@ function printEqLogic(_eqLogic) {
jeedomUtils.showAlert({ message: data.result, level: "danger" })
return
}
let el = document.querySelector(".qrCodeImg")
el.innerHTML = ""
if (data.result == "internalError") {
el.innerHTML = "{{Erreur pas d'adresse interne (voir configuration de votre Jeedom !)}}"
} else if (data.result == "externalError") {
el.innerHTML = "{{Erreur pas d'adresse externe (voir configuration de votre Jeedom !)}}"
} else if (data.result == "UserError") {
el.innerHTML = "{{Erreur pas d'utilisateur selectionné}}"
} else {
el.innerHTML = '<img src="data:image/png;base64, ' + data.result + '" />'
let el = document.querySelector(".affect_user")
if (el != null) {
el.value = data.result
}
}
})
Expand Down
15 changes: 1 addition & 14 deletions desktop/php/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,7 @@
<div class="form-group">
<label class="col-sm-4 control-label">{{Utilisateur}}</label>
<div class="col-sm-6">
<select class="eqLogicAttr configuration form-control" data-l1key="configuration" data-l2key="affect_user">
<option value="">{{Aucun}}</option>
<?php
$hidden_user = array('jeedom_support', 'internal_report');
foreach (user::all() as $user) {
if (in_array($user->getLogin(), $hidden_user) || $user->getEnable() != 1) continue;
echo '<option value="' . $user->getId() . '">' . ucfirst($user->getLogin()) . '</option>';
}
?>
</select>
<input type="text" class="affect_user" disabled>
</div>
</div>
<!-- to be uncommented when the app is ready for this new feature -->
Expand All @@ -239,10 +230,6 @@
-->
</div>
<div class="col-lg-6">
<legend><i class="fas fa-qrcode"></i> {{QRCode}}</legend>
<center>
<div class="qrCodeImg"></div>
</center>
<legend><i class="fas fa-mobile-alt"></i> {{Notifications}}</legend>
<div class="form-group">
<label class="col-sm-3 control-label">{{Id Mobile}}
Expand Down

0 comments on commit f439181

Please sign in to comment.