From: Eric Fayolle Date: Mon, 25 Mar 2024 09:55:05 +0000 (+0100) Subject: Mise au point des nvlles interractions avec les event eficas X-Git-Tag: V_demo_28_mars_2024~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0943c92bcda50e02383fdee072bc135a6f59d3f4;p=tools%2Feficas.git Mise au point des nvlles interractions avec les event eficas --- diff --git a/Web/mdm2.py b/Web/mdm2.py index 69dc952c..bc145480 100755 --- a/Web/mdm2.py +++ b/Web/mdm2.py @@ -28,12 +28,10 @@ from markupsafe import escape from flask_sse import sse app = Flask(__name__) -app.secret_key = 'EssaiPN' # CATALOGS_EXT=("py","jpg") #TODO : supprimer jpg pour test # catalogs = UploadSet("catalogs",CATALOGS_EXT) # app.config["UPLOADED_CATALOGS_DEST"] = "data/catalogs" -# app.config["SECRET_KEY"] = os.urandom(24) # configure_uploads(app, catalogs) @@ -88,9 +86,11 @@ app.fromConnecteur=fromConnecteur # - ReAffichage d'un noeud (et ses enfants) # - Changement d'un nom de mot-cle reference -def propageValide(sId, id, valid): #TODO: RENAME TO ... propagateValidation +def propageValide(eId, id, valid): #TODO: RENAME TO ... propagateValidation +#def propageValide(eId, cId, id, valid): #TODO: RENAME TO ... propagateValidation print ('Flask/propageValide: ', id, valid) sse.publish( {'id':id, 'valid':valid, 'message': "Hello from propageValide!"}, type='propageValide') +# sse.publish( {'eId':eId, 'id':id, 'valid':valid, 'message': "Hello from propageValide!"}, type='propageValide', channel=cId) def updateNodeInfo(sId, id, info): print ('Flask/updateNodeInfo', sId, id, info, session['eficasSession']) @@ -239,7 +239,7 @@ def index(): print ('_______________________________________________') print (session) print ('_______________________________________________') - (eficasSession, codeErreur, message) =eficasAppli.getSessionId() + (eficasSession, codeErreur, message) = eficasAppli.getSessionId() debug=1 if not codeErreur : session['eficasSession'] = eficasSession @@ -249,14 +249,19 @@ def index(): if not(eficasEditor) : return render_template('commandes_2.html', titre='Pb a l enrolement ', + # efi_update_chanel, listeCommandes = [], - tree= None + tree= None ) cataFile = os.path.abspath('../Codes/WebTest/cata_essai.py') dataSetFile = os.path.abspath('../Codes/WebTest/web_tres_simple_avec_2Fact.comm') if eficasSession == 3: dataSetFile = os.path.abspath('../Codes/WebTest/web_tres_simple_incomplet.comm') (eficasEditor, codeErreur, message) = eficasAppli.getWebEditor(eficasSession, cataFile, dataSetFile) + # ((N°canal_maj, N°eficasEditor), codeErreur, message) = eficasAppli.getWebEditor(eficasSession, cataFile, dataSetFile) + # ((N°canal_maj, N°eficasEditor), codeErreur, message) = eficasAppli.getWebEditor(eficasSession, cataFile, dataSetFile) + # ((N°canal_maj, N°eficasEditor), codeErreur, message) = eficasAppli.getWebEditor(eficasSession, cataFile, dataSetFile) + # ((N°canal_maj, N°eficasEditor), codeErreur, message) = eficasAppli.getWebEditor(eficasSession, cataFile, dataSetFile) # TODO : separer les erreurs ouverture cata / ouvertur fichier if debug : print ('dans index : eficasEditor : ', eficasEditor, ' code Erreur : ', codeErreur,'message : ', message) if not codeErreur : @@ -266,8 +271,9 @@ def index(): if not(eficasEditor) : return render_template('commandes_2.html', titre='Pb a l enrolement ', + # efi_update_chanel = efi_update_chanel, listeCommandes = [], - tree= None + tree= None ) if not(eficasEditor) : @@ -298,6 +304,7 @@ def index(): return render_template('commandes_2.html', titre=code, + # efi_update_chanel = efi_update_chanel, listeCommandes = eficasEditor.getListeCommandes(), tree=myFancyTreeJS, # tree=tree4Fancy, diff --git a/Web/templates/commandes_2.html b/Web/templates/commandes_2.html index bce1014e..f0505e5d 100644 --- a/Web/templates/commandes_2.html +++ b/Web/templates/commandes_2.html @@ -266,7 +266,7 @@ function callService(msgCssSelStr, serviceName, obj) { 'use strict'; const success = function(data, status) { - let message="Successfull "+serviceName+" call with status : " + status; + let message="Successfull call for "+serviceName+" with status : " + status; treeMessage(msgCssSelStr,"alert-success",message) ; }; @@ -283,6 +283,7 @@ function callService(msgCssSelStr, serviceName, obj) { }); }; +// Les fonctions clickOn sont associées aux balises html function clickOnRemove(treeCssSelStr, msgCssSelStr, key ) { 'use strict'; const tree = $.ui.fancytree.getTree(treeCssSelStr); @@ -480,30 +481,46 @@ function sendUpdateSimp(treeCssSelStr, msgCssSelStr, node, eltNameWithValue) { let checkCallBack = function(data) { // Tester data == NULL ! - const changeIsAccepted = data.changeIsAccepted; - const wValue = data.source['wValue']; - const validite = data.source['validite']; - const rMessage = data.message + // const changeIsAccepted = data.changeIsAccepted; + const errorCode = data.errorCode; + const msgLevel = data.msgLevel; + const rMessage = data.message; + const wValue = data.source['wValue']; + const validite = data.source['validite']; //node.fromDict() //source=JSON.parse(getTree1()) - if ( changeIsAccepted ) { - // Il faudrait gérer les représentations des types pour activer cet assert (ex: string vs int) - // or on laisse le kernel eficas vérifier des strings. - // $.ui.fancytree.assert(value == wValue); - node.data.wValue = wValue - node.data.validite = validite - let message = "Changing SIMP "+node.title+" value to "+value+" has been accepted ("+rMessage+")"; - treeMessage(msgCssSelStr,"alert-success",message); - //node.data = data.source ?? A priori, il est inutile d'essayer de remplacer la source complète du noeud - console.log('wValue : '+ node.data.wValue); - console.log('validite : '+validite); - } else { - // TODO: Gérer le input pour laisser le focus et passer en rouge ? + if ( errorCode != undefined && + errorCode != 0 ) { + // TODO: Gérer le input pour laisser le focus et passer en rouge ? Non ou bien rouge avec délai ! let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, value |"+value+"| has not been accepted ("+rMessage+")"; treeMessage(msgCssSelStr,"alert-warning",message); + treeMessage(_msgCssSelStr,msgLevel,rMessage); + return; + }; + + if ( rMessage == undefined) rMessage=''; + if ( wValue == undefined) { + let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, wValue is undefined ("+rMessage+")"; + treeMessage(msgCssSelStr,"alert-danger",message); + }; + if ( validite == undefined) { + let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, validite is undefined ("+rMessage+")"; + treeMessage(msgCssSelStr,"alert-danger",message); }; + + // Il faudrait gérer les représentations des types pour activer cet assert (ex: string vs int,double,...) + // or on laisse le kernel eficas vérifier des strings (ex. PI). + // $.ui.fancytree.assert(value == wValue); + node.data.wValue = wValue; + node.data.validite = validite; + let message = "Changing SIMP "+node.title+" value to "+value+" has been accepted ("+rMessage+")"; + treeMessage(msgCssSelStr,"alert-success",message); + //node.data = data.source ?? A priori, il est inutile d'essayer de remplacer la source complète du noeud + console.log('wValue : '+ node.data.wValue); + console.log('validite : '+validite); //alert("sendUpdateSimp-2"); + node.render(true,false); //force rendering the node (not parents nor descendants) // if (eltNameWithValue != 'select') node.render(true,false); //force rendering the node (not parents nor descendants) //node.renderStatus(); //CSS element updates @@ -532,11 +549,21 @@ function sendNewDataset(catalogName, datasetName) { let _treeCssIdTab; let _treeCssIdNav; let _treeCssSelStr; - const source = data.source; - const commands = data.commands; - const title = data.title; - const rMessage = data.message; - console.log(source); + + const errorCode = data.errorCode; + const msgLevel = data.msgLevel; + const rMessage = data.message; + const source = data.source; + const commands = data.commands; + const title = data.title; + + if ( errorCode != undefined && + errorCode != 0 ) { + treeMessage(_msgCssSelStr,msgLevel,rMessage); + return; + }; + + //console.log(source); // //tree.destroy(); // let message = "New Dataset has been loaded ("+rMessage+")"; @@ -547,15 +574,20 @@ function sendNewDataset(catalogName, datasetName) { // efiNewTab("tree1"); // $("#tree1").fancytree(efiFancytreeOptions("#tree1",source)); - _treeId=efiNewTab(catalogName, datasetName,commands); + _treeId = efiNewTab(catalogName, datasetName,commands); _treeCssSelStr = '#'+_treeId; _treeCssIdTab = _treeCssSelStr+'Tab'; _treeCssIdNav = _treeCssSelStr+'Nav'; + $("#Welcome").hide() + $(_treeCssSelStr).fancytree(efiFancytreeOptions(_treeCssSelStr,source)); + createNewSetOfEvents(_treeCssSelStr,'#tree1-messages'); + console.log($(_treeCssIdNav)); $('.nav-tabs a[href="'+_treeCssIdTab+'"]').tab('show') + //$(_treeCssIdNav).tab('show'); // if ( tree == null) { // let message = "Unsuccessfull sendNewDataset processing. Tree ("+_treeCssSelStr+") returned (null)" ; @@ -564,10 +596,6 @@ function sendNewDataset(catalogName, datasetName) { // }; let message = "New Dataset has been loaded ("+rMessage+")"; - - //TODO : Gérer les commandes - //TODO : Gérer le titre/code - }; //alert("sendNewDataset-1"); @@ -593,6 +621,28 @@ source.addEventListener('message', function(event) { alert(message); }, false); +// --- displayMessage --- +(function (treeCssSelStr, msgCssSelStr) { + 'use strict'; + source.addEventListener('displayMessage', function(event) { + const data = JSON.parse(event.data); + const color = data.color; + const message = data.message; + const messageClass = data.messageClass; + const _message = "The server says " + message; + //const tree = $.ui.fancytree.getTree(_treeCssSelStr); + //const _rootNode = tree.rootNode.children[0]; + //const _eId = _rootNode.data.eId; + + //if ( eId != _eId ) return; //TODO:Lorsque l'on modifiera Flask/affiche{Message/Alerte} + if ( messageClass == 'alert-danger' ) { + alert(_message); + } else { + treeMessage(msgCssSelStr,messageClass,_message); + }; + }, false); +})('','#tree1-messages'); //TODO: Changer la balise + // --- propageValid --- function createNewSetOfEvents(treeCssSelStr, msgCssSelStr) { @@ -619,7 +669,7 @@ function createNewSetOfEvents(treeCssSelStr, msgCssSelStr) { if (node == null) { treeMessage(_msgCssSelStr,"alert-danger",msgerror); return; - }; + }; node.data.validite=valid; //TODO : ?? Pas encore réussi à tester ... ?? //alert("propageValid"); node.render(true,false); //force rendering the node (not parents nor descendants) @@ -627,27 +677,27 @@ function createNewSetOfEvents(treeCssSelStr, msgCssSelStr) { }, false); })(treeCssSelStr,'#tree1-messages'); - // --- displayMessage --- - (function (treeCssSelStr, msgCssSelStr) { - 'use strict'; - source.addEventListener('displayMessage', function(event) { - const data = JSON.parse(event.data); - const id = data.id; - const eId = data.eId; - const txt = data.txt; - const color = data.color; - const message = data.message; - const messageClass = data.messageClass; - const _message = "The server says " + data.message; - const tree = $.ui.fancytree.getTree(_treeCssSelStr); - const _rootNode = tree.rootNode.children[0]; - const _eId = _rootNode.data.eId; + // // --- displayMessage --- + // (function (treeCssSelStr, msgCssSelStr) { + // 'use strict'; + // source.addEventListener('displayMessage', function(event) { + // const data = JSON.parse(event.data); + // const id = data.id; + // const eId = data.eId; + // const txt = data.txt; + // const color = data.color; + // const message = data.message; + // const messageClass = data.messageClass; + // const _message = "The server says " + data.message; + // const tree = $.ui.fancytree.getTree(_treeCssSelStr); + // const _rootNode = tree.rootNode.children[0]; + // const _eId = _rootNode.data.eId; - if ( eId != _eId ) return; - treeMessage(_msgCssSelStr,messageClass,_message); - treeMessage(_msgCssSelStr,messageClass,txt); - }, false); - })(treeCssSelStr,'#tree1-messages'); + // if ( eId != _eId ) return; //TODO:Lorsque l'on modifiera Flask/affiche{Message/Alerte} + // treeMessage(_msgCssSelStr,messageClass,_message); + // treeMessage(_msgCssSelStr,messageClass,txt); + // }, false); + // })(treeCssSelStr,'#tree1-messages'); // --- updateNodeInfo --- (function (treeCssSelStr, msgCssSelStr) { diff --git a/Web/templates/file_management.html b/Web/templates/file_management.html index 3e11fdb9..15ed9f3a 100644 --- a/Web/templates/file_management.html +++ b/Web/templates/file_management.html @@ -4,10 +4,11 @@