From: Eric Fayolle Date: Mon, 24 Jan 2022 17:51:13 +0000 (+0100) Subject: Première implémentation des optionnels X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=03049a370d484f57e69e4d7b7def93a665f7a61a;p=tools%2Feficas.git Première implémentation des optionnels --- diff --git a/testFlask/mdm.py b/testFlask/mdm.py index 91717df2..eb32e1d5 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -3,14 +3,15 @@ import sys sys.path.append('/home/eric/FLASK/eficas.eecj.git/testFlask') from connectEficas import accasConnecteur + code='Essai' from flask import Flask, request, render_template, url_for, jsonify, make_response, session, g, Response # from flask import Flask, request, render_template, url_for, json, jsonify import json -import pprint +from pprint import pprint from forms import BasicForm -from collections import OrderedDict +from collections import OrderedDict from markupsafe import escape from flask_sse import sse @@ -49,7 +50,7 @@ def fromConnecteur(maFonction,*args,**kwargs): # gérer un appel register callback app.fromConnecteur=fromConnecteur -## SSE from Eficas signals : +## ServerSideEvent from Eficas signals : # - Validite # - Ajouter un noeud (et ses enfants) # - Supprimer un noeud (et ses enfants), @@ -169,14 +170,16 @@ def index(): # myNewTreeDico=OrderedDict([('text', 'MonProc2'), ('nodes', OrderedDict([('text', 'MonProc22'), ('nodes', [{'text': 'param1 1.0'}, [OrderedDict([('text', 'Fact1'), ('nodes', [{'text': 'param3 43.0'}])]), OrderedDict([('text', 'Fact1'), ('nodes', [{'text': 'param3 44.0'}])])]])]))]) # myNewTreeJS=json.dumps([myNewTreeDico]) - print("---- myTreeDico : ") - pprint.pprint(myTreeDico) - print("---- myTreeJS : ", myTreeJS) - print("---- tree4Fancy : ", tree4Fancy) + # print("---- myTreeDico : ") + # pprint.pprint(myTreeDico) + # print("---- myTreeJS : ", myTreeJS) + # print("---- tree4Fancy : ", tree4Fancy) # print("---- myNewTreeDico : ", myNewTreeDico) # print("---- myNewTreeJS : ", myNewTreeJS) - print("---- myFancyTreeDico : ", myFancyTreeDico) - print("---- myFancyTreeJS : ", myFancyTreeJS) + print("---- myFancyTreeDico ----") + pprint(myFancyTreeDico) + print("---- myFancyTreeJS ----") + pprint( myFancyTreeJS) return render_template('commandes_2.html', titre=code, @@ -228,6 +231,24 @@ def updateSimp(): #return make_response(jsonify({"message": "Request body must be JSON"}), 400) +@app.route("/removeNode", methods=['POST']) +def removeNode(): + # 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("/removeNode ",req);print("/removeNode ",req['id']); + id =req['id']; + ret,message = monConnecteur.suppNode(id); + print ("/removeNode : ret : ",ret," message : ",message) + + return make_response(json.dumps( {'ret':ret} )) + 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("/appendChild", methods=['POST']) def appendChild(): # Validate the request body contains JSON @@ -235,7 +256,7 @@ def appendChild(): # Parse the JSON into a Python dictionary req = request.get_json() # Print the dictionary - print(req);print(req['id']) + print(req);print(req['id']);print(req['name']);print(req['pos']) id=req['id'];name=req['name'];pos=req['pos']; # id, value = req.values() # Dangereux correspondance implicite #rId,message,changeDone = monConnecteur.appendChild(id,name,pos); diff --git a/testFlask/templates/base.html b/testFlask/templates/base.html index 61bb3c9e..c6f5262f 100644 --- a/testFlask/templates/base.html +++ b/testFlask/templates/base.html @@ -5,7 +5,10 @@ - + + + + diff --git a/testFlask/templates/commandes_2.html b/testFlask/templates/commandes_2.html index b1f06e9d..934c9e0d 100644 --- a/testFlask/templates/commandes_2.html +++ b/testFlask/templates/commandes_2.html @@ -7,7 +7,7 @@ - + @@ -23,556 +23,759 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - {% for commande in listeCommandes %} - -
- - - - - - - - -
- {% endfor %} -
-
- - - - -
-
-
DatasetName : {{titre}}
+ + + + + + + + - - - - - - - - - - - - - - - - - - -
Mot Clé Value
-
- -
-
Optionals
-
Essai
-
-
-
- - - - - - - - - -
....
- - - - -
-
- - {% endblock %} + +// # Différents tests : + +var tree1=$.ui.fancytree.getTree("#tree1") +a={ source: [ {title: "Node 1", key: "1000"},{title: "Folder 2", key: "2", folder: true, children: [ {title: "Node 2.1", key: "3000"},{title: "Node 2.2", key: "44"} ]} ], } +$("#Optionals").fancytree( a ) +ou +$.ui.fancytree.createTree('#Optionals', a) + +var tree2=$.ui.fancytree.getTree("#Optionals") +b=tree2.toDict() +$("#bebe").fancytree( { source: b} ) +$("#bebe").fancytree( { source: tree1.toDict()} ) +classeAccas == "MCSIMP" +p1=tree1.getNodeByKey("54930c427ad911ec90fb64c901d49bcd") +let myOpt=[} +p1.visit( (n)=>{if (n.data.classeAccas == "MCSIMP") {myOpt.push(n)}}, true) +------ + +var tree1=$.ui.fancytree.getTree("#tree1") +p1=tree1.getNodeByKey("721bcb347adc11ec8c2a64c901d49bcd") +opt=p1.data.infoOptionnels[0] + +var optNodes= opt.map((o)=>{return {'title':o} }) +optTreeSrc=[{'title': p1.title+' (optionals)', 'children': optNodes}]; +$optTree=$("#bebe").fancytree( { source: optTreeSrc} ) +optTree=$optTree.fancytree() +#var optTree=$.ui.fancytree.getTree("#bebe") +optTree.expandAll()