From: Eric Fayolle Date: Wed, 26 Jan 2022 10:28:37 +0000 (+0100) Subject: Ajout d'une méthode updateNodeInfo X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2258e839867dde7d2bad761f07dcc935f836dab0;p=tools%2Feficas.git Ajout d'une méthode updateNodeInfo --- diff --git a/testFlask/mdm.py b/testFlask/mdm.py index eb32e1d5..75c7a5d0 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -9,9 +9,9 @@ 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 -from pprint import pprint -from forms import BasicForm -from collections import OrderedDict +from pprint import pprint +from forms import BasicForm +from collections import OrderedDict from markupsafe import escape from flask_sse import sse @@ -26,7 +26,7 @@ from flask_sse import sse # """Flask subclass using the custom request class""" # request_class = MyReq -def createConnecteur(app): +def createConnecteur(app): monConnecteur=accasConnecteur(code, langue='ang',appWeb=app) return monConnecteur @@ -61,14 +61,18 @@ def propageValide(id, valid): #print ('Flask/propageValide: ', id, valid) sse.publish( {'id':id, 'valid':valid, 'message': "Hello from propageValide!"}, type='propageValide') +def updateNodeInfo(id, info): + #print ('Flask/updateNodeInfo: ', id, info) + sse.publish( {'id':id, 'info':info, 'message': "Hello from updateNodeInfo!"}, type='updateNodeInfo') + def appendChildren(id, 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 ('Flask/deleteChildren: ', idList) sse.publish( {'idList':idList,'message': "Hello from deleteChildren!"}, type='deleteChildren') - + # # Pour test curl # @app.route('/update') # def publish_update(): @@ -166,7 +170,8 @@ def index(): myFancyTreeDico=monConnecteur.getDicoForFancy(monConnecteur.monEditeur.tree.racine) myTreeJS=json.dumps([myTreeDico]) - myFancyTreeJS=json.dumps([myFancyTreeDico]) + # myFancyTreeJS=json.dumps([myFancyTreeDico]) + myFancyTreeJS=json.dumps([myFancyTreeDico],indent=4) #TODO : remove indent if not DEBUG # 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]) @@ -256,12 +261,12 @@ def appendChild(): # Parse the JSON into a Python dictionary req = request.get_json() # Print the dictionary - print(req);print(req['id']);print(req['name']);print(req['pos']) + print(__file__+"/appendChild : ",req); 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,pos); - print ("/appendChild : newId : ",newId) + print (__file__+"/appendChild : newId : ",newId) return make_response(json.dumps( {'id':newId} )) # return make_response(json.dumps( {'source':node, 'changeIsAccepted' : changeDone, 'message': message} )) diff --git a/testFlask/templates/base.html b/testFlask/templates/base.html index c6f5262f..4635a200 100644 --- a/testFlask/templates/base.html +++ b/testFlask/templates/base.html @@ -183,16 +183,26 @@