From ef8f044d12c0ba5aa3dfc174ae130bfa3d7def40 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 16 Feb 2015 14:43:54 +0000 Subject: [PATCH] created a dedicate graph page. modified Chart.js to provide tooltipLabel: in other graph types --- codepot/src/codepot/controllers/Makefile.am | 1 + codepot/src/codepot/controllers/Makefile.in | 1 + codepot/src/codepot/controllers/code.php | 2 +- codepot/src/codepot/controllers/graph.php | 115 +++++ .../codepot/language/english/common_lang.php | 2 + .../language/indonesian/common_lang.php | 2 + .../codepot/language/korean/common_lang.php | 2 + codepot/src/codepot/views/Makefile.am | 1 + codepot/src/codepot/views/Makefile.in | 1 + codepot/src/codepot/views/graph_main.php | 408 ++++++++++++++++++ codepot/src/codepot/views/project_home.php | 218 ---------- codepot/src/codepot/views/projectbar.php | 6 +- codepot/src/css/project.css | 15 - codepot/src/js/Chart.js | 6 + 14 files changed, 543 insertions(+), 237 deletions(-) create mode 100644 codepot/src/codepot/controllers/graph.php create mode 100644 codepot/src/codepot/views/graph_main.php diff --git a/codepot/src/codepot/controllers/Makefile.am b/codepot/src/codepot/controllers/Makefile.am index 10fc19e1..0c4fb50a 100644 --- a/codepot/src/codepot/controllers/Makefile.am +++ b/codepot/src/codepot/controllers/Makefile.am @@ -3,6 +3,7 @@ www_DATA = \ api.php \ code.php \ file.php \ + graph.php \ index.html \ issue.php \ main.php \ diff --git a/codepot/src/codepot/controllers/Makefile.in b/codepot/src/codepot/controllers/Makefile.in index 81c7bd29..789a2ea5 100644 --- a/codepot/src/codepot/controllers/Makefile.in +++ b/codepot/src/codepot/controllers/Makefile.in @@ -198,6 +198,7 @@ www_DATA = \ api.php \ code.php \ file.php \ + graph.php \ index.html \ issue.php \ main.php \ diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index 598cc308..b7a7f7d3 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -49,7 +49,7 @@ class Code extends Controller { $data['message'] = 'DATABASE ERROR'; $this->load->view ($this->VIEW_ERROR, $data); - } + } else if ($project === NULL) { $data['message'] = diff --git a/codepot/src/codepot/controllers/graph.php b/codepot/src/codepot/controllers/graph.php new file mode 100644 index 00000000..828acc52 --- /dev/null +++ b/codepot/src/codepot/controllers/graph.php @@ -0,0 +1,115 @@ +load->helper ('url'); + $this->load->helper ('form'); + $this->load->library ('Converter', 'converter'); + $this->load->model (CODEPOT_LOGIN_MODEL, 'login'); + + $this->load->library ('Language', 'lang'); + $this->lang->load ('common', CODEPOT_LANG); + $this->lang->load ('code', CODEPOT_LANG); + } + + function home ($projectid = '') + { + return $this->main ($projectid); + } + + function _normalize_path ($path) + { + $path = preg_replace('/[\/]+/', '/', $path); + if ($path == '/') $path = ''; + return $path; + } + + function main ($projectid = '') + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('SubversionModel', 'subversion'); + + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + $data['login'] = $login; + + //$path = $this->converter->HexToAscii ($path); + //if ($path == '.') $path = ''; /* treat a period specially */ + //$path = $this->_normalize_path ($path); + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + if ($project->public !== 'Y' && $login['id'] == '') + { + // non-public projects require sign-in. + redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); + } + + $data['project'] = $project; + $this->load->view ($this->VIEW_MAIN, $data); + } + } + + function history_json ($projectid = '', $path = '', $rev = SVN_REVISION_HEAD) + { + $this->load->model ('ProjectModel', 'projects'); + + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + { + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); + return; + } + + $project = $this->projects->get ($projectid); + if ($project === FALSE || ($project->public !== 'Y' && $login['id'] == '')) + { + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); + return; + } + + $this->load->model ('SubversionModel', 'subversion'); + + $path = $this->converter->HexToAscii ($path); + if ($path == '.') $path = ''; /* treat a period specially */ + $path = $this->_normalize_path ($path); + + $file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD); + if ($file === FALSE) + { + $history = array(); + } + else + { + $history = $file['history']; + $count = count($history); + for ($i = 0; $i < $count; $i++) + { + unset ($history[$i]['msg']); + unset ($history[$i]['paths']); + } + } + + print codepot_json_encode ($history); + } +} diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 2e9b4d98..37fd38f8 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -31,6 +31,8 @@ $lang['Files'] = 'Files'; $lang['First'] = 'First'; $lang['Folder'] = 'Folder'; $lang['Full Difference'] = 'FullDiff'; +$lang['Graph'] = 'Graph'; +$lang['Graphs'] = 'Graphs'; $lang['Head revision'] = 'Head revision'; $lang['Hide details'] = 'Hide details'; $lang['History'] = 'History'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index c8922e09..385d9190 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -29,6 +29,8 @@ $lang['Files'] = 'File'; $lang['First'] = 'Pertama'; $lang['Folder'] = 'Folder'; $lang['Full Difference'] = 'FullDiff'; +$lang['Graph'] = 'Graph'; +$lang['Graphs'] = 'Graphs'; $lang['Head revision'] = 'Kepala revisi'; $lang['History'] = 'Sejarah'; $lang['Home'] = 'Beranda'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 1cfbd9aa..bc7fb962 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -31,6 +31,8 @@ $lang['Files'] = '파일'; $lang['First'] = '처음'; $lang['Folder'] = '폴더'; $lang['Full Difference'] = '전체차이'; +$lang['Graph'] = '그래프'; +$lang['Graphs'] = '그래프'; $lang['Head revision'] = '최신리비전'; $lang['Hide details'] = '상세내역숨김'; $lang['History'] = '변경기록'; diff --git a/codepot/src/codepot/views/Makefile.am b/codepot/src/codepot/views/Makefile.am index 588c7da8..b112d08a 100644 --- a/codepot/src/codepot/views/Makefile.am +++ b/codepot/src/codepot/views/Makefile.am @@ -13,6 +13,7 @@ www_DATA = \ file_home.php \ file_show.php \ footer.php \ + graph_main.php \ index.html \ issue_delete.php \ issue_edit.php \ diff --git a/codepot/src/codepot/views/Makefile.in b/codepot/src/codepot/views/Makefile.in index 73e722e1..1625f9d5 100644 --- a/codepot/src/codepot/views/Makefile.in +++ b/codepot/src/codepot/views/Makefile.in @@ -208,6 +208,7 @@ www_DATA = \ file_home.php \ file_show.php \ footer.php \ + graph_main.php \ index.html \ issue_delete.php \ issue_edit.php \ diff --git a/codepot/src/codepot/views/graph_main.php b/codepot/src/codepot/views/graph_main.php new file mode 100644 index 00000000..db04f329 --- /dev/null +++ b/codepot/src/codepot/views/graph_main.php @@ -0,0 +1,408 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<?=htmlspecialchars($project->name)?> + + + + +
+ + + + +load->view ('taskbar'); ?> + + + +load->view ( + 'projectbar', + array ( + 'banner' => NULL, + + 'page' => array ( + 'type' => 'project', + 'id' => 'graph', + 'project' => $project, + ), + + 'ctxmenuitems' => array ( + /* + array ("project/update/{$project->id}", $this->lang->line('Edit')), + array ("project/delete/{$project->id}", $this->lang->line('Delete')) + */ + ) + ) +); +?> + + + + + + + + +
+ +
+name)?> +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ + + + +load->view ('footer'); ?> + + + +
+ + + + + diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index 283fbf0b..6cc957e0 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -22,207 +22,7 @@ - - @@ -249,7 +43,6 @@ function render_wiki()
- load->view ('taskbar'); ?> @@ -487,17 +280,6 @@ foreach ($urls as $url)
-
-id}"); -//print ""; -?> - -
- - -
- diff --git a/codepot/src/codepot/views/projectbar.php b/codepot/src/codepot/views/projectbar.php index 4733dde6..f327a254 100644 --- a/codepot/src/codepot/views/projectbar.php +++ b/codepot/src/codepot/views/projectbar.php @@ -43,7 +43,7 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems) foreach ($ctxmenuitems as $item) { $extra = (count($item) >= 3)? "id='{$item[2]}'": ''; - print anchor ($item[0], $item[1], $extra); + print anchor ($item[0], $item[1], $extra); } } else print ' '; @@ -58,7 +58,8 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems) array ("wiki/home/{$project->id}", $con->lang->line('Wiki')), array ("issue/home/{$project->id}", $con->lang->line('Issues')), array ("code/home/{$project->id}", $con->lang->line('Code')), - array ("file/home/{$project->id}", $con->lang->line('Files')) + array ("file/home/{$project->id}", $con->lang->line('Files')), + array ("graph/home/{$project->id}", $con->lang->line('Graphs')) ); foreach ($menuitems as $item) @@ -103,7 +104,6 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems) print anchor ($menulink, $item[1], $extra); } } - else print ' '; print ''; diff --git a/codepot/src/css/project.css b/codepot/src/css/project.css index e8432a78..7564362d 100644 --- a/codepot/src/css/project.css +++ b/codepot/src/css/project.css @@ -39,20 +39,6 @@ white-space: pre-wrap; } - -#project_home_mainarea_stat { - overflow: hidden; -} - -#project_home_commits_per_month_graph { - max-width: 100%; -} - -#project_home_commits_per_month_canvas { - max-width: 100%; - width: 100%; -} - /*----------------------------------------------- * project file edit view *-----------------------------------------------*/ @@ -64,7 +50,6 @@ width: 100%; } - /*----------------------------------------------- * project catalog view *-----------------------------------------------*/ diff --git a/codepot/src/js/Chart.js b/codepot/src/js/Chart.js index 089b1995..54b7f0b8 100644 --- a/codepot/src/js/Chart.js +++ b/codepot/src/js/Chart.js @@ -2143,6 +2143,9 @@ datasetObject.bars.push(new this.BarClass({ value : dataPoint, label : data.labels[index], + // HYUNG-HWAN + tooltipLabel: (data.tooltipLabels? data.tooltipLabels[index]: data.labels[index]), + // END HYUNG-HWAN datasetLabel: dataset.label, strokeColor : dataset.strokeColor, fillColor : dataset.fillColor, @@ -2433,6 +2436,9 @@ strokeColor : this.options.segmentStrokeColor, startAngle : Math.PI * 1.5, circumference : (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value), + // HYUNG-HWAN + tooltipLabel: (segment.tooltipLabel? segment.tooltipLabel: segment.label), + // END HYUNG-HWAN label : segment.label })); if (!silent){