From bb2dec6b23980dced60cb669ee569db4e5275105 Mon Sep 17 00:00:00 2001 From: pjap93 Date: Wed, 28 Feb 2018 11:00:35 +0100 Subject: [PATCH 01/52] Ajout de fonctions time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout fonctions pour les conditions des scénarios. --- api/core/time/index.js | 11 +++++++--- api/core/time/time.command.js | 36 +++++++++++++++---------------- api/core/time/time.get.js | 12 +++++------ api/core/time/time.getTime.js | 21 ++++++++++++++++++ api/core/time/time.isItAM.js | 8 +++++++ api/core/time/time.isItEvening.js | 8 +++++++ api/core/time/time.isItNight.js | 8 +++++++ api/core/time/time.isItPM.js | 8 +++++++ 8 files changed, 85 insertions(+), 27 deletions(-) create mode 100644 api/core/time/time.getTime.js create mode 100644 api/core/time/time.isItAM.js create mode 100644 api/core/time/time.isItEvening.js create mode 100644 api/core/time/time.isItNight.js create mode 100644 api/core/time/time.isItPM.js diff --git a/api/core/time/index.js b/api/core/time/index.js index 8a67163ab1..0d380a5546 100644 --- a/api/core/time/index.js +++ b/api/core/time/index.js @@ -1,3 +1,8 @@ - -module.exports.get = require('./time.get.js'); -module.exports.command = require('./time.command.js'); \ No newline at end of file + +module.exports.get = require('./time.get.js'); +module.exports.command = require('./time.command.js'); +module.exports.getTime = require('./time.getTime.js'); +module.exports.isItAM = require('./time.isItAM.js'); +module.exports.isItPM = require('./time.isItPM.js'); +module.exports.isItNight = require('./time.isItNight.js'); +module.exports.isItEvening = require('./time.isItEvening.js'); \ No newline at end of file diff --git a/api/core/time/time.command.js b/api/core/time/time.command.js index 56e22b25a9..58e33c181e 100644 --- a/api/core/time/time.command.js +++ b/api/core/time/time.command.js @@ -1,19 +1,19 @@ -const moment = require('moment'); - -module.exports = function command(scope) { - var result; - var now = moment().locale(scope.language); - - switch(scope.label) { - case 'get-time': - result = { - label: 'say-time', - scope: { - '%TIME%': now.format('LT') - } - }; - break; - } - - return Promise.resolve(result); +const moment = require('moment'); + +module.exports = function command(scope) { + var result; + var now = moment().locale(scope.language); + + switch(scope.label) { + case 'get-time': + result = { + label: 'say-time', + scope: { + '%TIME%': now.format('LT') + } + }; + break; + } + + return Promise.resolve(result); }; \ No newline at end of file diff --git a/api/core/time/time.get.js b/api/core/time/time.get.js index d20cf6ba35..aa5250bae7 100644 --- a/api/core/time/time.get.js +++ b/api/core/time/time.get.js @@ -1,7 +1,7 @@ -const moment = require('moment'); -const Promise = require('bluebird'); - -module.exports = function get(options){ - var now = moment(); - return Promise.resolve(now); +const moment = require('moment'); +const Promise = require('bluebird'); + +module.exports = function get(options){ + var now = moment(); + return Promise.resolve(now); }; \ No newline at end of file diff --git a/api/core/time/time.getTime.js b/api/core/time/time.getTime.js new file mode 100644 index 0000000000..a50c92d2d8 --- /dev/null +++ b/api/core/time/time.getTime.js @@ -0,0 +1,21 @@ +const moment = require('moment'); +const Promise = require('bluebird'); +var SunCalc = require('suncalc'); + +module.exports = function getTime(options){ + // foreach house + return gladys.house.getById({id: options.house}) + .then(function(house){ + var now = new Date(); + var midi = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 12, 0, 0, 0); + var times = SunCalc.getTimes(new Date(), house.latitude , house.longitude); + + if (now < times.sunrise) + return {state: 'night'}; + if (now < midi) + return {state: 'morning'}; + if (now < times.sunset) + return {state: 'afternoon'}; + return {state: 'evening'}; + }); +}; \ No newline at end of file diff --git a/api/core/time/time.isItAM.js b/api/core/time/time.isItAM.js new file mode 100644 index 0000000000..13350ad43f --- /dev/null +++ b/api/core/time/time.isItAM.js @@ -0,0 +1,8 @@ +module.exports = isItAM; +function isItAM(options){ + return gladys.time.getTime(options) + .then(function(result){ + if(result.state === 'morning') return true; + return false; + }); +} \ No newline at end of file diff --git a/api/core/time/time.isItEvening.js b/api/core/time/time.isItEvening.js new file mode 100644 index 0000000000..6ef3e0fec6 --- /dev/null +++ b/api/core/time/time.isItEvening.js @@ -0,0 +1,8 @@ +module.exports = isItEvening; +function isItEvening(options){ + return gladys.time.getTime(options) + .then(function(result){ + if(result.state === 'evening') return true; + return false; + }); +} \ No newline at end of file diff --git a/api/core/time/time.isItNight.js b/api/core/time/time.isItNight.js new file mode 100644 index 0000000000..61a71c5ac6 --- /dev/null +++ b/api/core/time/time.isItNight.js @@ -0,0 +1,8 @@ +module.exports = isItNight; +function isItNight(options){ + return gladys.time.getTime(options) + .then(function(result){ + if(result.state === 'night') return true; + return false; + }); +} \ No newline at end of file diff --git a/api/core/time/time.isItPM.js b/api/core/time/time.isItPM.js new file mode 100644 index 0000000000..a3e0ec2bfb --- /dev/null +++ b/api/core/time/time.isItPM.js @@ -0,0 +1,8 @@ +module.exports = isItPM; +function isItPM(options){ + return gladys.time.getTime(options) + .then(function(result){ + if(result.state === 'afternoon') return true; + return false; + }); +} \ No newline at end of file From 0e93952a80f3fcfa7ef5d633cad65732097a186c Mon Sep 17 00:00:00 2001 From: pjap93 Date: Thu, 1 Mar 2018 08:26:54 +0100 Subject: [PATCH 02/52] Update time.isItAM.js --- api/core/time/time.isItAM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/time/time.isItAM.js b/api/core/time/time.isItAM.js index 13350ad43f..818081a9f9 100644 --- a/api/core/time/time.isItAM.js +++ b/api/core/time/time.isItAM.js @@ -5,4 +5,4 @@ function isItAM(options){ if(result.state === 'morning') return true; return false; }); -} \ No newline at end of file +}; From 82a95357c08e47018f9c4a6fc8b6e20aa54739cb Mon Sep 17 00:00:00 2001 From: pjap93 Date: Thu, 1 Mar 2018 08:27:10 +0100 Subject: [PATCH 03/52] Update time.isItEvening.js --- api/core/time/time.isItEvening.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/time/time.isItEvening.js b/api/core/time/time.isItEvening.js index 6ef3e0fec6..027eb0e531 100644 --- a/api/core/time/time.isItEvening.js +++ b/api/core/time/time.isItEvening.js @@ -5,4 +5,4 @@ function isItEvening(options){ if(result.state === 'evening') return true; return false; }); -} \ No newline at end of file +}; From c1ceeaf46c132110001b0c3e7c3ccdc8d7d7bb2b Mon Sep 17 00:00:00 2001 From: pjap93 Date: Thu, 1 Mar 2018 08:27:23 +0100 Subject: [PATCH 04/52] Update time.isItNight.js --- api/core/time/time.isItNight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/time/time.isItNight.js b/api/core/time/time.isItNight.js index 61a71c5ac6..707db30a9c 100644 --- a/api/core/time/time.isItNight.js +++ b/api/core/time/time.isItNight.js @@ -5,4 +5,4 @@ function isItNight(options){ if(result.state === 'night') return true; return false; }); -} \ No newline at end of file +}; From 83f98f02ecc184228164397911d78f9832b020d1 Mon Sep 17 00:00:00 2001 From: pjap93 Date: Thu, 1 Mar 2018 08:27:38 +0100 Subject: [PATCH 05/52] Update time.isItPM.js --- api/core/time/time.isItPM.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/time/time.isItPM.js b/api/core/time/time.isItPM.js index a3e0ec2bfb..ca82ddb136 100644 --- a/api/core/time/time.isItPM.js +++ b/api/core/time/time.isItPM.js @@ -5,4 +5,4 @@ function isItPM(options){ if(result.state === 'afternoon') return true; return false; }); -} \ No newline at end of file +}; From e5279978b7bfa29be0df0e322172de9922adb556 Mon Sep 17 00:00:00 2001 From: LeptitGeek Date: Sun, 4 Mar 2018 14:09:24 +0100 Subject: [PATCH 06/52] Fix bug launcher view Get launcher after create or edit a launcher in editor to update view --- assets/js/app/scenario/scenario.controller.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/js/app/scenario/scenario.controller.js b/assets/js/app/scenario/scenario.controller.js index cc2f4487c0..c7b25796f2 100644 --- a/assets/js/app/scenario/scenario.controller.js +++ b/assets/js/app/scenario/scenario.controller.js @@ -279,6 +279,9 @@ vm.launchers[vm.currentScenario.index] = data.data.trigger; $('#modalUpdateScenario').modal('hide'); }) + .then(function(){ + finishScenario(); + }) .catch(function () { notificationService.errorNotificationTranslated('SCENARIO.UPDATE_ERROR') }); @@ -291,6 +294,9 @@ vm.launchers.push(data.data.trigger); $('#modalUpdateScenario').modal('hide'); }) + .then(function(){ + finishScenario(); + }) .catch(function () { notificationService.errorNotificationTranslated('SCENARIO.CREATE_ERROR') }); @@ -343,4 +349,4 @@ } } -})(); \ No newline at end of file +})(); From c43cf208a4658d215662ad22dad9ff94a9dfa846 Mon Sep 17 00:00:00 2001 From: LeptitGeek Date: Mon, 5 Mar 2018 13:24:42 +0100 Subject: [PATCH 07/52] Fix the height of ul menu Cut the contents of the ul menu when there is too much devices --- views/boxs/chart.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/boxs/chart.ejs b/views/boxs/chart.ejs index 3d7c318d48..e8416825fc 100644 --- a/views/boxs/chart.ejs +++ b/views/boxs/chart.ejs @@ -13,7 +13,7 @@ -