add filters for sockets

This commit is contained in:
Tykayn 2025-04-27 22:05:21 +02:00 committed by tykayn
parent ebb2c87bcc
commit edef80c926
5 changed files with 301 additions and 99 deletions

View file

@ -116,44 +116,53 @@
⚙️ Filtres: ⚙️ Filtres:
</h2> </h2>
<div class="filter-group"> <div class="filter-group">
<h3>Types de prises</h3>
<div class="filter-group">
Montrer:
<br>
<label> <label>
<input type="checkbox" id="filterCableAttached"> Prise avec câble attaché <input type="checkbox" id="filterCableAttached">
<span class="checkbox-custom"></span>
<span>Prise avec câble attaché</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterCCS"> Prise CCS <input type="checkbox" id="filterCCS">
<span class="checkbox-custom"></span>
<span>Prise CCS</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterType2"> Prise Type 2 <input type="checkbox" id="filterType2">
<span class="checkbox-custom"></span>
<span>Prise Type 2</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterDomestic"> Prise domestique <input type="checkbox" id="filterDomestic">
<span class="checkbox-custom"></span>
<span>Prise domestique</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterChademo"> Prise CHAdeMO <input type="checkbox" id="filterChademo">
<span class="checkbox-custom"></span>
<span>Prise CHAdeMO</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterType1"> Prise Type 1 <input type="checkbox" id="filterType1">
<span class="checkbox-custom"></span>
<span>Prise Type 1</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterType3"> Prise Type 3 <input type="checkbox" id="filterType3">
<span class="checkbox-custom"></span>
<span>Prise Type 3</span>
</label> </label>
<hr> <hr>
<h3>Qualité des données</h3>
<label> <label>
<input type="checkbox" id="filterQuality"> Contrôle qualité <input type="checkbox" id="filterQuality">
<span class="checkbox-custom"></span>
<span>Contrôle qualité</span>
</label> </label>
<br>
<label> <label>
<input type="checkbox" id="filterUnkown"> ❓ kW max inconnu <input type="checkbox" id="filterUnkown">
<span class="checkbox-custom"></span>
<span>❓ kW max inconnu</span>
</label> </label>
</div> </div>
<!-- <!--

View file

@ -342,7 +342,7 @@ function calculerPourcentage(partie, total, reduc) {
return ((partie / total) * 100 * coef_reduction).toFixed(1) return ((partie / total) * 100 * coef_reduction).toFixed(1)
} }
function displayStatsFromGeoJson(resultAsGeojson) { function displayStatsFromGeoJson(resultAsGeojson, stats) {
let count = resultAsGeojson.features.length; let count = resultAsGeojson.features.length;
let count_station_output = 0; let count_station_output = 0;
let count_ref_eu = 0; let count_ref_eu = 0;
@ -355,7 +355,6 @@ function displayStatsFromGeoJson(resultAsGeojson) {
let count_estimated_type2combo = 0; let count_estimated_type2combo = 0;
let count_found_type2combo = 0; let count_found_type2combo = 0;
let count_found_type2 = 0; let count_found_type2 = 0;
let count_hidden_by_filters = 0;
// Compter les filtres désactivés // Compter les filtres désactivés
let disabledFilters = 0; let disabledFilters = 0;
@ -363,7 +362,7 @@ function displayStatsFromGeoJson(resultAsGeojson) {
if (!lcm_config.filterConfigs[filterId]) disabledFilters++; if (!lcm_config.filterConfigs[filterId]) disabledFilters++;
}); });
$('#count_features_fond').html('⚡' + count + ' stations' + (disabledFilters > 0 ? ` (${disabledFilters} filtre${disabledFilters > 1 ? 's' : ''} désactivé${disabledFilters > 1 ? 's' : ''}, ${count_hidden_by_filters} masqué${count_hidden_by_filters > 1 ? 's' : ''})` : '')); $('#count_features_fond').html('⚡' + count + ' stations' + (disabledFilters > 0 ? ` (${disabledFilters} filtre${disabledFilters > 1 ? 's' : ''} désactivé${disabledFilters > 1 ? 's' : ''}, ${stats.count_hidden_by_filters} masqué${stats.count_hidden_by_filters > 1 ? 's' : ''})` : ''));
resultAsGeojson.features.map(feature => { resultAsGeojson.features.map(feature => {
let found_type2_combo = false; let found_type2_combo = false;
@ -501,7 +500,11 @@ function displayPointsFromApi(points, convert_to_osm_json) {
geojsondata = osmtogeojson(points); geojsondata = osmtogeojson(points);
} }
displayStatsFromGeoJson(geojsondata); let stats = {
count_hidden_by_filters: 0
};
displayStatsFromGeoJson(geojsondata, stats);
let resultLayer = L.geoJson(geojsondata, { let resultLayer = L.geoJson(geojsondata, {
style: function (feature) { style: function (feature) {
@ -523,7 +526,9 @@ function displayPointsFromApi(points, convert_to_osm_json) {
supprimerMarqueurs(); supprimerMarqueurs();
displayPointsFromApi(); displayPointsFromApi();
}, },
onEachFeature: eachFeature, onEachFeature: function(feature, layer) {
eachFeature(feature, layer, stats);
},
}); });
} }
@ -569,7 +574,7 @@ function makePopupOfFeature(feature) {
* @param feature * @param feature
* @param layer * @param layer
*/ */
function eachFeature(feature, layer) { function eachFeature(feature, layer, stats) {
let link_josm = createJOSMEditLink(feature); let link_josm = createJOSMEditLink(feature);
let popupContent = makePopupOfFeature(feature); let popupContent = makePopupOfFeature(feature);
@ -581,32 +586,32 @@ function eachFeature(feature, layer) {
// Vérifier les filtres activés // Vérifier les filtres activés
if (lcm_config.filterCCS && !feature.properties.tags['socket:type2_combo']) { if (lcm_config.filterCCS && !feature.properties.tags['socket:type2_combo']) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
if (lcm_config.filterType2 && !feature.properties.tags['socket:type2']) { if (lcm_config.filterType2 && !feature.properties.tags['socket:type2']) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
if (lcm_config.filterDomestic && !feature.properties.tags['socket:typee']) { if (lcm_config.filterDomestic && !feature.properties.tags['socket:typee']) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
if (lcm_config.filterChademo && !feature.properties.tags['socket:chademo']) { if (lcm_config.filterChademo && !feature.properties.tags['socket:chademo']) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
if (lcm_config.filterType1 && !feature.properties.tags['socket:type1']) { if (lcm_config.filterType1 && !feature.properties.tags['socket:type1']) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
if (lcm_config.filterType3 && !feature.properties.tags['socket:type3']) { if (lcm_config.filterType3 && !feature.properties.tags['socket:type3']) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
@ -619,7 +624,7 @@ function eachFeature(feature, layer) {
} }
}); });
if (!hasCableAttached) { if (!hasCableAttached) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
} }
@ -631,7 +636,7 @@ function eachFeature(feature, layer) {
feature.properties.tags['payment:none'] || feature.properties.tags['payment:none'] ||
feature.properties.tags['opening_hours']; feature.properties.tags['opening_hours'];
if (!hasQualityInfo) { if (!hasQualityInfo) {
count_hidden_by_filters++; stats.count_hidden_by_filters++;
return; return;
} }
} }
@ -1316,11 +1321,11 @@ function init() {
}; };
// Créer deux contrôles de couches séparés // Créer deux contrôles de couches séparés
const baseLayerControl = L.control.layers(baseLayers, null, { // const baseLayerControl = L.control.layers(baseLayers, null, {
collapsed: true, // collapsed: true,
className: 'leaflet-control-layers base-layers', // className: 'leaflet-control-layers base-layers',
id: 'base-layers-control' // id: 'base-layers-control'
}).addTo(map); // }).addTo(map);
const overlayControl = L.control.layers(null, overlayMaps, { const overlayControl = L.control.layers(null, overlayMaps, {
collapsed: true, collapsed: true,

123
styles/filters.scss Normal file
View file

@ -0,0 +1,123 @@
// Variables
$primary-color: #28a745;
$border-color: #6c757d;
$hover-bg: #e9ecef;
$text-color: #495057;
$disabled-color: #adb5bd;
// Mixins
@mixin flex-center {
display: flex;
align-items: center;
}
@mixin transition($property: all, $duration: 0.3s, $timing: ease) {
transition: $property $duration $timing;
}
// Styles pour le groupe de filtres
.filter-group {
margin: 15px 0;
padding: 15px;
background: #f8f9fa;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
h3 {
margin-bottom: 10px;
color: $text-color;
font-size: 16px;
}
label {
@include flex-center;
padding: 8px 0;
cursor: pointer;
@include transition;
border-radius: 4px;
margin: 4px 0;
&:hover {
background: $hover-bg;
}
}
input[type="checkbox"] {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.checkbox-custom {
position: relative;
display: inline-block;
width: 20px;
height: 20px;
background: #fff;
border: 2px solid $border-color;
border-radius: 4px;
margin-right: 10px;
@include transition;
label:hover & {
border-color: darken($border-color, 10%);
}
}
input[type="checkbox"]:checked + .checkbox-custom {
background: $primary-color;
border-color: $primary-color;
animation: checkboxPop 0.3s ease;
&::after {
content: '';
position: absolute;
left: 6px;
top: 2px;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
}
hr {
margin: 15px 0;
border: 0;
height: 1px;
background: #dee2e6;
}
span {
font-size: 14px;
color: $text-color;
@include transition(color);
}
label:hover span {
color: darken($text-color, 10%);
}
input[type="checkbox"]:disabled {
+ .checkbox-custom {
background: $hover-bg;
border-color: $disabled-color;
cursor: not-allowed;
}
+ .checkbox-custom + span {
color: $disabled-color;
cursor: not-allowed;
}
}
}
// Animation
@keyframes checkboxPop {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}

View file

@ -400,46 +400,6 @@ button+button {
margin-left: 1rem; margin-left: 1rem;
} }
.filter-group button {
padding: 1rem 2rem;
border-radius: 0.25rem;
&:after {
position: relative;
float: right;
left: 1rem;
top: 1rem;
font-size: 0.9em;
}
&.filter-state-hide:after {
content: "cacher";
color: grey;
}
&.filter-state-show:after {
content: "montrer";
color: green;
}
&.filter-state-showOnly:after {
content: "montrer uniquement";
color: orange;
}
&.filter-state-hide {
background: #fff;
}
&.filter-state-show {
color: green;
}
&.filter-state-showOnly {
color: orange;
}
}
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
background-size: contain; background-size: contain;
} }

File diff suppressed because one or more lines are too long