Esempio n. 1
0
<?php

echo '<table class="table table-striped table-condensed">';
echo '<thead><tr>
        <th>Server Name</th>
        <th>Port Status</th>
        <th>Operating System</th>
        <th>Memory</th>
        <th>CPU</th>
      </tr></thead>';
foreach (dbFetchRows("SELECT * FROM vminfo WHERE device_id = ? ORDER BY vmwVmDisplayName", array($device['device_id'])) as $vm) {
    print_vm_row($vm, $device);
}
echo "</table>";
$pagetitle[] = "Virtual Machines";
Esempio n. 2
0
function print_vm_table($vars)
{
    $sql = generate_vm_query($vars);
    $vms = array();
    foreach (dbFetchRows($sql) as $vm) {
        if (isset($GLOBALS['cache']['devices']['id'][$vm['device_id']])) {
            $vm['hostname'] = $GLOBALS['cache']['devices']['id'][$vm['device_id']]['hostname'];
            $vms[] = $vm;
        }
    }
    // Sorting
    // FIXME. Sorting can be as function, but in must before print_table_header and after get table from db
    switch ($vars['sort_order']) {
        case 'desc':
            $sort_order = SORT_DESC;
            $sort_neg = SORT_ASC;
            break;
        case 'reset':
            unset($vars['sort'], $vars['sort_order']);
            // no break here
        // no break here
        default:
            $sort_order = SORT_ASC;
            $sort_neg = SORT_DESC;
    }
    switch ($vars['sort']) {
        case 'name':
            $vms = array_sort_by($vms, 'vm_name', $sort_order, SORT_STRING);
            break;
        case 'os':
            $vms = array_sort_by($vms, 'vm_os', $sort_order, SORT_STRING);
            break;
        case 'state':
            $vms = array_sort_by($vms, 'vm_state', $sort_order, SORT_STRING);
            break;
        case 'memory':
            $vms = array_sort_by($vms, 'vm_memory', $sort_order, SORT_NUMERIC);
            break;
        case 'cpu':
            $vms = array_sort_by($vms, 'vm_cpucount', $sort_order, SORT_NUMERIC);
            break;
        default:
            // Not sorted
    }
    $vms_count = count($vms);
    // Pagination
    $pagination_html = pagination($vars, $vms_count);
    echo $pagination_html;
    if ($vars['pageno']) {
        $vms = array_chunk($vms, $vars['pagesize']);
        $vms = $vms[$vars['pageno'] - 1];
    }
    // End Pagination
    echo generate_box_open();
    print_vm_table_header($vars);
    foreach ($vms as $vm) {
        print_vm_row($vm, $vars);
    }
    echo '</tbody></table>';
    echo generate_box_close();
    echo $pagination_html;
}