node-red-contrib-sun-position
Advanced tools
Comparing version 0.4.6 to 0.4.7
# node-red-contrib-sun-position | ||
#### 0.4.7: BugFix Release | ||
- fix problems | ||
- if time tooltip has wrong format | ||
- if not initialized | ||
- on exception get backend data | ||
#### 0.4.6: Maintenance Release | ||
@@ -4,0 +11,0 @@ |
@@ -473,3 +473,3 @@ /******************************************** | ||
getTimeProp(_srcNode, msg, data) { | ||
// _srcNode.debug(`getTimeProp data=${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity })} tzOffset=${this.tzOffset}`); | ||
_srcNode.debug(`getTimeProp data=${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity })} tzOffset=${this.tzOffset}`); | ||
let result = { | ||
@@ -537,5 +537,17 @@ value: null, | ||
result.fix = true; | ||
} else if (data.type === 'str') { | ||
result.fix = true; | ||
if (data.format) { | ||
result.value = hlp.parseDateFromFormat(data.value, data.format, RED._('position-config.days'), RED._('position-config.month'), RED._('position-config.dayDiffNames')); | ||
} else { | ||
result.value = hlp.getDateOfText(data.value, (this.tzOffset === 0), this.tzOffset); | ||
} | ||
const offsetX = this.getFloatProp(_srcNode, msg, data.offsetType, data.offset, 0); | ||
result.value = hlp.normalizeDate(result.value, offsetX, data.multiplier, data.next, data.days); | ||
if (this.tzOffset) { | ||
result.value = hlp.convertDateTimeZone(result.value, this.tzOffset); | ||
} | ||
} else { | ||
// can handle context, json, jsonata, env, ... | ||
result.fix = (data.type === 'json'); // is not a fixed time if can be changed | ||
result.fix = false; // is not a fixed time if can be changed | ||
const res = this.getPropValue(_srcNode, msg, data); | ||
@@ -571,3 +583,3 @@ if (res) { | ||
} | ||
// _srcNode.debug(`getTimeProp data=${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity })} tzOffset=${this.tzOffset} result=${ util.inspect(result, { colors: true, compact: 10, breakLength: Infinity }) }`); | ||
_srcNode.debug(`getTimeProp data=${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity })} tzOffset=${this.tzOffset} result=${ util.inspect(result, { colors: true, compact: 10, breakLength: Infinity }) }`); | ||
return result; | ||
@@ -995,2 +1007,3 @@ } | ||
RED.httpAdmin.get('/sun-position/data', RED.auth.needsPermission('sun-position.read'), (req, res) => { | ||
// console.log('RED.httpAdmin.get - result for getTimeData', req.query.config); | ||
if (req.query.config && req.query.config !== '_ADD_') { | ||
@@ -1009,5 +1022,6 @@ const posConfig = RED.nodes.getNode(req.query.config); | ||
obj.value = NaN; | ||
obj.error = err; | ||
obj.error = err.message; | ||
obj.errorStack= err.stack; | ||
} | ||
res.status(200).send(JSON.stringify(obj)); | ||
res.status(200).send(JSON.stringify(obj,Object.getOwnPropertyNames(obj))); | ||
break; | ||
@@ -1020,5 +1034,6 @@ } | ||
obj.value = NaN; | ||
obj.error = err; | ||
obj.error = err.message; | ||
obj.errorStack= err.stack; | ||
} | ||
res.status(200).send(JSON.stringify(obj)); | ||
res.status(200).send(JSON.stringify(obj,Object.getOwnPropertyNames(obj))); | ||
break; | ||
@@ -1028,5 +1043,5 @@ } | ||
} else { | ||
res.status(200).send(JSON.stringify({})); | ||
res.status(200).send(JSON.stringify({value: '', error: 'no valid configuration!!'})); | ||
} | ||
}); | ||
}; |
@@ -583,3 +583,3 @@ /************************************************************************/ | ||
function appendOptions(node, parent, elementName, filter) { // eslint-disable-line no-unused-vars | ||
// console.log('appendOptions elementName='+ elementName + ' limit='+limit); | ||
// console.log('[IN appendOptions] elementName='+ elementName + ' limit='+limit); | ||
const groups = getSelectFields()[elementName + 'Groups']; | ||
@@ -700,3 +700,3 @@ if (!groups) { | ||
function initCombobox(node, $inputSelect, $inputBox, dataListID, optionElementName, value, baseWidth, timeFormat) { // eslint-disable-line no-unused-vars | ||
// console.log('initCombobox node=' + node + ' dataList=' + dataList + ' optionElementName=' + optionElementName + ' value=' + value + ' width=' + width); // eslint-disable-line | ||
// console.log('[IN initCombobox] node=' + node + ' dataList=' + dataList + ' optionElementName=' + optionElementName + ' value=' + value + ' width=' + width); // eslint-disable-line | ||
appendOptions(node, $inputSelect, optionElementName); | ||
@@ -897,23 +897,62 @@ autocomplete($inputBox, dataListID); | ||
function getBackendData(result, data) { // eslint-disable-line no-unused-vars | ||
console.log('getBackendData'); // eslint-disable-line | ||
console.log(data); // eslint-disable-line | ||
// data | ||
if (!data || data.type === 'none' || data.type === '' || data.type === 'json' || data.type === 'jsonata' || data.type === 'bin') { | ||
result({ value: data.type}); | ||
} else if (data.type === 'num' || data.type === 'str' || data.type === 'bool') { | ||
result({ value: data.value }); | ||
// console.log('[IN getBackendData] ',data); // eslint-disable-line | ||
let res = ''; | ||
if (!data || data.type === 'none' || data.type === '' || data.type === 'jsonata' || data.type === 'json' || data.type === 'bin') { | ||
res = data.type; | ||
} else if ( data.type === 'bool') { | ||
res = data.value; | ||
} else if (data.type === 'msg' || data.type === 'flow' || data.type === 'global' || data.type === 'env') { | ||
result({ value: data.type + '.' + data.value }); | ||
res = data.type + '.' + data.value; | ||
} else if (data.type === 'msgPayload') { | ||
result({ value: 'msg.payload' }); | ||
res = 'msg.payload'; | ||
} else if (data.type === 'msgTs') { | ||
result({ value: 'msg.ts' }); | ||
res = 'msg.ts'; | ||
} else if (data.type === 'msgLC') { | ||
result({ value: 'msg.lc' }); | ||
res = 'msg.lc'; | ||
} else if (data.type === 'msgValue') { | ||
result({ value: 'msg.value' }); | ||
res = 'msg.value'; | ||
} else { | ||
const url = 'sun-position/data?' + jQuery.param( data ); | ||
$.getJSON(url, result); | ||
return; | ||
} | ||
if (data.kind === 'getTimeData') { | ||
result({ value: res}); | ||
} | ||
result(res); | ||
} | ||
/** | ||
* checks if a value is a valid Date object | ||
* @param {*} d - a value to check | ||
* @returns {boolean} returns __true__ if it is a valid Date, otherwhise __false__ | ||
*/ | ||
function isValidDate(d) { | ||
return d instanceof Date && !isNaN(d); | ||
// d !== 'Invalid Date' && !isNaN(d) | ||
} | ||
/** | ||
* formate Dtae to local time | ||
* @param {*} d - Date | ||
*/ | ||
function bdDateToTime(d, add) { // eslint-disable-line no-unused-vars | ||
// console.log('[IN bdDateToTime]',d,add); | ||
if (d) { | ||
if (d.error) { | ||
return add + 'Error: ' + d.error; | ||
} | ||
if (d.value) { | ||
d = d.value; | ||
} | ||
const dv = new Date(d); | ||
if (isValidDate(dv)) { | ||
return dv.toLocaleTimeString() + ' (' + dv.toISOString() + ')' + ((add) ? ' ' + add : ''); | ||
} | ||
} | ||
if (typeof d === 'string') { | ||
return d + ((add) ? ' ' + add : ''); | ||
} | ||
return ((add) ? add : ''); | ||
} |
{ | ||
"name": "node-red-contrib-sun-position", | ||
"version": "0.4.6", | ||
"version": "0.4.7", | ||
"description": "NodeRED nodes to get sun and moon position", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
8385
1048447