added revision graph to the code file view.

made revision graph resizable
This commit is contained in:
hyung-hwan 2016-12-15 01:09:25 +00:00
parent dd619e2e19
commit 7fb63d8e94
3 changed files with 147 additions and 14 deletions

View File

@ -1123,10 +1123,8 @@ class SubversionModel extends Model
)
*/
$fileinfo['fullpath'] = substr (
$info1[0]['url'], strlen($info1[0]['repos']));
$fileinfo['against']['fullpath'] = substr (
$info2[0]['url'], strlen($info2[0]['repos']));
$fileinfo['fullpath'] = substr ($info1[0]['url'], strlen($info1[0]['repos']));
$fileinfo['against']['fullpath'] = substr ($info2[0]['url'], strlen($info2[0]['repos']));
fclose($errors);

View File

@ -83,6 +83,8 @@
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/vis.min.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/vis.min.css')?>" />
<?php
@ -231,6 +233,88 @@ function showRawCode()
}
<?php endif; ?>
var revision_network = null;
function show_revision_graph (response)
{
var data = $.parseJSON(response);
if (data == null)
{
show_alert ('Invalid data received', "<?php print $this->lang->line('Error')?>");
}
else if (data.nodes.length <= 0)
{
show_alert ('No data to show', "<?php print $this->lang->line('Info')?>");
}
else
{
var options = {
autoResize: false,
height: '500px',
width: '100%',
clickToUse: true,
layout: {
hierarchical: {
enabled: true,
//levelSeparation: 150,
//nodeSpacing: 200,
//treeSpacing: 300,
direction: 'LR', //'LR' 'UD', 'DU', 'RL'
sortMethod: 'directed' // 'hubsize'
}
},
edges: {
smooth: {
type: 'cubicBezier',
forceDirection: 'horizontal', // 'vertical',
roundness: 0.4
}
},
physics: {
enabled: true
}
};
var i, j;
j = data.nodes.length;
for (i = 0; i < j; i++)
{
data.nodes[i].shape = 'box';
}
j = data.edges.length;
for (i = 0; i < j; i++)
{
data.edges[i].length = 60;
data.edges[i].width = 1;
data.edges[i].arrows = 'to';
data.edges[i].font = { color: 'red' };
}
if (revision_network === null)
{
revision_network = new vis.Network(document.getElementById('code_file_result_revision_graph'), data, options);
$('#code_file_result_revision_graph').resizable({
create: function (event, ui) {
revision_network.setSize (ui.size.width - 10, ui.size.height - 10);
revision_network.redraw();
},
resize: function (event, ui) {
revision_network.setSize (ui.size.width - 10, ui.size.height - 10);
revision_network.redraw();
}
});
}
else
{
revision_network.setData (data);
}
}
$("#code_file_revision_graph_button").button("enable");
$("#code_file_revision_graph_spin" ).removeClass ("fa-cog fa-spin");
}
$(function () {
@ -241,7 +325,7 @@ $(function () {
<?php if (!$is_special_stream): ?>
$("#code_file_loc_info").hide();
btn = $("#code_file_mainarea_loc_button").button().click (function () {
btn = $("#code_file_loc_button").button().click (function () {
if ($("#code_file_loc_info").is(":visible"))
{
$("#code_file_loc_info").hide("blind",{},200);
@ -255,9 +339,28 @@ $(function () {
});
$("#code_file_mainarea_edit_button").button();
$("#code_file_edit_button").button();
<?php endif; ?>
$("#code_file_revision_graph_button").button().click (function () {
$("#code_file_revision_graph_button").button("disable");
$("#code_file_revision_graph_spin").addClass ("fa-cog fa-spin");
var ajax_req = $.ajax ({
url: codepot_merge_path (
"<?php print site_url(); ?>",
"/graph/enjson_revision_graph/<?php print $project->id; ?>/<?php print $hex_headpath;?><?php print $revreq?>"),
context: document.body,
success: show_revision_graph,
error: function (xhr, ajaxOptions, thrownError) {
show_alert (xhr.status + ' ' + thrownError, "<?php print $this->lang->line('Error')?>");
$("#code_file_revision_graph_button").button("enable");
$("#code_file_revision_graph_spin" ).removeClass ("fa-cog fa-spin");
}
});
return false;
});
<?php if ($file['created_rev'] != $file['head_rev']): ?>
$("#code_file_headrev_button").button().click (function() {
$(location).attr ('href', codepot_merge_path("<?php print site_url(); ?>", '<?php print "/code/file/{$project->id}/${hex_headpath}"; ?>'));
@ -474,9 +577,9 @@ $this->load->view (
if ((isset($login['id']) && $login['id'] != '') )
{
print ' ';
print anchor ("code/edit/{$project->id}/{$hex_headpath}{$revreq}", $this->lang->line('Edit'), 'id="code_file_mainarea_edit_button"');
print anchor ("code/edit/{$project->id}/{$hex_headpath}{$revreq}", $this->lang->line('Edit'), 'id="code_file_edit_button"');
}
print anchor ("#", "LOC", "id=code_file_mainarea_loc_button");
print anchor ("#", "LOC", "id=code_file_loc_button");
}
?>
</div>
@ -514,6 +617,12 @@ $this->load->view (
//print anchor ('', $download_anchor_text, 'id="code_file_download_button"');
print anchor ("code/fetch/{$project->id}/${hex_headpath}{$revreq}", $download_anchor_text, 'id="code_file_download_button"');
if (!$is_special_stream) print anchor ('#', $this->lang->line('Enstyle'), 'id="code_file_style_button"');
print '<a id="code_file_revision_graph_button" href="#">';
print '<i id="code_file_revision_graph_spin" class="fa"></i>';
print $this->lang->line('CODE_REVISION_GRAPH');
print '</a>';
print '</div>';
print '<div class="metadata-commit-date">';
@ -550,6 +659,10 @@ $this->load->view (
</div>
</div>
<div id="code_folder_graph" class="graph">
<div id="code_file_result_revision_graph"></div>
</div>
<div style="display:none">
<pre id="code_file_result_raw">
</pre>

View File

@ -201,6 +201,8 @@ function show_loc_by_file_graph (response)
$("#code_folder_loc_by_file_spin" ).removeClass ("fa-cog fa-spin");
}
var revision_network = null;
function show_revision_graph (response)
{
var data = $.parseJSON(response);
@ -215,15 +217,16 @@ function show_revision_graph (response)
else
{
var options = {
autoResize: true,
autoResize: false,
height: '500px',
width: '100%',
clickToUse: true,
layout: {
hierarchical: {
enabled: true,
levelSeparation: 150,
nodeSpacing: 200,
treeSpacing: 400,
//levelSeparation: 150,
//nodeSpacing: 200,
//treeSpacing: 300,
direction: 'LR', //'LR' 'UD', 'DU', 'RL'
sortMethod: 'directed' // 'hubsize'
}
@ -235,7 +238,9 @@ function show_revision_graph (response)
roundness: 0.4
}
},
physics: true
physics: {
enabled: true
}
};
var i, j;
@ -255,7 +260,24 @@ function show_revision_graph (response)
data.edges[i].font = { color: 'red' };
}
var network = new vis.Network(document.getElementById('code_folder_result_revision_graph'), data, options);
if (revision_network === null)
{
revision_network = new vis.Network(document.getElementById('code_folder_result_revision_graph'), data, options);
$('#code_folder_result_revision_graph').resizable({
create: function (event, ui) {
revision_network.setSize (ui.size.width - 10, ui.size.height - 10);
revision_network.redraw();
},
resize: function (event, ui) {
revision_network.setSize (ui.size.width - 10, ui.size.height - 10);
revision_network.redraw();
}
});
}
else
{
revision_network.setData (data);
}
}
$("#code_folder_revision_graph_button").button("enable");