Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"php": "^8.4",
"php-http/guzzle7-adapter": "^1.1",
"php-di/php-di": "7.1.1",
"dhope0000/lxd": "^1.2.0",
"dhope0000/lxd": "^1.3.0",
"vlucas/phpdotenv": "^5.6",
"symfony/http-foundation": "^7.3.6",
"symfony/filesystem": "^7.3.6",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace dhope0000\LXDClient\Controllers\Hosts\OS\Applications;

use dhope0000\LXDClient\Model\Users\FetchUserDetails;
use dhope0000\LXDClient\Objects\Host;
use dhope0000\LXDClient\Tools\Hosts\OS\GetOSOverview;
use Symfony\Component\Routing\Attribute\Route;

class GetApplicationController
{
public function __construct(
private readonly GetOSOverview $getOSOverview,
private readonly FetchUserDetails $fetchUserDetails
) {
}

#[Route(path: '/api/hosts/os/applications', name: 'Get OS system application (IncusOS host only)', methods: ['POST', 'GET'])]
public function get(int $userId, Host $host, string $application)
{
$isAdmin = $this->fetchUserDetails->isAdmin($userId);
if (!$isAdmin) {
throw new \Exception('No access', 1);
}
return $host->incusOS->applications->info($application);
}
}
27 changes: 27 additions & 0 deletions src/classes/Controllers/Hosts/OS/GetHostOSController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace dhope0000\LXDClient\Controllers\Hosts\OS;

use dhope0000\LXDClient\Model\Users\FetchUserDetails;
use dhope0000\LXDClient\Objects\Host;
use dhope0000\LXDClient\Tools\Hosts\OS\GetOSOverview;
use Symfony\Component\Routing\Attribute\Route;

class GetHostOSController
{
public function __construct(
private readonly GetOSOverview $getOSOverview,
private readonly FetchUserDetails $fetchUserDetails
) {
}

#[Route(path: '/api/hosts/os', name: 'Get host OS data (IncusOS host only)', methods: ['POST', 'GET'])]
public function get(int $userId, Host $host)
{
$isAdmin = $this->fetchUserDetails->isAdmin($userId);
if (!$isAdmin) {
throw new \Exception('No access', 1);
}
return $this->getOSOverview->get($host);
}
}
27 changes: 27 additions & 0 deletions src/classes/Controllers/Hosts/OS/Services/GetServiceController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace dhope0000\LXDClient\Controllers\Hosts\OS\Services;

use dhope0000\LXDClient\Model\Users\FetchUserDetails;
use dhope0000\LXDClient\Objects\Host;
use dhope0000\LXDClient\Tools\Hosts\OS\GetOSOverview;
use Symfony\Component\Routing\Attribute\Route;

class GetServiceController
{
public function __construct(
private readonly GetOSOverview $getOSOverview,
private readonly FetchUserDetails $fetchUserDetails
) {
}

#[Route(path: '/api/hosts/os/services', name: 'Get OS service data (IncusOS host only)', methods: ['POST', 'GET'])]
public function get(int $userId, Host $host, string $service)
{
$isAdmin = $this->fetchUserDetails->isAdmin($userId);
if (!$isAdmin) {
throw new \Exception('No access', 1);
}
return $host->incusOS->services->info($service);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace dhope0000\LXDClient\Controllers\Hosts\OS\System;

use dhope0000\LXDClient\Model\Users\FetchUserDetails;
use dhope0000\LXDClient\Objects\Host;
use dhope0000\LXDClient\Tools\Hosts\OS\GetOSOverview;
use Symfony\Component\Routing\Attribute\Route;

class GetSystemEndpointController
{
public function __construct(
private readonly GetOSOverview $getOSOverview,
private readonly FetchUserDetails $fetchUserDetails
) {
}

#[Route(path: '/api/hosts/os/system/endpoint', name: 'Get OS system data (IncusOS host only)', methods: ['POST', 'GET'])]
public function get(int $userId, Host $host, string $endpoint)
{
$isAdmin = $this->fetchUserDetails->isAdmin($userId);
if (!$isAdmin) {
throw new \Exception('No access', 1);
}
return $host->incusOS->system->$endpoint->info();
}
}
23 changes: 23 additions & 0 deletions src/classes/Tools/Hosts/OS/GetOSOverview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace dhope0000\LXDClient\Tools\Hosts\OS;

use dhope0000\LXDClient\Objects\Host;

class GetOSOverview
{
public function __construct(
) {}

public function get(Host $host)
{
$systemEndpoints = $host->incusOS->system->endpoints();
$applications = $host->incusOS->applications->all();
$services = $host->incusOS->services->all();
return [
"applications"=>$applications,
"systemEndpoints"=>$systemEndpoints,
"services"=>$services
];
}
}
17 changes: 17 additions & 0 deletions src/classes/Tools/Hosts/OS/System/GetSystemEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace dhope0000\LXDClient\Tools\Hosts\OS;

use dhope0000\LXDClient\Objects\Host;

class GetSystemEndpoint
{
public function __construct(
) {}

public function get(Host $host, string $endpoint)
{
return $host->incusOS->system->$endpoint->info();

}
}
8 changes: 8 additions & 0 deletions src/views/boxes/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
<i class="fas fa-exchange-alt pe-2"></i>Proxy Devices
</div>
</li>
<li class="nav-item enableIfAdmin" data-view="serverOSView">
<div class="nav-link " id="serverDiskBtn">
<i class="fas fa-server pe-2" style="color: black !important;"></i>OS
</div>
</li>
<li class="nav-item enableIfAdmin" data-view="serverDiskBox">
<div class="nav-link " id="serverDiskBtn">
<i class="fas fa-hdd pe-2" style="color: black !important;"></i>Disks
Expand Down Expand Up @@ -217,6 +222,7 @@
</div>
<?php
require_once __DIR__ . "/server/instances.html";
require_once __DIR__ . "/server/os.php";
?>
</div>
</div>
Expand Down Expand Up @@ -574,6 +580,8 @@ function loadHostWarnings(req){
router.navigate(`/host/${currentServer.hostAlias}/settings`)
}else if($(this).data("view") == "serverDiskBox"){
router.navigate(`/host/${currentServer.hostAlias}/disks`)
}else if($(this).data("view") == "serverOSView"){
router.navigate(`/host/${currentServer.hostAlias}/os`)
}
});

