WIP atomic JS map. Minor fix to keep working
Former-commit-id: fee809008311942f1d9ad14aea70ba78e3d6eb3a
This commit is contained in:
parent
4854d4b2df
commit
b0a6ea7415
|
@ -191,6 +191,20 @@ class NetworkMap
|
||||||
*/
|
*/
|
||||||
public $relations;
|
public $relations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private nodes converted to JS.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $nodesJS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private relations converted to JS.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $relationsJS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include a Pandora (or vendor) node or not.
|
* Include a Pandora (or vendor) node or not.
|
||||||
*
|
*
|
||||||
|
@ -1604,6 +1618,11 @@ class NetworkMap
|
||||||
$node['style'] = json_decode($node['style'], true);
|
$node['style'] = json_decode($node['style'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Propagate styles.
|
||||||
|
foreach ($node['style'] as $k => $v) {
|
||||||
|
$item[$k] = $v;
|
||||||
|
}
|
||||||
|
|
||||||
$item['type'] = $node['type'];
|
$item['type'] = $node['type'];
|
||||||
$item['fixed'] = true;
|
$item['fixed'] = true;
|
||||||
$item['x'] = (int) $node['x'];
|
$item['x'] = (int) $node['x'];
|
||||||
|
@ -1643,7 +1662,13 @@ class NetworkMap
|
||||||
|
|
||||||
$node['style']['label'] = $node['label'];
|
$node['style']['label'] = $node['label'];
|
||||||
$node['style']['shape'] = 'circle';
|
$node['style']['shape'] = 'circle';
|
||||||
$item['color'] = self::getColorByStatus($node['status']);
|
if (isset($source_data['color'])) {
|
||||||
|
$item['color'] = $source_data['color'];
|
||||||
|
} else {
|
||||||
|
$item['color'] = self::getColorByStatus(
|
||||||
|
$node['status']
|
||||||
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1669,11 +1694,6 @@ class NetworkMap
|
||||||
$count_item_holding_area++;
|
$count_item_holding_area++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propagate styles.
|
|
||||||
foreach ($node['style'] as $k => $v) {
|
|
||||||
$item[$k] = $v;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Node image.
|
// Node image.
|
||||||
$item['image_url'] = '';
|
$item['image_url'] = '';
|
||||||
$item['image_width'] = 0;
|
$item['image_width'] = 0;
|
||||||
|
@ -2700,9 +2720,13 @@ class NetworkMap
|
||||||
$nodes = [];
|
$nodes = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->nodes = $nodes;
|
$this->nodesJS = $this->nodesToJS($nodes);
|
||||||
$nodes_js = $this->nodesToJS($nodes);
|
$output .= 'networkmap.nodes = ('.json_encode($this->nodesJS).");\n";
|
||||||
$output .= 'networkmap.nodes = ('.json_encode($nodes_js).");\n";
|
|
||||||
|
// Clean.
|
||||||
|
unset($this->nodes);
|
||||||
|
unset($this->rawNodes);
|
||||||
|
unset($this->nodeMapping);
|
||||||
|
|
||||||
// Translate edges to js links.
|
// Translate edges to js links.
|
||||||
$relations = $this->graph['relations'];
|
$relations = $this->graph['relations'];
|
||||||
|
@ -2710,9 +2734,11 @@ class NetworkMap
|
||||||
$relations = [];
|
$relations = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->relations = $relations;
|
$this->relationsJS = $this->edgeToJS($relations);
|
||||||
$links_js = $this->edgeToJS($relations);
|
$output .= 'networkmap.links = ('.json_encode($this->relationsJS).");\n";
|
||||||
$output .= 'networkmap.links = ('.json_encode($links_js).");\n";
|
|
||||||
|
// Clean.
|
||||||
|
unset($this->relations);
|
||||||
|
|
||||||
$output .= '
|
$output .= '
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3246,9 +3272,6 @@ class NetworkMap
|
||||||
if (enterprise_installed()
|
if (enterprise_installed()
|
||||||
&& $this->useTooltipster
|
&& $this->useTooltipster
|
||||||
) {
|
) {
|
||||||
$nodes_js = $this->nodesToJS($this->nodes);
|
|
||||||
$links_js = $this->edgeToJS($this->relations);
|
|
||||||
|
|
||||||
$output .= '<script type="text/javascript">
|
$output .= '<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
controller = new SimpleMapController({
|
controller = new SimpleMapController({
|
||||||
|
@ -3256,8 +3279,8 @@ class NetworkMap
|
||||||
map_height: '.$this->map['height'].',
|
map_height: '.$this->map['height'].',
|
||||||
id: "'.$this->idMap.'",
|
id: "'.$this->idMap.'",
|
||||||
target: "#simple_map",
|
target: "#simple_map",
|
||||||
nodes: '.json_encode($nodes_js).',
|
nodes: '.json_encode($this->nodesJS).',
|
||||||
arrows: '.json_encode($links_js).',
|
arrows: '.json_encode($this->relationsJS).',
|
||||||
center_x: '.$this->map['center_x'].',
|
center_x: '.$this->map['center_x'].',
|
||||||
center_y: '.$this->map['center_y'].',
|
center_y: '.$this->map['center_y'].',
|
||||||
z_dash: '.$this->map['filter']['z_dash'].',
|
z_dash: '.$this->map['filter']['z_dash'].',
|
||||||
|
|
Loading…
Reference in New Issue