revamped settings frontend

This commit is contained in:
huangjx
2022-07-29 21:09:08 +08:00
parent 9075c8fb50
commit e85b8b87ba
15 changed files with 648 additions and 337 deletions

View File

@@ -9,7 +9,8 @@ use OCP\IDBConnection;
use OCP\Settings\ISettings;
use OCA\NCDownloader\Db\Settings;
class Admin implements ISettings {
class Admin implements ISettings
{
/** @var IDBConnection */
private $connection;
@@ -18,9 +19,11 @@ class Admin implements ISettings {
/** @var IConfig */
private $config;
public function __construct(IDBConnection $connection,
ITimeFactory $timeFactory,
IConfig $config) {
public function __construct(
IDBConnection $connection,
ITimeFactory $timeFactory,
IConfig $config
) {
$this->connection = $connection;
$this->timeFactory = $timeFactory;
$this->config = $config;
@@ -31,13 +34,18 @@ class Admin implements ISettings {
/**
* @return TemplateResponse
*/
public function getForm() {
public function getForm()
{
$this->settings->setType($this->settings::TYPE['SYSTEM']);
$parameters = [
"path" => "/apps/ncdownloader/admin/save",
"ncd_yt_binary" => $this->settings->get("ncd_yt_binary"),
"ncd_aria2_binary" => $this->settings->get("ncd_aria2_binary"),
"ncd_rpctoken" => $this->settings->get("ncd_rpctoken"),
'settings' => [
"path" => "/apps/ncdownloader/admin/save",
"ncd_yt_binary" => $this->settings->get("ncd_yt_binary"),
"ncd_aria2_binary" => $this->settings->get("ncd_aria2_binary"),
"ncd_rpctoken" => $this->settings->get("ncd_rpctoken"),
"ncd_aria2_rpc_host" => $this->settings->get("ncd_aria2_rpc_host"),
"ncd_aria2_rpc_port" => $this->settings->get("ncd_aria2_rpc_port"),
]
];
return new TemplateResponse('ncdownloader', 'settings/Admin', $parameters, '');
}
@@ -45,7 +53,8 @@ class Admin implements ISettings {
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection(): string {
public function getSection(): string
{
return 'ncdownloader';
}
@@ -56,7 +65,8 @@ class Admin implements ISettings {
*
* E.g.: 70
*/
public function getPriority(): int {
public function getPriority(): int
{
return 0;
}
}

View File

@@ -10,7 +10,8 @@ use OCP\Settings\ISettings;
use OCA\NCDownloader\Db\Settings;
use OCA\NCDownloader\Tools\Helper;
class Personal implements ISettings {
class Personal implements ISettings
{
/** @var IDBConnection */
private $connection;
@@ -19,39 +20,45 @@ class Personal implements ISettings {
/** @var IConfig */
private $config;
public function __construct(IDBConnection $connection,
ITimeFactory $timeFactory,
IConfig $config) {
public function __construct(
IDBConnection $connection,
ITimeFactory $timeFactory,
IConfig $config
) {
$this->connection = $connection;
$this->timeFactory = $timeFactory;
$this->config = $config;
$this->UserId = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->UserId);
$this->UserId = \OC::$server->getUserSession()->getUser()->getUID();
$this->settings = new Settings($this->UserId);
}
/**
* @return TemplateResponse
*/
public function getForm() {
public function getForm()
{
$parameters = [
"ncd_downloader_dir" => Helper::getDownloadDir(),
"ncd_torrents_dir" => $this->settings->get("ncd_torrents_dir"),
"ncd_seed_ratio" => $this->settings->get("ncd_seed_ratio"),
'ncd_seed_time_unit' => $this->settings->get("ncd_seed_time_unit"),
'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
"path" => '/apps/ncdownloader/personal/save',
"settings" => [
"ncd_downloader_dir" => Helper::getDownloadDir(),
"ncd_torrents_dir" => $this->settings->get("ncd_torrents_dir"),
"ncd_seed_ratio" => $this->settings->get("ncd_seed_ratio"),
'ncd_seed_time_unit' => $this->settings->get("ncd_seed_time_unit"),
'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
"path" => '/apps/ncdownloader/personal/save',
]
];
//\OC_Util::addScript($this->appName, 'common');
//\OC_Util::addScript($this->appName, 'settings/personal');
//file_put_contents("/tmp/re.log",print_r($parameters,true));
//file_put_contents("/tmp/re.log",print_r($parameters,true));
return new TemplateResponse('ncdownloader', 'settings/Personal', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection(): string {
public function getSection(): string
{
return 'ncdownloader';
}
@@ -62,7 +69,8 @@ class Personal implements ISettings {
*
* E.g.: 70
*/
public function getPriority(): int {
public function getPriority(): int
{
return 100;
}
}