Skip to content

Commit

Permalink
Merge pull request #1804 from jeedom/beta
Browse files Browse the repository at this point in the history
Beta To Stable 4.1.19
  • Loading branch information
rocket13011 authored Feb 1, 2021
2 parents 6a158d1 + fbf36bd commit 6edbb96
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 177 deletions.
2 changes: 1 addition & 1 deletion core/ajax/view.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
$view_ajax = json_decode(init('view'), true);
utils::a2o($view, $view_ajax);
$view->save();
$view->removeviewZone();
if (isset($view_ajax['zones']) && count($view_ajax['zones']) > 0) {
$view->removeviewZone();
foreach ($view_ajax['zones'] as $viewZone_info) {
$viewZone = new viewZone();
$viewZone->setView_id($view->getId());
Expand Down
282 changes: 143 additions & 139 deletions core/class/jeedom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1375,184 +1375,188 @@ public static function cleanDatabase() {
}

public static function cleanFileSytemRight() {
self::cleanFileSystemRight();
}

public static function cleanFileSystemRight() {
$cmd = system::getCmdSudo() . 'chown -R ' . system::get('www-uid') . ':' . system::get('www-gid') . ' ' . __DIR__ . '/../../*;';
$cmd .= system::getCmdSudo() . 'chmod 775 -R ' . __DIR__ . '/../../*;';
$cmd .= system::getCmdSudo() . 'find ' . __DIR__ . '/../../log -type f -exec chmod 665 {} +;';
$cmd .= system::getCmdSudo() . 'chmod 775 -R ' . __DIR__ . '/../../.* ;';
exec($cmd);
}
$cmd .= system::getCmdSudo() . 'chmod 775 -R ' . __DIR__ . '/../../.* ;';
exec($cmd);
}

public static function checkSpaceLeft($_dir = null) {
if ($_dir == null) {
$path = __DIR__ . '/../../';
} else {
$path = $_dir;
}
return round(disk_free_space($path) / disk_total_space($path) * 100);
public static function checkSpaceLeft($_dir = null) {
if ($_dir == null) {
$path = __DIR__ . '/../../';
} else {
$path = $_dir;
}
return round(disk_free_space($path) / disk_total_space($path) * 100);
}

public static function getTmpFolder($_plugin = null) {
$return = '/' . trim(config::byKey('folder::tmp'), '/');
if ($_plugin !== null) {
$return .= '/' . $_plugin;
}
if (!file_exists($return)) {
mkdir($return, 0774, true);
$cmd = system::getCmdSudo() . 'chown -R ' . system::get('www-uid') . ':' . system::get('www-gid') . ' ' . $return . ';';
com_shell::execute($cmd);
}
return $return;
public static function getTmpFolder($_plugin = null) {
$return = '/' . trim(config::byKey('folder::tmp'), '/');
if ($_plugin !== null) {
$return .= '/' . $_plugin;
}
if (!file_exists($return)) {
mkdir($return, 0774, true);
$cmd = system::getCmdSudo() . 'chown -R ' . system::get('www-uid') . ':' . system::get('www-gid') . ' ' . $return . ';';
com_shell::execute($cmd);
}
return $return;
}

/* * ******************hardware management*************************** */
/* * ******************hardware management*************************** */

public static function getHardwareKey() {
$return = config::byKey('jeedom::installKey');
if ($return == '') {
$return = substr(sha512(microtime() . config::genKey()), 0, 63);
config::save('jeedom::installKey', $return);
}
return $return;
public static function getHardwareKey() {
$return = config::byKey('jeedom::installKey');
if ($return == '') {
$return = substr(sha512(microtime() . config::genKey()), 0, 63);
config::save('jeedom::installKey', $return);
}
return $return;
}

public static function getHardwareName() {
if (config::byKey('hardware_name') != '') {
return config::byKey('hardware_name');
}
$result = 'diy';
$uname = shell_exec('uname -a');
if (file_exists('/.dockerinit')) {
$result = 'docker';
} else if (file_exists('/usr/bin/raspi-config')) {
$result = 'rpi';
$hardware_revision = strtolower(shell_exec('cat /proc/cpuinfo | grep Revision'));
global $JEEDOM_RPI_HARDWARE;
foreach ($JEEDOM_RPI_HARDWARE as $key => $values) {
foreach ($values as $value) {
if(strpos($hardware_revision,$value) !== false){
$result = $key;
}
public static function getHardwareName() {
if (config::byKey('hardware_name') != '') {
return config::byKey('hardware_name');
}
$result = 'diy';
$uname = shell_exec('uname -a');
if (file_exists('/.dockerinit')) {
$result = 'docker';
} else if (file_exists('/usr/bin/raspi-config')) {
$result = 'rpi';
$hardware_revision = strtolower(shell_exec('cat /proc/cpuinfo | grep Revision'));
global $JEEDOM_RPI_HARDWARE;
foreach ($JEEDOM_RPI_HARDWARE as $key => $values) {
foreach ($values as $value) {
if(strpos($hardware_revision,$value) !== false){
$result = $key;
}
}
} else if (strpos($uname, 'cubox') !== false || strpos($uname, 'imx6') !== false || file_exists('/media/boot/multiboot/meson64_odroidc2.dtb.linux')) {
$result = 'miniplus';
} else if (file_exists('/usr/bin/grille-pain')) {
$result = 'freeboxDelta';
}
if (file_exists('/media/boot/multiboot/meson64_odroidc2.dtb.linux')) {
$result = 'smart';
}
config::save('hardware_name', $result);
return config::byKey('hardware_name');
} else if (strpos($uname, 'cubox') !== false || strpos($uname, 'imx6') !== false || file_exists('/media/boot/multiboot/meson64_odroidc2.dtb.linux')) {
$result = 'miniplus';
} else if (file_exists('/usr/bin/grille-pain')) {
$result = 'freeboxDelta';
}
if (file_exists('/media/boot/multiboot/meson64_odroidc2.dtb.linux')) {
$result = 'smart';
}
config::save('hardware_name', $result);
return config::byKey('hardware_name');
}

public static function isCapable($_function, $_forceRefresh = false) {
global $JEEDOM_COMPATIBILIY_CONFIG;
if ($_function == 'sudo') {
if (!$_forceRefresh) {
$cache = cache::byKey('jeedom::isCapable::sudo');
if ($cache->getValue(0) == 1) {
return true;
}
public static function isCapable($_function, $_forceRefresh = false) {
global $JEEDOM_COMPATIBILIY_CONFIG;
if ($_function == 'sudo') {
if (!$_forceRefresh) {
$cache = cache::byKey('jeedom::isCapable::sudo');
if ($cache->getValue(0) == 1) {
return true;
}
$result = (shell_exec('sudo -l > /dev/null 2>&1; echo $?') == 0) ? true : false;
cache::set('jeedom::isCapable::sudo', $result,3600*24);
return $result;
}
$hardware = self::getHardwareName();
if (!isset($JEEDOM_COMPATIBILIY_CONFIG[$hardware])) {
return false;
}
if (in_array($_function, $JEEDOM_COMPATIBILIY_CONFIG[$hardware])) {
return true;
}
$result = (shell_exec('sudo -l > /dev/null 2>&1; echo $?') == 0) ? true : false;
cache::set('jeedom::isCapable::sudo', $result,3600*24);
return $result;
}
$hardware = self::getHardwareName();
if (!isset($JEEDOM_COMPATIBILIY_CONFIG[$hardware])) {
return false;
}
if (in_array($_function, $JEEDOM_COMPATIBILIY_CONFIG[$hardware])) {
return true;
}
return false;
}

/* * ******************Benchmark*************************** */

public static function benchmark() {
$return = array();
/* * ******************Benchmark*************************** */

$param = array('cache_write' => 5000, 'cache_read' => 5000, 'database_write_delete' => 1000, 'database_update' => 1000, 'database_replace' => 1000, 'database_read' => 50000, 'subprocess' => 200);
public static function benchmark() {
$return = array();

$starttime = getmicrotime();
for ($i = 0; $i < $param['cache_write']; $i++) {
cache::set('jeedom_benchmark', $i);
}
$return['cache_write_' . $param['cache_write']] = getmicrotime() - $starttime;
$param = array('cache_write' => 5000, 'cache_read' => 5000, 'database_write_delete' => 1000, 'database_update' => 1000, 'database_replace' => 1000, 'database_read' => 50000, 'subprocess' => 200);

$starttime = getmicrotime();
for ($i = 0; $i < $param['cache_read']; $i++) {
$cache = cache::byKey('jeedom_benchmark');
$cache->getValue();
}
$return['cache_read_' . $param['cache_read']] = getmicrotime() - $starttime;
$starttime = getmicrotime();
for ($i = 0; $i < $param['cache_write']; $i++) {
cache::set('jeedom_benchmark', $i);
}
$return['cache_write_' . $param['cache_write']] = getmicrotime() - $starttime;

$starttime = getmicrotime();
for ($i = 0; $i < $param['database_write_delete']; $i++) {
$sql = 'DELETE FROM config
WHERE `key`="jeedom_benchmark"
AND plugin="core"';
try {
DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {
$starttime = getmicrotime();
for ($i = 0; $i < $param['cache_read']; $i++) {
$cache = cache::byKey('jeedom_benchmark');
$cache->getValue();
}
$return['cache_read_' . $param['cache_read']] = getmicrotime() - $starttime;

}
$sql = 'INSERT INTO config
SET `key`="jeedom_benchmark",plugin="core",`value`="' . $i . '"';
try {
DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {
$starttime = getmicrotime();
for ($i = 0; $i < $param['database_write_delete']; $i++) {
$sql = 'DELETE FROM config
WHERE `key`="jeedom_benchmark"
AND plugin="core"';
try {
DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {

}
}
$return['database_write_delete_' . $param['database_write_delete']] = getmicrotime() - $starttime;

$sql = 'INSERT INTO config
SET `key`="jeedom_benchmark",plugin="core",`value`="0"';
SET `key`="jeedom_benchmark",plugin="core",`value`="' . $i . '"';
try {
DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {

}
$starttime = getmicrotime();
for ($i = 0; $i < $param['database_update']; $i++) {
$sql = 'UPDATE config
SET `value`=:value
WHERE `key`="jeedom_benchmark"
AND plugin="core"';
try {
DB::Prepare($sql, array('value' => $i), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {
}
$return['database_write_delete_' . $param['database_write_delete']] = getmicrotime() - $starttime;

}
}
$return['database_update_' . $param['database_update']] = getmicrotime() - $starttime;
$sql = 'INSERT INTO config
SET `key`="jeedom_benchmark",plugin="core",`value`="0"';
try {
DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {

$starttime = getmicrotime();
for ($i = 0; $i < $param['database_replace']; $i++) {
config::save('jeedom_benchmark', $i);
}
$return['database_replace_' . $param['database_replace']] = getmicrotime() - $starttime;
}
$starttime = getmicrotime();
for ($i = 0; $i < $param['database_update']; $i++) {
$sql = 'UPDATE config
SET `value`=:value
WHERE `key`="jeedom_benchmark"
AND plugin="core"';
try {
DB::Prepare($sql, array('value' => $i), DB::FETCH_TYPE_ROW);
} catch (Exception $e) {

$starttime = getmicrotime();
for ($i = 0; $i < $param['database_read']; $i++) {
config::byKey('jeedom_benchmark');
}
$return['database_read_' . $param['database_read']] = getmicrotime() - $starttime;
}
$return['database_update_' . $param['database_update']] = getmicrotime() - $starttime;

$starttime = getmicrotime();
for ($i = 0; $i < $param['subprocess']; $i++) {
shell_exec('echo ' . $i);
}
$return['subprocess_' . $param['subprocess']] = getmicrotime() - $starttime;
$starttime = getmicrotime();
for ($i = 0; $i < $param['database_replace']; $i++) {
config::save('jeedom_benchmark', $i);
}
$return['database_replace_' . $param['database_replace']] = getmicrotime() - $starttime;

$total = 0;
foreach ($return as $value) {
$total += $value;
}
$return['total'] = $total;
return $return;
$starttime = getmicrotime();
for ($i = 0; $i < $param['database_read']; $i++) {
config::byKey('jeedom_benchmark');
}
$return['database_read_' . $param['database_read']] = getmicrotime() - $starttime;

$starttime = getmicrotime();
for ($i = 0; $i < $param['subprocess']; $i++) {
shell_exec('echo ' . $i);
}
$return['subprocess_' . $param['subprocess']] = getmicrotime() - $starttime;

$total = 0;
foreach ($return as $value) {
$total += $value;
}
$return['total'] = $total;
return $return;
}
}
4 changes: 2 additions & 2 deletions core/config/jeedom.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@
'MEDIA_RESUME' => array('name' => __('Lecture',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action'),
'MEDIA_STOP' => array('name' => __('Stop',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action'),
'MEDIA_NEXT' => array('name' => __('Suivant',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action'),
'MEDIA_PREVIOUS' => array('name' => __('Précedent',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action'),
'MEDIA_PREVIOUS' => array('name' => __('Précédent',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action'),
'MEDIA_ON' => array('name' => __('On',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action', 'noapp' => true),
'MEDIA_OFF' => array('name' => __('On',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action', 'noapp' => true),
'MEDIA_OFF' => array('name' => __('Off',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action', 'noapp' => true),
'MEDIA_MUTE' => array('name' => __('Muet',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action', 'noapp' => true),
'MEDIA_UNMUTE' => array('name' => __('Non Muet',__FILE__), 'family' => __('Multimédia',__FILE__), 'type' => 'Action', 'noapp' => true),
'GENERIC_INFO' => array('name' => __(' Générique',__FILE__), 'family' => __('Generic',__FILE__), 'type' => 'Info'),
Expand Down
2 changes: 1 addition & 1 deletion core/config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.18
4.1.19
4 changes: 3 additions & 1 deletion core/template/dashboard/cmd.info.numeric.default.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
<script>
jeedom.cmd.update['#id#'] = function(_options) {
$('.cmd[data-cmd_id=#id#]').attr('title','{{Date de valeur}} : '+_options.valueDate+'<br/>{{Date de collecte}} : '+_options.collectDate)
$('.cmd[data-cmd_uid=#uid#] .gauge').highcharts().series[0].points[0].update(_options.display_value)
if ($('.cmd[data-cmd_uid=#uid#] .gauge').highcharts() !== undefined) {
$('.cmd[data-cmd_uid=#uid#] .gauge').highcharts().series[0].points[0].update(_options.display_value)
}
}

if (is_numeric('#state#')) {
Expand Down
2 changes: 1 addition & 1 deletion desktop/common/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ function initPage() {

try {
if (getDeviceType()['type'] == 'desktop') $("input[id^='in_search']").first().focus()
} catch {}
} catch (error) {}
}

var __OBSERVER__ = null
Expand Down
8 changes: 8 additions & 0 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog Jeedom V4.1


## 4.1.19

- Bugfix suppression de zone sur une Vue.
- Bugfix erreur js pouvant apparaitre sur d'anciens navigateurs.
- Bugfix cmd.info.numeric.default.html si commande non visible.
- Bugfix page de connection.

## 4.1.18

- Bugfix historiques sur les Designs.
Expand Down
Loading

0 comments on commit 6edbb96

Please sign in to comment.