From d3c9a21034588a3dfa09452c88b0b7e17fda8f43 Mon Sep 17 00:00:00 2001 From: bogdan Date: Wed, 15 May 2024 08:20:11 +0200 Subject: [PATCH] save all astro data records --- cards/AstroTimerCard.vue | 124 ++++++++++++++------------------------- 1 file changed, 44 insertions(+), 80 deletions(-) diff --git a/cards/AstroTimerCard.vue b/cards/AstroTimerCard.vue index 5bd0421..b7acf6e 100644 --- a/cards/AstroTimerCard.vue +++ b/cards/AstroTimerCard.vue @@ -9,44 +9,41 @@
- - -
-
- - -
Task {{ astrorec.num }}
-
- -
Task enabled -
-
Sun rise/set
-
Light sensor
-
-
-
Sensor time: {{ min_to_str(astrorec.sensor_time) }} - -
-
-
-
-
Time: {{ min_to_str(astrorec.main_time) }} -
-
- - -
- - Apply - Delete - -
-
+ +
+
+ + +
Task {{ astrorec.num }}
+
+ +
Task enabled +
+
+ {{ (astrorec.rise) ? 'Sunrise' : 'Sunset' }}
+
Light sensor
+
+
+
Apply time: {{ min_to_str(astrorec.sensor_time) }}
+
+
+
+
Apply time: {{ min_to_str(astrorec.main_time) }}
+
+ + +
+ + Apply + Delete + +
+
+ +
- -
Add new @@ -64,25 +61,19 @@ function min_to_str(min) { return `${Math.floor(min / 60)}h ${min % 60}m` } -let initrecs = function () { - let out = [], rec; +function event_str(v) { + return `${Math.floor(min / 60)}h ${min % 60}m` +} + +function initrecs() { + let out = [], rec, i; for (i = 1; i <= 16; i++) { rec = { - num: i, - del: 1, - enab: 1, - rise: 1, - sensor_enab: 0, - sensor_angle: 0, - sensor_time: 0, - main_angle: 0, - main_time: 0, - name: "", - exec: "", + num: i, del: 1, enab: 1, rise: 1, sensor_enab: 0, sensor_angle: 0, + sensor_time: 0, main_angle: 0, main_time: 0, name: "", exec: "", } out.push(rec); } - console.log(JSON.stringify(out)); return out; }; @@ -91,30 +82,12 @@ const init = { astrorecs: { lat: 0, lon: 0, - records: initrecs + records: initrecs() } } -function ApplyAstroRecord(num) { - PostData({ - astrorecs: { - lat: data.astrorecs.lat, - lon: data.astrorecs.lon, - records: [ - { - num: data.astrorecs.records[num - 1].num, - del: data.astrorecs.records[num - 1].del, - enab: data.astrorecs.records[num - 1].enab, - rise: data.astrorecs.records[num - 1].rise, - sensor_enab: data.astrorecs.records[num - 1].sensor_enab, - sensor_angle: data.astrorecs.records[num - 1].sensor_angle, - main_angle: data.astrorecs.records[num - 1].main_angle, - name: data.astrorecs.records[num - 1].name, - exec: data.astrorecs.records[num - 1].exec - } - ] - } - }, 1, 1, ShowDelayDialog('Data applying...', 250, PostData(data, 2, 0, null))); +function ApplyAstroRecord() { + PostData(data, 1, 1, null); } function DeleteAstroRecord(num) { @@ -133,15 +106,6 @@ function AddAstroRecord() { } } - -const scrollHeight = computed(() => { - let num = 0; - for (let i = 0; i < 16; i++) if (!data.astrorecs.records[i].del) ++num; - return (num <= 2) ? num * 400 : 800; -}); - - - const data = reactive(init); PostData(data, 2, 0, null);