Skip to content

Commit

Permalink
Merge pull request #1797 from jeedom/beta
Browse files Browse the repository at this point in the history
Beta to Stable 4.1.18
  • Loading branch information
rocket13011 committed Jan 25, 2021
2 parents 76af35c + f3cefc6 commit 111076e
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 58 deletions.
11 changes: 6 additions & 5 deletions core/ajax/plan.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,17 @@
mkdir($uploaddir, 0777);
}
shell_exec('rm -rf ' . $uploaddir . '/*');
$name = sha512(base64_encode(file_get_contents($_FILES['file']['tmp_name']))) . $extension;
$fileName = sha512(base64_encode(file_get_contents($_FILES['file']['tmp_name']))) . $extension;
$filePath = $uploaddir . '/' . $fileName;
$img_size = getimagesize($_FILES['file']['tmp_name']);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . '/' . $name)) {
throw new Exception(__('Impossible de déplacer le fichier temporaire dans : ', __FILE__) . $uploaddir . '/' . $name);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $filePath)) {
throw new Exception(__('Impossible de déplacer le fichier temporaire dans : ', __FILE__) . $uploaddir . '/' . $fileName);
}
$plan->setDisplay('width', $img_size[0]);
$plan->setDisplay('height', $img_size[1]);
$plan->setDisplay('path', 'data/plan/plan_' . $plan->getId() . '/' . $name);
$plan->setDisplay('path', 'data/plan/plan_' . $plan->getId() . '/' . $fileName);
$plan->save();
ajax::success();
ajax::success(array('filepath' => $filePath));
}

throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
Expand Down
2 changes: 1 addition & 1 deletion core/class/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static function byKey($_key, $_plugin = 'core', $_default = '', $_forceFr
WHERE `key`=:key
AND plugin=:plugin';
$value = DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW);
if (($value['value'] === '' || $value['value'] === null)) {
if (!is_array($value) || !isset($value['value']) || $value['value'] === '' || $value['value'] === null) {
$defaultConfiguration = self::getDefaultConfiguration($_plugin);
if (isset($defaultConfiguration[$_plugin][$_key])) {
self::$cache[$_plugin . '::' . $_key] = $defaultConfiguration[$_plugin][$_key];
Expand Down
8 changes: 8 additions & 0 deletions core/class/plan.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ public function save() {
}

public function remove() {
$link_type = $this->getLink_type();
if ($this->getLink_type() == 'image') {
$imgPath = $this->getDisplay('path', '');
if ($imgPath != '') {
@unlink(str_replace('data/plan/', __DIR__ . '/../../data/plan/', $imgPath));
@rmdir(__DIR__ . '/../../data/plan/plan_'.$this->getId());
}
}
DB::remove($this);
}

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.17
4.1.18
16 changes: 13 additions & 3 deletions desktop/common/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,14 @@ function setJeedomGlobalUI() {
$('#md_modal').dialog({title: "{{Erreur Javascript}}"}).load('index.php?v=d&modal=js.error').dialog('open')
})

$('body').on('click', '.objectSummaryParent',function() {
$('body').on('click', '.objectSummaryParent', function() {
if ($('body').attr('data-page') == "overview" && $(this).parents('.objectSummaryglobal').length == 0) return false
loadPage('index.php?v=d&p=dashboard&summary='+$(this).data('summary')+'&object_id='+$(this).data('object_id'))

var url = 'index.php?v=d&p=dashboard&summary=' + $(this).data('summary') + '&object_id=' + $(this).data('object_id')
if (window.location.href.includes('&btover=1')) {
url += '&btover=1'
}
loadPage(url)
})

$('body').off('click','.jeeHelper[data-helper=cron]').on('click','.jeeHelper[data-helper=cron]',function() {
Expand Down Expand Up @@ -848,7 +853,12 @@ function datePickerInit() {

//General functions__
function normTextLower(_text) {
return _text.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toLowerCase()
try {
var result = _text.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toLowerCase()
} catch(error) {
var result = ''
}
return result
}

function linkify(inputText) {
Expand Down
12 changes: 10 additions & 2 deletions desktop/css/desktop.main.css
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,10 @@ Theme Core 2021 @Jeedom
}

/* ____________________OVERVIEW */
#objectOverviewContainer .objectPreview,
#dashOverviewPrev .objectPreview {
background-position: center !important;
}
#objectOverviewContainer {
text-align: center !important;
margin:15px;
Expand Down Expand Up @@ -975,7 +979,6 @@ Theme Core 2021 @Jeedom
.objectPreview .objectSummaryParent,
.objectPreview .objectSummaryParent i {
font-size: 16px !important;
color: var(--link-color) !important;
}
.objectPreview .topPreview .objectSummaryParent {
position: absolute;
Expand Down Expand Up @@ -1085,6 +1088,10 @@ Theme Core 2021 @Jeedom
[data-page="dashboard"] #dashOverviewPrev.dashboard .li_object span {
cursor: pointer !important;
}
[data-page="dashboard"] #dashOverviewPrev.dashboard .li_object > span {
margin-left: 30px;
}

[data-page="dashboard"] #dashOverviewPrev .objectSummaryglobal {
padding-left: 25px;
}
Expand Down Expand Up @@ -2035,7 +2042,7 @@ Theme Core 2021 @Jeedom
right: 10px;
padding: 5px;
height: 40px !important;
z-index: 10;
z-index: 15;
background: rgba(var(--panel-bg-color), var(--opacity));
}

Expand Down Expand Up @@ -4144,6 +4151,7 @@ Theme Core 2021 @Jeedom
}
#pre_globallog,
#pre_scenariolog,
#pre_eventlog,
#pre_commandResult,
#div_commandResult {
font-family: "CamingoCode", monospace;
Expand Down
11 changes: 9 additions & 2 deletions desktop/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,15 @@ $('#bt_createFile').off('click').on('click', function() {
if (editorType == 'widget') {
$('#md_widgetCreate').dialog({title: "{{Options}}"}).dialog('open')
$('#sel_widgetType').trigger('change')

$("#md_widgetCreate").keydown(function (event) {
if (event.keyCode == $.ui.keyCode.ENTER) {
$('#bt_widgetCreate').trigger('click')
return false
}
})
} else {
bootbox.prompt("Nom du fichier ?", function(result) {
bootbox.prompt("{{Nom du fichier ?}}", function(result) {
if (result !== null) {
jeedom.createFile({
path : CURRENT_FOLDER,
Expand All @@ -254,4 +261,4 @@ $('#bt_createFile').off('click').on('click', function() {
}
})
}
})
})
28 changes: 25 additions & 3 deletions desktop/js/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,35 @@ $(".li_history .remove").on('click', function() {
})
})

//search filter opening:
$('body').on({
'keyup': function(event) {
if ($(this).value() == '') {
$('.cmdList').hide()
$('.displayObject').find('i.fas').removeClass('fa-arrow-circle-down').addClass('fa-arrow-circle-right')
} else {
$('.cmdList').show()
//let filtering job gone:
setTimeout(function() {
$('.cmdList').each(function() {
if ($(this).find('.li_history:visible').length > 0) {
$('.displayObject[data-object_id=' + $(this).attr('data-object_id') + ']').find('i.fas').removeClass('fa-arrow-circle-right').addClass('fa-arrow-circle-down')
} else {
$('.displayObject[data-object_id=' + $(this).attr('data-object_id') + ']').find('i.fas').removeClass('fa-arrow-circle-down').addClass('fa-arrow-circle-right')
}
})
}, 250)
}
}
}, 'ul li input.filter')

$('.displayObject').on('click', function() {
var list = $('.cmdList[data-object_id=' + $(this).attr('data-object_id') + ']')
if (list.is(':visible')) {
$(this).find('i.fa').removeClass('fa-arrow-circle-down').addClass('fa-arrow-circle-right')
$(this).find('i.fas').removeClass('fa-arrow-circle-down').addClass('fa-arrow-circle-right')
list.hide()
} else {
$(this).find('i.fa').removeClass('fa-arrow-circle-right').addClass('fa-arrow-circle-down')
$(this).find('i.fas').removeClass('fa-arrow-circle-right').addClass('fa-arrow-circle-down')
list.show()
}
})
Expand Down Expand Up @@ -364,4 +386,4 @@ function setChartExtremes() {
chart.yAxis[0].setExtremes(min, max, true, true)
}
catch(error) {}
}
}
21 changes: 4 additions & 17 deletions desktop/js/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,22 +621,6 @@ $('.div_displayObject').off('resize', '.graph-widget').on('resize', '.graph-widg
}
})

$pageContainer.off('click','.eqLogic-widget .history').on('click','.eqLogic-widget .history', function(event) {
if (planEditOption.state == true) return false
event.stopImmediatePropagation()
event.stopPropagation()
if (event.ctrlKey || event.metaKey) {
var cmdIds = []
$(this).closest('.eqLogic.eqLogic-widget').find('.history[data-cmd_id]').each(function () {
cmdIds.push($(this).data('cmd_id'))
})
cmdIds = cmdIds.join('-')
} else {
var cmdIds = $(this).closest('.history[data-cmd_id]').data('cmd_id')
}
$('#md_modal2').dialog({title: "{{Historique}}"}).load('index.php?v=d&modal=cmd.history&id=' + cmdIds).dialog('open')
})

/***********************************************************************************/
function createNewDesign() {
bootbox.prompt("{{Nom du design ?}}", function(result) {
Expand Down Expand Up @@ -1274,8 +1258,11 @@ function displayObject(_plan, _html, _noRender) {
initEditOption(planEditOption.state)
}

//back to mobile home with three fingers on mobile:
$(function() {
jeedomUI.setEqSignals()
jeedomUI.setHistoryModalHandler()

//back to mobile home with three fingers on mobile:
if ($('body').attr('data-device') == 'mobile') {
$('body').on('touchstart', function(event) {
if (event.touches.length == 3) {
Expand Down
12 changes: 9 additions & 3 deletions desktop/js/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,9 @@ $divScenario.on('click', '.bt_collapse', function(event) {
} else {
//comment
txt = _el.find('.expression textarea').val()
if (typeof txt === 'object') {
txt = JSON.stringify(expression.expression)
}
txt = '<b>' + txt.split('\n')[0] + '</b>' + txt.replace(txt.split('\n')[0], '')
if (!txt) txt = _el.find('.expression input.form-control').val()
}
Expand Down Expand Up @@ -1845,19 +1848,22 @@ function addSubElement(_subElement) {
retour += '<div>'
retour += '<i class="bt_sortable fas fa-arrows-alt-v pull-left cursor"></i>'
if (!isset(_subElement.options) || !isset(_subElement.options.collapse) || _subElement.options.collapse == 0) {
retour += '<a class="bt_collapse cursor subElementAttr" tooltip="{{Masquer ce bloc.<br>Ctrl+click: tou).}}" data-l1key="options" data-l2key="collapse" value="0"><i class="far fa-eye"></i></a>'
retour += '<a class="bt_collapse cursor subElementAttr" tooltip="{{Masquer ce bloc.<br>Ctrl+click: tous.}}" data-l1key="options" data-l2key="collapse" value="0"><i class="far fa-eye"></i></a>'
} else {
retour += '<a class="bt_collapse cursor subElementAttr" tooltip="{{Afficher ce bloc.<br>Ctrl+click: tou).}}" data-l1key="options" data-l2key="collapse" value="1"><i class="far fa-eye-slash"></i></a>'
retour += '<a class="bt_collapse cursor subElementAttr" tooltip="{{Afficher ce bloc.<br>Ctrl+click: tous.}}" data-l1key="options" data-l2key="collapse" value="1"><i class="far fa-eye-slash"></i></a>'
}
retour += '</div>'
retour += '<div>'
retour += '<legend >{{COMMENTAIRE}}</legend>'
var expression = {type: 'comment'}
if (isset(_subElement.expressions) && isset(_subElement.expressions[0])) {
expression = _subElement.expressions[0]
if (typeof expression.expression === 'object') {
expression.expression = JSON.stringify(expression.expression, null, 2)
}
var txt = expression.expression.substring(0,200)
txt = '<b>' + txt.split('\n')[0] + '</b>' + txt.replace(txt.split('\n')[0], '')
retour += '<div class="blocPreview">'+txt+'</div>'
retour += '<div class="blocPreview">' + txt + '</div>'
} else {
retour += '<div class="blocPreview"></div>'
}
Expand Down
4 changes: 4 additions & 0 deletions desktop/js/view_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ function addGraphService(_viewData) {
tr += '<td>'
tr += '<select class="viewDataAttr form-control input-sm" data-l1key="configuration" data-l2key="groupingType">'
tr += '<option value="">{{Aucun groupement}}</option>'
tr += '<option value="sum::hour">{{Somme par heure}}</option>'
tr += '<option value="average::hour">{{Moyenne par heure}}</option>'
tr += '<option value="low::hour">{{Minimum par heure}}</option>'
tr += '<option value="high::hour">{{Maximum par heure}}</option>'
tr += '<option value="sum::day">{{Somme par jour}}</option>'
tr += '<option value="average::day">{{Moyenne par jour}}</option>'
tr += '<option value="low::day">{{Minimum par jour}}</option>'
Expand Down
20 changes: 18 additions & 2 deletions desktop/modal/plan.configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
</div>
</div>
</div>
<div class="form-group link_type link_image">
<div class="col-lg-4"></div>
<div class="col-lg-4 planImg">
<img src="" width="240px" height="auto" />
</div>
</div>
<div class="form-group link_type link_image display_mode display_mode_camera" style="display:none;">
<label class="col-lg-4 control-label">{{Autoriser la fenêtre de zoom}}</label>
<div class="col-lg-2">
Expand Down Expand Up @@ -544,10 +550,17 @@ function addActionPlanConfigure(_action, _type) {
url: 'core/ajax/plan.ajax.php?action=uploadImagePlan&id=' + id,
dataType: 'json',
done: function(e, data) {
if (plan.plan.state != 'ok') {
$('#div_alertPlanConfigure').showAlert({message: plan.plan.result, level: 'danger'})
if (data.result.state != 'ok') {
$('#div_alertPlanConfigure').showAlert({message: data.result.result, level: 'danger'})
return
}
if (isset(data.result.result.filepath)) {
var filePath = data.result.result.filepath
filePath = '/data/plan/' + filePath.split('/data/plan/')[1]
$('.planImg img').attr('src',filePath).show()
} else {
$('.planImg img').hide()
}
}
})

Expand Down Expand Up @@ -617,6 +630,9 @@ function addActionPlanConfigure(_action, _type) {
addActionPlanConfigure(plan.plan.configuration.action_other[i],'other')
}
}
if (plan.plan.link_type == 'image') {
$('#fd_planConfigure .planImg img').attr('src', plan.plan.display.path).show()
}
if (plan.plan.link_type == 'text') {
var code = $('.planAttr[data-l1key=display][data-l2key=text]')
if (code.attr('id') == undefined) {
Expand Down
14 changes: 7 additions & 7 deletions desktop/modal/scenario.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
<form class="form-horizontal">
<legend><i class="fas fa-home"></i> {{Général}}</legend>
<div class="form-group">
<label class="col-xs-2 control-label">{{Gérer}}</label>
<div class="col-xs-6">
<a class='btn btn-danger' id='bt_scenarioTemplateRemove'><i class="fas fa-times"></i> {{Supprimer}}</a>
<a class="btn btn-primary" id="bt_scenarioTemplateDownload"><i class="fas fa-cloud-download-alt"></i> {{Télécharger}}</a>
<label class="col-xs-4 control-label">{{Gérer}}</label>
<div class="col-xs-8">
<a class="btn btn-sm btn-danger pull-right" id="bt_scenarioTemplateRemove"><i class="fas fa-times"></i> {{Supprimer}}</a>
<a class="btn btn-sm btn-primary pull-right" id="bt_scenarioTemplateDownload"><i class="fas fa-cloud-download-alt"></i> {{Télécharger}}</a>
</div>
</div>
<div id='div_scenarioTemplateParametreConfiguration' style='display:none;'>
Expand Down Expand Up @@ -161,9 +161,9 @@ function refreshListAfterMarketObjectInstall() {
html += '<div class="col-xs-4">'
html += '<span class="templateScenarioAttr" data-l1key="begin" style="display : none;" >' + i + '</span>'
html += '<div class="input-group">'
html += '<input class="form-control templateScenarioAttr" data-l1key="end" value="'+data[i]+'"/>'
html += '<input class="form-control templateScenarioAttr roundedLeft" data-l1key="end" value="'+data[i]+'"/>'
html += '<span class="input-group-btn">'
html += '<a class="btn btn-default cursor bt_scenarioTemplateSelectCmd"><i class="fas fa-list-alt"></i></a>'
html += '<a class="btn btn-default cursor bt_scenarioTemplateSelectCmd roundedRight"><i class="fas fa-list-alt"></i></a>'
html += '</span>'
html += '</div>'
html += '</div>'
Expand Down Expand Up @@ -207,4 +207,4 @@ function refreshListAfterMarketObjectInstall() {
refreshScenarioTemplateList()
}
})
</script>
</script>
6 changes: 3 additions & 3 deletions desktop/modal/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function searchFor_variable(_searchFor) {
interactResult.push({'humanName':result[i].usedBy.interactDef[sc]['humanName'], 'id':result[i].usedBy.interactDef[sc]['id']})
}
for (var sc in result[i].usedBy.eqLogic) {
eqlogicResult.push({'humanName':result[i].usedBy.eqLogic[sc]['humanName'], 'id':result[i].usedBy.eqLogic[sc]['id']})
eqlogicResult.push({'humanName':result[i].usedBy.eqLogic[sc]['humanName'], 'id':result[i].usedBy.eqLogic[sc]['link']})
}
for (var sc in result[i].usedBy.cmd) {
cmdResult.push({'humanName':result[i].usedBy.cmd[sc]['humanName'], 'id':result[i].usedBy.cmd[sc]['id']})
Expand Down Expand Up @@ -669,7 +669,7 @@ function showNotesResult(_Notes, _empty=true) {
var url = 'index.php?v=d&p=scenario&id=' + tr.attr('data-id')
if (searchType != 'plugin') {
var searchFor = $('#in_searchFor_'+searchType).val()
url += '&search=' + searchFor.replace('#', '')
url += '&search=' + encodeURI(searchFor.replace('#', ''))
}
window.open(url).focus()
}
Expand Down Expand Up @@ -735,4 +735,4 @@ function showNotesResult(_Notes, _empty=true) {
}
})
})
</script>
</script>
4 changes: 2 additions & 2 deletions desktop/php/administration.php
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-lg-4 col-md-5 col-sm-6 col-xs-6 control-label">{{Delai d'attente après génération de la page}}
<label class="col-lg-4 col-md-5 col-sm-6 col-xs-6 control-label">{{Délai d'attente après génération de la page}}
<sub>ms</sub>
</label>
<div class="col-lg-2 col-md-2 col-sm-4 col-xs-6">
Expand Down Expand Up @@ -1907,7 +1907,7 @@
$div .= '<option value="disable">{{Désactivé}}</option>';
$div .= '</select>';
$div .= '</div>';
$div .= '<label class="col-lg-2 col-md-2 col-sm-3 col-xs-12 control-label">{{Ne pas autoriser les methodes générales}}</label>';
$div .= '<label class="col-lg-2 col-md-2 col-sm-3 col-xs-12 control-label">{{Ne pas autoriser les méthodes générales}}</label>';
$div .= '<div class="col-lg-2 col-md-2 col-sm-3 col-xs-12">';
$div .= '<input type="checkbox" class="form-control configKey" data-l1key="api::' . $plugin->getId() . '::restricted" />';
$div .= '</select>';
Expand Down
Loading

0 comments on commit 111076e

Please sign in to comment.