فهرست منبع

fixed fetch recurse in RefGraph

Piotr Labudda 8 سال پیش
والد
کامیت
a7c49d0ca5
1فایلهای تغییر یافته به همراه11 افزوده شده و 5 حذف شده
  1. 11 5
      SE/se-lib/Route/RefGraph.php.view.js

+ 11 - 5
SE/se-lib/Route/RefGraph.php.view.js

@@ -6,6 +6,8 @@ if ('undefined' === typeof PRIMARY_KEY) throw "Missing PRIMARY_KEY";
 // if ('undefined' === typeof FUNCTION_FETCH_PARENTS) throw "Missing FUNCTION_FETCH_PARENTS";
 // if ('undefined' === typeof FUNCTION_FETCH_PARENTS) throw "Missing FUNCTION_FETCH_PARENTS";
 // if ('undefined' === typeof JS_CHANNEL_UPDATE_NAME) throw "Missing JS_CHANNEL_UPDATE_NAME";
 // if ('undefined' === typeof JS_CHANNEL_UPDATE_NAME) throw "Missing JS_CHANNEL_UPDATE_NAME";
 var DBG = DBG || 0;
 var DBG = DBG || 0;
+var DBG_SANKEY = DBG_SANKEY || 0;
+DBG_SANKEY = 1
 var SHOW_FLOW_DIAGRAM = SHOW_FLOW_DIAGRAM || 0;
 var SHOW_FLOW_DIAGRAM = SHOW_FLOW_DIAGRAM || 0;
 
 
 var _isFullScreen = true; // TODO: get from arg
 var _isFullScreen = true; // TODO: get from arg
@@ -365,6 +367,7 @@ function fetchNodeMoreRefs(selectedNode, featureID) {
 		var backRefPK = selectedNode.ref['@backRefPK']
 		var backRefPK = selectedNode.ref['@backRefPK']
 		var backRefField = selectedNode.ref['@typeName']
 		var backRefField = selectedNode.ref['@typeName']
 		var startIndex = selectedNode.ref['@startIndex']
 		var startIndex = selectedNode.ref['@startIndex']
+		if(DBG)console.log('DBG:fetch: fetchNodeMoreRefs', { 'selectedNode': selectedNode, 'featureID': featureID });
 		_nodes.update({
 		_nodes.update({
 			id: idSelectedNode,
 			id: idSelectedNode,
 			label: "Pobieranie danych..."
 			label: "Pobieranie danych..."
@@ -454,10 +457,11 @@ function fetchNodeRecurse(selectedNode, featureID) {
 		if (!featureID) throw "Missing featureID"
 		if (!featureID) throw "Missing featureID"
 		var featureEx = featureID.split('.')
 		var featureEx = featureID.split('.')
 		if (2 !== featureEx.length) throw "Not supported featureID format"
 		if (2 !== featureEx.length) throw "Not supported featureID format"
-		var featureTypeName = 'default_db__x3A__' + featureEx[0] + ':' + featureEx[0]
+		var featureTypeName = selectedNode.typeName; // 'default_db__x3A__' + featureEx[0] + ':' + featureEx[0]
 		var wfsParams = Object.assign({}, _defaultWfsParams, {
 		var wfsParams = Object.assign({}, _defaultWfsParams, {
 			primaryKey: featureEx[1]
 			primaryKey: featureEx[1]
 		});
 		});
+		if(DBG)console.log('DBG:fetch: fetchNodeRecurse', { 'selectedNode': selectedNode, 'featureID': featureID });
 
 
 		// view-source:http://visjs.org/examples/network/data/dynamicData.html
 		// view-source:http://visjs.org/examples/network/data/dynamicData.html
 		_nodes.update({
 		_nodes.update({
@@ -579,7 +583,7 @@ function renderSelectedNode(node) {
 }
 }
 
 
 function updateSankeyDiagram() {
 function updateSankeyDiagram() {
-	console.log('updateSankeyDiagram..');
+	if(DBG||DBG_SANKEY)console.log('updateSankeyDiagram..');
 	if (!SHOW_FLOW_DIAGRAM || !sankey) return;
 	if (!SHOW_FLOW_DIAGRAM || !sankey) return;
 	// var sankeyData = { // example
 	// var sankeyData = { // example
 	// 	nodes: [
 	// 	nodes: [
@@ -620,15 +624,17 @@ function updateSankeyDiagram() {
 		ret[id] = idx;
 		ret[id] = idx;
 		return ret;
 		return ret;
 	}, {});
 	}, {});
+	// TODO: fix - count from leaf's to root's
 	var countOutLinks = _edges.get().reduce(function (ret, edge) {
 	var countOutLinks = _edges.get().reduce(function (ret, edge) {
 		if (!mapVisNodeIdToIdx.hasOwnProperty(edge.from)) throw "Missing to in mapVisNodeIdToIdx["+edge.from+"]"
 		if (!mapVisNodeIdToIdx.hasOwnProperty(edge.from)) throw "Missing to in mapVisNodeIdToIdx["+edge.from+"]"
 		var idxTarget = mapVisNodeIdToIdx[edge.from]
 		var idxTarget = mapVisNodeIdToIdx[edge.from]
 		ret[idxTarget] = (ret[idxTarget] > 0) ? ret[idxTarget] + 1 : 1
 		ret[idxTarget] = (ret[idxTarget] > 0) ? ret[idxTarget] + 1 : 1
-		console.log('DBG:sankey: countOutLinks reduce', edge, ret);
+		// if(DBG||DBG_SANKEY)console.log('DBG:sankey: countOutLinks reduce', edge, ret);
 		return ret
 		return ret
 	}, {})
 	}, {})
-	console.log('DBG:sankey: mapVisNodeIdToIdx', mapVisNodeIdToIdx);
-	console.log('DBG:sankey: countOutLinks', countOutLinks);
+	if(DBG||DBG_SANKEY)console.log('DBG:sankey: countOutLinks', Object.keys(countOutLinks).map(function (idx) {
+		return '' + _nodes.get()[idx].label + ' ('+countOutLinks[idx]+')';
+	}));
 	var sankeyInstance = sankey({
 	var sankeyInstance = sankey({
 		nodes: _nodes.map(function (node) {
 		nodes: _nodes.map(function (node) {
 			return {
 			return {