diff --git a/codepot/src/codepot/controllers/graph.php b/codepot/src/codepot/controllers/graph.php index 5ef91409..65f714a2 100644 --- a/codepot/src/codepot/controllers/graph.php +++ b/codepot/src/codepot/controllers/graph.php @@ -34,7 +34,7 @@ class Graph extends CI_Controller $this->load->model ('ProjectModel', 'projects'); $this->load->model ('SubversionModel', 'subversion'); - $login = $this->login->getUser (); + $login = $this->login->getUser(); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect (CODEPOT_SIGNIN_REDIR_PATH . $this->converter->AsciiTohex(current_url())); $data['login'] = $login; @@ -73,7 +73,7 @@ class Graph extends CI_Controller { $this->load->model ('ProjectModel', 'projects'); - $login = $this->login->getUser (); + $login = $this->login->getUser(); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') { header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); @@ -116,7 +116,7 @@ class Graph extends CI_Controller { $this->load->model ('ProjectModel', 'projects'); - $login = $this->login->getUser (); + $login = $this->login->getUser(); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') { header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); @@ -144,7 +144,7 @@ class Graph extends CI_Controller { $this->load->model ('ProjectModel', 'projects'); - $login = $this->login->getUser (); + $login = $this->login->getUser(); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') { header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); @@ -172,7 +172,7 @@ class Graph extends CI_Controller { $this->load->model ('ProjectModel', 'projects'); - $login = $this->login->getUser (); + $login = $this->login->getUser(); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') { header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); @@ -200,7 +200,7 @@ class Graph extends CI_Controller { $this->load->model ('ProjectModel', 'projects'); - $login = $this->login->getUser (); + $login = $this->login->getUser(); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') { header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 159bce36..91c7cf6c 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -1596,10 +1596,9 @@ class SubversionModel extends CodeRepoModel if ($info === FALSE || $info === NULL || count($info) != 1) continue; } - if ($info[0]['kind'] == SVN_NODE_FILE) return FALSE; - $info0 = &$info[0]; + if ($info[0]['kind'] == SVN_NODE_FILE) continue; - $list = @svn_ls ($workurl, $rev, FALSE, TRUE); + $list = @svn_ls($workurl, $rev, FALSE, TRUE); if ($list === FALSE) return FALSE; foreach ($list as $key => $value) @@ -1609,21 +1608,26 @@ class SubversionModel extends CodeRepoModel { $obj = new stdClass(); //$obj->name = $key; - $obj->name = $full_path; + //$obj->name = $full_path; + $obj->name = substr($full_path, strlen($path) + 1); // relative path - $text = @svn_cat ("{$orgurl}/{$key}{$trailer}", $rev); - if ($text === FALSE) $obj->size = 0; + $text = @svn_cat("{$orgurl}/{$key}{$trailer}", $rev); + if ($text === FALSE) + { + $obj->lines = 0; + $obj->bytes = 0; + } else { $text_len = strlen($text); - $obj->size = substr_count($text, "\n"); - if ($text_len > 0 && $text[$text_len - 1] != "\n") $obj->size++; + $obj->lines = substr_count($text, "\n"); + if ($text_len > 0 && $text[$text_len - 1] != "\n") $obj->lines++; + $obj->bytes = $text_len; } $obj->language = substr(strrchr($key, '.'), 1); // file extension if ($obj->language === FALSE) $obj->language = ''; - array_push ($current_cloc->children, $obj); } else @@ -1634,11 +1638,11 @@ class SubversionModel extends CodeRepoModel // other same base name in a different directory. // let's use a full path. it's anyway clearer. //$obj->name = $key; - $obj->name = $full_path; + //$obj->name = $full_path; + $obj->name = substr($full_path, strlen($path) + 1); // relativte path $obj->children = array(); array_push ($current_cloc->children, $obj); - array_push ($stack, $full_path); array_push ($stack, $obj); } diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 5398c635..3244983a 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -102,9 +102,7 @@ - - - + @@ -404,6 +402,10 @@ var GraphApp = (function () self.resizeGraph (); }); + this.graph_container.on ("dialogclose", function (evt, ui) { + self.closeGraph (); + }); + this.graph_button.button().click (function () { open_graph.call (self); @@ -441,6 +443,11 @@ var GraphApp = (function () /* SHOULD BE IMPLEMENTED BY INHERITER */ } + App.prototype.closeGraph = function () + { + /* SHOULD BE IMPLEMENTED BY INHERITER */ + } + return App; })(); @@ -558,15 +565,18 @@ var LocGraphApp = (function () function App (top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title) { GraphApp.call (this, top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title); + this.chart = null; this.plot_dataset = null; this.plot_options = null; return this; } + App.prototype = Object.create(GraphApp.prototype); App.prototype.constructor = App; + App.prototype.renderGraph = function (data) { - if (!data.hasOwnProperty('SUM')) + if (!("SUM" in data)) { this.showMessage ('No data to show'); return; @@ -579,36 +589,38 @@ var LocGraphApp = (function () this.clearMessage (); - // files, blank, comment, code - // files is always 1. - this.plot_dataset = [ - { label: "lang->line('Blank')?>", data: data.SUM[1] }, - { label: "lang->line('Comment')?>", data: data.SUM[2] }, - { label: "lang->line('Code')?>", data: data.SUM[3] } + var labels = [ + "lang->line('Blank')?>", + "lang->line('Comment')?>", + "lang->line('Code')?>" ]; - this.plot_options = - { - series: { - shadowSize: 0, - pie: { - show: true, - innerRadius: 0.1, - label: { - show: true, - radius: 0.9, - formatter: function labelFormatter(label, series) - { - return "
" + label + "
" + series.data[0][1] + "(" + Math.round(series.percent) + "%)
"; - }, - backgraound: { opacity: 0.8 } - } + // data.SUM[] => files, blank, comment, code + // files is always 1. + this.plot_dataset = { + labels: labels, + datasets: [ + { + data: [data.SUM[1], data.SUM[2], data.SUM[3]], + backgroundColor: [ + 'rgb(255, 99, 132)', + 'rgb(54, 162, 235)', + 'rgb(255, 205, 86)' + ] } - }, - legend: { - show: false - } + ] }; + + this.plot_options = { + responsive: true, + maintainAspectRatio: false + }; + + this.chart = new Chart(this.graph_canvas[0].getContext('2d'), { + type: 'doughnut', + data: this.plot_dataset, + options: this.plot_options + }); } App.prototype.resizeGraph = function () @@ -617,7 +629,15 @@ var LocGraphApp = (function () { this.graph_canvas.width (this.graph_container.width() - 5); this.graph_canvas.height (this.graph_container.height() - 10); - $.plot(this.graph_canvas, this.plot_dataset, this.plot_options); + } + } + + App.prototype.closeGraph = function () + { + if (this.chart != null) + { + this.chart.destroy(); + this.chart = null; } } @@ -982,7 +1002,8 @@ $this->load->view (
-
+ +
diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index f4a60776..72be2114 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -28,8 +28,6 @@ - - @@ -448,6 +446,7 @@ var LocLangApp = (function () this.chart = null; } } + return App; })(); @@ -472,35 +471,55 @@ var LocFileApp = (function () this.clearMessage (); - var gen_color = function() { - var letters = '0123456789ABCDEF'.split(''); - var color = '#'; - for (var i = 0; i < 6; i++) color += letters[Math.floor(Math.random() * 16)]; - return color; - }; + //var gen_color = function() { + // var letters = '0123456789ABCDEF'.split(''); + // var color = '#'; + // for (var i = 0; i < 6; i++) color += letters[Math.floor(Math.random() * 16)]; + // return color; + //}; var labels = []; - var dataset = []; + var dataset_lines = []; + var dataset_bytes = []; var bgcolors = []; - for (var key in loc.children) { - var size = loc.children[key].size; - if (size == null) size = 0; - var name = loc.children[key].name; - name = name.split('/').reverse()[0]; - labels.push (name); - dataset.push (size); - //bgcolors.push(gen_color()); - } + var add_items = function(items) + { + for (var key in items) { + var item = items[key]; + if ('children' in item) + { + // directory item. + add_items (item.children); + } + else + { + // plain file item + var lines = item.lines; + if (lines == null) lines = 0; + var size = item.size; + if (size == null) lines = 0; + labels.push (item.name); + dataset_lines.push (item.lines == null? 0: item.lines); + dataset_bytes.push (item.bytes == null? 0: item.bytes); + //bgcolors.push(gen_color()); + } + } + }; + add_items (loc.children); this.plot_dataset = { labels: labels, datasets: [ { - label: 'LOC', - data: dataset, + label: 'Lines', + data: dataset_lines //backgroundColor: bgcolors - } + }/*, + { + label: 'Bytes', + data: dataset_bytes + }*/ ] }; this.plot_options = { @@ -508,7 +527,8 @@ var LocFileApp = (function () maintainAspectRatio: false, scales: { x: { - grid: { display: false } + grid: { display: false }, + stacked: true }, y: { beginAtZero: true,