added a username filter to the project user relation graph view
This commit is contained in:
parent
680bc1a2f6
commit
f2d0c1ec32
@ -198,7 +198,7 @@ class Graph extends Controller
|
|||||||
print codepot_json_encode ($rg);
|
print codepot_json_encode ($rg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function enjson_project_user_relation_graph ()
|
function enjson_project_user_relation_graph ($filter = '')
|
||||||
{
|
{
|
||||||
$this->load->model ('ProjectModel', 'projects');
|
$this->load->model ('ProjectModel', 'projects');
|
||||||
|
|
||||||
@ -209,7 +209,8 @@ class Graph extends Controller
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rel = $this->projects->getAllProjectUserRelationGraph();
|
$filter = $this->converter->HexToAscii ($filter);
|
||||||
|
$rel = $this->projects->getProjectUserRelationGraph($filter);
|
||||||
print codepot_json_encode($rel);
|
print codepot_json_encode($rel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ $lang['Projects'] = 'Projects';
|
|||||||
$lang['Public'] = 'Public';
|
$lang['Public'] = 'Public';
|
||||||
$lang['Purge'] = 'Purge';
|
$lang['Purge'] = 'Purge';
|
||||||
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
||||||
|
$lang['Refresh'] = 'Refresh';
|
||||||
$lang['Rename'] = 'Rename';
|
$lang['Rename'] = 'Rename';
|
||||||
$lang['Repository'] = 'Repository';
|
$lang['Repository'] = 'Repository';
|
||||||
$lang['Return'] = 'Return';
|
$lang['Return'] = 'Return';
|
||||||
|
@ -88,6 +88,7 @@ $lang['Projects'] = 'Proyek';
|
|||||||
$lang['Public'] = 'Public';
|
$lang['Public'] = 'Public';
|
||||||
$lang['Purge'] = 'Purge';
|
$lang['Purge'] = 'Purge';
|
||||||
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
$lang['Recently resolved issues'] = 'Recently resolved issues';
|
||||||
|
$lang['Refresh'] = 'Refresh';
|
||||||
$lang['Rename'] = 'Rename';
|
$lang['Rename'] = 'Rename';
|
||||||
$lang['Return'] = 'Return';
|
$lang['Return'] = 'Return';
|
||||||
$lang['Repository'] = 'Repository';
|
$lang['Repository'] = 'Repository';
|
||||||
|
@ -88,6 +88,7 @@ $lang['Projects'] = '프로젝트';
|
|||||||
$lang['Public'] = '공개';
|
$lang['Public'] = '공개';
|
||||||
$lang['Purge'] = '정화하기';
|
$lang['Purge'] = '정화하기';
|
||||||
$lang['Recently resolved issues'] = '최근해결이슈';
|
$lang['Recently resolved issues'] = '최근해결이슈';
|
||||||
|
$lang['Refresh'] = '재갱신';
|
||||||
$lang['Rename'] = '이름변경';
|
$lang['Rename'] = '이름변경';
|
||||||
$lang['Return'] = '복귀';
|
$lang['Return'] = '복귀';
|
||||||
$lang['Repository'] = '저장소';
|
$lang['Repository'] = '저장소';
|
||||||
|
@ -606,30 +606,60 @@ class ProjectModel extends Model
|
|||||||
array_push ($edges, array ('from' => $from, 'to' => $to, 'label' => $label));
|
array_push ($edges, array ('from' => $from, 'to' => $to, 'label' => $label));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllProjectUserRelationGraph ()
|
function getProjectUserRelationGraph ($filter)
|
||||||
{
|
{
|
||||||
$this->db->trans_start ();
|
$this->db->trans_begin ();
|
||||||
|
|
||||||
$this->db->select ('project.id,project_membership.userid');
|
$this->db->select ('project.id,project_membership.userid');
|
||||||
|
if ($filter != '') $this->db->where ('userid', $filter);
|
||||||
$this->db->join ('project_membership', 'project_membership.projectid = project.id');
|
$this->db->join ('project_membership', 'project_membership.projectid = project.id');
|
||||||
$query = $this->db->get ('project');
|
$query = $this->db->get ('project');
|
||||||
|
|
||||||
$this->db->trans_complete ();
|
if ($this->db->trans_status() === FALSE)
|
||||||
|
{
|
||||||
|
$this->db->trans_rollback ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->db->trans_status() === FALSE) return FALSE;
|
|
||||||
$result = $query->result ();
|
$result = $query->result ();
|
||||||
|
|
||||||
$nodes = array();
|
$nodes = array();
|
||||||
$nodeids = array();
|
$nodeids = array();
|
||||||
$edges = array();
|
$edges = array();
|
||||||
|
|
||||||
foreach ($result as $r)
|
if (count($result) > 0)
|
||||||
{
|
{
|
||||||
$id1 = $this->_add_rg_node ($nodeids, $nodes, $r->id, 'project');
|
foreach ($result as $r)
|
||||||
$id2 = $this->_add_rg_node ($nodeids, $nodes, $r->userid, 'user');
|
{
|
||||||
$this->_add_rg_edge ($edges, $id1, $id2, "");
|
$id1 = $this->_add_rg_node ($nodeids, $nodes, $r->id, 'project');
|
||||||
|
$id2 = $this->_add_rg_node ($nodeids, $nodes, $r->userid, 'user');
|
||||||
|
$this->_add_rg_edge ($edges, $id1, $id2, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filter != '')
|
||||||
|
{
|
||||||
|
$this->db->select ('project.id,project_membership.userid');
|
||||||
|
$this->db->where_in ('id', array_keys($nodeids));
|
||||||
|
$this->db->where ('userid <>', $filter);
|
||||||
|
$this->db->join ('project_membership', 'project_membership.projectid = project.id');
|
||||||
|
$query = $this->db->get ('project');
|
||||||
|
if ($this->db->trans_status() === FALSE)
|
||||||
|
{
|
||||||
|
$this->db->trans_rollback ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $query->result ();
|
||||||
|
foreach ($result as $r)
|
||||||
|
{
|
||||||
|
$id1 = $this->_add_rg_node ($nodeids, $nodes, $r->id, 'project');
|
||||||
|
$id2 = $this->_add_rg_node ($nodeids, $nodes, $r->userid, 'user');
|
||||||
|
$this->_add_rg_edge ($edges, $id1, $id2, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->db->trans_commit ();
|
||||||
return array ('nodes' => $nodes, 'edges' => $edges);
|
return array ('nodes' => $nodes, 'edges' => $edges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ var revision_network_data = null;
|
|||||||
function resize_window()
|
function resize_window()
|
||||||
{
|
{
|
||||||
var footer = $("#codepot_footer");
|
var footer = $("#codepot_footer");
|
||||||
var mainarea = $("#project_map_mainarea");
|
var titleband = $("#project_map_title_band");
|
||||||
var code = $("#project_user_relation_graph");
|
var code = $("#project_user_relation_graph");
|
||||||
|
|
||||||
if (revision_network !== null)
|
if (revision_network !== null)
|
||||||
@ -51,12 +51,14 @@ function resize_window()
|
|||||||
//revision_network.redraw();
|
//revision_network.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ioff = mainarea.offset();
|
var ioff = titleband.offset();
|
||||||
var foff = footer.offset();
|
var foff = footer.offset();
|
||||||
|
|
||||||
|
ioff.top += titleband.outerHeight() + 5;
|
||||||
|
|
||||||
if (revision_network !== null)
|
if (revision_network !== null)
|
||||||
{
|
{
|
||||||
revision_network.setSize (footer.innerWidth() - 10, foff.top - ioff.top - 10);
|
revision_network.setSize (footer.innerWidth() - 10, foff.top - ioff.top- 10);
|
||||||
revision_network.redraw();
|
revision_network.redraw();
|
||||||
revision_network.fit();
|
revision_network.fit();
|
||||||
}
|
}
|
||||||
@ -82,19 +84,7 @@ function show_project_user_relation_graph (response)
|
|||||||
clickToUse: false,
|
clickToUse: false,
|
||||||
layout: {
|
layout: {
|
||||||
hierarchical: {
|
hierarchical: {
|
||||||
enabled: true,
|
enabled: false,
|
||||||
//levelSeparation: 150,
|
|
||||||
//nodeSpacing: 200,
|
|
||||||
//treeSpacing: 300,
|
|
||||||
//direction: 'LR', //'LR' 'UD', 'DU', 'RL'
|
|
||||||
sortMethod: 'hubsize' // 'directed'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
edges: {
|
|
||||||
smooth: {
|
|
||||||
type: 'cubicBezier',
|
|
||||||
forceDirection: 'horizontal', // 'vertical',
|
|
||||||
roundness: 0.4
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
physics: {
|
physics: {
|
||||||
@ -102,30 +92,32 @@ function show_project_user_relation_graph (response)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var i, j;
|
for (var i = 0, j = data.nodes.length; i < j; i++)
|
||||||
|
|
||||||
j = data.nodes.length;
|
|
||||||
for (i = 0; i < j; i++)
|
|
||||||
{
|
{
|
||||||
if (data.nodes[i]._type == 'project')
|
if (data.nodes[i]._type == 'project')
|
||||||
{
|
{
|
||||||
data.nodes[i].shape = 'box';
|
data.nodes[i].shape = 'box';
|
||||||
//data.nodes[i].label = '<a href="xxx">' + codepot_htmlspecialchars(data.nodes[i].label) + '</a>';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data.nodes[i].shape = 'ellipse';
|
//data.nodes[i].shape = 'ellipse';
|
||||||
data.nodes[i].color = { border: '#FF7777', background: '#DACACA' };
|
//data.nodes[i].color = { border: '#777799', background: '#DACACA' };
|
||||||
|
data.nodes[i].shape = 'image';
|
||||||
|
data.nodes[i].image = codepot_merge_path('<?php print site_url(); ?>', '/user/icon/' + codepot_string_to_hex(data.nodes[i].label));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = data.edges.length;
|
for (var i = 0, j = data.edges.length; i < j; i++)
|
||||||
for (i = 0; i < j; i++)
|
|
||||||
{
|
{
|
||||||
data.edges[i].length = 60;
|
//data.edges[i].length = 500;
|
||||||
data.edges[i].width = 1;
|
data.edges[i].width = 1;
|
||||||
data.edges[i].arrows = 'to';
|
|
||||||
data.edges[i].font = { color: 'red' };
|
data.edges[i].font = { color: 'red' };
|
||||||
|
data.edges[i].color = {
|
||||||
|
color:'#5577CC',
|
||||||
|
highlight:'pink',
|
||||||
|
hover: '#5577CC',
|
||||||
|
opacity:1.0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (revision_network === null)
|
if (revision_network === null)
|
||||||
@ -133,11 +125,10 @@ function show_project_user_relation_graph (response)
|
|||||||
revision_network = new vis.Network(document.getElementById('project_user_relation_graph'), data, options);
|
revision_network = new vis.Network(document.getElementById('project_user_relation_graph'), data, options);
|
||||||
revision_network_data = data;
|
revision_network_data = data;
|
||||||
|
|
||||||
revision_network.on ('click', function (props) {
|
revision_network.on ('doubleClick', function (props) {
|
||||||
if (props.nodes.length > 0)
|
if (props.nodes.length > 0)
|
||||||
{
|
{
|
||||||
var i, j;
|
for (var i = 0, j = revision_network_data.nodes.length; i < j; i++)
|
||||||
for (i = 0, j = revision_network_data.nodes.length; i < j; i++)
|
|
||||||
{
|
{
|
||||||
if (revision_network_data.nodes[i].id == props.nodes[0])
|
if (revision_network_data.nodes[i].id == props.nodes[0])
|
||||||
{
|
{
|
||||||
@ -162,23 +153,38 @@ function show_project_user_relation_graph (response)
|
|||||||
|
|
||||||
$(window).resize(resize_window);
|
$(window).resize(resize_window);
|
||||||
resize_window ();
|
resize_window ();
|
||||||
|
|
||||||
|
$("#project_map_refresh_button").button("enable");
|
||||||
|
$("#project_map_refresh_spin").removeClass ("fa-cog fa-spin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
var ajax_req = $.ajax ({
|
$("#project_map_refresh_button").button().click (function () {
|
||||||
url: codepot_merge_path (
|
$("#project_map_refresh_button").button("disable");
|
||||||
"<?php print site_url(); ?>",
|
$("#project_map_refresh_spin").addClass ("fa-cog fa-spin");
|
||||||
"/graph/enjson_project_user_relation_graph"),
|
|
||||||
context: document.body,
|
var filter = $("#project_map_filter").val();
|
||||||
success: show_project_user_relation_graph,
|
filter = filter.trim();
|
||||||
error: function (xhr, ajaxOptions, thrownError) {
|
|
||||||
show_alert (xhr.status + ' ' + thrownError, "<?php print $this->lang->line('Error')?>");
|
var graph_url = graph_url = codepot_merge_path ("<?php print site_url(); ?>", "/graph/enjson_project_user_relation_graph");
|
||||||
//$("#code_folder_revision_graph_button").button("enable");
|
if(filter.length > 0) graph_url += "/" + codepot_string_to_hex(filter);
|
||||||
//$("#code_folder_revision_graph_spin" ).removeClass ("fa-cog fa-spin");
|
|
||||||
}
|
var ajax_req = $.ajax ({
|
||||||
|
url: graph_url,
|
||||||
|
context: document.body,
|
||||||
|
success: show_project_user_relation_graph,
|
||||||
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
|
show_alert (xhr.status + ' ' + thrownError, "<?php print $this->lang->line('Error')?>");
|
||||||
|
$("#project_map_refresh_button").button("enable");
|
||||||
|
$("#project_map_refresh_spin").removeClass ("fa-cog fa-spin");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#project_map_refresh_button").trigger ('click');
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -218,6 +224,17 @@ $this->load->view (
|
|||||||
|
|
||||||
<div class="mainarea" id="project_map_mainarea">
|
<div class="mainarea" id="project_map_mainarea">
|
||||||
|
|
||||||
|
<div class="codepot-title-band" id="project_map_title_band">
|
||||||
|
<div class="title"><?php print $this->lang->line('Graph');?></div>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<input type="text" id="project_map_filter" placeholder="<?php print $this->lang->line('Username'); ?>" />
|
||||||
|
<a id="project_map_refresh_button" href='#'><i id="project_map_refresh_spin" class="fa"></i><?php print $this->lang->line('Refresh')?></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style='clear: both'></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="result" id="project_map_result">
|
<div class="result" id="project_map_result">
|
||||||
|
|
||||||
<div id="project_user_relation_graph">
|
<div id="project_user_relation_graph">
|
||||||
@ -225,7 +242,7 @@ $this->load->view (
|
|||||||
|
|
||||||
</div> <!-- project_map_result -->
|
</div> <!-- project_map_result -->
|
||||||
|
|
||||||
<div id='code_folder_alert'></div>
|
<div id='project_map_alert'></div>
|
||||||
|
|
||||||
</div> <!-- project_map_mainarea -->
|
</div> <!-- project_map_mainarea -->
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user