diff --git a/codepot/src/codepot/controllers/graph.php b/codepot/src/codepot/controllers/graph.php index d6ac4242..3c1e0c55 100644 --- a/codepot/src/codepot/controllers/graph.php +++ b/codepot/src/codepot/controllers/graph.php @@ -198,7 +198,7 @@ class Graph extends Controller print codepot_json_encode ($rg); } - function enjson_project_user_relation_graph () + function enjson_project_user_relation_graph ($filter = '') { $this->load->model ('ProjectModel', 'projects'); @@ -209,7 +209,8 @@ class Graph extends Controller return; } - $rel = $this->projects->getAllProjectUserRelationGraph(); + $filter = $this->converter->HexToAscii ($filter); + $rel = $this->projects->getProjectUserRelationGraph($filter); print codepot_json_encode($rel); } } diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 41364eea..c62a91f3 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -88,6 +88,7 @@ $lang['Projects'] = 'Projects'; $lang['Public'] = 'Public'; $lang['Purge'] = 'Purge'; $lang['Recently resolved issues'] = 'Recently resolved issues'; +$lang['Refresh'] = 'Refresh'; $lang['Rename'] = 'Rename'; $lang['Repository'] = 'Repository'; $lang['Return'] = 'Return'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index 79882865..25f3dae0 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -88,6 +88,7 @@ $lang['Projects'] = 'Proyek'; $lang['Public'] = 'Public'; $lang['Purge'] = 'Purge'; $lang['Recently resolved issues'] = 'Recently resolved issues'; +$lang['Refresh'] = 'Refresh'; $lang['Rename'] = 'Rename'; $lang['Return'] = 'Return'; $lang['Repository'] = 'Repository'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index fcf3be0b..b3006fd7 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -88,6 +88,7 @@ $lang['Projects'] = '프로젝트'; $lang['Public'] = '공개'; $lang['Purge'] = '정화하기'; $lang['Recently resolved issues'] = '최근해결이슈'; +$lang['Refresh'] = '재갱신'; $lang['Rename'] = '이름변경'; $lang['Return'] = '복귀'; $lang['Repository'] = '저장소'; diff --git a/codepot/src/codepot/models/projectmodel.php b/codepot/src/codepot/models/projectmodel.php index 8689bfb3..89b0df57 100644 --- a/codepot/src/codepot/models/projectmodel.php +++ b/codepot/src/codepot/models/projectmodel.php @@ -606,30 +606,60 @@ class ProjectModel extends Model 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'); + if ($filter != '') $this->db->where ('userid', $filter); $this->db->join ('project_membership', 'project_membership.projectid = project.id'); $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 (); $nodes = array(); $nodeids = array(); $edges = array(); - foreach ($result as $r) + if (count($result) > 0) { - $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, ""); + 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, ""); + } + + 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); } } diff --git a/codepot/src/codepot/views/project_map.php b/codepot/src/codepot/views/project_map.php index 429a8a57..90c37cc9 100644 --- a/codepot/src/codepot/views/project_map.php +++ b/codepot/src/codepot/views/project_map.php @@ -41,7 +41,7 @@ var revision_network_data = null; function resize_window() { var footer = $("#codepot_footer"); - var mainarea = $("#project_map_mainarea"); + var titleband = $("#project_map_title_band"); var code = $("#project_user_relation_graph"); if (revision_network !== null) @@ -51,12 +51,14 @@ function resize_window() //revision_network.redraw(); } - var ioff = mainarea.offset(); + var ioff = titleband.offset(); var foff = footer.offset(); + ioff.top += titleband.outerHeight() + 5; + 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.fit(); } @@ -82,19 +84,7 @@ function show_project_user_relation_graph (response) clickToUse: false, layout: { hierarchical: { - enabled: true, - //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 + enabled: false, } }, physics: { @@ -102,30 +92,32 @@ function show_project_user_relation_graph (response) } }; - var i, j; - - j = data.nodes.length; - for (i = 0; i < j; i++) + for (var i = 0, j = data.nodes.length; i < j; i++) { if (data.nodes[i]._type == 'project') { data.nodes[i].shape = 'box'; - //data.nodes[i].label = '' + codepot_htmlspecialchars(data.nodes[i].label) + ''; } else { - data.nodes[i].shape = 'ellipse'; - data.nodes[i].color = { border: '#FF7777', background: '#DACACA' }; + //data.nodes[i].shape = 'ellipse'; + //data.nodes[i].color = { border: '#777799', background: '#DACACA' }; + data.nodes[i].shape = 'image'; + data.nodes[i].image = codepot_merge_path('', '/user/icon/' + codepot_string_to_hex(data.nodes[i].label)); } } - j = data.edges.length; - for (i = 0; i < j; i++) + for (var i = 0, j = data.edges.length; i < j; i++) { - data.edges[i].length = 60; + //data.edges[i].length = 500; data.edges[i].width = 1; - data.edges[i].arrows = 'to'; data.edges[i].font = { color: 'red' }; + data.edges[i].color = { + color:'#5577CC', + highlight:'pink', + hover: '#5577CC', + opacity:1.0 + }; } 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_data = data; - revision_network.on ('click', function (props) { + revision_network.on ('doubleClick', function (props) { if (props.nodes.length > 0) { - var i, j; - for (i = 0, j = revision_network_data.nodes.length; i < j; i++) + for (var i = 0, j = revision_network_data.nodes.length; i < j; i++) { 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); resize_window (); + + $("#project_map_refresh_button").button("enable"); + $("#project_map_refresh_spin").removeClass ("fa-cog fa-spin"); } - - $(function () { - var ajax_req = $.ajax ({ - url: codepot_merge_path ( - "", - "/graph/enjson_project_user_relation_graph"), - context: document.body, - success: show_project_user_relation_graph, - error: function (xhr, ajaxOptions, thrownError) { - show_alert (xhr.status + ' ' + thrownError, "lang->line('Error')?>"); - //$("#code_folder_revision_graph_button").button("enable"); - //$("#code_folder_revision_graph_spin" ).removeClass ("fa-cog fa-spin"); - } + $("#project_map_refresh_button").button().click (function () { + $("#project_map_refresh_button").button("disable"); + $("#project_map_refresh_spin").addClass ("fa-cog fa-spin"); + + var filter = $("#project_map_filter").val(); + filter = filter.trim(); + + var graph_url = graph_url = codepot_merge_path ("", "/graph/enjson_project_user_relation_graph"); + if(filter.length > 0) graph_url += "/" + codepot_string_to_hex(filter); + + 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, "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'); + }); @@ -218,6 +224,17 @@ $this->load->view (