Skip to content

Commit ddeb93f

Browse files
authored
Merge pull request #66 from Tructruc/mapBat
implementation de l'echelle et du batE a fix
2 parents c713b54 + 8fd4bc7 commit ddeb93f

15 files changed

+2558
-1050
lines changed

frontend/front-vue/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/front-vue/src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ export default {
4141

4242
<style >
4343
#app {
44-
padding-top: 80px; /* Adjust the padding to make space for the header */
44+
padding-top: 50px; /* Adjust the padding to make space for the header */
4545
}
4646
</style>

frontend/front-vue/src/components/BatABibAmphis.vue

+305-152
Large diffs are not rendered by default.

frontend/front-vue/src/components/BatB.vue

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
<template>
3-
<div :class="{ 'small-view': showRdc || showEt1 || showEt2 }">Bat B
3+
<div :class="{ 'small-view': showRdc || showEt1 || showEt2 , 'grid':true}">
4+
<h2>BatB</h2>
45
<!-- SVG avec les chemins spécifiques pour le bâtiment C -->
56
<svg viewBox="0 0 2141.3333 1064">
67
<g id="rdc" class="changeColor" @click="displayBatBRdc">
@@ -178,7 +179,11 @@ g.changeColor:hover {
178179
/* stroke:rgb(255, 193, 183);
179180
fill: rgb(233, 8, 0); */
180181
}
181-
182+
.grid{
183+
display: flex;
184+
gap: 50px;
185+
width: 80vw;
186+
}
182187
.small-view {
183188
float: left;
184189
width: 20%; /* Ajustez la largeur comme nécessaire */

frontend/front-vue/src/components/BatBRdc.vue

+154-47
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<template>
2-
<select :value="selectedOption" @change="updateSelectedOption">
3-
<option value="temperature">Température</option>
4-
<option value="humidity">Humidité</option>
5-
<option value="co2">CO2</option>
6-
<option value="activity">Présence</option>
7-
</select>
8-
<div>
2+
<div class="grid">
3+
<h2>RDC</h2>
4+
<select :value="selectedOption" @change="updateSelectedOption">
5+
<option value="temperature">Température</option>
6+
<option value="humidity">Humidité</option>
7+
<option value="co2">CO2</option>
8+
<option value="activity">Présence</option>
9+
</select>
10+
<dataScale :min="valMin" :max="valMax" :real-min="realMin" :real-max="realMax" :unit="unit"></dataScale>
911
<svg width="100%" height="100%" viewBox="50 250 990 320">
10-
<g v-for="(room, roomId) in roomData" :key="roomId" :id="roomId" :class="{ changeColor: true } "
12+
<g v-for="(room, roomId) in roomData" :key="roomId" :id="roomId" :class="{ changeColor: true }"
1113
:style="{ fill: room.color }" @click="showRoomDetail(roomId)">
1214
<title>{{ roomId }}</title>
1315
<path v-for="(path, index) in room.path" :key="index" :id="'path' + roomId + '_' + index" :d="path" />
@@ -21,14 +23,23 @@
2123
<script>
2224
import { ref, reactive, onMounted, watch } from 'vue';
2325
import RoomDetail from './roomDetail.vue';
26+
import dataScale from './dataScale.vue';
2427
2528
2629
export default {
2730
components: {
2831
RoomDetail,
32+
dataScale
2933
},
3034
3135
setup() {
36+
37+
const valMin = ref(0);
38+
const valMax = ref(500);
39+
const realMax = ref(500);
40+
const realMin = ref(0);
41+
const unit = ref("");
42+
3243
const roomData = reactive({
3344
rgt: { color: "grey", state: true, path: ["m 608.19842,259.42256 21.57668,0.55555 -6.3626,88.06307 -19.02962,-0.27646 z"], data: {} },
3445
magasin: { color: "grey", state: true, path: ["m 907.97947,435.3071 9.75036,2.17174 c 4.81623,21.39286 18.55939,22.092 31.43436,24.80373 l 8.17867,20.57223 -28.03037,56.07916 -54.14,-14.42874 z"], data: {} },
@@ -47,7 +58,7 @@ export default {
4758
B010: { color: "grey", state: true, path: ["m 58.614622,362.70239 88.180798,-31.58652 38.83639,95.61686 -26.12719,6.44509 c -11.45798,-7.50656 -22.61479,-9.04978 -33.0913,-4.9618 -15.0115,5.85755 -17.69079,13.23839 -20.5334,20.16686 l -10.957198,-3.78735 z"], data: {} }
4859
});
4960
50-
const selectedOption = ref('temperature');
61+
const selectedOption = ref('activity');
5162
const roomName = ref(null);
5263
5364
@@ -59,54 +70,55 @@ export default {
5970
roomName.value = roomId;
6071
};
6172
62-
const fetchDataForRoom = async (roomId) => {
73+
const fetchAllRoomData = async () => {
6374
try {
64-
const response = await fetch(`http://localhost:8000/ByRoom/${roomId}/?last_data=1&depth=1`);
65-
const data = await response.json();
66-
67-
roomData[roomId]['data'] = {
68-
id: data.all_data[0].id,
69-
time: data.all_data[0].time,
70-
temperature: data.all_data[0].temperature,
71-
humidity: data.all_data[0].humidity,
72-
activity: data.all_data[0].activity,
73-
co2: data.all_data[0].co2,
74-
tvoc: data.all_data[0].tvoc,
75-
illuminance: data.all_data[0].illuminance,
76-
infrared: data.all_data[0].infrared,
77-
infrared_and_visible: data.all_data[0].infrared_and_visible,
78-
pressure: data.all_data[0].pressure,
79-
state: true
80-
};
81-
82-
// Vous pouvez également traiter les autres données de l'API si nécessaire
83-
// data.sensor, data.building, data.floor, etc.
84-
} catch (error) {
85-
roomData[roomId]['state'] = false;
86-
}
87-
};
75+
const response = await fetch('http://localhost:8000/ByRoom/?last_data=1&depth=1');
76+
const roomsData = await response.json();
8877
89-
const fetchAllRoomData = async () => {
90-
// Pour chaque salle, appelez fetchDataForRoom
91-
for (const roomId in roomData) {
92-
if (roomData.hasOwnProperty(roomId)) {
93-
await fetchDataForRoom(roomId);
78+
for (const roomKey in roomData) {
79+
if (roomData.hasOwnProperty(roomKey)) {
80+
const roomId = roomKey;
81+
const roomInfo = roomsData.find(room => room.room === roomId);
82+
83+
if (roomInfo) {
84+
roomData[roomId].data = {
85+
id: roomInfo.all_data[0].id,
86+
time: roomInfo.all_data[0].time,
87+
temperature: roomInfo.all_data[0].temperature,
88+
humidity: roomInfo.all_data[0].humidity,
89+
activity: roomInfo.all_data[0].activity,
90+
co2: roomInfo.all_data[0].co2,
91+
tvoc: roomInfo.all_data[0].tvoc,
92+
illuminance: roomInfo.all_data[0].illuminance,
93+
infrared: roomInfo.all_data[0].infrared,
94+
infrared_and_visible: roomInfo.all_data[0].infrared_and_visible,
95+
pressure: roomInfo.all_data[0].pressure,
96+
state: true
97+
};
98+
} else {
99+
// Gérer le cas où les données de la salle ne sont pas disponibles
100+
roomData[roomId].state = false;
101+
}
102+
}
94103
}
104+
105+
updateColors();
106+
updateScale();
107+
} catch (error) {
108+
console.error('Erreur lors de la récupération des données des salles.', error);
95109
}
96-
console.log(roomData);
97-
updateColors();
98110
};
99111
112+
113+
100114
const updateColors = () => {
101115
for (const roomId in roomData) {
102116
if (roomData.hasOwnProperty(roomId) && roomData[roomId].state) {
103117
const metricValue = parseFloat(roomData[roomId]['data'][selectedOption.value]);
104-
console.log('Updating colors...');
118+
105119
if (!isNaN(metricValue)) {
106120
roomData[roomId].color = getColorForMetric(metricValue, selectedOption.value);
107-
console.log("VOUI");
108121
}
109-
console.log("toto");
110122
}
111123
}
112124
};
@@ -126,15 +138,69 @@ export default {
126138
};
127139
128140
if (option === "temperature") {
141+
valMin.value = 14;
142+
valMax.value = 30;
143+
if (value > valMax.value) {
144+
realMax.value = value + 5;
145+
} else {
146+
realMax.value = 30;
147+
}
148+
if (value < valMin.value) {
149+
realMin.value = value - 5;
150+
} else {
151+
realMin.value = 14;
152+
}
153+
unit.value = "°C";
129154
return getColor(14, 30, value);
130155
}
131156
if (option == "humidity") {
157+
valMin.value = 40;
158+
valMax.value = 60;
159+
if (value > valMax.value) {
160+
realMax.value = value + 5;
161+
} else {
162+
realMax.value = 60;
163+
}
164+
165+
if (value < valMin.value) {
166+
realMin.value = value - 5;
167+
} else {
168+
realMin.value = 40;
169+
}
170+
171+
unit.value = "%";
132172
return getColor(40, 60, value);
133173
};
134174
if (option == "co2") {
175+
valMin.value = 0;
176+
valMax.value = 1500;
177+
if (value > valMax.value) {
178+
realMax.value = value + 5;
179+
} else {
180+
realMax.value = 1500;
181+
}
182+
if (value < valMin.value) {
183+
realMin.value = value - 5;
184+
} else {
185+
realMin.value = 0;
186+
}
187+
unit.value = "ppm";
135188
return getColor(0, 1500, value);
136189
};
137190
if (option == "activity") {
191+
valMin.value = 0;
192+
valMax.value = 500;
193+
if (value > valMax.value) {
194+
realMax.value = value + 5;
195+
} else {
196+
realMax.value = 500;
197+
}
198+
if (value < valMin.value) {
199+
realMin.value = value - 5;
200+
} else {
201+
realMin.value = 0;
202+
}
203+
unit.value = "";
138204
return getColor(0, 500, value);
139205
};
140206
};
@@ -150,7 +216,7 @@ export default {
150216
fetchAllRoomData();
151217
});
152218
153-
return { roomData, selectedOption, updateColors, updateSelectedOption , roomName, showRoomDetail};
219+
return { roomData, selectedOption, updateColors, updateSelectedOption, roomName, showRoomDetail, valMin, valMax, realMin, realMax, unit };
154220
}
155221
};
156222
</script>
@@ -172,10 +238,51 @@ g {
172238
transition: fill 1.2s, stroke 1s;
173239
}
174240
241+
.grid {
242+
display: flex;
243+
flex-direction: column;
244+
/* Aligner les éléments en colonne */
245+
align-items: center;
246+
gap: 50px;
247+
width: 80vw;
248+
}
249+
250+
/* Style de base pour le sélecteur */
251+
select {
252+
padding: 10px;
253+
font-size: 16px;
254+
border: 1px solid #ccc;
255+
border-radius: 5px;
256+
background-color: #fff;
257+
color: #333;
258+
outline: none;
259+
transition: border-color 0.3s;
260+
}
261+
262+
263+
264+
265+
/* Flèche personnalisée */
266+
select::after {
267+
content: '\25BC';
268+
position: absolute;
269+
top: 50%;
270+
right: 10px;
271+
transform: translateY(-50%);
272+
pointer-events: none;
273+
}
274+
275+
select option {
276+
padding: 10px;
277+
}
278+
279+
select option:hover {
280+
background-color: #66afe9;
281+
color: #fff;
282+
}
283+
175284
g.changeColor:hover {
176285
stroke-width: 4px;
177-
/* Augmenter la largeur du contour à 2 pixels */
178286
}
179-
180287
</style>
181288

0 commit comments

Comments
 (0)