From: Eric F Date: Wed, 15 Dec 2021 23:02:02 +0000 (+0100) Subject: Connexion de propageValide X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c63334094e9a00e6a643ab452e92e026ae146f8;p=tools%2Feficas.git Connexion de propageValide --- diff --git a/testFlask/mdm.py b/testFlask/mdm.py index aa5de055..d775bd3d 100755 --- a/testFlask/mdm.py +++ b/testFlask/mdm.py @@ -51,15 +51,15 @@ app.fromConnecteur=fromConnecteur def propageValide(id, valid): #print ('dans propageValide: ', id, valid) - sse.publish({"idUnique" : id, "valid":valid, "message": "Hello from propageValide!"}, type='propageValide') + sse.publish( {'id':id, 'valid':valid, 'message': "Hello from propageValide!"}, type='propageValide') -def appendChildren(id, nodeList, pos): - print ('dans appendChildren: ', nodeList, pos) - sse.publish({'id':id, 'nodeList':nodeList, 'pos':pos, "message": "Hello from appendChildren!"}, type='appendChildren') +def appendChildren(id, fcyTreeJson, pos): + print ('dans appendChildren: ', fcyTreeJson, pos) + sse.publish( {'id':id, 'fcyTreeSrc':fcyTreeJson, 'pos':pos, 'message': "Hello from appendChildren!"}, type='appendChildren') def deleteChildren(idList): #print ('dans deleteChildren: ', idList) - sse.publish({"idList":idList,"message": "Hello from deleteChildren!"}, type='deleteChildren') + sse.publish( {'idList':idList,'message': "Hello from deleteChildren!"}, type='deleteChildren') # # Pour test curl # @app.route('/update') @@ -174,7 +174,7 @@ def index(): return render_template('commandes_2.html', titre=code, listeCommandes = monConnecteur.getListeCommandes(), - profondeur=4, + # profondeur=4, mcTraite={'MonProc2': {'s1': ('I', 2), 'F2': {'s2': ('I', 3), 'F3': {'s3': ('I', 4)}}}}, mcTraiteJson=json.dumps(mcTraite), tree=myFancyTreeJS, diff --git a/testFlask/templates/commandes_2.html b/testFlask/templates/commandes_2.html index 7c9ee805..3ab2dcbb 100644 --- a/testFlask/templates/commandes_2.html +++ b/testFlask/templates/commandes_2.html @@ -7,35 +7,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -90,19 +61,45 @@
+
+

Choose Object to add

+ + + + + + + + + + {% for commande in listeCommandes %} + +
+ + + + + + + + +
+ {% endfor %} +
-

My dataset

+

My Current dataset : {{titre}}

