feat: add admin example

This commit is contained in:
2024-11-30 02:08:27 +02:00
parent 5f175ff8f4
commit 1b3804ba0d
5 changed files with 85 additions and 2 deletions

4
.phpactor.json Normal file
View File

@@ -0,0 +1,4 @@
{
"$schema": "/phpactor.schema.json",
"language_server_php_cs_fixer.enabled": true
}

View File

@@ -44,7 +44,7 @@ don't hesitate to open an appropriate issue and I will do my best to reply promp
<category>organization</category>
<bugs>https://github.com/chenasraf/nextcloud-autocurrency/issues</bugs>
<dependencies>
<nextcloud min-version="25" max-version="25"/>
<nextcloud min-version="25" max-version="30"/>
</dependencies>
<navigations>
<navigation>
@@ -55,4 +55,8 @@ don't hesitate to open an appropriate issue and I will do my best to reply promp
<background-jobs>
<job>OCA\AutoCurrency\Cron\FetchCurrenciesJob</job>
</background-jobs>
<settings>
<admin>OCA\AutoCurrency\Settings\CurrencyAdmin</admin>
<admin-section>OCA\AutoCurrency\Sections\CurrencyAdmin</admin-section>
</settings>
</info>

View File

@@ -0,0 +1,32 @@
<?php
namespace OCA\AutoCurrency\Sections;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;
class CurrencyAdmin 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 'autocurrency';
}
public function getName(): string {
return $this->l->t('Notes tutorial');
}
public function getPriority(): int {
return 98;
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace OCA\AutoCurrency\Settings;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;
class CurrencyAdmin implements ISettings {
private IL10N $l;
private IConfig $config;
public function __construct(IConfig $config, IL10N $l) {
$this->config = $config;
$this->l = $l;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'mySetting' => $this->config->getSystemValue('my_notes_setting', true),
];
return new TemplateResponse('settings', 'settings/admin', $parameters, '');
}
public function getSection() {
return 'autocurrency'; // 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 10;
}
}

View File

@@ -30,7 +30,7 @@
"extends @nextcloud/browserslist-config"
],
"engines": {
"node": "^16.0.0",
"node": ">=20.0.0",
"npm": "^7.0.0 || ^8.0.0"
},
"devDependencies": {