if debug : print("Flask/updateSimp request['id'] : ",req['id'])
eId = req['eId'];id=req['id'];value=req['value']
# id, value = req.values() # Dangereux correspondance implicite
- value = str(value) # L'utilisateur peut écrire la valeur Pi
+ value = str(value) # L'utilisateur peut écrire la valeur Pi
(eficasEditor, errorCode, errorMsg, infoMsg) = eficasAppli.getWebEditorById(session['canalId'],eId)
if errorCode :
if errorCode :
msgLevel = "alert-danger"
message = errorMsg + infoMsg
- return make_response(json.dumps( {'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} ))
+ #Ds le cas d'un SIMP il faut renvoyer le node
+ return make_response(json.dumps( {'source':node, 'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} ))
if infoMsg != "" : msgLevel = 'alert-success'
else : msgLevel = "alert-info"
return make_response(json.dumps( {'source':node, 'errorCode' : errorCode, 'message': infoMsg,'msgLevel':msgLevel} ))
message = errorMsg + infoMsg
return make_response(json.dumps( {'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} ))
- (errorCode, errorMsg, infoMsg) = eficasEditor.removeNode(session['canalId'],session['externEditorId'],id);
+ (errorCode, errorMsg, infoMsg) = eficasEditor.removeNode(session['canalId'],eId,id);
if debug : print ("Flask/removeNode : errorCode : ",errorCode," errorMsg, : ",errorMsg, "infoMsg", infoMsg)
if errorCode :
msgLevel = "alert-danger"
message = errorMsg + infoMsg
- ret = False #TODO: à Supprimer
+ #ret = False #TODO: à Supprimer
else :
msgLevel = "alert-success"
message = infoMsg
- ret = True #TODO: à Supprimer
+ #ret = True #TODO: à Supprimer
- return make_response(json.dumps( {'ret':ret, 'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} ))
+ return make_response(json.dumps( { 'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} ))
+ #return make_response(json.dumps( {'ret':ret, 'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} ))
else:
# The request body wasn't JSON so return a 400 HTTP status code
return "Request was not JSON", 400
msgLevel = "alert-success"
message = ""
+ #TODO PN: Je n'utilise pas le newId, est-ce normal ?
return make_response(json.dumps( {'id':newId, 'errorCode' : errorCode, 'message': message,'msgLevel':msgLevel} )) #TODO: Code Erreur
# return make_response(json.dumps( {'source':node, 'changeIsAccepted' : changeDone, 'message': message} ))
# Return a string along with an HTTP status code
$(msgCssSelStr).addClass(messageClass);
if ( messageClass == "alert-danger" ) {
$.ui.fancytree.error(message); // debugLevel >= 1
+ // alert(message); // Activer lorsque la mise au point sera achevée.
} else if ( messageClass == "alert-warning" ) {
$.ui.fancytree.warn(message); // debugLevel >= 2
} else if ( messageClass == "alert-info" ) {
// Les fonctions clickOn sont associées aux balises html
function clickOnRemove(treeCssSelStr, msgCssSelStr, key ) {
'use strict';
+
const tree = $.ui.fancytree.getTree(treeCssSelStr);
const _key = key;
if ( tree == null) {
let message = "Unsuccessfull removeNode tree selection ("+treeCssSelStr+") returned (null)";
- alert(message) ;
+ treeMessage(msgCssSelStr,"alert-danger",message) ;
+ alert(message) ; // A supprimer lorsque ce sera activé ds treeMssage
return;
};
const _rootNode = tree.rootNode.children[0];
- const _eId=_rootNode.data.eId;
+ const _eId =_rootNode.data.eId;
if ( key === undefined || key == "") {
activeNode = tree.activeNode;
};
const checkCallBack = function(data) {
- // Tester data == NULL (?None python?)!
- const ret = data['ret'];
- if ( ret == 0 | ret == null ) {
- let message = "Unsuccessfull removeNode processing for key " + _key + ". Service removeNode has returned an error ("+data.message+")";
- treeMessage(msgCssSelStr,"alert-danger",message) ;
+ const errorCode = data.errorCode;
+ const msgLevel = data.msgLevel;
+ const rMessage = data.message;
+
+ if ( errorCode != undefined && errorCode != 0 ) {
+ let message = "Unsuccessfull removeNode processing for key " + _key + ". Service removeNode has returned an error ("+rMessage+")";
+ treeMessage(msgCssSelStr,"alert-warning",message);
+ treeMessage(msgCssSelStr,msgLevel,rMessage);
+ return;
};
+
+ let message = "Successfull removeNode processing for key " + _key + ". Service removeNode has returned ("+rMessage+")";
+ treeMessage(msgCssSelStr,msgLevel,message) ;
};
return callService(msgCssSelStr, 'removeNode', {eId:_eId, id: _key} ).done( (data)=>checkCallBack(data) );
function clickOnRemoveRef(treeCssSelStr, msgCssSelStr, key ) {
'use strict';
+
const tree = $.ui.fancytree.getTree(treeCssSelStr);
const _key = key;
if ( tree == null) {
return;
};
const _rootNode = tree.rootNode.children[0];
-
+ const _eId =_rootNode.data.eId;
+
if ( key == "") {
activeNode = tree.activeNode;
if ( activeNode != null) {
};
};
- const checkCallBack = function(data) {
- // Tester data == NULL !
- ret = data['ret'];
- if ( ret == 0 | ret == null ) {
- let message = "Unsuccessfull removeNode processing for key " + _key + ". Service removeNode has returned an error ("+data.message+")";
- treeMessage(msgCssSelStr,"alert-danger",message) ;
+ const checkCallBack = function(data) {
+ const errorCode = data.errorCode;
+ const msgLevel = data.msgLevel;
+ const rMessage = data.message;
+
+ if ( errorCode != undefined && errorCode != 0 ) {
+ let message = "Unsuccessfull removeRef processing for key " + _key + ". Service removeRef has returned an error ("+rMessage+")";
+ treeMessage(msgCssSelStr,"alert-warning",message);
+ treeMessage(msgCssSelStr,msgLevel,rMessage);
+ return;
};
- };
- return callService(msgCssSelStr, 'removeNodeRef', {eId:_rootNode.data.eId, id: _key} ).done( (data)=>checkCallBack(data) );
+ let message = "Successfull removeRef processing for key " + _key + ". Service removeRef has returned ("+rMessage+")";
+ treeMessage(msgCssSelStr,msgLevel,message) ;
+ };
+ return callService(msgCssSelStr, 'removeNodeRef', {eId:_eId, id: _key} ).done( (data)=>checkCallBack(data) );
};
// TODO : Il faudrait s'assurer que si une requête de ce type est envoyée au serveur
// on récupère bien l'evenement appendChild --> validation, promise...
function sendAppendChild(treeCssSelStr, msgCssSelStr, key, name, pos) {
'use strict';
+
const tree = $.ui.fancytree.getTree(treeCssSelStr);
- //const msgCssSelStr = '#tree1-messages';
if ( tree == null) {
let message = "Unsuccessfull appendChild tree selection ("+treeCssSelStr+") returned (null)"
alert(message) ;
return;
};
const _rootNode = tree.rootNode.children[0];
- const _eId=_rootNode.data.eId;
+ const _eId = _rootNode.data.eId;
const checkCallBack = function(data) {
- // Tester data == NULL !
- let rId = data['id']; //TODO : Changer en code d'erreur
- if ( rId == 0 || rId == null ) {
- let message = "Unsuccessfull appendChild processing for command " + name + ". Service appendChild has returned an error ("+data.message+")";
- treeMessage(msgCssSelStr,"alert-danger",message) ;
+ const errorCode = data.errorCode;
+ const msgLevel = data.msgLevel;
+ const rMessage = data.message;
+
+ if ( errorCode != undefined && errorCode != 0 ) {
+ let message = "Unsuccessfull AppendChild processing for key " + _key + ". Service AppendChild has returned an error ("+rMessage+")";
+ treeMessage(msgCssSelStr,"alert-warning",message);
+ treeMessage(msgCssSelStr,msgLevel,rMessage);
+ return;
};
+
+ let message = "Successfull AppendChild processing for key " + _key + ". Service removeRef has returned ("+rMessage+")";
+ treeMessage(msgCssSelStr,msgLevel,message) ;
};
return callService(msgCssSelStr, 'appendChild', {eId:_eId, id: key, name:name, pos:pos } ).done( (data)=>checkCallBack(data) );
if ( key !== undefined && key != "") {
fromNode = tree.getNodeByKey(key);
- } else {
+ } else {
fromNode = tree.activeNode;
};
if ( fromNode == null) {
return;
};
const _rootNode = tree.rootNode.children[0];
- const _eId=_rootNode.data.eId;
+ const _eId =_rootNode.data.eId;
//let $input=$(node.tr).find('input');
let $input=$(node.tr).find(eltNameWithValue);
const errorCode = data.errorCode;
const msgLevel = data.msgLevel;
const rMessage = data.message;
- const wValue = data.source['wValue'];
- const validite = data.source['validite'];
+ const source = data.source;
//node.fromDict()
//source=JSON.parse(getTree1())
- if ( errorCode != undefined &&
- errorCode != 0 ) {
+ 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);
+ treeMessage(msgCssSelStr,msgLevel ,rMessage);
+ node.render(true,false); //force rendering the node (not parents nor descendants)
return;
};
+ if ( source == undefined) {
+ let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, source is undefined ("+rMessage+")";
+ treeMessage(msgCssSelStr,"alert-danger",message);
+ return;
+ };
+ const wValue = source['wValue'];
+ const validite = source['validite'];
if ( rMessage == undefined) rMessage='';
if ( wValue == undefined) {
let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, wValue is undefined ("+rMessage+")";
treeMessage(msgCssSelStr,"alert-danger",message);
+ return;
};
if ( validite == undefined) {
let message = "Unsuccessfull SIMP processing for |" + node.getPath() + "|, validite is undefined ("+rMessage+")";
treeMessage(msgCssSelStr,"alert-danger",message);
+ return;
};
// 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;
+ 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
let _treeCssIdNav;
let _treeCssSelStr;
- const errorCode = data.errorCode;
- const msgLevel = data.msgLevel;
- const rMessage = data.message;
- const source = data.source;
- const commands = data.commands;
- const title = data.title;
+ 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 ) {
+ if ( errorCode != undefined && errorCode != 0 ) {
treeMessage(_msgCssSelStr,msgLevel,rMessage);
return;
};
// 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';
createNewSetOfEvents(_treeCssSelStr,'#tree1-messages');
- console.log($(_treeCssIdNav));
+ // console.log($(_treeCssIdNav));
$('.nav-tabs a[href="'+_treeCssIdTab+'"]').tab('show')
//$(_treeCssIdNav).tab('show');
let message = "New Dataset has been loaded ("+rMessage+")";
};
- //alert("sendNewDataset-1");
return callService(_msgCssSelStr, 'newDataset', { catalogName:catalogName, datasetName:datasetName } ).done( (data)=>checkCallBack(data) );
}, false);
})('','#tree1-messages'); //TODO: Changer la balise
-// --- propageValid ---
function createNewSetOfEvents(treeCssSelStr, msgCssSelStr) {
+ // --- propageValid ---
(function (treeCssSelStr, msgCssSelStr) {
'use strict';
let _treeCssSelStr = treeCssSelStr; //inutile