This commit is contained in:
Hari 2026-03-31 23:50:51 -04:00 committed by GitHub
parent 4f174ec3a8
commit b68151035a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
81 changed files with 6263 additions and 545 deletions

View file

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace OCA\BetterNasControlplane\Controller;
use OCA\BetterNasControlplane\AppInfo\Application;
use OCA\BetterNasControlplane\Service\ControlPlaneClient;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
class ApiController extends OCSController {
public function __construct(
IRequest $request,
private readonly ControlPlaneClient $controlPlaneClient,
) {
parent::__construct(Application::APP_ID, $request);
}
#[NoAdminRequired]
#[ApiRoute(verb: 'GET', url: '/api/status')]
public function status(): DataResponse {
return new DataResponse($this->controlPlaneClient->fetchSnapshot());
}
}

View file

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace OCA\BetterNasControlplane\Controller;
use OCA\BetterNasControlplane\AppInfo\Application;
use OCA\BetterNasControlplane\Service\ControlPlaneClient;
use OCA\BetterNasControlplane\Service\ControlPlaneConfig;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
class PageController extends Controller {
public function __construct(
IRequest $request,
private readonly ControlPlaneClient $controlPlaneClient,
private readonly ControlPlaneConfig $controlPlaneConfig,
) {
parent::__construct(Application::APP_ID, $request);
}
#[NoCSRFRequired]
#[NoAdminRequired]
#[OpenAPI(OpenAPI::SCOPE_IGNORE)]
#[FrontpageRoute(verb: 'GET', url: '/')]
public function index(): TemplateResponse {
return new TemplateResponse(
Application::APP_ID,
'index',
[
'appName' => 'betterNAS Control Plane',
'controlPlaneUrl' => $this->controlPlaneConfig->getBaseUrl(),
'snapshot' => $this->controlPlaneClient->fetchSnapshot(),
],
);
}
}