moved options data to backend processsing
This commit is contained in:
@@ -28,7 +28,6 @@ class Aria2Controller extends Controller
|
|||||||
private $rootFolder;
|
private $rootFolder;
|
||||||
private $downloadDir;
|
private $downloadDir;
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
|
|
||||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, IRootFolder $rootFolder, Aria2 $aria2)
|
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, IRootFolder $rootFolder, Aria2 $aria2)
|
||||||
{
|
{
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class Admin implements ISettings
|
|||||||
];
|
];
|
||||||
$parameters = [
|
$parameters = [
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
|
'options' => Helper::getAdminOptions($settings),
|
||||||
];
|
];
|
||||||
return new TemplateResponse('ncdownloader', 'settings/Admin', $parameters, '');
|
return new TemplateResponse('ncdownloader', 'settings/Admin', $parameters, '');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class Personal implements ISettings
|
|||||||
*/
|
*/
|
||||||
public function getForm()
|
public function getForm()
|
||||||
{
|
{
|
||||||
|
$path = '/apps/ncdownloader/personal/save';
|
||||||
$parameters = [
|
$parameters = [
|
||||||
"settings" => [
|
"settings" => [
|
||||||
"ncd_downloader_dir" => Helper::getDownloadDir(),
|
"ncd_downloader_dir" => Helper::getDownloadDir(),
|
||||||
@@ -46,11 +47,27 @@ class Personal implements ISettings
|
|||||||
"ncd_seed_ratio" => $this->settings->get("ncd_seed_ratio"),
|
"ncd_seed_ratio" => $this->settings->get("ncd_seed_ratio"),
|
||||||
'ncd_seed_time_unit' => $this->settings->get("ncd_seed_time_unit"),
|
'ncd_seed_time_unit' => $this->settings->get("ncd_seed_time_unit"),
|
||||||
'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
|
'ncd_seed_time' => $this->settings->get("ncd_seed_time"),
|
||||||
"path" => '/apps/ncdownloader/personal/save',
|
"path" => $path,
|
||||||
"disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"),
|
"disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"),
|
||||||
"is_admin" => \OC_User::isAdminUser($this->uid),
|
"is_admin" => \OC_User::isAdminUser($this->uid),
|
||||||
"aria2_version" => Helper::getAria2Version(),
|
"aria2_version" => Helper::getAria2Version(),
|
||||||
"ytdl_version" => Helper::getYtdlVersion(),
|
"ytdl_version" => Helper::getYtdlVersion(),
|
||||||
|
],
|
||||||
|
"options" => [
|
||||||
|
[
|
||||||
|
"label" => "Downloads Folder ",
|
||||||
|
"id" => "ncd_downloader_dir",
|
||||||
|
"value" => Helper::getDownloadDir(),
|
||||||
|
"placeholder" => Helper::getDownloadDir() ?? "/downloads",
|
||||||
|
"path" => $path,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"label" => "Torrents Folder",
|
||||||
|
"id" => "ncd_torrents_dir",
|
||||||
|
"value" => $this->settings->get("ncd_torrents_dir"),
|
||||||
|
"placeholder" => $this->settings->get("ncd_torrents_dir") ?? "/torrents",
|
||||||
|
"path" => $path,
|
||||||
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -550,4 +550,46 @@ class Helper
|
|||||||
$ytdl = self::query(Ytdl::class);
|
$ytdl = self::query(Ytdl::class);
|
||||||
return $ytdl->version();
|
return $ytdl->version();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getAdminOptions($data)
|
||||||
|
{
|
||||||
|
$options = [
|
||||||
|
[
|
||||||
|
"label" => "Aria2 RPC Host",
|
||||||
|
"id" => "ncd_aria2_rpc_host",
|
||||||
|
"value" => $data['ncd_aria2_rpc_host'] ?? "",
|
||||||
|
"placeholder" => $data['ncd_aria2_rpc_host'] ?? "127.0.0.1",
|
||||||
|
"path" => $data['path'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"label" => "Aria2 RPC Port",
|
||||||
|
"id" => "ncd_aria2_rpc_port",
|
||||||
|
"value" => $data['ncd_aria2_rpc_port'] ?? "",
|
||||||
|
"placeholder" => $data['ncd_aria2_rpc_port'] ?? 6800,
|
||||||
|
"path" => $data['path'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"label" => "Aria2 RPC Token",
|
||||||
|
"id" => "ncd_aria2_rpc_token",
|
||||||
|
"value" => $data['ncd_aria2_rpc_token'] ?? "",
|
||||||
|
"placeholder" => $data['ncd_aria2_rpc_token'] ?? "ncdownloader123",
|
||||||
|
"path" => $data['path'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"label" => "Youtube-dl binary",
|
||||||
|
"id" => "ncd_yt_binary",
|
||||||
|
"value" => $data['ncd_yt_binary'] ?? "",
|
||||||
|
"placeholder" => $data['ncd_yt_binary'] ?? "/usr/bin/youtube-dl",
|
||||||
|
"path" => $data['path'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"label" => "Aria2c binary",
|
||||||
|
"id" => "ncd_aria2_binary",
|
||||||
|
"value" => $data['ncd_aria2_binary'] ?? "",
|
||||||
|
"placeholder" => $data['ncd_aria2_binary'] ?? "/usr/bin/aria2c",
|
||||||
|
"path" => $data['path'],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<settingsRow
|
<settingsRow v-for="(option, key) in optionRows" v-bind:key="key" :value="option.value" :id="option.id"
|
||||||
v-for="(option, key) in optionRows"
|
:label="option.label" :placeholder="option.placeholder" :path="option.path" />
|
||||||
v-bind:key="key"
|
|
||||||
:value="option.value"
|
|
||||||
:id="option.id"
|
|
||||||
:label="option.label"
|
|
||||||
:placeholder="option.placeholder"
|
|
||||||
:path="option.path"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<toggleButton
|
<toggleButton :defaultStatus="pStatus" disabledText="No Aria2 Settings for non-admin Users"
|
||||||
:defaultStatus="pStatus"
|
enabledText="No Aria2 Settings for non-admin Users" @changed="toggle" name="disallow_aria2_settings">
|
||||||
disabledText="No Aria2 Settings for non-admin Users"
|
</toggleButton>
|
||||||
enabledText="No Aria2 Settings for non-admin Users"
|
|
||||||
@changed="toggle"
|
|
||||||
name="disallow_aria2_settings"
|
|
||||||
></toggleButton>
|
|
||||||
</div>
|
</div>
|
||||||
<customOptions
|
<customOptions name="admin-aria2-settings" @mounted="render" title="Global Aria2 Settings"
|
||||||
name="admin-aria2-settings"
|
path="/apps/ncdownloader/admin/aria2/save" :validOptions="validOptions">
|
||||||
@mounted="render"
|
|
||||||
title="Global Aria2 Settings"
|
|
||||||
path="/apps/ncdownloader/admin/aria2/save"
|
|
||||||
:validOptions="validOptions"
|
|
||||||
>
|
|
||||||
<template #save>Save Settings</template>
|
<template #save>Save Settings</template>
|
||||||
</customOptions>
|
</customOptions>
|
||||||
</template>
|
</template>
|
||||||
@@ -95,50 +79,11 @@ export default {
|
|||||||
try {
|
try {
|
||||||
let data = this.$el.parentElement.getAttribute("data-settings");
|
let data = this.$el.parentElement.getAttribute("data-settings");
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
let options = this.$el.parentElement.getAttribute("data-options");
|
||||||
|
options = JSON.parse(options);
|
||||||
this.settings = data;
|
this.settings = data;
|
||||||
this.pStatus = helper.str2Boolean(data["disallow_aria2_settings"]);
|
this.pStatus = helper.str2Boolean(data["disallow_aria2_settings"]);
|
||||||
let path = "/apps/ncdownloader/admin/save";
|
this.options = options;
|
||||||
this.options = [
|
|
||||||
{
|
|
||||||
label: "Aria2 RPC Host",
|
|
||||||
id: "ncd_aria2_rpc_host",
|
|
||||||
value: data.ncd_aria2_rpc_host,
|
|
||||||
placeholder: "127.0.0.1",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Aria2 RPC Port",
|
|
||||||
id: "ncd_aria2_rpc_port",
|
|
||||||
value: data.ncd_aria2_rpc_port,
|
|
||||||
placeholder: "6800",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Aria2 RPC Token",
|
|
||||||
id: "ncd_aria2_rpc_token",
|
|
||||||
value: data.ncd_aria2_rpc_token,
|
|
||||||
placeholder: data.ncd_aria2_rpc_token
|
|
||||||
? data.ncd_aria2_rpc_token
|
|
||||||
: "ncdownloader123",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Youtube-dl binary",
|
|
||||||
id: "ncd_yt_binary",
|
|
||||||
value: data.ncd_yt_binary,
|
|
||||||
placeholder: data.ncd_yt_binary
|
|
||||||
? data.ncd_yt_binary
|
|
||||||
: "/usr/local/bin/youtube-dl",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Aria2c binary",
|
|
||||||
id: "ncd_aria2_binary",
|
|
||||||
value: data.ncd_aria2_binary,
|
|
||||||
placeholder: "/usr/local/bin/aria2c",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
helper.error(e);
|
helper.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,27 +98,13 @@ export default {
|
|||||||
try {
|
try {
|
||||||
let data = this.$el.parentElement.getAttribute("data-settings");
|
let data = this.$el.parentElement.getAttribute("data-settings");
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
let path = "/apps/ncdownloader/personal/save";
|
let options = this.$el.parentElement.getAttribute("data-options");
|
||||||
|
options = JSON.parse(options);
|
||||||
this.disallowAria2Settings = helper.str2Boolean(data["disallow_aria2_settings"]);
|
this.disallowAria2Settings = helper.str2Boolean(data["disallow_aria2_settings"]);
|
||||||
this.isAdmin = data["is_admin"];
|
this.isAdmin = data["is_admin"];
|
||||||
this.aria2Version = data["aria2_version"];
|
this.aria2Version = data["aria2_version"];
|
||||||
this.ytdVersion = data["ytdl_version"];
|
this.ytdVersion = data["ytdl_version"];
|
||||||
this.options = [
|
this.options = options
|
||||||
{
|
|
||||||
label: "Downloads Folder ",
|
|
||||||
id: "ncd_downloader_dir",
|
|
||||||
value: data.ncd_downloader_dir,
|
|
||||||
placeholder: data.ncd_downloader_dir ? data.ncd_downloader_dir : "/downloads",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Torrents Folder",
|
|
||||||
id: "ncd_torrents_dir",
|
|
||||||
value: data.ncd_torrents_dir,
|
|
||||||
placeholder: data.ncd_torrents_dir ? data.ncd_torrents_dir : "/torrents",
|
|
||||||
path: path,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
helper.error(e);
|
helper.error(e);
|
||||||
}
|
}
|
||||||
@@ -126,7 +112,6 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.system-info {
|
.system-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ script("ncdownloader", 'appSettings');
|
|||||||
style("ncdownloader", 'appSettings');
|
style("ncdownloader", 'appSettings');
|
||||||
extract($_);
|
extract($_);
|
||||||
?>
|
?>
|
||||||
<div id="ncdownloader-admin-settings" class="ncdownloader-admin-settings" data-settings='<?php print json_encode($settings);?>'>
|
<div id="ncdownloader-admin-settings" class="ncdownloader-admin-settings" data-settings='<?php print json_encode($settings);?>' data-options='<?php print json_encode($options);?>'>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -4,6 +4,5 @@ style("ncdownloader", 'appSettings');
|
|||||||
extract($_);
|
extract($_);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="ncdownloader-personal-settings" id="ncdownloader-personal-settings" data-settings='<?php print json_encode($settings); ?>'>
|
<div class="ncdownloader-personal-settings" id="ncdownloader-personal-settings" data-settings='<?php print json_encode($settings); ?>' data-options='<?php print json_encode($options); ?>'>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user