diff --git a/plugins/dynamix/DashStats.page b/plugins/dynamix/DashStats.page index d78ef65d1..21ed585e8 100644 --- a/plugins/dynamix/DashStats.page +++ b/plugins/dynamix/DashStats.page @@ -251,12 +251,12 @@ foreach ($ports as $port) {
| Docker Containers | |||||
| Virtual Machines | |||||
| ";
- if ($_POST['docker']) {
- $user_prefs = $dockerManPaths['user-prefs'];
- $DockerClient = new DockerClient();
- $DockerTemplates = new DockerTemplates();
- $containers = $DockerClient->getDockerContainers();
- $allInfo = $DockerTemplates->getAllInfo();
- if (file_exists($user_prefs)) {
- $prefs = parse_ini_file($user_prefs); $sort = [];
- foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs) ?? 999;
- array_multisort($sort,SORT_NUMERIC,$containers);
- }
- foreach ($containers as $ct) {
- $name = $ct['Name'];
- $id = $ct['Id'];
- $info = &$allInfo[$name];
- $running = $info['running'] ? 1:0;
- $paused = $info['paused'] ? 1:0;
- $is_autostart = $info['autostart'] ? 'true':'false';
- $updateStatus = $info['updated']=='true'||$info['updated']=='undef' ? 'true':'false';
- $template = $info['template'];
- $shell = $info['shell'];
- $webGui = html_entity_decode($info['url']);
- $support = html_entity_decode($info['Support']);
- $project = html_entity_decode($info['Project']);
- $menu[] = sprintf("addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s');", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project));
- $shape = $running ? ($paused ? 'pause' : 'play') : 'square';
- $status = $running ? ($paused ? 'paused' : 'started') : 'stopped';
- $color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text');
- $update = $updateStatus=='false' ? 'blue-text' : '';
- $icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png';
- $image = substr($icon,-4)=='.png' ? " $status"; - } - $none = count($containers) ? "No running docker containers" : "No docker containers defined"; - echo ""; - } else { - echo "Docker service not running "; + $user_prefs = $dockerManPaths['user-prefs']; + $DockerClient = new DockerClient(); + $DockerTemplates = new DockerTemplates(); + $containers = $DockerClient->getDockerContainers(); + $allInfo = $DockerTemplates->getAllInfo(); + if (file_exists($user_prefs)) { + $prefs = parse_ini_file($user_prefs); $sort = []; + foreach ($containers as $ct) $sort[] = array_search($ct['Name'],$prefs) ?? 999; + array_multisort($sort,SORT_NUMERIC,$containers); } + echo " | |||||
| ";
+ foreach ($containers as $ct) {
+ $name = $ct['Name'];
+ $id = $ct['Id'];
+ $info = &$allInfo[$name];
+ $running = $info['running'] ? 1:0;
+ $paused = $info['paused'] ? 1:0;
+ $is_autostart = $info['autostart'] ? 'true':'false';
+ $updateStatus = $info['updated']=='true'||$info['updated']=='undef' ? 'true':'false';
+ $template = $info['template'];
+ $shell = $info['shell'];
+ $webGui = html_entity_decode($info['url']);
+ $support = html_entity_decode($info['Support']);
+ $project = html_entity_decode($info['Project']);
+ $menu[] = sprintf("addDockerContainerContext('%s','%s','%s',%s,%s,%s,%s,'%s','%s','%s','%s','%s');", addslashes($name), addslashes($ct['ImageId']), addslashes($template), $running, $paused, $updateStatus, $is_autostart, addslashes($webGui), $shell, $id, addslashes($support), addslashes($project));
+ $shape = $running ? ($paused ? 'pause' : 'play') : 'square';
+ $status = $running ? ($paused ? 'paused' : 'started') : 'stopped';
+ $color = $status=='started' ? 'green-text' : ($status=='paused' ? 'orange-text' : 'red-text');
+ $update = $updateStatus=='false' ? 'blue-text' : '';
+ $icon = $info['icon'] ?: '/plugins/dynamix.docker.manager/images/question.png';
+ $image = substr($icon,-4)=='.png' ? " $status"; + } + $none = count($containers) ? "No running docker containers" : "No docker containers defined"; + echo ""; echo " | |||||
| ";
- if ($_POST['vm']) {
- $user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg';
- $vms = $lv->get_domains();
- if (file_exists($user_prefs)) {
- $prefs = parse_ini_file($user_prefs); $sort = [];
- foreach ($vms as $vm) $sort[] = array_search($vm,$prefs) ?? 999;
- array_multisort($sort,SORT_NUMERIC,$vms);
- } else {
- natcasesort($vms);
- }
- foreach ($vms as $vm) {
- $res = $lv->get_domain_by_name($vm);
- $uuid = libvirt_domain_get_uuid_string($res);
- $dom = $lv->domain_get_info($res);
- $id = $lv->domain_get_id($res);
- $state = $lv->domain_state_translate($dom['state']);
- $vncport = $lv->domain_get_vnc_port($res);
- $vnc = '';
- if ($vncport > 0) {
- $wsport = $lv->domain_get_ws_port($res);
- $vnc = '/plugins/dynamix.vm.manager/vnc.html?autoconnect=true&host='.$_SERVER['HTTP_HOST'].'&port=&path=/wsproxy/'.$wsport.'/';
- } else {
- $vncport = ($vncport < 0) ? "auto" : "";
- }
- $template = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@name');
- if (empty($template)) $template = 'Custom';
- $log = (is_file("/var/log/libvirt/qemu/$vm.log") ? "libvirt/qemu/$vm.log" : '');
- $menu[] = sprintf("addVMContext('%s','%s','%s','%s','%s','%s');", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vnc), addslashes($log));
- $icon = $lv->domain_get_icon_url($res);
- switch ($state) {
- case 'running':
- $shape = 'play';
- $status = 'started';
- $color = 'green-text';
- break;
- case 'paused':
- case 'pmsuspended':
- $shape = 'pause';
- $status = 'paused';
- $color = 'orange-text';
- break;
- default:
- $shape = 'square';
- $status = 'stopped';
- $color = 'red-text';
- break;
- }
- $image = substr($icon,-4)=='.png' ? " $status"; - } - $none = count($vms) ? "No running virtual machines" : "No virtual machines defined"; - echo ""; + $user_prefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg'; + $vms = $lv->get_domains(); + if (file_exists($user_prefs)) { + $prefs = parse_ini_file($user_prefs); $sort = []; + foreach ($vms as $vm) $sort[] = array_search($vm,$prefs) ?? 999; + array_multisort($sort,SORT_NUMERIC,$vms); } else { - echo "VM service not running "; + natcasesort($vms); } + echo " | |||||
| ";
+ foreach ($vms as $vm) {
+ $res = $lv->get_domain_by_name($vm);
+ $uuid = libvirt_domain_get_uuid_string($res);
+ $dom = $lv->domain_get_info($res);
+ $id = $lv->domain_get_id($res);
+ $state = $lv->domain_state_translate($dom['state']);
+ $vncport = $lv->domain_get_vnc_port($res);
+ $vnc = '';
+ if ($vncport > 0) {
+ $wsport = $lv->domain_get_ws_port($res);
+ $vnc = '/plugins/dynamix.vm.manager/vnc.html?autoconnect=true&host='.$_SERVER['HTTP_HOST'].'&port=&path=/wsproxy/'.$wsport.'/';
+ } else {
+ $vncport = ($vncport < 0) ? "auto" : "";
+ }
+ $template = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@name');
+ if (empty($template)) $template = 'Custom';
+ $log = (is_file("/var/log/libvirt/qemu/$vm.log") ? "libvirt/qemu/$vm.log" : '');
+ $menu[] = sprintf("addVMContext('%s','%s','%s','%s','%s','%s');", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vnc), addslashes($log));
+ $icon = $lv->domain_get_icon_url($res);
+ switch ($state) {
+ case 'running':
+ $shape = 'play';
+ $status = 'started';
+ $color = 'green-text';
+ break;
+ case 'paused':
+ case 'pmsuspended':
+ $shape = 'pause';
+ $status = 'paused';
+ $color = 'orange-text';
+ break;
+ default:
+ $shape = 'square';
+ $status = 'stopped';
+ $color = 'red-text';
+ break;
+ }
+ $image = substr($icon,-4)=='.png' ? " $status"; + } + $none = count($vms) ? "No running virtual machines" : "No virtual machines defined"; + echo ""; echo " | |||||