+ */
public static function byClassFunctionAndEvent($_class, $_function, $_event) {
$value = array(
'class' => $_class,
@@ -277,6 +298,10 @@ public function addEvent($_id, $_type = 'cmd') {
/* * **********************Getteur Setteur*************************** */
+ /**
+ *
+ * @return int
+ */
public function getId() {
return $this->id;
}
diff --git a/core/class/log.class.php b/core/class/log.class.php
index bf1bb6404f..33bedbed6d 100644
--- a/core/class/log.class.php
+++ b/core/class/log.class.php
@@ -58,7 +58,7 @@ public static function getLogger($_log) {
$handler = new SyslogHandler(self::getLogLevel($_log));
break;
case 'SyslogUdp':
- $handler = new SyslogUdpHandler(config::byKey('log::syslogudphost'), config::byKey('log::syslogudpport'), 'user', self::getLogLevel($_log));
+ $handler = new SyslogUdpHandler(config::byKey('log::syslogudphost'), config::byKey('log::syslogudpport'), config::byKey('log::syslogudpfacility'), self::getLogLevel($_log),true,'jeedom');
break;
case 'StreamHandler':
default:
diff --git a/core/class/network.class.php b/core/class/network.class.php
index 88530777ec..f8e91cfdab 100644
--- a/core/class/network.class.php
+++ b/core/class/network.class.php
@@ -340,7 +340,7 @@ public static function dns_create() {
$openvpn->setEqType_name('openvpn');
$openvpn->setConfiguration('dev', 'tun');
$openvpn->setConfiguration('proto', 'udp');
- if(strpos(config::byKey('dns::protocol'),config::byKey('dns::preferProtocol')) !== false && config::byKey('dns::preferProtocol') != ''){
+ if(config::byKey('dns::preferProtocol') != '' && strpos(config::byKey('dns::protocol'),config::byKey('dns::preferProtocol')) !== false){
$openvpn->setConfiguration('proto', config::byKey('dns::preferProtocol'));
}
if (config::byKey('dns::vpnurl') != '') {
diff --git a/core/class/report.class.php b/core/class/report.class.php
index 016a993b3f..8456242159 100644
--- a/core/class/report.class.php
+++ b/core/class/report.class.php
@@ -56,7 +56,7 @@ public static function generate($_url, $_type, $_name, $_format = 'png', $_param
$_url .= '#' . $_parameter['tab'];
}
if ($_format == 'pdf') {
- $cmd = 'chromium --headless --no-sandbox --disable-gpu --print-to-pdf=' . $out . ' --window-size=' . $min_width . ',' . $min_height . ' "' . $_url . '"';
+ $cmd = 'chromium --headless --no-sandbox --disable-gpu --no-pdf-header-footer --print-to-pdf-no-header --print-to-pdf=' . $out . ' --window-size=' . $min_width . ',' . $min_height . ' "' . $_url . '"';
} else {
$cmd = 'chromium --headless --no-sandbox --disable-gpu --screenshot=' . $out . ' --window-size=' . $min_width . ',' . $min_height . ' "' . $_url . '"';
}
diff --git a/core/class/system.class.php b/core/class/system.class.php
index d12b5c9769..a06abb10b2 100644
--- a/core/class/system.class.php
+++ b/core/class/system.class.php
@@ -83,7 +83,7 @@ public static function get($_key = '') {
return $return;
}
- public static function getCmdSudo() {
+ public static function getCmdSudo(): string {
if (!class_exists('jeedom')) {
return 'sudo ';
}
@@ -93,7 +93,7 @@ public static function getCmdSudo() {
return 'sudo ';
}
- public static function fuserk($_port, $_protocol = 'tcp') {
+ public static function fuserk($_port, $_protocol = 'tcp'): void {
if (file_exists($_port)) {
exec(system::getCmdSudo() . 'fuser -k ' . $_port . ' > /dev/null 2>&1');
} else {
@@ -180,7 +180,7 @@ public static function php($arguments, $_sudo = false) {
return exec('php ' . $arguments);
}
- public static function getArch() {
+ public static function getArch(): string {
$arch = php_uname('m');
if ($arch == 'x86_64') {
return 'amd64';
@@ -396,7 +396,7 @@ public static function getInstallPackage($_type) {
return self::$_installPackage[$_type];
}
- public static function os_incompatible($_type, $_package, $_info) {
+ public static function os_incompatible($_type, $_package, $_info): bool {
if (isset($_info['denyDebianHigherEqual']) && self::getDistrib() == 'debian' && version_compare(self::getOsVersion(), $_info['denyDebianHigherEqual'], '>=')) {
return true;
}
@@ -684,7 +684,7 @@ public static function checkAndInstall($_packages, $_fix = false, $_foreground =
self::launchScriptPackage($_plugin);
}
- public static function installPackageInProgress($_plugin = '') {
+ public static function installPackageInProgress($_plugin = ''): bool {
if (count(self::ps('^dpkg ')) > 0 || count(self::ps('^apt ')) > 0) {
return true;
}
@@ -798,7 +798,7 @@ public static function getOsVersion() {
return self::$_os_version;
}
- public static function checkInstallationLog($_plugin = '') {
+ public static function checkInstallationLog($_plugin = ''): string {
if (class_exists('log')) {
if ($_plugin != '') {
$log = log::getPathToLog($_plugin . '_packages');
diff --git a/core/class/user.class.php b/core/class/user.class.php
index 77c5f35923..4d5ad578aa 100644
--- a/core/class/user.class.php
+++ b/core/class/user.class.php
@@ -53,7 +53,7 @@ public static function byId($_id) {
* @param string $_mdp motsz de passe en sha512
* @return user object user
*/
- public static function connect($_login, $_mdp) {
+ public static function connect(string $_login, string $_mdp) {
$sMdp = (!is_sha512($_mdp)) ? sha512($_mdp) : $_mdp;
if (config::byKey('ldap:enable') == '1' && function_exists('ldap_connect')) {
log::add("connection", "info", __('LDAP Authentification', __FILE__));
@@ -207,7 +207,7 @@ public static function byLoginAndHash($_login, $_hash) {
return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__);
}
- public static function byLoginAndPassword($_login, $_password) {
+ public static function byLoginAndPassword(string $_login, string $_password) {
$values = array(
'login' => $_login,
'password' => $_password,
@@ -229,7 +229,7 @@ public static function all() {
return DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
}
- public static function searchByRight($_rights) {
+ public static function searchByRight(string $_rights) {
$values = array(
'rights' => '%"' . $_rights . '":1%',
'rights2' => '%"' . $_rights . '":"1"%',
@@ -274,19 +274,19 @@ public static function byEnable($_enable) {
return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__);
}
- public static function failedLogin() {
+ public static function failedLogin(): void {
@session_start();
$_SESSION['failed_count'] = (isset($_SESSION['failed_count'])) ? $_SESSION['failed_count'] + 1 : 1;
$_SESSION['failed_datetime'] = strtotime('now');
@session_write_close();
}
- public static function removeBanIp() {
+ public static function removeBanIp(): void {
$cache = cache::byKey('security::banip');
$cache->remove();
}
- public static function isBan() {
+ public static function isBan(): bool {
$ip = getClientIp();
if ($ip == '') {
return false;
@@ -348,7 +348,7 @@ public static function isBan() {
return false;
}
- public static function getAccessKeyForReport() {
+ public static function getAccessKeyForReport(): string {
$user = user::byLogin('internal_report');
if (!is_object($user)) {
$user = new user();
@@ -441,13 +441,13 @@ public static function regenerateHash() {
/* * *********************Méthodes d'instance************************* */
- public function preInsert() {
+ public function preInsert(): void {
if (is_object(self::byLogin($this->getLogin()))) {
throw new Exception(__('Ce nom d\'utilisateur est déja pris', __FILE__));
}
}
- public function preSave() {
+ public function preSave(): void {
if ($this->getLogin() == '') {
throw new Exception(__('Le nom d\'utilisateur ne peut pas être vide', __FILE__));
}
@@ -465,11 +465,11 @@ public function preSave() {
}
}
- public function encrypt() {
+ public function encrypt(): void {
$this->getOptions('twoFactorAuthentification', utils::encrypt($this->getOptions('twoFactorAuthentification')));
}
- public function decrypt() {
+ public function decrypt(): void {
$this->getOptions('twoFactorAuthentification', utils::decrypt($this->getOptions('twoFactorAuthentification')));
}
@@ -477,7 +477,7 @@ public function save() {
return DB::save($this);
}
- public function preRemove() {
+ public function preRemove(): void {
if (count(user::byProfils('admin', true)) == 1 && ($this->getProfils() == 'admin' && $this->getEnable() == 1)) {
throw new Exception(__('Vous ne pouvez supprimer le dernier administrateur', __FILE__));
}
@@ -488,7 +488,7 @@ public function remove() {
return DB::remove($this);
}
- public function refresh() {
+ public function refresh(): void {
DB::refresh($this);
}
@@ -496,7 +496,7 @@ public function refresh() {
*
* @return boolean vrai si l'utilisateur est valide
*/
- public function is_Connected() {
+ public function is_Connected(): bool {
return (is_numeric($this->id) && $this->login != '');
}
@@ -519,19 +519,19 @@ public function getPassword() {
return $this->password;
}
- public function setId($_id) {
+ public function setId($_id): self {
$this->_changed = utils::attrChanged($this->_changed, $this->id, $_id);
$this->id = $_id;
return $this;
}
- public function setLogin($_login) {
+ public function setLogin($_login): self {
$this->_changed = utils::attrChanged($this->_changed, $this->login, $_login);
$this->login = $_login;
return $this;
}
- public function setPassword($_password) {
+ public function setPassword(string $_password): self {
if ($_password != '') {
$_password = (!is_sha512($_password)) ? sha512($_password) : $_password;
} else {
@@ -563,7 +563,7 @@ public function getRights($_key = '', $_default = '') {
return utils::getJsonAttr($this->rights, $_key, $_default);
}
- public function setRights($_key, $_value) {
+ public function setRights($_key, $_value): self {
$rights = utils::setJsonAttr($this->rights, $_key, $_value);
$this->_changed = utils::attrChanged($this->_changed, $this->rights, $rights);
$this->rights = $rights;
@@ -574,7 +574,7 @@ public function getEnable() {
return $this->enable;
}
- public function setEnable($_enable) {
+ public function setEnable($_enable): self {
$this->_changed = utils::attrChanged($this->_changed, $this->enable, $_enable);
$this->enable = $_enable;
return $this;
@@ -603,7 +603,7 @@ public function getProfils() {
return $this->profils;
}
- public function setProfils($_profils) {
+ public function setProfils($_profils): self {
$this->_changed = utils::attrChanged($this->_changed, $this->profils, $_profils);
$this->profils = $_profils;
return $this;
@@ -613,7 +613,7 @@ public function getChanged() {
return $this->_changed;
}
- public function setChanged($_changed) {
+ public function setChanged($_changed): self {
$this->_changed = $_changed;
return $this;
}
diff --git a/core/com/http.com.php b/core/com/http.com.php
index 401a423dc4..17163878e5 100644
--- a/core/com/http.com.php
+++ b/core/com/http.com.php
@@ -31,6 +31,7 @@ class com_http {
private $sleepTime = 500000;
private $post = '';
private $put = '';
+ private $patch = '';
private $delete = '';
private $header = array('Connection: close');
private $cookiesession = false;
@@ -95,6 +96,10 @@ public function exec($_timeout = 2, $_maxRetry = 3) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getPut());
}
+ if ($this->getPatch() != '') {
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getPatch());
+ }
if ($this->getDelete() != '') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getDelete());
@@ -248,6 +253,15 @@ public function setPut($put = array()) {
return $this;
}
+ public function getPatch() {
+ return $this->patch;
+ }
+
+ public function setPatch($patch = array()) {
+ $this->patch = $patch;
+ return $this;
+ }
+
public function getUserAgent() {
return $this->userAgent;
}
@@ -275,4 +289,4 @@ public function setCURLOPT($CURLOPT) {
return $this;
}
-}
+}
\ No newline at end of file
diff --git a/core/config/default.config.ini b/core/config/default.config.ini
index 486d0fb8ce..cd5888f9a8 100644
--- a/core/config/default.config.ini
+++ b/core/config/default.config.ini
@@ -80,6 +80,7 @@ security::whiteips = "127.0.0.1;192.168.*.*;10.*.*.*;172.*.*.*"
maxLineLog = 500
log::level = 400
log::syslogudpport = 514
+log::syslogudpfacility = user
log::engine = StreamHandler
log::formatter = [%datetime%][%level_name%] : %message%\n
timeline::maxevent = 500
diff --git a/core/i18n/de_DE.json b/core/i18n/de_DE.json
index 6dec198378..cadbfbee48 100644
--- a/core/i18n/de_DE.json
+++ b/core/i18n/de_DE.json
@@ -84,6 +84,7 @@
"Crons": "Kronen",
"Démons": "Dämonen",
"Message": "Nachricht",
+ "Scenario": "Szenario",
"Accueil": "Mein Haus",
"Vue": "Gesehen",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "Udp Syslog",
"Adresse syslog UDP": "UDP-Syslog-Adresse",
"Port syslog UDP": "Syslog-UDP-Port",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Format der Protokolle",
"Nombre maximal de lignes dans un fichier de log": "Maximale Anzahl von Zeilen in einer Protokolldatei",
"Niveau de log par défaut": "Standard-Protokollebene",
diff --git a/core/i18n/en_US.json b/core/i18n/en_US.json
index c76bab8138..1ba8d262c5 100644
--- a/core/i18n/en_US.json
+++ b/core/i18n/en_US.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Demons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "Home",
"Vue": "Seen",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "UDP syslog address",
"Port syslog UDP": "UDP syslog port",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Log format",
"Nombre maximal de lignes dans un fichier de log": "Maximum number of lines in a log file",
"Niveau de log par défaut": "Default log level",
diff --git a/core/i18n/es_ES.json b/core/i18n/es_ES.json
index 8efca0c2a0..7efaafb52d 100644
--- a/core/i18n/es_ES.json
+++ b/core/i18n/es_ES.json
@@ -84,6 +84,7 @@
"Crons": "Crones",
"Démons": "Demonios",
"Message": "Mensaje",
+ "Scenario": "Guión",
"Accueil": "Inicio",
"Vue": "Visto",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Dirección syslog UDP",
"Port syslog UDP": "Puerto UDP Syslog",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Formato de los registros",
"Nombre maximal de lignes dans un fichier de log": "Número máximo de líneas en un archivo de registro",
"Niveau de log par défaut": "Nivel de registro predeterminado",
diff --git a/core/i18n/fr_FR.json b/core/i18n/fr_FR.json
index 391c760702..d17cbb4306 100644
--- a/core/i18n/fr_FR.json
+++ b/core/i18n/fr_FR.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Démons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "Accueil",
"Vue": "Vue",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Adresse syslog UDP",
"Port syslog UDP": "Port syslog UDP",
+ "Facility syslog UDP": "Facility syslog UDP",
"Format des logs": "Format des logs",
"Nombre maximal de lignes dans un fichier de log": "Nombre maximal de lignes dans un fichier de log",
"Niveau de log par défaut": "Niveau de log par défaut",
diff --git a/core/i18n/id_ID.json b/core/i18n/id_ID.json
index fc8250be70..45227a0809 100644
--- a/core/i18n/id_ID.json
+++ b/core/i18n/id_ID.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Démons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "Rumah",
"Vue": "Vue",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Alamat syslog UDP",
"Port syslog UDP": "Syslog UDP Pelabuhan",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Format log",
"Nombre maximal de lignes dans un fichier de log": "Nombre maximal de lignes dans un fichier de log",
"Niveau de log par défaut": "Tingkat default log",
diff --git a/core/i18n/it_IT.json b/core/i18n/it_IT.json
index 6c0fb91208..eeef7ba930 100644
--- a/core/i18n/it_IT.json
+++ b/core/i18n/it_IT.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Démons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "Principale",
"Vue": "Vue",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Indirizzo syslog UDP",
"Port syslog UDP": "Syslog porta UDP",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Log Format",
"Nombre maximal de lignes dans un fichier de log": "Nombre maximal de lignes dans un fichier de log",
"Niveau de log par défaut": "Livello di log di default",
diff --git a/core/i18n/ja_JP.json b/core/i18n/ja_JP.json
index d183ea2c80..e1e14dbb33 100644
--- a/core/i18n/ja_JP.json
+++ b/core/i18n/ja_JP.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Démons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "家庭",
"Vue": "Vue",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "アドレスのsyslog UDP",
"Port syslog UDP": "SyslogのUDPポート",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "フォーマットのログ",
"Nombre maximal de lignes dans un fichier de log": "Nombre maximal de lignes dans un fichier de log",
"Niveau de log par défaut": "デフォルトのログレベル",
diff --git a/core/i18n/pt_PT.json b/core/i18n/pt_PT.json
index 53f038a1d5..98d4d70d98 100644
--- a/core/i18n/pt_PT.json
+++ b/core/i18n/pt_PT.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Demônios",
"Message": "Mensagem",
+ "Scenario": "Cenário",
"Accueil": "Início",
"Vue": "Visto",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Endereço syslog UDP",
"Port syslog UDP": "Porta syslog UDP",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Formato dos registos",
"Nombre maximal de lignes dans un fichier de log": "Número máximo de linhas em um arquivo de log",
"Niveau de log par défaut": "Nível de registo predefinido",
diff --git a/core/i18n/ru_RU.json b/core/i18n/ru_RU.json
index dd69e520fa..d932c157c8 100644
--- a/core/i18n/ru_RU.json
+++ b/core/i18n/ru_RU.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Démons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "Домой",
"Vue": "Vue",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Адрес системного журнала UDP",
"Port syslog UDP": "Syslog UDP-порт",
+ "Facility syslog UDP": "UDP syslog faciliy",
"Format des logs": "Формат логов",
"Nombre maximal de lignes dans un fichier de log": "Nombre maximal de lignes dans un fichier de log",
"Niveau de log par défaut": "Уровень лога по умолчанию",
diff --git a/core/i18n/tr.json b/core/i18n/tr.json
index 2d7a99bd84..b774d6d58b 100644
--- a/core/i18n/tr.json
+++ b/core/i18n/tr.json
@@ -84,6 +84,7 @@
"Crons": "Crons",
"Démons": "Démons",
"Message": "Message",
+ "Scenario": "Scenario",
"Accueil": "Ana sayfa",
"Vue": "Vue",
"Dashboard": "Dashboard"
@@ -1803,6 +1804,7 @@
"SyslogUdp": "SyslogUdp",
"Adresse syslog UDP": "Adres syslog UDP",
"Port syslog UDP": "Sistem Günlüğü UDP Bağlantı Noktası",
+ "Facility syslog UDP": "Facility syslog UDP",
"Format des logs": "Logların formatı",
"Nombre maximal de lignes dans un fichier de log": "Nombre maximal de lignes dans un fichier de log",
"Niveau de log par défaut": "Varsayılan log seviyesi",
diff --git a/core/js/appMobile.class.js b/core/js/appMobile.class.js
index c8bffd025f..4b64ff0107 100644
--- a/core/js/appMobile.class.js
+++ b/core/js/appMobile.class.js
@@ -40,15 +40,17 @@ jeedom.appMobile.syncBoxs = function () {
jeedom.appMobile.postToApp('syncBoxs')
}
-jeedom.appMobile.notifee = function (title, body, time) {
+jeedom.appMobile.notifee = function (title, body, time = 5000, display = "") {
/**
- * time : display time for inapp notification, in ms
+ * time (Number) : display time for inapp notification, in ms
+ * display (string) : display notiication : error(red), success(green), warn(orange) and info(blue). if "" : classic notification in App
*
*/
jeedom.appMobile.postToApp('notifee', {
body: body,
time: time,
- title: title
+ title: title,
+ display : display
});
}
diff --git a/core/js/jeedom.class.js b/core/js/jeedom.class.js
index bd06778999..3ade67f5a7 100644
--- a/core/js/jeedom.class.js
+++ b/core/js/jeedom.class.js
@@ -449,6 +449,24 @@ jeedom.getConfiguration = function(_params) {
domUtils.ajax(paramsAJAX)
}
+jeedom.getInfoApplication = function(_params) {
+ var paramsRequired = []
+ var paramsSpecifics = {}
+ try {
+ jeedom.private.checkParamsRequired(_params || {}, paramsRequired)
+ } catch (e) {
+ (_params.error || paramsSpecifics.error || jeedom.private.default_params.error)(e)
+ return
+ }
+ var params = domUtils.extend({}, jeedom.private.default_params, paramsSpecifics, _params || {})
+ var paramsAJAX = jeedom.private.getParamsAJAX(params)
+ paramsAJAX.url = 'core/ajax/jeedom.ajax.php'
+ paramsAJAX.data = {
+ action: 'getInfoApplication',
+ }
+ domUtils.ajax(paramsAJAX)
+}
+
jeedom.haltSystem = function(_params) {
var paramsRequired = []
var paramsSpecifics = {}
diff --git a/core/php/js.inc.php b/core/php/js.inc.php
index 58f3750c88..e339be835d 100644
--- a/core/php/js.inc.php
+++ b/core/php/js.inc.php
@@ -45,3 +45,4 @@
include_file('core', 'listener', 'class.js');
include_file('core', 'widgets', 'class.js');
include_file('core', 'timeline', 'class.js');
+include_file('core', 'appMobile', 'class.js');
diff --git a/desktop/common/js/utils.js b/desktop/common/js/utils.js
index b5dad4b76c..e7e2626627 100644
--- a/desktop/common/js/utils.js
+++ b/desktop/common/js/utils.js
@@ -23,32 +23,32 @@ var jeedomUtils = {
}
jeedomUtils.tileWidthStep = (parseInt(jeedom.theme['widget::step::width']) > 80 ? parseInt(jeedom.theme['widget::step::width']) : 80) + parseInt(jeedom.theme['widget::margin']) // with margin
jeedomUtils.tileHeightStep = (parseInt(jeedom.theme['widget::step::height']) > 60 ? parseInt(jeedom.theme['widget::step::height']) : 60) + parseInt(jeedom.theme['widget::margin']) // with margin
-jeedomUtils.tileHeightSteps = Array.apply(null, { length: 50 }).map(function(value, index) { return (index + 1) * jeedomUtils.tileHeightStep })
+jeedomUtils.tileHeightSteps = Array.apply(null, { length: 50 }).map(function (value, index) { return (index + 1) * jeedomUtils.tileHeightStep })
/*Hijack jQuery ready function, still used in plugins
*/
if (typeof jQuery === 'function') {
jeedomUtils.$readyFn = jQuery.fn.ready
- jQuery.fn.ready = function() {
+ jQuery.fn.ready = function () {
if (domUtils._DOMloading <= 0) {
jeedomUtils.$readyFn.apply(this, arguments)
} else {
- setTimeout(function() {
+ setTimeout(function () {
jQuery.fn.ready.apply(this, arguments[1])
}, 250, this, arguments)
}
}
}
//Deprecated, keep for plugins using jQuery ajax call
-document.addEventListener('DOMContentLoaded', function() {
+document.addEventListener('DOMContentLoaded', function () {
jeedomUtils._elBackground = document.getElementById('backgroundforJeedom')
if (typeof jQuery === 'function') {
$(document)
- .ajaxStart(function() {
+ .ajaxStart(function () {
domUtils.showLoading()
})
- .ajaxStop(function() {
+ .ajaxStop(function () {
domUtils.hideLoading()
})
}
@@ -56,7 +56,7 @@ document.addEventListener('DOMContentLoaded', function() {
//js error in ! ui:
jeedomUtils.JS_ERROR = []
-window.addEventListener('error', function(event) {
+window.addEventListener('error', function (event) {
if (event.filename.indexOf('3rdparty/') != -1) return
if (event.message.includes('ResizeObserver loop')) return
jeedomUtils.JS_ERROR.push(event)
@@ -65,7 +65,7 @@ window.addEventListener('error', function(event) {
})
if ('SecurityPolicyViolationEvent' in window) { // Check browser support of SecurityPolicyViolationEnevt interface
- window.addEventListener("securitypolicyviolation", function(event) {
+ window.addEventListener("securitypolicyviolation", function (event) {
var uri = event.blockedURI
var msg = `{{Erreur de directive Content Security Policy sur la ressource "${uri}"}}`
if (event.originalPolicy && event.violatedDirective) {
@@ -84,7 +84,7 @@ if ('SecurityPolicyViolationEvent' in window) { // Check browser support of Secu
}
//UI Time display:
-setInterval(function() {
+setInterval(function () {
if (document.getElementById('horloge') === null) {
return
}
@@ -94,7 +94,7 @@ setInterval(function() {
}, 1000)
var modifyWithoutSave = false
-jeedomUtils.checkPageModified = function() {
+jeedomUtils.checkPageModified = function () {
if (jeeFrontEnd.modifyWithoutSave || window.modifyWithoutSave) {
if (!confirm('{{Attention vous quittez une page ayant des données modifiées non sauvegardées. Voulez-vous continuer ?}}')) {
domUtils.hideLoading()
@@ -109,10 +109,11 @@ jeedomUtils.checkPageModified = function() {
var prePrintEqLogic = undefined
var printEqLogic = undefined
var addCmdToTable = undefined
+var saveEqLogic = undefined
jeedomUtils.userDevice = getDeviceType()
//OnePage design PageLoader -------------------------------------
-jeedomUtils.loadPage = function(_url, _noPushHistory) {
+jeedomUtils.loadPage = function (_url, _noPushHistory) {
jeeFrontEnd.PREVIOUS_LOCATION = window.location.href
if (jeedomUtils.checkPageModified()) return
if (jeedomUtils.JS_ERROR.length > 0) {
@@ -159,7 +160,7 @@ jeedomUtils.loadPage = function(_url, _noPushHistory) {
jeedom.scenario.update = []
jeephp2js = {}
delete window.jeeP
- prePrintEqLogic = printEqLogic = addCmdToTable = undefined
+ prePrintEqLogic = printEqLogic = addCmdToTable = saveEqLogic = undefined
if (typeof jQuery === 'function') $('body').off('changeThemeEvent')
if (_url.indexOf('#') == -1) {
@@ -189,7 +190,7 @@ jeedomUtils.loadPage = function(_url, _noPushHistory) {
//AJAX LOAD URL INTO PAGE CONTAINER:
domUtils.DOMloading += 1
- document.getElementById('div_pageContainer').load(url, function() {
+ document.getElementById('div_pageContainer').load(url, function () {
document.body.setAttribute('data-page', getUrlVars('p') || '')
document.getElementById('bt_getHelpPage')?.setAttribute('data-page', getUrlVars('p'))
document.getElementById('bt_getHelpPage')?.setAttribute('data-plugin', getUrlVars('m') || '')
@@ -207,7 +208,7 @@ jeedomUtils.loadPage = function(_url, _noPushHistory) {
}
}
- setTimeout(function() {
+ setTimeout(function () {
if (window.location.hash != '') {
var tab = document.querySelector('.nav-tabs a[data-target="' + window.location.hash + '"]') || document.querySelector('.nav-tabs a[href="' + window.location.hash + '"]')
if (tab != null) {
@@ -216,7 +217,7 @@ jeedomUtils.loadPage = function(_url, _noPushHistory) {
}
}, 150) //let time for plugin page!
- setTimeout(function() {
+ setTimeout(function () {
modifyWithoutSave = false
jeeFrontEnd.modifyWithoutSave = false
}, 250)
@@ -228,14 +229,14 @@ jeedomUtils.loadPage = function(_url, _noPushHistory) {
/* First time loading, all next goes by loadpage()
*/
-document.addEventListener('DOMContentLoaded', function() {
+document.addEventListener('DOMContentLoaded', function () {
jeedom.init()
document.body.setAttribute('data-device', jeedomUtils.userDevice.type)
document.body.setAttribute('data-page', getUrlVars('p'))
document.body.style.setProperty('--bkg-opacity-light', jeedom.theme['interface::background::opacitylight'])
document.body.style.setProperty('--bkg-opacity-dark', jeedom.theme['interface::background::opacitydark'])
- document.body.addEventListener('jeedom_page_load', function(event) {
+ document.body.addEventListener('jeedom_page_load', function (event) {
if (getUrlVars('saveSuccessFull') == 1) {
jeedomUtils.showAlert({ message: '{{Sauvegarde effectuée avec succès}}', level: 'success' })
jeeFrontEnd.PREVIOUS_PAGE = window.location.href.split('&saveSuccessFull')[0] + window.location.hash
@@ -261,7 +262,7 @@ document.addEventListener('DOMContentLoaded', function() {
//custom jQuery event can't use pur js event listener
if (typeof jQuery === 'function') {
- $('body').on('shown.bs.tab', '.nav-tabs a', function(event) {
+ $('body').on('shown.bs.tab', '.nav-tabs a', function (event) {
if (event.target.getAttribute('data-target') == '' && event.target.getAttribute('href') == '') return
if (event.target.closest('.ui-dialog-content')?.innerHTML !== undefined) return
if (event.target.closest('.jeeDialog')?.innerHTML !== undefined) return
@@ -279,14 +280,14 @@ document.addEventListener('DOMContentLoaded', function() {
})
}
- window.addEventListener('hashchange', function(event) {
+ window.addEventListener('hashchange', function (event) {
jeeFrontEnd.NO_POPSTAT = true
- setTimeout(function() {
+ setTimeout(function () {
jeeFrontEnd.NO_POPSTAT = false
}, 200)
})
- window.addEventListener('popstate', function(event) {
+ window.addEventListener('popstate', function (event) {
if (event.state === null) {
if (jeeFrontEnd.NO_POPSTAT) {
jeeFrontEnd.NO_POPSTAT = false
@@ -320,7 +321,7 @@ document.addEventListener('DOMContentLoaded', function() {
}
jeedomUtils.initPage()
- setTimeout(function() {
+ setTimeout(function () {
jeedomUtils.initTooltips()
document.body.triggerEvent('jeedom_page_load')
})
@@ -355,7 +356,7 @@ document.addEventListener('DOMContentLoaded', function() {
}
})
-jeedomUtils.showAlert = function(_options) {
+jeedomUtils.showAlert = function (_options) {
//if (getUrlVars('report') == 1) return
var options = init(_options, {})
options.title = init(options.title, '')
@@ -373,18 +374,18 @@ jeedomUtils.showAlert = function(_options) {
jeeDialog.toast(options)
}
-jeedomUtils.hideAlert = function() {
+jeedomUtils.hideAlert = function () {
jeeDialog.clearToasts()
//Deprecated, old div_alert may be used by plugins:
- document.querySelectorAll('.jqAlert').forEach(function(element) {
+ document.querySelectorAll('.jqAlert').forEach(function (element) {
element.innerHTML = ''
element.unseen()
})
}
//Jeedom theme__
-jeedomUtils.setJeedomTheme = function() {
+jeedomUtils.setJeedomTheme = function () {
if (getCookie('currentTheme') == 'alternate') {
var themeButton = ' {{Thème principal}}'
document.getElementById('bt_switchTheme')?.html(themeButton)
@@ -399,19 +400,19 @@ jeedomUtils.setJeedomTheme = function() {
}
//button event:
- document.getElementById('bt_switchTheme')?.addEventListener('click', function() {
+ document.getElementById('bt_switchTheme')?.addEventListener('click', function () {
jeedomUtils.closeJeedomMenu()
jeedomUtils.switchTheme()
})
- jeedomUtils.changeTheme = function(_theme) {
+ jeedomUtils.changeTheme = function (_theme) {
var currentTheme = document.body.getAttribute('data-theme').toLowerCase()
if (_theme == 'toggle' || !currentTheme.endsWith(_theme)) {
jeedomUtils.switchTheme()
}
}
- jeedomUtils.switchTheme = function() {
+ jeedomUtils.switchTheme = function () {
var theme = 'core/themes/' + jeedom.theme.jeedom_theme_alternate + '/desktop/' + jeedom.theme.jeedom_theme_alternate + '.css'
var themeShadows = 'core/themes/' + jeedom.theme.jeedom_theme_alternate + '/desktop/shadows.css'
var themeCook = 'alternate'
@@ -457,19 +458,19 @@ jeedomUtils.setJeedomTheme = function() {
}
}
-jeedomUtils.changeJeedomThemeAuto = function() {
+jeedomUtils.changeJeedomThemeAuto = function () {
if (typeof jeedom.theme == 'undefined') return
if (typeof jeedom.theme.theme_changeAccordingTime == 'undefined' || jeedom.theme.theme_changeAccordingTime == 0) return
if (typeof jeedom.theme.jeedom_theme_main == 'undefined' || typeof jeedom.theme.jeedom_theme_alternate == 'undefined') return
if (jeedom.theme.jeedom_theme_main == jeedom.theme.jeedom_theme_alternate) return
jeedomUtils.checkThemechange()
- setInterval(function() {
+ setInterval(function () {
jeedomUtils.checkThemechange()
}, 60000)
}
-jeedomUtils.checkThemechange = function() {
+jeedomUtils.checkThemechange = function () {
//User forced current theme:
if (getCookie('currentTheme') == 'alternate' || document.getElementById('jeedom_theme_currentcss')?.getAttribute('data-nochange') == 1) return
@@ -480,8 +481,8 @@ jeedomUtils.checkThemechange = function() {
//if (parseInt(jeedom.theme.theme_start_day_hour.replace(':', '')) < currentTime && parseInt(jeedom.theme.theme_end_day_hour.replace(':', '')) > currentTime) {
if (
- (parseInt(jeedom.theme.theme_start_day_hour.replace(':','')) < currentTime
- && parseInt(jeedom.theme.theme_end_day_hour.replace(':','')) > currentTime)
+ (parseInt(jeedom.theme.theme_start_day_hour.replace(':', '')) < currentTime
+ && parseInt(jeedom.theme.theme_end_day_hour.replace(':', '')) > currentTime)
|| typeof jeedom.theme.theme_changeAccordingTime == 'undefined'
|| jeedom.theme.theme_changeAccordingTime == 0
) {
@@ -502,7 +503,7 @@ jeedomUtils.checkThemechange = function() {
}
}
-jeedomUtils.triggerThemechange = function() {
+jeedomUtils.triggerThemechange = function () {
//set jeedom logo:
if (document.body.hasAttribute('data-theme')) {
var currentTheme = document.body.getAttribute('data-theme')
@@ -527,11 +528,11 @@ jeedomUtils.triggerThemechange = function() {
if (currentTheme.endsWith('Dark')) {
flatpickrDarkCss.disabled = false
} else {
- flatpickrDarkCss.disabled= true
+ flatpickrDarkCss.disabled = true
}
}
-jeedomUtils.setBackgroundImage = function(_path) {
+jeedomUtils.setBackgroundImage = function (_path) {
if (getUrlVars('rescue') == 1) return false
//Exact same function desktop/mobile, only transitionJeedomBackground() differ
if (!isset(jeedom) || !isset(jeedom.theme) || !isset(jeedom.theme.showBackgroundImg) || jeedom.theme.showBackgroundImg == 0) {
@@ -585,7 +586,7 @@ jeedomUtils.setBackgroundImage = function(_path) {
jeedomUtils.backgroundIMG = _path
}
-jeedomUtils.transitionJeedomBackground = function(_path) {
+jeedomUtils.transitionJeedomBackground = function (_path) {
_path = 'url("../../../../' + _path + '")'
if (document.body.getAttribute('data-theme') == 'core2019_Dark') {
var opacity = document.body.style.getPropertyValue('--bkg-opacity-dark')
@@ -602,18 +603,18 @@ jeedomUtils.transitionJeedomBackground = function(_path) {
top.style.opacity = 0
top.style.backgroundImage = _path
top.fade(250, opacity)
- bottom.fade(200, 0, function() {
+ bottom.fade(200, 0, function () {
bottom.style.backgroundImage = _path
})
}
//Jeedom UI__
-jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbox
+jeedomUtils.initJeedomModals = function () { //Deprecated jQuery UI dilaog/bootbox
if (typeof jQuery !== 'function') return
if (typeof $.fn.modal !== 'function') return
- $.fn.modal.Constructor.prototype.enforceFocus = function() { }
+ $.fn.modal.Constructor.prototype.enforceFocus = function () { }
//Deprecated bootbox, keep for plugins
if (isset(jeeFrontEnd.language)) {
@@ -628,14 +629,14 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
}
//Deprecated bootbox, keep for plugins
- $('body').on('show', '.modal', function() {
+ $('body').on('show', '.modal', function () {
document.activeElement.blur()
$(this).find('.modal-body :input:visible').first().focus()
})
- $('body').on('focusin', '.bootbox-input', function(event) {
+ $('body').on('focusin', '.bootbox-input', function (event) {
event.stopPropagation()
})
- $('.bootbox.modal').on('shown.bs.modal', function() {
+ $('.bootbox.modal').on('shown.bs.modal', function () {
$(this).find(".bootbox-accept").focus()
})
@@ -647,7 +648,7 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
height: (window.innerHeight - 125),
width: ((window.innerWidth - 50) < 1500) ? (window.innerWidth - 50) : 1500,
position: { my: 'center top+80', at: 'center top', of: window },
- open: function() {
+ open: function () {
document.body.style.overflow = 'hidden'
this.closest('.ui-dialog').querySelectorAll('button, input[type="button"]')?.forEach(el => { el.blur() })
$(this).dialog({
@@ -655,9 +656,9 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
width: ((window.innerWidth - 50) < 1500) ? (window.innerWidth - 50) : 1500,
position: { my: 'center top+80', at: 'center top', of: window }
})
- setTimeout(function() { jeedomUtils.initTooltips($('#md_modal')) }, 500)
+ setTimeout(function () { jeedomUtils.initTooltips($('#md_modal')) }, 500)
},
- beforeClose: function(event, ui) {
+ beforeClose: function (event, ui) {
$(this).parent('.ui-dialog').removeClass('summaryActionMain')
emptyModal('md_modal')
$('#md_modal').off('dialogresize')
@@ -671,7 +672,7 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
height: (window.innerHeight - 125),
width: ((window.innerWidth - 150) < 1200) ? (window.innerWidth - 50) : 1200,
position: { my: 'center bottom-50', at: 'center bottom', of: window },
- open: function() {
+ open: function () {
document.body.style.overflow = 'hidden'
this.closest('.ui-dialog').querySelectorAll('button, input[type="button"]')?.forEach(el => { el.blur() })
$(this).dialog({
@@ -679,9 +680,9 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
width: ((window.innerWidth - 150) < 1200) ? (window.innerWidth - 50) : 1200,
position: { my: 'center bottom-50', at: 'center bottom', of: window },
})
- setTimeout(function() { jeedomUtils.initTooltips($('#md_modal2')) }, 500)
+ setTimeout(function () { jeedomUtils.initTooltips($('#md_modal2')) }, 500)
},
- beforeClose: function(event, ui) {
+ beforeClose: function (event, ui) {
emptyModal('md_modal2')
$('#md_modal2').off('dialogresize')
}
@@ -694,7 +695,7 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
height: (window.innerHeight - 125),
width: ((window.innerWidth - 250) < 1000) ? (window.innerWidth - 50) : 1000,
position: { my: 'center bottom-50', at: 'center bottom', of: window },
- open: function() {
+ open: function () {
document.body.style.overflow = 'hidden'
this.closest('.ui-dialog').querySelectorAll('button, input[type="button"]')?.forEach(el => { el.blur() })
$(this).dialog({
@@ -702,9 +703,9 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
width: ((window.innerWidth - 250) < 1000) ? (window.innerWidth - 50) : 1000,
position: { my: 'center bottom-50', at: 'center bottom', of: window },
})
- setTimeout(function() { jeedomUtils.initTooltips($('#md_modal3')) }, 500)
+ setTimeout(function () { jeedomUtils.initTooltips($('#md_modal3')) }, 500)
},
- beforeClose: function(event, ui) {
+ beforeClose: function (event, ui) {
emptyModal('md_modal3')
$('#md_modal3').off('dialogresize')
}
@@ -717,7 +718,7 @@ jeedomUtils.initJeedomModals = function() { //Deprecated jQuery UI dilaog/bootbo
}
}
-jeedomUtils.setButtonCtrlHandler = function(_buttonId, _title, _uri, _modal = 'jee_modal', _open = true) {
+jeedomUtils.setButtonCtrlHandler = function (_buttonId, _title, _uri, _modal = 'jee_modal', _open = true) {
if (document.getElementById(_buttonId) === null) {
return
}
@@ -748,7 +749,7 @@ jeedomUtils.setButtonCtrlHandler = function(_buttonId, _title, _uri, _modal = 'j
})
}
-jeedomUtils.setJeedomGlobalUI = function() {
+jeedomUtils.setJeedomGlobalUI = function () {
if (typeof jeeFrontEnd.jeedom_firstUse != 'undefined' && isset(jeeFrontEnd.jeedom_firstUse) && jeeFrontEnd.jeedom_firstUse == 1 && getUrlVars('noFirstUse') != 1) {
jeeDialog.dialog({
id: 'md_firstUse',
@@ -756,14 +757,14 @@ jeedomUtils.setJeedomGlobalUI = function() {
width: window.innerWidth > 800 ? 720 : '80vw',
height: window.innerHeight > 600 ? 400 : '80vw',
zIndex: 1040,
- onClose: function() {
+ onClose: function () {
jeeDialog.get('#md_firstUse').destroy()
},
contentUrl: 'index.php?v=d&modal=first.use'
})
}
- window.addEventListener('beforeunload', function(event) {
+ window.addEventListener('beforeunload', function (event) {
//keep old root for plugins
if (jeeFrontEnd.modifyWithoutSave == true || window.modifyWithoutSave == true) {
event.preventDefault()
@@ -777,7 +778,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
jeedomUtils.setButtonCtrlHandler('bt_showDatastoreVariable', '{{Variables}}', 'dataStore.management&type=scenario', 'jee_modal', false)
jeedomUtils.setButtonCtrlHandler('bt_showSearching', '{{Recherche}}', 'search', 'jee_modal')
- document.getElementById('bt_gotoDashboard')?.addEventListener('click', function(event) {
+ document.getElementById('bt_gotoDashboard')?.addEventListener('click', function (event) {
if (!getDeviceType()['type'] == 'desktop' || window.innerWidth < 768) {
event.stopPropagation()
return
@@ -789,7 +790,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
jeedomUtils.loadPage('index.php?v=d&p=dashboard')
})
- document.getElementById('bt_gotoView')?.addEventListener('click', function(event) {
+ document.getElementById('bt_gotoView')?.addEventListener('click', function (event) {
if (!getDeviceType()['type'] == 'desktop' || window.innerWidth < 768) {
event.stopPropagation()
return
@@ -797,7 +798,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
jeedomUtils.loadPage('index.php?v=d&p=view')
})
- document.getElementById('bt_gotoPlan')?.addEventListener('click', function(event) {
+ document.getElementById('bt_gotoPlan')?.addEventListener('click', function (event) {
if (!getDeviceType()['type'] == 'desktop' || window.innerWidth < 768) {
event.stopPropagation()
return
@@ -805,7 +806,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
jeedomUtils.loadPage('index.php?v=d&p=plan')
})
- document.getElementById('bt_gotoPlan3d')?.addEventListener('click', function(event) {
+ document.getElementById('bt_gotoPlan3d')?.addEventListener('click', function (event) {
if (!getDeviceType()['type'] == 'desktop' || window.innerWidth < 768) {
event.stopPropagation()
return
@@ -813,7 +814,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
jeedomUtils.loadPage('index.php?v=d&p=plan3d')
})
- document.getElementById('bt_jeedomAbout')?.addEventListener('click', function(event) {
+ document.getElementById('bt_jeedomAbout')?.addEventListener('click', function (event) {
jeedomUtils.closeJeedomMenu()
jeeDialog.dialog({
id: 'jee_modal3',
@@ -824,21 +825,21 @@ jeedomUtils.setJeedomGlobalUI = function() {
})
})
- document.getElementById('bt_getHelpPage')?.addEventListener('click', function(event) {
+ document.getElementById('bt_getHelpPage')?.addEventListener('click', function (event) {
jeedom.getDocumentationUrl({
plugin: this.getAttribute('data-plugin'),
page: this.getAttribute('data-page'),
theme: document.body.getAttribute('data-theme'),
- error: function(error) {
+ error: function (error) {
jeedomUtils.showAlert({ message: error.message, level: 'danger' })
},
- success: function(url) {
+ success: function (url) {
window.open(url, '_blank')
}
})
})
- document.querySelector('.bt_reportBug')?.addEventListener('click', function(event) {
+ document.querySelector('.bt_reportBug')?.addEventListener('click', function (event) {
if (!getDeviceType()['type'] == 'desktop' || window.innerWidth < 768) {
event.stopPropagation()
return
@@ -852,7 +853,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
})
})
- document.getElementById('bt_messageModal')?.addEventListener('click', function(event) {
+ document.getElementById('bt_messageModal')?.addEventListener('click', function (event) {
jeeDialog.dialog({
id: 'jee_modal',
title: "{{Centre de Messages}}",
@@ -860,7 +861,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
})
})
- document.getElementById('bt_jsErrorModal')?.addEventListener('click', function(event) {
+ document.getElementById('bt_jsErrorModal')?.addEventListener('click', function (event) {
jeeDialog.dialog({
id: 'jee_modal',
title: "{{Erreur Javascript}}",
@@ -868,12 +869,12 @@ jeedomUtils.setJeedomGlobalUI = function() {
})
})
- document.body.addEventListener('keydown', function(event) {
+ document.body.addEventListener('keydown', function (event) {
//search input escape:
if (event.target.matches('input[id^="in_search"]')) {
if (event.key == 'Escape') {
event.stopPropagation()
- var els = ((els = document.querySelectorAll('#categoryfilter li .catFilterKey')) != null ? els.forEach(function(item) { item.checked = true }) : null)
+ var els = ((els = document.querySelectorAll('#categoryfilter li .catFilterKey')) != null ? els.forEach(function (item) { item.checked = true }) : null)
var els = ((els = document.querySelectorAll('#dashTopBar button.dropdown-toggle')) != null ? els.removeClass('warning') : null)
event.target.value = ''
return
@@ -881,7 +882,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
}
})
- document.body.addEventListener('click', function(event) {
+ document.body.addEventListener('click', function (event) {
//Summary display:
if (!event.ctrlKey && (event.target.matches('.objectSummaryParent') || event.target.closest('.objectSummaryParent') != null)) {
event.stopPropagation()
@@ -921,7 +922,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
event.stopPropagation()
var input = event.target.closest('div').querySelector('input')
if (input) {
- jeedom.getCronSelectModal({}, function(result) {
+ jeedom.getCronSelectModal({}, function (result) {
input.value = result.value
})
}
@@ -945,7 +946,7 @@ jeedomUtils.setJeedomGlobalUI = function() {
}
//Initiators__
-jeedomUtils.initPage = function() {
+jeedomUtils.initPage = function () {
jeedomUtils.initTableSorter()
jeedomUtils.initReportMode()
if (typeof jQuery === 'function' && typeof $.initTableFilter === 'function') $.initTableFilter()
@@ -965,7 +966,7 @@ jeedomUtils.initPage = function() {
})
*/
- setTimeout(function() {
+ setTimeout(function () {
jeedomUtils.initTooltips()
}, 750)
try {
@@ -974,7 +975,7 @@ jeedomUtils.initPage = function() {
jeedomUtils.initDisplayAsTable()
}
-jeedomUtils.initDisplayAsTable = function() {
+jeedomUtils.initDisplayAsTable = function () {
var buttonAsTable = document.getElementById('bt_displayAsTable')
if (buttonAsTable != null) {
if (getCookie('jeedom_displayAsTable') == 'true' || jeedom.theme.theme_displayAsTable == 1) {
@@ -990,7 +991,7 @@ jeedomUtils.initDisplayAsTable = function() {
}
}
- buttonAsTable.addEventListener('click', function(event) {
+ buttonAsTable.addEventListener('click', function (event) {
if (this.dataset.state == '0') {
this.dataset.state = '1'
this.addClass('active')
@@ -1036,7 +1037,7 @@ jeedomUtils.TOOLTIPSOPTIONS = {
//trigger: 'click',
//hideOnClick: false
}
-jeedomUtils.initTooltips = function(_el) {
+jeedomUtils.initTooltips = function (_el) {
var selector = '[tooltip]:not(.tippied), [title]:not(.tippied):not(.ui-button)'
var items = null
@@ -1058,30 +1059,30 @@ jeedomUtils.initTooltips = function(_el) {
}
})
- tippy(items , jeedomUtils.TOOLTIPSOPTIONS)
+ tippy(items, jeedomUtils.TOOLTIPSOPTIONS)
}
-jeedomUtils.disableTooltips = function() {
+jeedomUtils.disableTooltips = function () {
document.querySelectorAll('.tippied').forEach(_tip => {
if (_tip._tippy) _tip._tippy.disable()
})
}
-jeedomUtils.enableTooltips = function() {
+jeedomUtils.enableTooltips = function () {
document.querySelectorAll('.tippied').forEach(_tip => {
if (_tip._tippy) _tip._tippy.enable()
})
}
-jeedomUtils.initTextArea = function() {
+jeedomUtils.initTextArea = function () {
if (typeof jQuery === 'function') {
- $('body').on('change keyup keydown paste cut', 'textarea.autogrow', function() {
+ $('body').on('change keyup keydown paste cut', 'textarea.autogrow', function () {
$(this).height(0).height(this.scrollHeight)
})
}
}
-jeedomUtils.initReportMode = function() {
+jeedomUtils.initReportMode = function () {
if (getUrlVars('report') == 1) {
document.querySelectorAll('header')?.unseen()
document.querySelectorAll('footer')?.unseen()
@@ -1094,7 +1095,7 @@ jeedomUtils.initReportMode = function() {
}
}
-jeedomUtils.initTableSorter = function(filter) {
+jeedomUtils.initTableSorter = function (filter) {
if (typeof jQuery !== 'function') return
if (typeof $.tablesorter !== 'function') return
var widgets = ['uitheme', 'resizable']
@@ -1121,13 +1122,13 @@ jeedomUtils.initTableSorter = function(filter) {
stickyHeaders_offset: $('header.navbar-fixed-top').height()
},
cssIcon: 'tablesorter-icon',
- initialized: function(table) {
+ initialized: function (table) {
$(table).find('thead .tablesorter-header-inner').append('')
}
}).css('width', '')
}
-jeedomUtils.initDataTables = function(_selector, _paging, _searching) {
+jeedomUtils.initDataTables = function (_selector, _paging, _searching) {
if (!isset(_selector)) _selector = 'body'
if (!_paging) _paging = false
if (!_searching) _searching = false
@@ -1146,7 +1147,7 @@ jeedomUtils.initDataTables = function(_selector, _paging, _searching) {
}
-jeedomUtils.initHelp = function() {
+jeedomUtils.initHelp = function () {
document.querySelectorAll('.help').forEach(element => {
if (element.getAttribute('data-help') != undefined) {
element.insertAdjacentHTML('beforeend', ' ')
@@ -1155,11 +1156,11 @@ jeedomUtils.initHelp = function() {
}
//Deprecated, plugins may use, old jQuery ui autocomplete
-jeedomUtils.autocompleteDestroy = function() {
+jeedomUtils.autocompleteDestroy = function () {
document.querySelectorAll('ul.ui-autocomplete, div.ui-helper-hidden-accessible')?.remove()
}
-jeedomUtils.datePickerInit = function(_format, _selector) {
+jeedomUtils.datePickerInit = function (_format, _selector) {
if (!isset(_format)) _format = 'Y-m-d'
let _enableTime = _format.includes(' ') ? true : false
@@ -1179,7 +1180,7 @@ jeedomUtils.datePickerInit = function(_format, _selector) {
})
}
-jeedomUtils.dateTimePickerInit = function(_step) {
+jeedomUtils.dateTimePickerInit = function (_step) {
if (!isset(_step)) _step = 5
let lang = jeeFrontEnd.language.substring(0, 2)
if (lang == 'fr') flatpickr.localize(flatpickr.l10ns.fr)
@@ -1197,7 +1198,7 @@ jeedomUtils.dateTimePickerInit = function(_step) {
})
}
-jeedomUtils.datePickerDestroy = function() {
+jeedomUtils.datePickerDestroy = function () {
document.querySelectorAll('input.isdatepicker, input.in_datepicker').forEach(_input => {
if (isset(_input._flatpickr)) _input._flatpickr.destroy()
})
@@ -1206,7 +1207,7 @@ jeedomUtils.datePickerDestroy = function() {
})
}
-jeedomUtils.initSpinners = function() {
+jeedomUtils.initSpinners = function () {
if (typeof jQuery === 'function') {
$('input[type="number"].ui-spinner').spinner({
icons: {
@@ -1234,8 +1235,8 @@ jeedomUtils.initSpinners = function() {
})
}
-jeedomUtils.jeeCtxMenuDestroy = function() {
- document.querySelectorAll('div.jeeCtxMenu').forEach(_ctx => {
+jeedomUtils.jeeCtxMenuDestroy = function () {
+ document.querySelectorAll('div.jeeCtxMenu').forEach(_ctx => {
if (isset(_ctx._jeeCtxMenu)) {
_ctx._jeeCtxMenu.destroy()
} else {
@@ -1245,7 +1246,7 @@ jeedomUtils.jeeCtxMenuDestroy = function() {
}
//General functions__
-jeedomUtils.normTextLower = function(_text) {
+jeedomUtils.normTextLower = function (_text) {
try {
var result = _text.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toLowerCase()
} catch (error) {
@@ -1254,7 +1255,7 @@ jeedomUtils.normTextLower = function(_text) {
return result
}
-jeedomUtils.linkify = function(inputText) {
+jeedomUtils.linkify = function (inputText) {
if (!inputText || inputText == '' || inputText === null) {
return ''
}
@@ -1267,7 +1268,7 @@ jeedomUtils.linkify = function(inputText) {
return replacedText
}
-jeedomUtils.sleep = function(milliseconds) {
+jeedomUtils.sleep = function (milliseconds) {
var start = new Date().getTime()
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds) {
@@ -1277,7 +1278,7 @@ jeedomUtils.sleep = function(milliseconds) {
}
jeedomUtils.uniqId_count = 0
-jeedomUtils.uniqId = function(_prefix) {
+jeedomUtils.uniqId = function (_prefix) {
if (typeof _prefix == 'undefined') {
_prefix = 'jee-uniq'
}
@@ -1289,7 +1290,7 @@ jeedomUtils.uniqId = function(_prefix) {
return result
}
-jeedomUtils.taAutosize = function(_el) {
+jeedomUtils.taAutosize = function (_el) {
//http://www.jacklmoore.com/autosize/
if (isset(_el)) {
var doOn = _el
@@ -1300,7 +1301,7 @@ jeedomUtils.taAutosize = function(_el) {
autosize.update(doOn)
}
-jeedomUtils.hexToRgb = function(hex) {
+jeedomUtils.hexToRgb = function (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result ? {
r: parseInt(result[1], 16),
@@ -1309,12 +1310,12 @@ jeedomUtils.hexToRgb = function(hex) {
} : null
}
-jeedomUtils.componentToHex = function(c) {
+jeedomUtils.componentToHex = function (c) {
var hex = c.toString(16)
return hex.length == 1 ? "0" + hex : hex
}
-jeedomUtils.rgbToHex = function(r, g, b) {
+jeedomUtils.rgbToHex = function (r, g, b) {
if (typeof r === 'string' && !g) {
r = r.trim()
if (r.startsWith('rgb')) {
@@ -1334,7 +1335,7 @@ jeedomUtils.rgbToHex = function(r, g, b) {
return "#" + jeedomUtils.componentToHex(r) + jeedomUtils.componentToHex(g) + jeedomUtils.componentToHex(b)
}
-jeedomUtils.addOrUpdateUrl = function(_param, _value, _title) {
+jeedomUtils.addOrUpdateUrl = function (_param, _value, _title) {
var url = new URL(window.location.href)
var query_string = url.search
var search_params = new URLSearchParams(query_string)
@@ -1365,9 +1366,9 @@ jeedomUtils.addOrUpdateUrl = function(_param, _value, _title) {
}
//Global UI functions__
-jeedomUtils.setJeedomMenu = function() {
+jeedomUtils.setJeedomMenu = function () {
//Listener on body to catch Jeedom links for loadpage() instead of reloading url
- document.body.addEventListener('click', function(event) {
+ document.body.addEventListener('click', function (event) {
var _target = null
if (_target = event.target.closest('a')) {
if (_target.hasClass('noOnePageLoad')) return
@@ -1444,9 +1445,9 @@ jeedomUtils.setJeedomMenu = function() {
}
}
-jeedomUtils.closeJeedomMenu = function() {
+jeedomUtils.closeJeedomMenu = function () {
document.querySelectorAll('#jeedomMenuBar .navbar-nav')?.addClass('disabled')
- setTimeout(function() {
+ setTimeout(function () {
document.querySelectorAll('#jeedomMenuBar .navbar-nav')?.removeClass('disabled')
}, 250)
@@ -1455,7 +1456,7 @@ jeedomUtils.closeJeedomMenu = function() {
}
}
-jeedomUtils.positionEqLogic = function(_id, _preResize, _scenario) {
+jeedomUtils.positionEqLogic = function (_id, _preResize, _scenario) {
var margin = '0px ' + jeedom.theme['widget::margin'] + 'px ' + jeedom.theme['widget::margin'] + 'px 0'
//Get full width, step columns, to fill right space:
@@ -1467,7 +1468,7 @@ jeedomUtils.positionEqLogic = function(_id, _preResize, _scenario) {
var cols = Math.floor(containerWidth / jeedomUtils.tileWidthStep)
var tileWidthAdd = containerWidth - (cols * jeedomUtils.tileWidthStep)
var widthStep = jeedomUtils.tileWidthStep + (tileWidthAdd / cols)
- var widthSteps = Array.apply(null, { length: 50 }).map(function(value, index) { return (index + 1) * widthStep })
+ var widthSteps = Array.apply(null, { length: 50 }).map(function (value, index) { return (index + 1) * widthStep })
if (_id != undefined) {
var tile = (_scenario) ? document.querySelector('.scenario-widget[data-scenario_id="' + _id + '"]') : document.querySelector('.eqLogic-widget[data-eqlogic_id="' + _id + '"]')
@@ -1492,14 +1493,14 @@ jeedomUtils.positionEqLogic = function(_id, _preResize, _scenario) {
for (idx = 0; idx < elements.length; idx++) {
tile = elements[idx]
-
+
if (tile.dataset.confWidth === undefined) {
tile.dataset.confWidth = tile.offsetWidth
tile.dataset.stepHeight = jeedomUtils.tileHeightSteps.indexOf(jeedomUtils.getClosestInArray(tile.offsetHeight, jeedomUtils.tileHeightSteps))
}
width = jeedomUtils.getClosestInArray(tile.dataset.confWidth, widthSteps)
height = jeedomUtils.tileHeightSteps[tile.dataset.stepHeight]
-
+
Object.assign(tile.style, {
width: (width - parseInt(jeedom.theme['widget::margin'])) + 'px',
height: (height - parseInt(jeedom.theme['widget::margin'])) + 'px',
@@ -1509,15 +1510,15 @@ jeedomUtils.positionEqLogic = function(_id, _preResize, _scenario) {
}
}
}
-jeedomUtils.getClosestInArray = function(_num, _refAr) {
- return _refAr.reduce(function(prev, curr) {
+jeedomUtils.getClosestInArray = function (_num, _refAr) {
+ return _refAr.reduce(function (prev, curr) {
//return (Math.abs(curr - _num) < Math.abs(prev - _num) ? curr : prev) // old
return (Math.abs(_num) > Math.abs(prev) ? curr : prev) // new
})
}
//Deprecated 4.4, obsolete 4.6
-jeedomUtils.showHelpModal = function(_name, _plugin) {
+jeedomUtils.showHelpModal = function (_name, _plugin) {
var url_helpWebsite
var url_helpSpe
if (init(_plugin) != '' && _plugin != undefined) {
@@ -1528,7 +1529,7 @@ jeedomUtils.showHelpModal = function(_name, _plugin) {
url_helpSpe = 'index.php?v=d&modal=help.' + init(_name)
}
- document.getElementById('div_helpWebsite').load(url_helpWebsite, function() {
+ document.getElementById('div_helpWebsite').load(url_helpWebsite, function () {
if (document.getElementById('div_helpWebsite').querySelectorAll('.alert.alert-danger').length > 0 || document.getElementById('div_helpWebsite').textContent.trim() == '') {
document.querySelector('a[href="#div_helpSpe"]').click()
document.querySelector('a[href="#div_helpWebsite"]').unseen()
@@ -1539,7 +1540,7 @@ jeedomUtils.showHelpModal = function(_name, _plugin) {
document.getElementById('div_helpSpe').load(url_helpSpe)
}
-jeedomUtils.reloadPagePrompt = function(_title) {
+jeedomUtils.reloadPagePrompt = function (_title) {
jeeDialog.confirm({
title: ' ' + _title,
message: '{{Voulez vous recharger la page maintenant ?}}',
@@ -1553,7 +1554,7 @@ jeedomUtils.reloadPagePrompt = function(_title) {
className: 'info'
}
},
- callback: function(result) {
+ callback: function (result) {
if (result) {
window.location.reload(true)
}
@@ -1561,7 +1562,7 @@ jeedomUtils.reloadPagePrompt = function(_title) {
})
}
-jeedomUtils.chooseIcon = function(_callback, _params) {
+jeedomUtils.chooseIcon = function (_callback, _params) {
var url = 'index.php?v=d&modal=icon.selector'
if (_params && _params.img && _params.img === true) {
url += '&showimg=1'
@@ -1569,7 +1570,7 @@ jeedomUtils.chooseIcon = function(_callback, _params) {
if (_params && _params.icon) {
var icon = _params.icon
var replaceAr = ['icon_blue', 'icon_green', 'icon_orange', 'icon_red', 'icon_yellow']
- replaceAr.forEach(function(element) {
+ replaceAr.forEach(function (element) {
if (icon.includes(element)) {
icon = icon.replace(element, '')
_params.color = (!_params.color) ? element : _params.color
@@ -1597,8 +1598,8 @@ jeedomUtils.chooseIcon = function(_callback, _params) {
label: '{{Appliquer}}',
className: 'success',
callback: {
- click: function(event) {
- if(document.getElementById('mod_selectIcon').querySelector('.iconSelected .iconSel') === null){
+ click: function (event) {
+ if (document.getElementById('mod_selectIcon').querySelector('.iconSelected .iconSel') === null) {
jeeDialog.get('#mod_selectIcon').close()
return;
}
@@ -1616,20 +1617,20 @@ jeedomUtils.chooseIcon = function(_callback, _params) {
label: '{{Annuler}}',
className: 'warning',
callback: {
- click: function(event) {
+ click: function (event) {
jeeDialog.get('#mod_selectIcon').close()
}
}
}
},
- onClose: function() {
+ onClose: function () {
jeeDialog.get('#mod_selectIcon').destroy() //No twice footer select/search
},
contentUrl: url
})
}
-jeedomUtils.getOpenedModal = function() {
+jeedomUtils.getOpenedModal = function () {
var _return = false
document.querySelectorAll('div.jeeDialog').forEach(_dialog => {
if (_dialog.isVisible()) _return = true
@@ -1642,7 +1643,7 @@ jeedomUtils.getOpenedModal = function() {
}
//Deprecated 4.4 keep for plugins
-jeedomUtils.closeModal = function(_modals = '') {
+jeedomUtils.closeModal = function (_modals = '') {
if (typeof jQuery != 'function') return
if (_modals == '') {
_modals = ['md_modal', 'md_modal2', 'md_modal3']
@@ -1650,7 +1651,7 @@ jeedomUtils.closeModal = function(_modals = '') {
if (!Array.isArray(_modals)) {
_modals = [_modals]
}
- _modals.forEach(function(_modal) {
+ _modals.forEach(function (_modal) {
try {
$('#' + _modal).dialog('close')
} catch (error) { }
@@ -1658,29 +1659,29 @@ jeedomUtils.closeModal = function(_modals = '') {
})
}
-jeedomUtils.closeJeeDialogs = function() {
- document.querySelectorAll('div.jeeDialog').forEach( _dialog => {
+jeedomUtils.closeJeeDialogs = function () {
+ document.querySelectorAll('div.jeeDialog').forEach(_dialog => {
//uninitialized modal doesn't have _jeeDialog
if (isset(_dialog._jeeDialog)) _dialog._jeeDialog.close(_dialog)
})
}
//Deprecated jQuery UI ui-dialog
-jeedomUtils.cleanModals = function(_modals = '') {
- document.querySelectorAll('.ui-dialog .cleanableModal')?.forEach(function(element) {
+jeedomUtils.cleanModals = function (_modals = '') {
+ document.querySelectorAll('.ui-dialog .cleanableModal')?.forEach(function (element) {
element.closest('.ui-dialog')?.remove()
})
}
//Context menu on checkbox
-jeedomUtils.setCheckboxStateByType = function(_type, _state, _callback) {
+jeedomUtils.setCheckboxStateByType = function (_type, _state, _callback) {
if (!isset(_type)) return false
if (!isset(_state)) _state = -1
var checkboxes = document.querySelectorAll(_type)
if (checkboxes == null) return
var isCallback = (isset(_callback) && typeof _callback === 'function') ? true : false
var execCallback = false
- checkboxes.forEach(function(checkbox) {
+ checkboxes.forEach(function (checkbox) {
execCallback = false
if (_state == -1) {
checkbox.checked = !checkbox.checked
@@ -1696,7 +1697,7 @@ jeedomUtils.setCheckboxStateByType = function(_type, _state, _callback) {
}
})
}
-jeedomUtils.getElementType = function(_el) {
+jeedomUtils.getElementType = function (_el) {
let thisType = ''
if (_el.tagName === 'INPUT') thisType = 'input[type="' + _el.getAttribute('type') + '"]'
@@ -1712,12 +1713,12 @@ jeedomUtils.getElementType = function(_el) {
}
return thisType
}
-jeedomUtils.setCheckContextMenu = function(_callback) {
+jeedomUtils.setCheckContextMenu = function (_callback) {
let ctxSelector = 'input[type="checkbox"].checkContext, input[type="radio"].checkContext'
try {
document.querySelector('.contextmenu-checkbox')._jeeCtxMenu.destroy()
document.querySelector('.contextmenu-checkbox')?.remove()
- } catch(e) { }
+ } catch (e) { }
jeedomUtils.checkContextMenu = new jeeCtxMenu({
selector: ctxSelector,
@@ -1727,21 +1728,21 @@ jeedomUtils.setCheckContextMenu = function(_callback) {
items: {
all: {
name: "{{Sélectionner tout}}",
- callback: function(key, opt) {
+ callback: function (key, opt) {
let thisType = jeedomUtils.getElementType(opt.trigger)
jeedomUtils.setCheckboxStateByType(thisType, 1, _callback)
}
},
none: {
name: "{{Désélectionner tout}}",
- callback: function(key, opt) {
+ callback: function (key, opt) {
let thisType = jeedomUtils.getElementType(opt.trigger)
jeedomUtils.setCheckboxStateByType(thisType, 0, _callback)
}
},
invert: {
name: "{{Inverser la sélection}}",
- callback: function(key, opt) {
+ callback: function (key, opt) {
let thisType = jeedomUtils.getElementType(opt.trigger)
jeedomUtils.setCheckboxStateByType(thisType, -1, _callback)
}
@@ -1752,11 +1753,11 @@ jeedomUtils.setCheckContextMenu = function(_callback) {
//Need jQuery and jQuery UI plugin loaded:
if (typeof jQuery === 'function') {
- jQuery.fn.setCursorPosition = function(position) {
+ jQuery.fn.setCursorPosition = function (position) {
if (this.lengh == 0) return this
return $(this).setSelection(position, position)
}
- jQuery.fn.setSelection = function(selectionStart, selectionEnd) {
+ jQuery.fn.setSelection = function (selectionStart, selectionEnd) {
if (this.lengh == 0) return this
input = this[0]
if (input.createTextRange) {
@@ -1782,7 +1783,7 @@ if (typeof jQuery === 'function') {
* @param {string} _to
* @param {string} _line
*/
-jeedomUtils.deprecatedFunc = function(_oldFnName, _newFnName, _since, _to, _line) {
+jeedomUtils.deprecatedFunc = function (_oldFnName, _newFnName, _since, _to, _line) {
if (jeeFrontEnd.coreBranch == 'V4-stable') return
var msg = `!WARNING! Deprecated function ${_oldFnName} since Core v${_since}: Use new Core v${_to} ${_newFnName}() function.`
@@ -1790,13 +1791,13 @@ jeedomUtils.deprecatedFunc = function(_oldFnName, _newFnName, _since, _to, _line
var _pluginId = $('body').attr('data-page')
jeedom.plugin.get({
id: _pluginId,
- error: function(error) {
+ error: function (error) {
jeedomUtils.showAlert({
message: error.message,
level: 'danger'
})
},
- success: function(data) {
+ success: function (data) {
msg += ' plugin: ' + _pluginId + ' | require: ' + data.require
}
})
diff --git a/desktop/js/dashboard.js b/desktop/js/dashboard.js
index 94e4163d42..197f73f617 100644
--- a/desktop/js/dashboard.js
+++ b/desktop/js/dashboard.js
@@ -44,6 +44,18 @@ if (!jeeFrontEnd.dashboard) {
jeeFrontEnd.dashboard.getObjectHtml(objId)
})
}
+ jeedom.getInfoApplication({
+ version: 'dashboard',
+ error: function(error) {
+ jeedomUtils.showAlert({
+ message: error.message,
+ level: 'danger'
+ })
+ },
+ success: function(data) {
+ jeedom.appMobile.postToApp('initSummary', data.summary)
+ }
+ })
},
postInit: function() {
jeedomUI.isEditing = false
@@ -706,6 +718,17 @@ document.getElementById('div_pageContainer').addEventListener('mousedown', funct
}
})
+//Event for App Mobile:
+document.body.addEventListener('jeeObject::summary::update', function(_event) {
+ for (var i in _event.detail) {
+ if(isset(_event.detail[i].force) && _event.detail[i].force == 1) continue
+ if(_event.detail[i].object_id == 'global') {
+ /* SEND UPDATE SUMMARY TO APP */
+ jeedom.appMobile.postToApp('updateSummary', _event.detail[i].keys)
+ }
+ }
+})
+
//Resize responsive tiles:
window.registerEvent('resize', function dashboard(event) {
if (event.isTrigger) return
diff --git a/desktop/js/plan.js b/desktop/js/plan.js
index 6277b6e557..7fcf003b4f 100644
--- a/desktop/js/plan.js
+++ b/desktop/js/plan.js
@@ -40,6 +40,18 @@ if (!jeeFrontEnd.plan) {
highlight: true
}
}
+ jeedom.getInfoApplication({
+ version: 'dashboard',
+ error: function(error) {
+ jeedomUtils.showAlert({
+ message: error.message,
+ level: 'danger'
+ })
+ },
+ success: function(data) {
+ jeedom.appMobile.postToApp('initSummary', data.summary)
+ }
+ })
},
postInit: function() {
for (var i in jeephp2js.planHeader) {
@@ -1469,9 +1481,19 @@ document.querySelector('.div_displayObject').addEventListener('mouseleave', func
}
}, {capture: true})
+//Event for App Mobile:
+document.body.addEventListener('jeeObject::summary::update', function(_event) {
+ for (var i in _event.detail) {
+ if(isset(_event.detail[i].force) && _event.detail[i].force == 1) continue
+ if(_event.detail[i].object_id == 'global') {
+ /* SEND UPDATE SUMMARY TO APP */
+ jeedom.appMobile.postToApp('updateSummary', _event.detail[i].keys)
+ }
+ }
+})
//back to mobile home with three fingers on mobile:
-if (user_isAdmin == 1 && jeedomUtils.userDevice.type == 'mobile') {
+if (user_isAdmin == 1 && jeedomUtils.userDevice.type != 'desktop') {
document.body.registerEvent('touchstart', function (event) {
if (event.touches.length == 3) {
event.preventDefault()
diff --git a/desktop/js/view.js b/desktop/js/view.js
index 039de2a9b6..369c3e70de 100644
--- a/desktop/js/view.js
+++ b/desktop/js/view.js
@@ -28,6 +28,18 @@ if (!jeeFrontEnd.view) {
if (jeephp2js.view_id != '') {
jeeFrontEnd.view.printView(jeephp2js.view_id)
}
+ jeedom.getInfoApplication({
+ version: 'dashboard',
+ error: function(error) {
+ jeedomUtils.showAlert({
+ message: error.message,
+ level: 'danger'
+ })
+ },
+ success: function(data) {
+ jeedom.appMobile.postToApp('initSummary', data.summary)
+ }
+ })
},
printView: function(_id) {
jeedom.view.toHtml({
@@ -222,6 +234,17 @@ if (!jeeFrontEnd.view) {
jeeFrontEnd.view.init()
+//Event for App Mobile:
+document.body.addEventListener('jeeObject::summary::update', function(_event) {
+ for (var i in _event.detail) {
+ if(isset(_event.detail[i].force) && _event.detail[i].force == 1) continue
+ if(_event.detail[i].object_id == 'global') {
+ /* SEND UPDATE SUMMARY TO APP */
+ jeedom.appMobile.postToApp('updateSummary', _event.detail[i].keys)
+ }
+ }
+})
+
//Register events on top of page container:
window.registerEvent("resize", function view(event) {
if (event.isTrigger) return
diff --git a/desktop/php/administration.php b/desktop/php/administration.php
index d59a303005..b85db4be97 100644
--- a/desktop/php/administration.php
+++ b/desktop/php/administration.php
@@ -953,6 +953,21 @@
+
diff --git a/mobile/js/application.js b/mobile/js/application.js
index 0555e27268..32e62f7ea3 100644
--- a/mobile/js/application.js
+++ b/mobile/js/application.js
@@ -381,6 +381,9 @@ jeedomUtils.initApplication = function(_reinit) {
confirm('Erreur de communication. Etes-vous connecté à Internet ? Voulez-vous réessayer ?')
},
success: function (data) {
+ /* SEND SUMMARY TO APP */
+ jeedom.appMobile.postToApp('initSummary', data.result.summary)
+
jeedom.theme = data.result
jeeFrontEnd.language = data.result.language
@@ -539,6 +542,7 @@ jeedomUtils.initApplication = function(_reinit) {
{page: 'deamon', title: '{{Démons}}'},
{page: 'message', title: '{{Message}}'},
{page: 'overview', title: " {{Synthèse}}"},
+ {page: 'scenario', title: "{{Scenario}}"},
{page: 'home', title: "{{Accueil}}"},
]
window.redirected = false
@@ -551,7 +555,7 @@ jeedomUtils.initApplication = function(_reinit) {
}
} else if (redirect == 'view') {
jeedomUtils.loadPage('view', '{{Vue}}', getUrlVars('view_id'));
- } else if (redirect == 'dashboard') {
+ } else if (redirect == 'dashboard' || redirect == 'equipment') {
jeedomUtils.loadPage('equipment', '{{Dashboard}}',getUrlVars('object_id'));
}
else if (redirect == 'plan') {
@@ -610,6 +614,15 @@ jeedomUtils.initApplication = function(_reinit) {
}
}
})
+ document.body.addEventListener('jeeObject::summary::update', function(_event) {
+ for (var i in _event.detail) {
+ if(isset(_event.detail[i].force) && _event.detail[i].force == 1) continue
+ if(_event.detail[i].object_id == 'global') {
+ /* SEND UPDATE SUMMARY TO APP */
+ jeedom.appMobile.postToApp('updateSummary', _event.detail[i].keys)
+ }
+ }
+ })
}
jeedomUtils.loadPage = function(_page, _title, _option, _plugin, _dialog) {
@@ -724,7 +737,10 @@ jeedomUtils.loadPage = function(_page, _title, _option, _plugin, _dialog) {
}
$('#page').trigger('create')
jeedomUtils.setBackgroundImage('')
- window.history.pushState('', '', 'index.php?v=m&p=' + _page)
+ page = 'index.php?v=m'
+ page += (init(_plugin) != '') ? '&p=' + _plugin : '&p=' + _page
+ if (getUrlVars('app_mode') == 1) page += '&app_mode=1'
+ window.history.pushState('', '', page)
var functionName = ''
if (init(_plugin) != '') {