From 81391ce49b0fbbc45d03d3b8f924f26ca6beb2f8 Mon Sep 17 00:00:00 2001 From: Eric Fayolle Date: Thu, 13 Jan 2022 14:27:28 +0100 Subject: [PATCH] =?utf8?q?Ajout=20de=20commandes=20au=20premier=20niveau,?= =?utf8?q?=20ajout=20d'un=20menu=20g=C3=A9n=C3=A9ral?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- testFlask/mdm.py | 49 ++++++++--- testFlask/templates/base.html | 42 +++++++++ testFlask/templates/commandes_2.html | 125 +++++++++++++++++++++------ 3 files changed, 179 insertions(+), 37 deletions(-) diff --git a/testFlask/mdm.py b/testFlask/mdm.py index d775bd3d..4782e896 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -49,16 +49,23 @@ def fromConnecteur(maFonction,*args,**kwargs): # gérer un appel register callback app.fromConnecteur=fromConnecteur +## SSE from Eficas signals : +# - Validite +# - Ajouter un noeud (et ses enfants) +# - Supprimer un noeud (et ses enfants), +# - ReAffichage d'un noeud (et ses enfants) +# - Changement d'un nom de mot-cle reference + def propageValide(id, valid): - #print ('dans propageValide: ', id, valid) + #print ('Flask/propageValide: ', id, valid) sse.publish( {'id':id, 'valid':valid, 'message': "Hello from propageValide!"}, type='propageValide') def appendChildren(id, fcyTreeJson, pos): - print ('dans appendChildren: ', fcyTreeJson, pos) + print ('Flask/appendChildren: ', id, fcyTreeJson, pos) sse.publish( {'id':id, 'fcyTreeSrc':fcyTreeJson, 'pos':pos, 'message': "Hello from appendChildren!"}, type='appendChildren') def deleteChildren(idList): - #print ('dans deleteChildren: ', idList) + #print ('Flask/deleteChildren: ', idList) sse.publish( {'idList':idList,'message': "Hello from deleteChildren!"}, type='deleteChildren') # # Pour test curl @@ -184,7 +191,7 @@ def index(): ) # etape = str(escape(request.args.get("etape", ""))) -## WebApp -> Eficas (signaux) : +## WebApp -> Eficas : # Pour SIMP : Ajoute, Supprime (MC facultatif), Change la valeur # Pour FACT : Ajoute, Supprime # Pour PROC : Ajoute, Supprime @@ -200,8 +207,8 @@ def updateSimp(): print(req) print(req['id']) id=req['id'];value=req['value'] - # id, value = req.values() # Dangereux correspondance implicite - value = str(value) #Oups PN + # id, value = req.values() # Dangereux correspondance implicite + value = str(value) #On peut écrire Pi rId,message,changeDone = monConnecteur.changeValeur(id,value); assert(rId==id) #changeDone = True @@ -220,12 +227,30 @@ def updateSimp(): return "Request was not JSON", 400 #return make_response(jsonify({"message": "Request body must be JSON"}), 400) -## SSE from Eficas signals : -# - Validite -# - Ajouter un noeud (et ses enfants) -# - Supprimer un noeud (et ses enfants), -# - ReAffichage d'un noeud (et ses enfants) -# - Changement d'un nom de mot-cle reference + +@app.route("/appendChild", methods=['POST']) +def appendChild(): + # Validate the request body contains JSON + if request.is_json: + # Parse the JSON into a Python dictionary + req = request.get_json() + # Print the dictionary + print(req);print(req['id']) + id=req['id'];name=req['name'];pos=req['pos']; + # id, value = req.values() # Dangereux correspondance implicite + #rId,message,changeDone = monConnecteur.appendChild(id,name,pos); + newId = monConnecteur.appendChild(id,name,'last'); #pos + print ("/appendChild : newId : ",newId) + + return make_response(json.dumps( {'id':newId} )) + # return make_response(json.dumps( {'source':node, 'changeIsAccepted' : changeDone, 'message': message} )) + # Return a string along with an HTTP status code + # return "JSON received!", 200 + else: + # The request body wasn't JSON so return a 400 HTTP status code + return "Request was not JSON", 400 + #return make_response(jsonify({"message": "Request body must be JSON"}), 400) + @app.route("/forward/", methods=['POST']) def move_forward(): diff --git a/testFlask/templates/base.html b/testFlask/templates/base.html index 69d63fa7..2bd6dd72 100644 --- a/testFlask/templates/base.html +++ b/testFlask/templates/base.html @@ -155,8 +155,50 @@ + + +
{% block content %} {% endblock %}
+ + + diff --git a/testFlask/templates/commandes_2.html b/testFlask/templates/commandes_2.html index 3ab2dcbb..88e6828d 100644 --- a/testFlask/templates/commandes_2.html +++ b/testFlask/templates/commandes_2.html @@ -25,7 +25,8 @@
-

MyDataModel : Testing the WebAPP approach

+ + @@ -62,7 +63,8 @@
-

Choose Object to add

+ + @@ -74,7 +76,7 @@ {% for commande in listeCommandes %} -
+
@@ -111,9 +113,9 @@
-

Messages

-
Ouuuu -
+

Messages

+
....
+
@@ -134,14 +136,77 @@