Amélioration de la recherche par adresse #10
9 changed files with 153 additions and 90 deletions
|
@ -71,8 +71,14 @@ def query_axione(cfg, body):
|
|||
timeout=120,
|
||||
)
|
||||
conn.request("POST", "/v3/fai", body, headers=headers)
|
||||
print("")
|
||||
print("[+] REQUEST")
|
||||
print(body)
|
||||
response = conn.getresponse()
|
||||
respData = response.read()
|
||||
print("")
|
||||
print("[+] RESPONSE")
|
||||
print(respData)
|
||||
except Exception as e:
|
||||
print("Error while querying Axione: ", file=sys.stderr)
|
||||
print(str(e), file=sys.stderr)
|
||||
|
|
7
static/boostrap-4.3.1.min.css
vendored
Normal file
7
static/boostrap-4.3.1.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
static/bootstrap-4.3.1.min.js
vendored
Normal file
7
static/bootstrap-4.3.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
static/jquery-3.3.1.slim.min.js
vendored
Normal file
2
static/jquery-3.3.1.slim.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
static/popper-1.14.7.min.js
vendored
Normal file
5
static/popper-1.14.7.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/trevorevre-autocomplete-js-style.css
Normal file
1
static/trevorevre-autocomplete-js-style.css
Normal file
|
@ -0,0 +1 @@
|
|||
.autocomplete-input{border:1px solid #eee;border-radius:8px;width:100%;padding:12px 12px 12px 48px;box-sizing:border-box;position:relative;font-size:16px;line-height:1.5;flex:1;background-color:#eee;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNjY2IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iOCIvPjxwYXRoIGQ9Ik0yMSAyMWwtNC00Ii8+PC9zdmc+");background-repeat:no-repeat;background-position:12px}.autocomplete-input:focus,.autocomplete-input[aria-expanded=true]{border-color:rgba(0,0,0,.12);background-color:#fff;outline:none;box-shadow:0 2px 2px rgba(0,0,0,.16)}[data-position=below] .autocomplete-input[aria-expanded=true]{border-bottom-color:transparent;border-radius:8px 8px 0 0}[data-position=above] .autocomplete-input[aria-expanded=true]{border-top-color:transparent;border-radius:0 0 8px 8px;z-index:2}.autocomplete[data-loading=true]:after{content:"";border:3px solid rgba(0,0,0,.12);border-right-color:rgba(0,0,0,.48);border-radius:100%;width:20px;height:20px;position:absolute;right:12px;top:50%;transform:translateY(-50%);animation:rotate 1s linear infinite}.autocomplete-result-list{margin:0;border:1px solid rgba(0,0,0,.12);padding:0;box-sizing:border-box;max-height:296px;overflow-y:auto;background:#fff;list-style:none;box-shadow:0 2px 2px rgba(0,0,0,.16)}[data-position=below] .autocomplete-result-list{margin-top:-1px;border-top-color:transparent;border-radius:0 0 8px 8px;padding-bottom:8px}[data-position=above] .autocomplete-result-list{margin-bottom:-1px;border-bottom-color:transparent;border-radius:8px 8px 0 0;padding-top:8px}.autocomplete-result{cursor:default;padding:12px 12px 12px 48px;background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjY2NjIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iOCIvPjxwYXRoIGQ9Ik0yMSAyMWwtNC00Ii8+PC9zdmc+");background-repeat:no-repeat;background-position:12px}.autocomplete-result:hover,.autocomplete-result[aria-selected=true]{background-color:rgba(0,0,0,.06)}@keyframes rotate{0%{transform:translateY(-50%) rotate(0deg)}to{transform:translateY(-50%) rotate(359deg)}}
|
1
static/trevorevre-autocomplete-js.min.js
vendored
Normal file
1
static/trevorevre-autocomplete-js.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -5,19 +5,21 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
<link rel="stylesheet" href="{{url_for('static', filename='boostrap-4.3.1.min.css')}}"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
|
||||
<script src="{{url_for('static', filename='jquery-3.3.1.slim.min.js')}}"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
|
||||
<script src="{{url_for('static', filename='popper-1.14.7.min.js')}}"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
|
||||
<script src="{{url_for('static', filename='bootstrap-4.3.1.min.js')}}"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.6/dist/autoComplete.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.6/dist/css/autoComplete.02.min.css">
|
||||
|
||||
<script src="{{url_for('static', filename='trevorevre-autocomplete-js.min.js')}}"></script>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{{url_for('static', filename='trevorevre-autocomplete-js-style.css')}}"
|
||||
/>
|
||||
<title>Aquilenet: Éligibilité FTTH</title>
|
||||
<style>
|
||||
{% include 'style.css'%}
|
||||
|
@ -66,27 +68,40 @@
|
|||
|
||||
<div id="methodAddress" class="collapse testMethods">
|
||||
<h2 class="text-center form-title">Test d'éligibilité par adresse</h2>
|
||||
|
||||
<form id="formAddressTest" method="post" action="/test/address">
|
||||
<div class="form-group row" id="communeForm">
|
||||
<label class="form-label col-sm-2 my-1" for="commune-autocomplete">Commune</label>
|
||||
<input id="commune-autocomplete" class="col-sm-9" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" class="form-control" autocapitalize="off"/>
|
||||
<div id="commune-form">
|
||||
<label class="form-label" for="commune-autocomplete-input">Commune</label>
|
||||
<div class="autocomplete" id="commune-autocomplete">
|
||||
<input id="commune-autocomplete-input" class="autocomplete-input"
|
||||
spellcheck="false" autocorrect="off" autocomplete="off"
|
||||
autocapitalize="off" placeholder="Nom/Code Postal de la Commune"/>
|
||||
<ul class="autocomplete-result-list"/>
|
||||
</div>
|
||||
<div class="form-row collapse" id="voieForm">
|
||||
<div class="col-sm-3 my-1">
|
||||
</div>
|
||||
<div class="collapse" id="voieForm">
|
||||
<div id="voieFormContent">
|
||||
<div id="street-number-form">
|
||||
<label class="form-label" for="numeroVoieInput">Numéro de voie</label>
|
||||
<input required type="text" name="numeroVoie" class="form-control" id="numeroVoieInput"
|
||||
aria-describedby="numeroVoieHelp" placeholder="Numéro de voie"
|
||||
oninvalid="this.setCustomValidity('Veuillez renseigner le numéro de voie')"
|
||||
oninput="setCustomValidity('')">
|
||||
</div>
|
||||
<div class="col-sm-7 my-1">
|
||||
<label class="form-label" for="fantoir-autocomplete">Nom de voie</label>
|
||||
<input id="fantoir-autocomplete" class="form-control" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off"/>
|
||||
<div id="street-name-form">
|
||||
<label class="form-label" for="street-name-autocomplete-input">Nom de voie</label>
|
||||
<div class="autocomplete" id="street-name-autocomplete">
|
||||
<input id="street-name-autocomplete-input" class="autocomplete-input"
|
||||
spellcheck="false" autocorrect="off" autocomplete="off"
|
||||
autocapitalize="off" placeholder="Nom de voie"/>
|
||||
<ul class="autocomplete-result-list"/>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button id="btnTestAdresse" type="submit" class="btn btn-sable collapse">Tester l'adresse</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="btnTestAdresseContainer"><button id="btnTestAdresse" type="submit" class="btn btn-sable collapse">Tester l'adresse</button></div>
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<button id="buttonReturnPto" type="button" data-toggle="collapse" data-target=".testMethods"
|
||||
class="btn btn-link page-nav-btn" aria-expanded="false" aria-controls="methodPto methodAddress">Revenir au test par
|
||||
|
@ -99,18 +114,12 @@
|
|||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
// AbortController allows to cancel promises
|
||||
const controllerCommunes = new AbortController();
|
||||
const { signalCommunes } = controllerCommunes;
|
||||
const controllerVoies = new AbortController();
|
||||
const { signalVoies } = controllerVoies;
|
||||
|
||||
// Global variables
|
||||
var communes = []
|
||||
var codeInsee = 0
|
||||
var codeRivoli = ""
|
||||
var voies = []
|
||||
var voie = ""
|
||||
let communes = []
|
||||
let codeInsee = 0
|
||||
let codeRivoli = ""
|
||||
let voies = []
|
||||
let voie = ""
|
||||
|
||||
function sanitizeInputStr(inputStr) {
|
||||
|
||||
|
@ -152,72 +161,43 @@
|
|||
$('#numeroVoieInput').focus();
|
||||
});
|
||||
|
||||
const autoCompleteCommune = new autoComplete({
|
||||
selector: "#commune-autocomplete",
|
||||
placeHolder: "Code postal/nom de commune...",
|
||||
data: {
|
||||
src: async (query) => {
|
||||
const communeAutocompleteOptions = {
|
||||
search: async (query) => {
|
||||
const api = "addresses/communes?limit=100";
|
||||
const reqUrl = query === '' ? api : api + "&s=" + query
|
||||
const source = await fetch(reqUrl, { signalCommunes });
|
||||
const reqUrl = query === '' ? api : `${api}&s=${query}`;
|
||||
const source = await fetch(reqUrl);
|
||||
const data = await source.json();
|
||||
return data;
|
||||
},
|
||||
keys: [ "codeZip", "nom" ],
|
||||
},
|
||||
resultList: {
|
||||
element: (list, data) => {
|
||||
}
|
||||
},
|
||||
resultItem: {
|
||||
highlight: true
|
||||
},
|
||||
debounce: 300,
|
||||
events: {
|
||||
input: {
|
||||
selection: (event) => {
|
||||
const selection = event.detail.selection.value;
|
||||
autoCompleteCommune.input.value = selection.codeZip + " - " + selection.nom ;
|
||||
codeInsee = selection.codeInsee;
|
||||
onSubmit: (res) => {
|
||||
const searchInput = $('#commune-autocomplete-input');
|
||||
searchInput.val(`${res.codeZip} - ${res.nom}`);
|
||||
$("#voieForm").collapse("show");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
codeInsee = res.codeInsee;
|
||||
},
|
||||
debounceTime: 300,
|
||||
renderResult: (res, props) => `<li ${props}>${res.codeZip} - ${res.nom}</li>`
|
||||
};
|
||||
const autocompleteCommune = new Autocomplete("#commune-autocomplete", communeAutocompleteOptions);
|
||||
|
||||
const autoCompleteFantoir = new autoComplete({
|
||||
selector: "#fantoir-autocomplete",
|
||||
placeHolder: "Nom de la voie...",
|
||||
data: {
|
||||
src: async (query) => {
|
||||
const api = "addresses/fantoirvoies/" + codeInsee + "?limit=100";
|
||||
const reqUrl = query === '' ? api : api + "&s=" + query
|
||||
const source = await fetch(reqUrl, { signalVoies });
|
||||
const voieAutocompleteOptions = {
|
||||
search: async (query) => {
|
||||
const api = `addresses/fantoirvoies/${codeInsee}?limit=100`;
|
||||
const reqUrl = query === '' ? api : `${api}&s=${query}`;
|
||||
const source = await fetch(reqUrl);
|
||||
const data = await source.json();
|
||||
return Object.entries(data).map(e => {return {"name": e[0], "value": e[1]}; });
|
||||
},
|
||||
keys: [ "name" ],
|
||||
},
|
||||
resultList: {
|
||||
element: (list, data) => {
|
||||
}
|
||||
},
|
||||
resultItem: {
|
||||
highlight: true
|
||||
},
|
||||
debounce: 300,
|
||||
events: {
|
||||
input: {
|
||||
selection: (event) => {
|
||||
const selection = event.detail.selection.value;
|
||||
autoCompleteFantoir.input.value = selection.name;
|
||||
codeRivoli = selection.value;
|
||||
onSubmit: (res) => {
|
||||
const searchInput = $("#street-name-autocomplete-input");
|
||||
searchInput.val(res.name);
|
||||
codeRivoli=res.value;
|
||||
$('#btnTestAdresse').collapse('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
debounceTime: 300,
|
||||
renderResult: (res, props) => `<li ${props}>${res.name}</li>`
|
||||
};
|
||||
const autocompleteVoie = new Autocomplete("#street-name-autocomplete", voieAutocompleteOptions);
|
||||
$('#formAddressTest').submit(function(eventObj) {
|
||||
setButtonSpinner("#btnTestAdresse", "Test...");
|
||||
$('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeInsee" value="${codeInsee}" />`);
|
||||
|
|
|
@ -99,3 +99,57 @@ td {
|
|||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
/*
|
||||
********************
|
||||
Form Styles
|
||||
*******************
|
||||
*/
|
||||
|
||||
#commune-form {
|
||||
margin-top: 2em;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#commune-autocomplete {
|
||||
margin-left: 1em;
|
||||
width: 65%;
|
||||
}
|
||||
|
||||
#voieFormContent {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#voieFormContent > div {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
#street-number-form {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
#street-name-form {
|
||||
width: 51%;
|
||||
}
|
||||
|
||||
#numeroVoieInput {
|
||||
padding: 12px;
|
||||
height: 3em;
|
||||
}
|
||||
|
||||
#btnTestAdresseContainer {
|
||||
margin-top: 2em;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue