From b245d86123f531eb25a60d3109cf09668594abec Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 11 May 2012 02:48:18 +0200 Subject: [PATCH] Add container list to user lookup page --- frontend/css/cvm.css | 2 ++ frontend/locales/english.lng | 2 ++ frontend/module.admin.user.php | 27 +++++++++++++++- frontend/templates/admin.user.tpl | 54 ++++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 2 deletions(-) diff --git a/frontend/css/cvm.css b/frontend/css/cvm.css index e15ac33..2052949 100644 --- a/frontend/css/cvm.css +++ b/frontend/css/cvm.css @@ -23,6 +23,8 @@ h2 h3 { font-size: 20px; + margin-top: 8px; + margin-bottom: 3px; } p diff --git a/frontend/locales/english.lng b/frontend/locales/english.lng index f166412..2aecdd1 100644 --- a/frontend/locales/english.lng +++ b/frontend/locales/english.lng @@ -31,6 +31,8 @@ title-console; Out-of-band console title-admin-userlist; User overview title-admin-userinfo; User lookup +header-admin-user-containers; Containers owned by this user + button-login; Login button-reinstall; Reinstall button-password; Set new root password diff --git a/frontend/module.admin.user.php b/frontend/module.admin.user.php index 76b4ae6..304b4a1 100644 --- a/frontend/module.admin.user.php +++ b/frontend/module.admin.user.php @@ -15,12 +15,37 @@ try { $sUserEntry = new User($router->uParameters[1]); + $sContainerList = array(); + + if($result = mysql_query_cached("SELECT * FROM containers WHERE `UserId` = '{$sUserEntry->sId}'")) + { + foreach($result->data as $row) + { + $sContainer = new Container($row); + + $sContainerList[] = array( + 'id' => $sContainer->sId, + 'hostname' => $sContainer->sHostname, + 'node' => $sContainer->sNode->sName, + 'node-hostname' => $sContainer->sNode->sHostname, + 'template' => $sContainer->sTemplate->sName, + 'diskspace' => number_format($sContainer->sDiskSpace / 1024), + 'diskspace-unit' => "GB", + 'guaranteed-ram' => $sContainer->sGuaranteedRam, + 'guaranteed-ram-unit' => "MB", + 'status' => $sContainer->sStatusText, + 'virtualization-type' => $sContainer->sVirtualizationType + ); + } + } + $sPageContents = Templater::InlineRender("admin.user", $locale->strings, array( 'id' => $sUserEntry->sId, 'username' => $sUserEntry->sUsername, 'email' => $sUserEntry->sEmailAddress, 'accesslevel' => $sUserEntry->sAccessLevel, - 'containers' => $sUserEntry->sContainerCount + 'containercount' => $sUserEntry->sContainerCount, + 'containers' => $sContainerList )); } catch (NotFoundException $e) diff --git a/frontend/templates/admin.user.tpl b/frontend/templates/admin.user.tpl index 223babd..447536c 100644 --- a/frontend/templates/admin.user.tpl +++ b/frontend/templates/admin.user.tpl @@ -29,6 +29,58 @@ <%!admin-title-containers> - <%?containers> + <%?containercount> + +

<%!header-admin-user-containers>

+ + + + + + + + + + <%foreach container in containers> + + + + + + + + + <%/foreach> +
<%!list-column-hostname><%!list-column-platform><%!list-column-disk><%!list-column-ram><%!list-column-template>
+ <%if container[status] == running> + <%!list-status-running> + <%/if><%if container[status] == stopped> + <%!list-status-stopped> + <%/if><%if container[status] == suspended> + <%!list-status-suspended> + <%/if> + + + <%?container[hostname]> + + + + <%if container[virtualization-type] == 1> + OpenVZ + <%/if><%if container[virtualization-type] == 2> + Xen PV + <%/if><%if container[virtualization-type] == 3> + Xen HVM + <%/if><%if container[virtualization-type] == 4> + KVM + <%/if> + + + <%?container[diskspace]> + <%?container[diskspace-unit]> + + <%?container[guaranteed-ram]> + <%?container[guaranteed-ram-unit]> + <%?container[template]>