- - - - - - - - + + + + + + + + + @@ -140,65 +137,77 @@ var source = new EventSource("{{ url_for('sse.stream') }}"); - source.addEventListener('propageValide', function(event) { - var data = JSON.parse(event.data); - var message = data.message; + source.addEventListener('propageValide', function(event) { + const data = JSON.parse(event.data); + var id = data.id; + var valid = data.valid; + var message = data.message; // alert("The server says " + data.message); - console.log("The server says " + data.message); + console.log("The server says " + data.message +" , id: "+id); $("#tree1-messages").text(message); var tree=$.ui.fancytree.getTree("#tree1"); - var activeNode = tree.getActiveNode(); - //p1=tree.getNodeByKey('8304986a334211ec853cac220bca9aa6') + //var activeNode = tree.getActiveNode(); + node=tree.getNodeByKey(id); + node.data.validite=valid; //Pas encore réussi à tester ... + node.render(true,false); //force rendering the node (not parents nor descendants) + //node.renderStatus(); //CSS element updates + //activeNode.addChildren({ // title: "Document using a custom icon", // icon: "customdoc1.gif" //}); }, false); - source.addEventListener('appendChildren', function(event) { - var data = JSON.parse(event.data); - var id = data.id; - var nodeList = data.nodeList; - var pos = data.pos; - var message = data.message; + (function (treeCssSelStr, msgCssSelStr) { + let _treeCssSelStr = treeCssSelStr; //inutile + let _msgCssSelStr = msgCssSelStr; //inutile + var _tree = $.ui.fancytree.getTree(_treeCssSelStr); + source.addEventListener('appendChildren', function(event) { + const data = JSON.parse(event.data); + var id = data.id; + const source = data.fcyTreeSrc; + var pos = data.pos; + var message = data.message; //alert("The server says " + data.message); console.log("The server says " + data.message); - $("#tree1-messages").text(message); - var tree = $.ui.fancytree.getTree("#tree1"); + $(_msgCssSelStr).text(message); //var activeNode = tree.getActiveNode(); + console.log("_tree : "+ _tree); //? + var tree = $.ui.fancytree.getTree(_treeCssSelStr); node=tree.getNodeByKey(id) - node.addChildren(nodeList,pos); + node.addChildren(source,pos); - }, false); - - source.addEventListener('deleteChildren', function(event) { - var data = JSON.parse(event.data); - - var keyList = data.idList; - var message = data.message; - - - - - - - //alert("The server says " + data.message); - console.log("The server says " + data.message); - $("#tree1-messages").text(message); - var tree = $.ui.fancytree.getTree("#tree1"); - nodeList = keyList.map( (x) => { return tree.getNodeByKey(x) } ); - nodeList.map( (x) => { x.remove()} ); - - //tree.findAll(match); - //var activeNode = tree.getActiveNode(); - //activeNode.addChildren({ - // title: "Document using a custom icon", - // icon: "customdoc1.gif" - //}); + }, false); + })('#tree1','#tree1-messages'); + + source.addEventListener('deleteChildren', function(event) { + const data = JSON.parse(event.data); + + const keyList = data.idList; + var message = data.message; + + + + + + + //alert("The server says " + data.message); + console.log("The server says " + data.message); + $("#tree1-messages").text(message); + var tree = $.ui.fancytree.getTree("#tree1"); + nodeList = keyList.map( (x) => { return tree.getNodeByKey(x) } ); + nodeList.map( (x) => { x.remove()} ); + + //tree.findAll(match); + //var activeNode = tree.getActiveNode(); + //activeNode.addChildren({ + // title: "Document using a custom icon", + // icon: "customdoc1.gif" + //}); }, false); @@ -211,10 +220,10 @@ return {{ tree|tojson }}; } - function getTree2() { - // Some logic to retrieve, or generate tree structure - return {{ mcTraiteJson|tojson }}; - } + + + + @@ -260,9 +269,15 @@ // levelOfs: "1.5em" // Adjust this if ul padding != "16px" //}, icon: function(event, data) { - if( data.node.isFolder() ) { - return "glyphicon glyphicon-book"; - } + + + + if( data.node.data.classeAccas == "MCSIMP") { + return "glyphicon glyphicon-leaf"; + } else { + return "glyphicon glyphicon-list-alt"; + } + return "glyphicon glyphicon-list-alt"; }, table: { // Options for the table extension checkboxColumnIdx: 1, // Tree Nodes Checkboxes are rendered at column #1 (numbered from #0) @@ -306,15 +321,15 @@ //VALIDATION STATES - Bootstrap includes validation styles for error, warning, and success messages. //To use, add .has-warning, .has-error, or .has-success to the parent element if( node.data.validite ) { - _attr='has-success'; + _attr='has-success has-feedback'; // $(".fancytree-exp-n > td:nth-child(2) span").filter(".fancytree-checkbox").css('background-color','blue') $tdList.eq(1).find("span").filter(".fancytree-checkbox").css('background-color','#00ff00'); // Update the checkbox validation state TODO: create a CSS class } else { - _attr='has-error'; + _attr='has-error has-feedback'; //$tdList.eq(1).css('background-color','red'); // Update the checkbox validation state TODO: create a CSS class $tdList.eq(1).find("span").filter(".fancytree-checkbox").css('background-color','#ff0000'); // Update the checkbox validation state TODO: create a CSS class } //TODO: paramétrer l'attribut/framework - //console.log("node.data.validite, _attr :"+node.data.validite+" , "+_attr); + console.log("node.data.validite, _attr :"+node.data.validite+" , "+_attr); // $tdList.eq(3).html(""); $tdList.eq(3) .html( @@ -322,7 +337,7 @@ "
" + // "
" + // "
" + - ""+ //"
Valid.
"+ //"
Please fill out this field.
"+ @@ -332,7 +347,7 @@ .addClass(_attr) .find("input").css('color','black'); //TODO : A placer ds le CSS } else { - $tdList.eq(2).prop("colspan", 3).nextAll().remove(); //Merge unused columns for easy keyboard navigation + $tdList.eq(2).prop("colspan", 4).nextAll().remove(); //Merge unused columns for easy keyboard navigation return; } }, @@ -367,7 +382,8 @@ dataType : "json", // The callback function when the web service return success. success: function(data, status) { - alert("Successfully Value Sent: " + value + "\nStatus: " + status +"\ndata.changeIsAccepted :" +data.changeIsAccepted ); + + console.log("Successfully Value Sent: " + value + "\nStatus: " + status +"\ndata.changeIsAccepted :" +data.changeIsAccepted ); rChangeIsAccepted = data.changeIsAccepted; rValue = data.source['wValue']; rValidite = data.source['validite'];
Mot Clé Value