|
18 | 18 |
|
19 | 19 | let filesInDropzone = $state(null); |
20 | 20 |
|
21 | | - let summaryDpeInfos = $state([]); |
| 21 | + let dpeInfos = $state([]); |
22 | 22 |
|
23 | 23 | /** |
24 | 24 | * Ademe xml data (json format) input of the 3CL engine |
|
99 | 99 | event.preventDefault(); |
100 | 100 | event.stopImmediatePropagation(); |
101 | 101 | setAnalyzedDpe({numero_dpe: undefined}); |
102 | | - summaryDpeInfos = []; |
| 102 | + dpeInfos = []; |
103 | 103 | filesInDropzone = null |
104 | 104 | } |
105 | 105 |
|
106 | 106 | const summarizeDpeInfos = () => { |
107 | 107 | const dpe = getAnalyzedDpe(); |
108 | 108 | /** @type {string} **/ |
109 | 109 | const methodeApplication = enums['methode_application_dpe_log'][dpe.logement.caracteristique_generale.enum_methode_application_dpe_log_id]; |
110 | | - console.log(methodeApplication); |
111 | | - summaryDpeInfos = []; |
| 110 | + const chauffageDpeInfos = []; |
| 111 | + const ecsDpeInfos = []; |
| 112 | + const ventilationDpeInfos = []; |
| 113 | + const generalInfos = []; |
| 114 | + const logementInfos = []; |
| 115 | + const meteoInfos = []; |
| 116 | + generalInfos.push({label: toDpeInfoLabel('Version dpe', dpe.administratif.enum_version_id), color: 'teal'}); |
112 | 117 |
|
113 | 118 | if (methodeApplication.includes('immeuble')) { |
114 | | - summaryDpeInfos.push({label: 'Dpe immeuble', color: 'lime'}); |
| 119 | + generalInfos.push({label: 'Dpe immeuble', color: 'teal'}); |
115 | 120 | } |
116 | 121 |
|
117 | 122 | if (methodeApplication.includes('individuel')) { |
118 | 123 | if (methodeApplication.includes('maison')) { |
119 | | - summaryDpeInfos.push({label: 'Maison individuelle', color: 'teal'}); |
| 124 | + generalInfos.push({label: 'Maison individuelle', color: 'teal'}); |
120 | 125 | } |
121 | 126 | if (methodeApplication.includes('appartement')) { |
122 | | - summaryDpeInfos.push({label: 'Appartement individuel', color: 'teal'}); |
| 127 | + generalInfos.push({label: 'Appartement individuel', color: 'teal'}); |
123 | 128 | } |
124 | 129 | } |
125 | 130 |
|
| 131 | + if (dpe.logement.caracteristique_generale.annee_construction) { |
| 132 | + logementInfos.push({label: toDpeInfoLabel('Année de construction', dpe.logement.caracteristique_generale.annee_construction ), color: 'amber'}); |
| 133 | + } |
| 134 | +
|
| 135 | + logementInfos.push({label: toDpeInfoLabel('Période de construction', enums['periode_construction'][dpe.logement.caracteristique_generale.enum_periode_construction_id]), color: 'amber'}); |
| 136 | + if (dpe.logement.caracteristique_generale.surface_habitable_logement) { |
| 137 | + logementInfos.push({label: toDpeInfoLabel('Surface logement', dpe.logement.caracteristique_generale.surface_habitable_logement, 'm²'), color: 'amber'}); |
| 138 | + } |
| 139 | + if (dpe.logement.caracteristique_generale.surface_habitable_immeuble) { |
| 140 | + logementInfos.push({label: toDpeInfoLabel('Surface immeuble', dpe.logement.caracteristique_generale.surface_habitable_immeuble, 'm²'), color: 'amber'}); |
| 141 | + } |
| 142 | + if (dpe.logement.caracteristique_generale.nombre_appartement) { |
| 143 | + logementInfos.push({label: toDpeInfoLabel('Nombre d\'appartements', dpe.logement.caracteristique_generale.nombre_appartement), color: 'amber'}); |
| 144 | + } |
| 145 | + logementInfos.push({label: toDpeInfoLabel('Hauteur ss plafond', dpe.logement.caracteristique_generale.hsp, 'm'), color: 'amber'}); |
| 146 | +
|
| 147 | + meteoInfos.push({label: toDpeInfoLabel('Zone climatique', enums['zone_climatique'][dpe.logement.meteo.enum_zone_climatique_id]), color: 'emerald'}); |
| 148 | + meteoInfos.push({label: toDpeInfoLabel('Altitude', enums['classe_altitude'][dpe.logement.meteo.enum_classe_altitude_id]), color: 'emerald'}); |
| 149 | +
|
126 | 150 | if (methodeApplication.includes('chauffage')) { |
127 | 151 | if (methodeApplication.includes('chauffage mixte')) { |
128 | | - summaryDpeInfos.push({label: 'Chauffage mixte', color: 'indigo'}); |
| 152 | + chauffageDpeInfos.push({label: 'Chauffage mixte', color: 'indigo'}); |
129 | 153 | } |
130 | 154 | if (methodeApplication.includes('chauffage collectif')) { |
131 | | - summaryDpeInfos.push({label: 'Chauffage collectif', color: 'indigo'}); |
| 155 | + chauffageDpeInfos.push({label: 'Chauffage collectif', color: 'indigo'}); |
132 | 156 | } |
133 | 157 | if (methodeApplication.includes('chauffage individuel')) { |
134 | | - summaryDpeInfos.push({label: 'Chauffage individuel', color: 'indigo'}); |
| 158 | + chauffageDpeInfos.push({label: 'Chauffage individuel', color: 'indigo'}); |
135 | 159 | } |
136 | 160 | } |
137 | | - summaryDpeInfos.push({label: `${dpe.logement.installation_chauffage_collection.installation_chauffage.length} installation(s) chauffage`, color: 'indigo'}); |
| 161 | + chauffageDpeInfos.push({label: `${dpe.logement.installation_chauffage_collection?.installation_chauffage?.length || 0} installation(s) chauffage`, color: 'indigo'}); |
| 162 | + const chauffagesGenDescriptions = dpe.logement |
| 163 | + .installation_chauffage_collection?.installation_chauffage?.flatMap(inst => inst.generateur_chauffage_collection |
| 164 | + .generateur_chauffage.map(gen => `générateur: ${enums['type_generateur_ch'][gen.donnee_entree.enum_type_generateur_ch_id]} (id: ${gen.donnee_entree.enum_type_generateur_ch_id})`)); |
| 165 | +
|
| 166 | + const chauffagesEmetteurDescriptions = dpe.logement |
| 167 | + .installation_chauffage_collection?.installation_chauffage?.flatMap(inst => inst.emetteur_chauffage_collection |
| 168 | + .emetteur_chauffage.map(emetteur => `émetteur: ${enums['equipement_intermittence'][emetteur.donnee_entree.enum_equipement_intermittence_id]} (id: ${emetteur.donnee_entree.enum_equipement_intermittence_id})`)); |
| 169 | +
|
| 170 | + chauffagesGenDescriptions.forEach(chauffagesGenDescription => { |
| 171 | + chauffageDpeInfos.push({label: chauffagesGenDescription, color: 'indigo'}); |
| 172 | + }); |
| 173 | +
|
| 174 | + chauffagesEmetteurDescriptions.forEach(chauffagesEmetteurDescription => { |
| 175 | + chauffageDpeInfos.push({label: chauffagesEmetteurDescription, color: 'indigo'}); |
| 176 | + }); |
138 | 177 |
|
139 | 178 | if (methodeApplication.includes('ecs')) { |
140 | 179 | if (methodeApplication.includes('ecs mixte')) { |
141 | | - summaryDpeInfos.push({label: 'Ecs mixte', color: 'fuchsia'}); |
| 180 | + ecsDpeInfos.push({label: 'Ecs mixte', color: 'fuchsia'}); |
142 | 181 | } |
143 | 182 | if (methodeApplication.includes('ecs collectif')) { |
144 | | - summaryDpeInfos.push({label: 'Ecs collectif', color: 'fuchsia'}); |
| 183 | + ecsDpeInfos.push({label: 'Ecs collectif', color: 'fuchsia'}); |
145 | 184 | } |
146 | 185 | if (methodeApplication.includes('ecs individuel')) { |
147 | | - summaryDpeInfos.push({label: 'Ecs individuel', color: 'fuchsia'}); |
| 186 | + ecsDpeInfos.push({label: 'Ecs individuel', color: 'fuchsia'}); |
148 | 187 | } |
149 | 188 | } |
150 | | - summaryDpeInfos.push({label: `${dpe.logement.installation_ecs_collection.installation_ecs.length} installation(s) ecs`, color: 'fuchsia'}); |
| 189 | + ecsDpeInfos.push({label: `${dpe.logement.installation_ecs_collection?.installation_ecs.length || 0} installation(s) ecs`, color: 'fuchsia'}); |
| 190 | +
|
| 191 | + const ecsGenDescriptions = dpe.logement |
| 192 | + .installation_ecs_collection?.installation_ecs?.flatMap(inst => inst.generateur_ecs_collection |
| 193 | + .generateur_ecs.map(gen => `générateur: ${enums['type_generateur_ecs'][gen.donnee_entree.enum_type_generateur_ecs_id]} (id: ${gen.donnee_entree.enum_type_generateur_ecs_id})`)); |
| 194 | +
|
| 195 | + ecsGenDescriptions.forEach(ecsGenDescription => { |
| 196 | + ecsDpeInfos.push({label: ecsGenDescription, color: 'fuchsia'}); |
| 197 | + }); |
| 198 | +
|
| 199 | + ventilationDpeInfos.push({label: `${dpe.logement.ventilation_collection?.ventilation.length || 0} installation(s) ventilation`, color: 'sky'}); |
| 200 | +
|
| 201 | + const ventilationDescriptions = dpe.logement |
| 202 | + .ventilation_collection?.ventilation?.map(ventilation => `${enums['type_ventilation'][ventilation.donnee_entree.enum_type_ventilation_id]} (id: ${ventilation.donnee_entree.enum_type_ventilation_id})`); |
| 203 | + ventilationDescriptions.forEach(ventilationDescription => { |
| 204 | + ventilationDpeInfos.push({label: ventilationDescription, color: 'sky'}); |
| 205 | + }); |
151 | 206 |
|
152 | | - summaryDpeInfos.push({label: `${dpe.logement.ventilation_collection.ventilation.length} installation(s) ventilation`, color: 'sky'}); |
| 207 | + dpeInfos.push(generalInfos); |
| 208 | + dpeInfos.push(logementInfos); |
| 209 | + dpeInfos.push(meteoInfos); |
| 210 | + dpeInfos.push(chauffageDpeInfos); |
| 211 | + dpeInfos.push(ecsDpeInfos); |
| 212 | + dpeInfos.push(ventilationDpeInfos); |
| 213 | + } |
| 214 | +
|
| 215 | + /** |
| 216 | + * @param label {string} |
| 217 | + * @param value {any} |
| 218 | + * @param suffix {string?} |
| 219 | + */ |
| 220 | + function toDpeInfoLabel(label, value, suffix = '') { |
| 221 | + return `${label} : <span class="font-bold underline">${value} ${suffix}</span>`; |
153 | 222 | } |
154 | 223 |
|
155 | 224 | </script> |
|
185 | 254 | <p class="text-xs text-gray-500 dark:text-gray-400">Format XML uniquement</p> |
186 | 255 | </Dropzone> |
187 | 256 | {:else} |
188 | | - <div class="flex gap-3"> |
189 | | - {#each summaryDpeInfos as info} |
190 | | - <Badge large color="{info.color}">{info.label}</Badge> |
| 257 | + <div class="flex gap-3 justify-start"> |
| 258 | + {#each dpeInfos as info} |
| 259 | + <div> |
| 260 | + {#each info as dpeInfo} |
| 261 | + <div class="pt-1"> |
| 262 | + <Badge large color="{dpeInfo.color}">{@html dpeInfo.label}</Badge> |
| 263 | + </div> |
| 264 | + {/each} |
| 265 | + </div> |
191 | 266 | {/each} |
192 | 267 | </div> |
193 | 268 |
|
|
0 commit comments