diff --git a/R4.01_R4.A.10/td_tp/tp6/README.md b/R4.01_R4.A.10/td_tp/tp6/README.md index 5ad2eba..947af58 100644 --- a/R4.01_R4.A.10/td_tp/tp6/README.md +++ b/R4.01_R4.A.10/td_tp/tp6/README.md @@ -105,6 +105,5 @@ Le modèle utilise PDO, en php. Il vous faudra créér une table avec les attrib 1. Complétez le fichier index.php 2. Testez votre api à la ligne de commandes en utilisant `curl`. 3. Connectez votre application todolist avec l'api. - -Écrivez un module "abstrait" en javascript pour l'interaction -avec l'api. Ce module devra pouvoir être changer pour utiliser firebase **sans que l'application cliente ne change**. +4. Connectez votre api à l'application [todo](./src/todo-riot). Il faut + complétez le fichier api.js. Prenez soin de modifier le fichier `htaccess`. diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/app.riot b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/app.riot new file mode 100644 index 0000000..4910834 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/app.riot @@ -0,0 +1,74 @@ + + + + +

To Do List

+ + + + !todo.done).length} /> + + + +
+
+ +
diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/css/todo.css b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/css/todo.css new file mode 100644 index 0000000..3eb40e5 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/css/todo.css @@ -0,0 +1,16 @@ +p.todo { +display : flex; +justify-content : space-between; +} + +.done { + text-decoration: line-through; + color: #ccc; +} +.is-active { + color : #8EB901; +} +.delete { + background-color :#9B2318; +} + diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/htaccess b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/htaccess new file mode 100644 index 0000000..f7e41ee --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/htaccess @@ -0,0 +1,8 @@ + +RewriteEngine On +RewriteBase /~denis/web_2024/tp5/todo-riot/ # votre url +RewriteRule ^index\.html$ - [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . index.html [L] + diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/index.html b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/index.html new file mode 100644 index 0000000..987dcf2 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/index.html @@ -0,0 +1,56 @@ + + + + + Riot todo + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/js/api.js b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/js/api.js new file mode 100644 index 0000000..7adb203 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/js/api.js @@ -0,0 +1,45 @@ +export default function makeDataService(){ + let url = 'http://localhost/~denis/web_2024/tp5/api_php/todo/' + let service = { + getTodos : getTodos, + addTodo : addTodo, + removeTodo : removeTodo, + toggleTodo : toggleTodo, + }; + + async function getTodos() + { + let res = await fetch(url,{ + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + } + }) + ; + let json = await res.json(); + return json.results; + + + } + async function addTodo(todo) + { + const response = await fetch(url, { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + method: "POST", + body: JSON.stringify(todo) + }); + } + async function removeTodo(todo) + { + // TODO + } + async function toggleTodo(todo) + { + // TODO + } + + return service; +} diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-form.riot b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-form.riot new file mode 100644 index 0000000..a7d65bb --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-form.riot @@ -0,0 +1,31 @@ + +
+
+ + +
+
+ +
diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-list.riot b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-list.riot new file mode 100644 index 0000000..f7e6eee --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-list.riot @@ -0,0 +1,17 @@ + +
+
+

+ + props.remove(e,todo)}> +

+
+
+
+
diff --git a/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-nav.riot b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-nav.riot new file mode 100644 index 0000000..a310ab3 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp6/src/todo-riot/todo-nav.riot @@ -0,0 +1,12 @@ + + +