| src/IDF/Views/Admin.php |
| 64 | 64 | $list_display = array( |
| 65 | 65 | 'shortname' => __('Short Name'), |
| 66 | 66 | 'name' => __('Name'), |
| 67 | array('id', 'IDF_Views_Admin_projectSize', __('Repository Size')), |
| 67 | 68 | ); |
| 68 | 69 | $pag->configure($list_display, array(), |
| 69 | 70 | array('shortname')); |
| 71 | $pag->extra_classes = array('', '', 'right'); |
| 70 | 72 | $pag->items_per_page = 25; |
| 71 | 73 | $pag->no_results_text = __('No projects were found.'); |
| 72 | 74 | $pag->setFromRequest($request); |
| ... | ... | |
| 74 | 76 | array( |
| 75 | 77 | 'page_title' => $title, |
| 76 | 78 | 'projects' => $pag, |
| 79 | 'size' => IDF_Views_Admin_getForgeSize(), |
| 77 | 80 | ), |
| 78 | 81 | $request); |
| 79 | 82 | } |
| ... | ... | |
| 283 | 286 | $img = ($item->$field) ? 'day' : 'night'; |
| 284 | 287 | $text = ($item->$field) ? __('Yes') : __('No'); |
| 285 | 288 | return sprintf('<img src="'.Pluf::f('url_media').'/idf/img/%s.png" alt="%s" /> ', $img, $text); |
| 286 | | } |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Display the size of the project. |
| 293 | * |
| 294 | * @param string Field |
| 295 | * @param IDF_Project |
| 296 | * @return string |
| 297 | */ |
| 298 | function IDF_Views_Admin_projectSize($field, $project) |
| 299 | { |
| 300 | $size = $project->getRepositorySize(); |
| 301 | if ($size == -1) { |
| 302 | return ''; |
| 303 | } |
| 304 | return Pluf_Utils::prettySize($size); |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Get a forge size. |
| 309 | * |
| 310 | * @return array Associative array with the size of each element |
| 311 | */ |
| 312 | function IDF_Views_Admin_getForgeSize() |
| 313 | { |
| 314 | $res = array(); |
| 315 | $res['repositories'] = 0; |
| 316 | foreach (Pluf::factory('IDF_Project')->getList() as $prj) { |
| 317 | $size = $prj->getRepositorySize(); |
| 318 | if ($size != -1) { |
| 319 | $res['repositories'] += $size; |
| 320 | } |
| 321 | } |
| 322 | $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs ' |
| 323 | .escapeshellarg(Pluf::f('upload_path')); |
| 324 | $out = split(' ', shell_exec($cmd), 2); |
| 325 | $res['downloads'] = $out[0]; |
| 326 | $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs ' |
| 327 | .escapeshellarg(Pluf::f('upload_issue_path')); |
| 328 | $out = split(' ', shell_exec($cmd), 2); |
| 329 | $res['attachments'] = $out[0]; |
| 330 | $res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments']; |
| 331 | // TODO: now we need the db |
| 332 | return $res; |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Get the database size as given by the database. |
| 337 | * |
| 338 | * @return int Database size |
| 339 | */ |
| 340 | function IDF_Views_Admin_getForgeDbSize() |
| 341 | { |
| 342 | |
| 343 | // MySQL: SHOW TABLE STATUS FROM database; |
| 344 | // then sum Data_length and Index_length for each table |
| 345 | // PostgreSQL: |
| 346 | // Directly stats the database file |
| 347 | } |
| src/IDF/templates/idf/gadmin/projects/index.html |
| 1 | 1 | {extends "idf/gadmin/projects/base.html"} |
| 2 | 2 | |
| 3 | | {block docclass}yui-t2{assign $inIndex=true}{/block} |
| 3 | {block docclass}yui-t3{assign $inIndex=true}{/block} |
| 4 | 4 | |
| 5 | 5 | {block body} |
| 6 | 6 | {$projects.render} |
| 7 | 7 | {/block} |
| 8 | 8 | |
| 9 | {block context} |
| 10 | <div class="issue-submit-info"> |
| 11 | <ul> |
| 12 | <li>{trans 'Repository size:'} {$size['repositories']|size}</li> |
| 13 | <li>{trans 'Attachment size:'} {$size['attachments']|size}</li> |
| 14 | <li>{trans 'Download size:'} {$size['downloads']|size}</li> |
| 15 | <li>{trans 'Forge size:'} {$size['total']|size}</li> |
| 16 | </ul> |
| 17 | <p>{trans 'The forge size does not include the database space yet.'}</p> |
| 18 | </div> |
| 19 | {/block} |
| 20 | |
| 21 | |