diff --git a/css/ens.css b/css/ens.css index e69de29..8bdbd70 100644 --- a/css/ens.css +++ b/css/ens.css @@ -0,0 +1,67 @@ +body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + margin: 0; + padding: 0; +} + +table { + border-collapse: collapse; + width: 100%; + margin-bottom: 20px; +} + +th, +td { + border: 1px solid #ddd; + padding: 8px; + text-align: left; +} + +th { + background-color: #f2f2f2; + font-weight: bold; + color: #333; +} + +tr:nth-child(even) { + background-color: #f2f2f2; +} + +tr:hover { + background-color: #ddd; +} + +/* Add some spacing around the table */ +#data-container { + padding: 20px; +} + +.gros-titre { + font-size: larger; + font-weight: bolder; +} + +.bulle-rouge{ + width: fit-content; + padding-top: 5px; + padding-left: 5px; + padding-right: 5px; + padding-bottom: 5px; + background-color: rgba(255, 0, 0, 0.283); + border-radius: 5px; + border-width: 2px; + border-color: rgba(255, 0, 0, 0.283); +} +.centre-txt{ + text-align: center; +} + +.color-red-tr{ + background-color: rgba(224, 54, 54, 0.482); + border-color: rgba(224, 54, 54, 0.482); +} +.centre-horizontal{ + margin: auto; + justify-content: center; +} \ No newline at end of file diff --git a/ens.php b/ens.php index 1dc47c8..524f3b8 100644 --- a/ens.php +++ b/ens.php @@ -5,9 +5,19 @@ include "_partials/_head.php"; ?> - +
+
+   __    ____   ___  _   _ /'/ ____  _  _  ___    __   
+  /__\  (  _ \ / __)( )_( )   (_  _)( \( )/ __)  /__\  
+ /(__)\  )   /( (__  ) _ (     _)(_  )  ( \__ \ /(__)\ 
+(__)(__)(_)\_) \___)(_) (_)   (____)(_)\_)(___/(__)(__)
+    
+ +
+ +
\ No newline at end of file diff --git a/index.php b/index.php index 8bc94e9..d6dc174 100644 --- a/index.php +++ b/index.php @@ -12,7 +12,7 @@ ?> -
+
    __    ____   ___  _   _ /'/ ____  _  _  ___    __   
   /__\  (  _ \ / __)( )_( )   (_  _)( \( )/ __)  /__\  
diff --git a/js/ens.js b/js/ens.js
index 70c4569..f7b2811 100644
--- a/js/ens.js
+++ b/js/ens.js
@@ -1,5 +1,4 @@
-
-    /*
+/*
 
     pour les docs afficher un truc du même acabit que la php :
         if (strtolower($extension) === 'pdf'):
@@ -11,22 +10,149 @@
     endif;
     */
 
-
 // fetch l'api et afficher tout ce qu'elle nous rend
 function querystring(key) {
-    var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
-    var r=[], m;
-    while ((m=re.exec(document.location.search)) != null) r[r.length]=m[1];
-    return r;
+  var re = new RegExp("(?:\\?|&)" + key + "=(.*?)(?=&|$)", "gi");
+  var r = [],
+    m;
+  while ((m = re.exec(document.location.search)) != null) r[r.length] = m[1];
+  return r;
 }
 
 
-async function gen_contenu(){
-    resp = await fetch("/annales/api.php/decomposer_ensemble?ensemble_id="+querystring("ensemble_id"));
-    data = await resp.json();
-
-    if(data["status"] == 1){
-        console.log(data);
+async function gen_contenu() {
+    try {
+      const response = await fetch('api.php/decomposer_ensemble?ensemble_id='+querystring("ensemble_id"));
+      const data = await response.json();
+      console.log(data);
+  
+      if (data.status === "1" && data.msg.documents.length > 0) {
+        const table = document.createElement('table');
+        const thead = document.createElement('thead');
+        const tbody = document.createElement('tbody');
+  
+        const headerRow = document.createElement('tr');
+        const idHeader = document.createElement('th');
+        idHeader.textContent = 'ID';
+        const titreHeader = document.createElement('th');
+        titreHeader.textContent = 'Titre';
+        const typeHeader = document.createElement('th');
+        typeHeader.textContent = 'Type';
+        const uploadPathHeader = document.createElement('th');
+        uploadPathHeader.textContent = 'Upload Path';
+        const previewHeader = document.createElement('th');
+        previewHeader.textContent = 'Preview';
+        const commentaireHeader = document.createElement('th');
+        commentaireHeader.textContent = 'Commentaire Auteur';
+        const exerciceHeader = document.createElement('th');
+        exerciceHeader.textContent = 'Exercices';
+  
+        headerRow.appendChild(idHeader);
+        headerRow.appendChild(titreHeader);
+        headerRow.appendChild(typeHeader);
+        headerRow.appendChild(uploadPathHeader);
+        headerRow.appendChild(previewHeader);
+        headerRow.appendChild(commentaireHeader);
+        headerRow.appendChild(exerciceHeader);
+  
+        thead.appendChild(headerRow);
+  
+        data.msg.documents.forEach(doc => {
+          const row = document.createElement('tr');
+          const idCell = document.createElement('td');
+          idCell.textContent = doc.id;
+          const titreCell = document.createElement('td');
+          titreCell.textContent = doc.titre;
+          const typeCell = document.createElement('td');
+          typeCell.textContent = doc.type;
+          const uploadPathCell = document.createElement('td');
+          uploadPathCell.textContent = doc.upload_path;
+  
+          let previewCell;
+          let ext = doc.upload_path.toString().split(".").pop();
+  
+          switch (ext) {
+            case "jpg": // image
+              previewCell = document.createElement('td');
+              const img = document.createElement('img');
+              img.src = doc.upload_path;
+              img.alt = doc.titre;
+              previewCell.appendChild(img);
+              break;
+            case "pdf": // pdf
+              previewCell = document.createElement('td');
+              const pdfLink = document.createElement('a');
+              pdfLink.href = doc.upload_path;
+              pdfLink.textContent = 'View PDF';
+              pdfLink.target = '_blank';
+              previewCell.appendChild(pdfLink);
+              break;
+            case "mp4": // video
+              previewCell = document.createElement('td');
+              const video = document.createElement('video');
+              video.src = doc.upload_path;
+              video.controls = true;
+              previewCell.appendChild(video);
+              break;
+            default: // link
+              previewCell = document.createElement('td');
+              const link = document.createElement('a');
+              link.href = doc.upload_path;
+              link.textContent = doc.titre;
+              link.target = '_blank';
+              previewCell.appendChild(link);
+              break;
+          }
+  
+          const commentaireCell = document.createElement('td');
+          commentaireCell.textContent = data.msg.commentaire_auteur || '';
+  
+          const exerciceCell = document.createElement('td');
+          if (doc.exercices && doc.exercices.length > 0) {
+            const exerciceList = document.createElement('ul');
+            doc.exercices.forEach(exercice => {
+              const exerciceItem = document.createElement('li');
+              exerciceItem.textContent = `Exo n°${exercice.id} ${exercice.commentaire_auteur}, Duree: ${exercice.duree}`;
+              exerciceList.appendChild(exerciceItem);
+            });
+            exerciceCell.appendChild(exerciceList);
+          } else {
+            exerciceCell.textContent = 'Pas de détails sur les exercices';
+          }
+  
+          row.appendChild(idCell);
+          row.appendChild(titreCell);
+          row.appendChild(typeCell);
+          row.appendChild(uploadPathCell);
+          row.appendChild(previewCell);
+          row.appendChild(commentaireCell);
+          row.appendChild(exerciceCell);
+  
+          tbody.appendChild(row);
+        });
+  
+        table.appendChild(thead);
+        table.appendChild(tbody);
+  
+        const dataContainer = document.getElementById('data-container');
+        dataContainer.appendChild(table);
+      } else {
+        const dataContainer = document.getElementById('data-container');
+        dataContainer.textContent = data.msg;
+      }
+    } catch (error) {
+      console.error(error);
+      alert(error);
     }
-    
-}
\ No newline at end of file
+}
+
+
+document.addEventListener("DOMContentLoaded", (event)=>{
+
+    gen_contenu();
+
+  document.getElementById("titre").addEventListener("click", (event) => {
+    window.location.pathname = "/archinsa";
+  });
+
+});
\ No newline at end of file
diff --git a/js/index.js b/js/index.js
index c97dc49..9e0f80d 100644
--- a/js/index.js
+++ b/js/index.js
@@ -178,5 +178,9 @@ document.addEventListener("DOMContentLoaded", (event)=>{
         unauthenticate_user();
     });
 
+    document.getElementById("titre").addEventListener("click", (event) => {
+        window.location.pathname = "/archinsa";
+    });
+
 });
 
diff --git a/js/televerser.js b/js/televerser.js
index 245bcef..0df35c2 100644
--- a/js/televerser.js
+++ b/js/televerser.js
@@ -269,5 +269,9 @@ document.addEventListener("DOMContentLoaded", (event) => {
         ajouter_details_exo();
     });
 
+    document.getElementById("titre").addEventListener("click", (event) => {
+        window.location.pathname = "/archinsa";
+    });
+
 });
 
diff --git a/televerser.php b/televerser.php
index c2fed88..0b3a62b 100644
--- a/televerser.php
+++ b/televerser.php
@@ -12,7 +12,7 @@ include('php-csrf.php');
 $csrf = new CSRF();
 ?>
 
-
+
    __    ____   ___  _   _ /'/ ____  _  _  ___    __   
   /__\  (  _ \ / __)( )_( )   (_  _)( \( )/ __)  /__\