Interface client + gestion API (via ajax) pour le choix de sujets (identifiants) et le type 'données cellulaires'
This commit is contained in:
parent
3f5137ebd7
commit
bcc9b669b2
|
@ -260,4 +260,7 @@
|
|||
//
|
||||
// $db->close();
|
||||
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
var_dump( $db->index() );
|
||||
|
||||
?>
|
||||
|
|
Binary file not shown.
|
@ -25,13 +25,10 @@ $pers = $request->answer();
|
|||
<h4>Exporter les données au format .csv</h4>
|
||||
|
||||
<strong>Choix des sujets</strong><br>
|
||||
<article style='display: inline;'>
|
||||
<input type='number' data-name='subjects' placeholder='Sujet' style='width: 5em;'>
|
||||
<input type='number' data-name='subjects' placeholder='Sujet' style='width: 5em;'>
|
||||
<input type='number' data-name='subjects' placeholder='Sujet' style='width: 5em;'>
|
||||
<input type='number' data-name='subjects' placeholder='Sujet' style='width: 5em;'>
|
||||
<article style='display: inline;' id='subject-list'>
|
||||
<input type='number' data-name='subjects' placeholder='Sujet' style='width: 5em; display: block;'>
|
||||
</article>
|
||||
<input type='button' id='add-subject' class='primary hover' value='+' style='padding:.2em .6em;'>
|
||||
<input type='button' id='add-subject' class='primary' value='Ajouter +' style='padding:.2em .6em; margin: .5em'>
|
||||
|
||||
<br><br><br><strong>Types de données</strong><br><br>
|
||||
<input type='checkbox' data-name='phone' value='1' id='phone_0'><label for='phone_0'>Données cellulaires</label>
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
var exportDeflater=new FormDeflater(document.getElementById("export-form"),["input"],["data-name"]);$("#export-form #export-all").addEventListener("click",function(b){"1"==exportDeflater.deflate().phone&&api.send({path:"download/phone",subjects:[341]},function(a){if(0!=a.ModuleError)return!1;document.location=a.link})},!1);
|
||||
var subjectList=$("#subject-list"),subjectAdd=$("#add-subject"),exportDeflater=new FormDeflater(document.getElementById("export-form"),["input"],["data-name"]);subjectAdd.addEventListener("click",function(a){a=document.createElement("input");a.type="number";a.dataset.name="subjects";a.placeholder="Sujet";a.style="width: 5em; display: block;";subjectList.appendChild(a)},!1);
|
||||
$("#export-form #export-all").addEventListener("click",function(a){a=(new FormDeflater(subjectList,["input"],["data-name"])).deflate().subjects;for(var c=[],b=0;b<a.length;b++)0<a[b].length&&!isNaN(a[b])&&c.push(a[b]);"1"==exportDeflater.deflate().phone&&api.send({path:"download/phone",subjects:c},function(a){if(0!=a.ModuleError)return!1;document.location=a.link;Notification.success("OK","Lancement du t\u00e9l\u00e9chargement..")})},!1);
|
||||
|
|
|
@ -1,22 +1,53 @@
|
|||
|
||||
/* [0] Gestion de l'export
|
||||
=========================================================*/
|
||||
/* (0) Initialisation des variables */
|
||||
var subjectList = $('#subject-list');
|
||||
var subjectAdd = $('#add-subject');
|
||||
|
||||
var exportDeflater = new FormDeflater(
|
||||
document.getElementById('export-form'),
|
||||
['input'], // éléments à éviter (tagName)
|
||||
['data-name'] // Attributs par ordre de priorité
|
||||
);
|
||||
|
||||
/* (1) Gestion de l'ajout dynamique des sujets */
|
||||
subjectAdd.addEventListener('click', function(e){
|
||||
|
||||
// On ajoute un input de sujet à la liste
|
||||
var newElement = document.createElement('input');
|
||||
newElement.type = 'number';
|
||||
newElement.dataset.name = 'subjects';
|
||||
newElement.placeholder = 'Sujet';
|
||||
newElement.style = 'width: 5em; display: block;';
|
||||
|
||||
subjectList.appendChild(newElement);
|
||||
|
||||
}, false);
|
||||
|
||||
|
||||
/* (2) Export des données */
|
||||
$('#export-form #export-all').addEventListener('click', function(e){
|
||||
|
||||
// On récupère les données du formulaire
|
||||
// {1} On récupère la liste des ids des sujets //
|
||||
var subjectDeflater = new FormDeflater(subjectList, ['input'], ['data-name']);
|
||||
var subjectDeflated = subjectDeflater.deflate()['subjects'];
|
||||
|
||||
// {2} On supprime les valeurs incorrectes //
|
||||
var subjects = [];
|
||||
for( var i = 0 ; i < subjectDeflated.length ; i++ )
|
||||
if( subjectDeflated[i].length > 0 && !isNaN(subjectDeflated[i]) )
|
||||
subjects.push( subjectDeflated[i] );
|
||||
|
||||
|
||||
// {3} On récupère les types de données que l'on veut //
|
||||
var deflated = exportDeflater.deflate();
|
||||
|
||||
/* (1) Si téléchargement de données cellulaires */
|
||||
// {4} Si téléchargement de données cellulaires //
|
||||
if( deflated.phone == '1' ){
|
||||
|
||||
api.send({ 'path': 'download/phone', 'subjects': [341] }, function(res){
|
||||
|
||||
api.send({ 'path': 'download/phone', 'subjects': subjects }, function(res){
|
||||
|
||||
// Si erreur
|
||||
if( res.ModuleError != 0 )
|
||||
|
@ -24,6 +55,8 @@ $('#export-form #export-all').addEventListener('click', function(e){
|
|||
|
||||
// Sinon on lance le téléchargement
|
||||
document.location = res.link;
|
||||
|
||||
Notification.success('OK', 'Lancement du téléchargement..');
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue