Skip to content

Commit

Permalink
Merge pull request #41 from rdmtc/dev
Browse files Browse the repository at this point in the history
0.4.4-beta release
  • Loading branch information
Hypnos3 authored Jun 28, 2019
2 parents 84f27b3 + 296c442 commit 9c7366c
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 386 deletions.
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#### 0.4.3: Maintenance Release

- fixed critical problem in calculating Julian cycle which leads into wrong sun times if it is calculated at certain times [#37](https://github.com/rdmtc/node-red-contrib-sun-position/issues/37)

#### 0.4.1 / 0.4.2: Maintenance Release
#### 0.4.4-beta: Maintenance Release

- fixed critical problem in sun - calculating Julian cycle which leads into wrong sun times if it is calculated at certain times
- [#37](https://github.com/rdmtc/node-red-contrib-sun-position/issues/37)
- [#39](https://github.com/rdmtc/node-red-contrib-sun-position/issues/39)
- fixed problems on RedMatic call of getBackendData
- tooltip with resolved time on typeInput now also available in RedMatic
- i18N reworked
Expand All @@ -16,9 +15,11 @@
- add clear button for rules
- add sort button in UI editor
- reworked minimum/maximum blind position settings by rule, enhanced in documentation
- addresses [#36](https://github.com/rdmtc/node-red-contrib-sun-position/issues/36)
- enhanced documentation
- fix [#31](https://github.com/rdmtc/node-red-contrib-sun-position/issues/31)
- fix [#33](https://github.com/rdmtc/node-red-contrib-sun-position/issues/33)
- added possibility for inverted open / close settings [#40](https://github.com/rdmtc/node-red-contrib-sun-position/issues/40)
- changed lot of internal
- cleanup procedures
- fixed problems with test function [#32](https://github.com/rdmtc/node-red-contrib-sun-position/issues/32)
Expand All @@ -28,6 +29,14 @@
- optimized access to backend services
- changed lot of UTC time compare problems [#34](https://github.com/rdmtc/node-red-contrib-sun-position/issues/34)

#### 0.4.3: Maintenance Release

- Version was unpublished due to critical Bugs

#### 0.4.1 / 0.4.2: Maintenance Release

- Version was unpublished due to critical Bugs

#### 0.4.0: Maintenance Release

- i18N for type-input options
Expand Down
46 changes: 30 additions & 16 deletions blind_control.md

Large diffs are not rendered by default.

138 changes: 70 additions & 68 deletions nodes/blind-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
function countDecimals(value) {
return value === value>> 0 ? 0 : value.toString().split('.')[1].length || 0;
}

/**
* get the min and maximum blind positions
* @param {*} node - the node representation
* @returns {object} object with property __min__ and __max__
*/
function getMinMaxBlindPos(node) {
let max = getVal(node, 'blindOpenPos');
let min = getVal(node, 'blindClosedPos');
if (max < min) {
[min, max] = [max, min];
}
return { min, max };
}

/**
* validates a blind position
* @param {*} node - the node representation
Expand All @@ -31,10 +46,12 @@
function validateBlindPos(node, v) {
const n = parseFloat(v);
const inc = getVal(node, 'blindIncrement');
const mm = getMinMaxBlindPos(node);

return RED.validators.number(v) &&
(v !== '') &&
(n <= getVal(node, 'blindOpenPos')) &&
(n >= getVal(node, 'blindClosedPos')) &&
(n <= mm.max) &&
(n >= mm.min) &&
Number.isInteger(Number((n / inc).toFixed(countDecimals(inc) + 2)));
}
/**
Expand Down Expand Up @@ -100,8 +117,12 @@
const $timeOperator = rule.find('.node-input-rule-time-operator');
const $time = rule.find('.node-input-rule-time');
$timeLbl.width('auto');
$timeOperator.width(70);
$time.typedInput('width', (newWidth - $timeLbl.width() - 103));
if ($timeOperator.is(':visible')) {
$timeOperator.width(70);
$time.typedInput('width', (newWidth - $timeLbl.width() - 103));
} else {
$time.typedInput('width', (newWidth - $timeLbl.width() - 33));
}
// row4
const $offset = rule.find('.node-input-rule-offset');
const $multiplier = rule.find('.node-input-rule-multiplier');
Expand All @@ -113,7 +134,6 @@
const $level = rule.find('.node-input-rule-level');
const $levelOperator = rule.find('.node-input-rule-level-operator');
$levelLbl.width('auto');
$levelOperator.show();
$levelOperator.width(40);
$level.typedInput('width', (newWidth - $levelLbl.width() - 60 - 10));
} catch (ex) {
Expand Down Expand Up @@ -148,9 +168,11 @@
required: true,
validate(v) {
const n = parseFloat(v);
const mm = getMinMaxBlindPos(this);

return (RED.validators.number(v) &&
(n <= getVal(this, 'blindOpenPos')) &&
(n >= getVal(this, 'blindClosedPos')) );
(n <= mm.max) &&
(n >= mm.min) );
}
},
blindOpenPos: {
Expand All @@ -160,7 +182,7 @@
const n = parseFloat(v);
return RED.validators.number(v) &&
(Number.isInteger(n / getVal(this, 'blindIncrement'))) &&
(n > getVal(this, 'blindClosedPos'));
(n !== getVal(this, 'blindClosedPos'));
}
},
blindClosedPos: {
Expand All @@ -170,7 +192,7 @@
const n = parseFloat(v);
return RED.validators.number(v) &&
(Number.isInteger(n / getVal(this, 'blindIncrement'))) &&
(n < getVal(this, 'blindOpenPos'));
(n !== getVal(this, 'blindOpenPos'));
}
},
blindPosReverse: {
Expand Down Expand Up @@ -232,10 +254,11 @@
required: false,
validate(v) {
const n = parseFloat(v);
const mm = getMinMaxBlindPos(this);
return ((Number(getVal(this, 'sunControlMode')) <= 1) ||
(v === '') ||
(n <= getVal(this, 'blindOpenPos')) &&
(n >= getVal(this, 'blindClosedPos')) &&
(n <= mm.max) &&
(n >= mm.min) &&
(n >= getVal(this, 'blindIncrement')) );
}
},
Expand Down Expand Up @@ -463,58 +486,16 @@
/**
* save dialog data back to rule
*/
/*
function _dialogSaveData() {
console.log('dialogSaveData'); // eslint-disable-line
if (!$dialogConnFields) { return; }
/*
$dialogConnFields.find('.node-input-item-id').val($dialogId.val());
$dialogConnFields.find('.node-input-item-name').val($dialogName.val());
$dialogConnFields.find('.node-input-item-nameAlt').val($dialogNameAlt.val());
$dialogConnFields.find('.node-input-item-character').val($dialogCharacter.val());
switch ($dialogDateType.val()) {
case 'easter':
$dialogConnFields.find('.node-input-item-month').val('-1');
$dialogConnFields.find('.node-input-item-day').val($dialogDaysRel.val());
break;
case 'advent':
$dialogConnFields.find('.node-input-item-month').val('-2');
$dialogConnFields.find('.node-input-item-day').val($dialogDaysRel.val());
break;
case 'weekdayfirst': {
$dialogConnFields.find('.node-input-item-month').val(String(parseInt($dialogMonth.val()) + 12));
const nth = (parseInt($dialogNthdow.val()) - 1);
$dialogConnFields.find('.node-input-item-nth').val(String(nth));
$dialogConnFields.find('.node-input-item-dow').val($dialogDayofweek.val());
const val = (nth * 7 + parseInt($dialogDayofweek.val()));
$dialogDaysRel.val(String(val));
$dialogConnFields.find('.node-input-item-day').val(String(val));
break;
}
case 'weekdaylast': {
$dialogConnFields.find('.node-input-item-month').val(String(parseInt($dialogMonth.val()) + 24));
const nth = (parseInt($dialogNthdow.val()) - 1);
$dialogConnFields.find('.node-input-item-nth').val(String(nth));
$dialogConnFields.find('.node-input-item-dow').val($dialogDayofweek.val());
const val = (nth * 7 + parseInt($dialogDayofweek.val()));
$dialogDaysRel.val(String(val));
$dialogConnFields.find('.node-input-item-day').val(String(val));
break;
}
default: {
const date = $dialogDate.datepicker('getDate');
if (date !== null) {
$dialogConnFields.find('.node-input-item-month').val(String(date.getUTCMonth() + 1));
$dialogConnFields.find('.node-input-item-day').val(date.getUTCDate());
}
}
} */
$dialog.dialog('close');
// ...
$dialogRule.dialog('close');
}
const $dialogConnFields = {};
const $dialog = $('#dialog-edit-rule').dialog({
const $dialogRule = $('#dialog-edit-rule').dialog({
title: node._('blind-control.label.dialogtitle'),
autoOpen: false,
resizable: true,
Expand All @@ -525,10 +506,18 @@
buttons: {
Ok: _dialogSaveData,
Cancel: () => {
$dialog.dialog('close');
$dialogRule.dialog('close');
}
}
});
const $dialogCtx = $('#dialog-select-context').dialog({
autoOpen: false,
height: 400,
width: 600,
modal: true
});
/* */
// #endregion Dialog

const setup = function(node) {
Expand Down Expand Up @@ -710,6 +699,13 @@
$validOperator.val(data.validOperator || selFields.comparator[0].id);
const finalspan = $('<span/>',{style:'float: right;margin-top: 6px;'}).appendTo($row1);
finalspan.append('<span class="node-input-rule-index">'+(containerIndex+1)+'</span> ');

/*
const $btn = $('<a />', {
class: 'node-button-item-edit btn ui-button ui-widget ui-corner-all'
}).append('<i class= "fa fa-pencil-square-o" >').appendTo(row);
*/

// #endregion row1
// #region row2 - property threshold -- lbl - [none / Bedingung]
addLabel($row2, 'node-input-rule-condOpB', 'fa fa-ellipsis-h', node._('blind-control.label.ruleConditionThreshold'));
Expand Down Expand Up @@ -780,16 +776,19 @@
$levelOperator.append($('<option></option>').val(0).text(node._('blind-control.label.ruleLevelAbs')));
$levelOperator.append($('<option></option>').val(1).text(node._('blind-control.label.ruleLevelMin')));
$levelOperator.append($('<option></option>').val(2).text(node._('blind-control.label.ruleLevelMax')));
$levelOperator.append($('<option></option>').val(3).text(node._('blind-control.label.ruleLevelMinAdd')));
$levelOperator.append($('<option></option>').val(4).text(node._('blind-control.label.ruleLevelMaxAdd')));
$levelOperator.val(data.levelOp || 0);
// #endregion row5
// #region fields changes
$time.change(() => {
const opType = $time.typedInput('type');
if (opType === types.TimeSun.value || opType === types.TimeMoon.value) {
if (opType === types.Undefined.value) {
$timeOperator.hide();
$row4.hide(); // offset
} else if (opType === types.TimeSun.value || opType === types.TimeMoon.value) {
$timeOperator.show();
$row4.show(); // offset
} else {
$timeOperator.show();
$row4.hide(); // offset
}
getBackendData(d => {
Expand Down Expand Up @@ -903,37 +902,34 @@
prerules.each(function(i) {
const data = $(this).data('data');
data.index = i;
data.timeOp = (Number(data.timeOp) || 0);
data.levelOp = (Number(data.levelOp) || 0);
data.conditional = ((data.validOperandAType !== 'none') ? 1 : 0);
data.timeLimited = ((data.timeType !== 'none') ? 1 : 0);
data.timeData = (parseFloat($(this).find('.node-input-rule-time').attr('timedata')) || 0);
data.timeOp = (data.timeLimited) ? (Number(data.timeOp) || 0) : -1;
});
/**
* 1 no time
* 2 time - until
* 3 time - from
*/
$('#node-input-rule-container').editableList('sort', (a, b) => {
const res = (a.timeLimited - b.timeLimited);
if (res !== 0) { // one is not time limited
return res; // not timeLimited before timeLimited (1-3)
}
const pos = (a.index - b.index);
if (!a.timeLimited && !b.timeLimited) { // both not time limited
return pos;
}
// both are time limited
const top = (a.timeOp - b.timeOp);
if (top !== 0) {
return top; // from before until
return top; // from before until; not timeLimited before timeLimited (1-3)
}
// both same from/until type
/*
if ((a.levelOp > 2) && (b.levelOp <= 2)) { // time is different
return 1; // a after b
} else if ((b.levelOp > 2) && (a.levelOp <= 2)) {
return -1; // a before b
}
} */

const time = a.timeData - b.timeData;
if ((a.timeData !== 0) && (b.timeData !== 0) && (time !== 0)) { // time is different
Expand Down Expand Up @@ -1532,6 +1528,7 @@
</div>

<!-- DIALOG ######################################################################## -->
<!--
<div id="dialog-edit-rule" class="red-ui-editor">
<div class="form-row">
<label for="dialog-input-id">includes</label>
Expand Down Expand Up @@ -1579,6 +1576,11 @@
<label id="dialog-label-date-out"></label>
</div>
</div>

<div id="dialog-select-context" title="Select Channel and Datapoint">
<div id="config-lookup-tree"></div>
</div>
-->
</script>
<style>
hr {
Expand Down
Loading

0 comments on commit 9c7366c

Please sign in to comment.