Skip to content

Commit

Permalink
update admin settings panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ylebre committed Oct 4, 2024
1 parent 4e49e20 commit 176afc4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 33 deletions.
3 changes: 2 additions & 1 deletion solid/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ When you do this, the Solid App can store data in your Nextcloud account through
<nextcloud min-version="28" max-version="30"/>
</dependencies>
<settings>
<admin>\OCA\Solid\Settings</admin>
<admin>OCA\Solid\Settings\SolidAdmin</admin>
<admin-section>OCA\Solid\Sections\SolidAdmin</admin-section>
</settings>
<navigations>
<navigation>
Expand Down
32 changes: 32 additions & 0 deletions solid/lib/Sections/SolidAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace OCA\Solid\Sections;

use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;

class SolidAdmin implements IIconSection {
private IL10N $l;
private IURLGenerator $urlGenerator;

public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
$this->l = $l;
$this->urlGenerator = $urlGenerator;
}

public function getIcon(): string {
return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg');
}

public function getID(): string {
return 'solid';
}

public function getName(): string {
return $this->l->t('Solid');
}

public function getPriority(): int {
return 98;
}
}
32 changes: 0 additions & 32 deletions solid/lib/Settings.php

This file was deleted.

47 changes: 47 additions & 0 deletions solid/lib/Settings/SolidAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
namespace OCA\Solid\Settings;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;
use OCA\Solid\ServerConfig;

class SolidAdmin implements ISettings {
private IL10N $l;
private IConfig $config;
private ServerConfig $serverConfig;

public function __construct(IConfig $config, IL10N $l, ServerConfig $serverConfig) {
$this->config = $config;
$this->l = $l;
$this->serverConfig = $serverConfig;
}

/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'privateKey' => $this->serverConfig->getPrivateKey(),
'encryptionKey' => $this->serverConfig->getEncryptionKey()
];

return new TemplateResponse('solid', 'admin', $parameters, '');
}

public function getSection() {
return 'solid'; // Name of the previously created section.
}

/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 70;
}
}

0 comments on commit 176afc4

Please sign in to comment.