Expand Down
71 changes: 71 additions & 0 deletions src/views/boxes/server/os.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<div class="serverViewBox" id="serverOSView">
<div class="row">
<div class="col-md-3">
<div class="card text-white bg-dark card-body">
<h5>System</h5>
<table class="table table-sm table-dark table-bordered" id="systemEndpointsTbl">
<thead></thead>
<tbody></tbody>
</table>
<h5>Applications</h5>
<table class="table table-sm table-dark table-bordered" id="systemApplicationsTbl">
<thead></thead>
<tbody></tbody>
</table>
<h5>Services</h5>
<table class="table table-sm table-dark table-bordered" id="systemServicesTbl">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="col-md-9">
<?php require __DIR__ . "/os/apps.php" ?>
<?php require __DIR__ . "/os/services.php" ?>
<?php require __DIR__ . "/os/system.php" ?>
</div>
</div>
</div>
<script>
function loadHostOSSidebar(targetUrl = null) {
ajaxRequest('/api/hosts/os', {
hostId: currentServer.hostId
}, (data) => {
data = makeToastr(data)

function _makeTrs(table, entries, entryClass) {
let trs = ""
entries.forEach(endpoint => {
const url = `host/${currentServer.hostAlias}/os/${entryClass}/${endpoint}`
trs += `<tr>
<td class="table-${targetUrl == url ? "primary" : ""}"><a class="text-${targetUrl == url ? "dark" : ""}" href="/${url}" data-navigo>${endpoint}</a></td>
</tr>`
})
$(table).empty().append(trs)
}
_makeTrs("#systemEndpointsTbl > tbody", data.systemEndpoints, "system")
_makeTrs("#systemApplicationsTbl > tbody", data.applications, "apps")
_makeTrs("#systemServicesTbl > tbody", data.services, "services")
router.updatePageLinks()
});
}

function loadHostOS(req) {
currentContainerDetails = null;
let hostId = req.data.hostId;
currentServer.hostId = hostId
currentServer.hostAlias = hostsAliasesLookupTable[hostId]
createDashboardSidebar()
_loadServerDetailsIfReq(hostId);
changeActiveNav(".overview")
$(".boxSlide, .serverViewBox, .serverOSBox").hide();
$("#serverOSView, #serverBox").show();

addBreadcrumbs(["Dashboard", hostsAliasesLookupTable[hostId], "OS"], ["", "", "active"], false, ["/", "", ""]);

$("#serverBoxNav").find(".active").removeClass("active")
$("#serverBoxNav .nav-item[data-view='serverOSView'] > .nav-link").addClass("active")

loadHostOSSidebar()
}
</script>
53 changes: 53 additions & 0 deletions src/views/boxes/server/os/applications/incus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div class="systemApplicationBox" id="systemAppIncus">
<div class="row">
<div class="col-md-6">
<div class="card bg-dark text-white">
<div class="card-header">
<h5>Config</h5>
</div>
<div class="card-body">
<table class="table table-dark" id="systemAppIncusConfigTbl">
<tbody>

</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card bg-dark text-white">
<div class="card-header">
<h5>State</h5>
</div>
<div class="card-body">
<table class="table table-dark" id="systemAppIncusStateTbl">
<tbody>

</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
function renderIncus(data) {
$("#systemAppIncus").show()
$("#systemAppIncusConfigTbl > tbody").empty().append(Object.keys(data.config).map(key => {
return `<tr>
<th>${key}</th>
<td>${data.config[key]}</td>
</tr>`
}).join(""))
$("#systemAppIncusStateTbl > tbody").empty().append(`
<tr>
<th>Initialized</th>
<td>${data.state.initialized}</td>
</tr>
<tr>
<th>Version</th>
<td>${data.state.version}</td>
</tr>
`)
}
</script>
Loading
Loading