moved options data to backend processsing
This commit is contained in:
@@ -28,7 +28,6 @@ class Aria2Controller extends Controller
|
||||
private $rootFolder;
|
||||
private $downloadDir;
|
||||
private $urlGenerator;
|
||||
|
||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, IRootFolder $rootFolder, Aria2 $aria2)
|
||||
{
|
||||
parent::__construct($appName, $request);
|
||||
|
||||
@@ -43,6 +43,7 @@ class Admin implements ISettings
|
||||
];
|
||||
$parameters = [
|
||||
'settings' => $settings,
|
||||
'options' => Helper::getAdminOptions($settings),
|
||||
];
|
||||
return new TemplateResponse('ncdownloader', 'settings/Admin', $parameters, '');
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class Personal implements ISettings
|
||||
*/
|
||||
public function getForm()
|
||||
{
|
||||
$path = '/apps/ncdownloader/personal/save';
|
||||
$parameters = [
|
||||
"settings" => [
|
||||
"ncd_downloader_dir" => Helper::getDownloadDir(),
|
||||
@@ -46,11 +47,27 @@ class Personal implements ISettings
|
||||
"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',
|
||||
"path" => $path,
|
||||
"disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"),
|
||||
"is_admin" => \OC_User::isAdminUser($this->uid),
|
||||
"aria2_version" => Helper::getAria2Version(),
|
||||
"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);
|
||||
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>
|
||||
<div class="section">
|
||||
<settingsRow
|
||||
v-for="(option, key) in optionRows"
|
||||
v-bind:key="key"
|
||||
:value="option.value"
|
||||
:id="option.id"
|
||||
:label="option.label"
|
||||
:placeholder="option.placeholder"
|
||||
:path="option.path"
|
||||
/>
|
||||
<settingsRow v-for="(option, key) in optionRows" v-bind:key="key" :value="option.value" :id="option.id"
|
||||
:label="option.label" :placeholder="option.placeholder" :path="option.path" />
|
||||
</div>
|
||||
<div class="section">
|
||||
<toggleButton
|
||||
:defaultStatus="pStatus"
|
||||
disabledText="No Aria2 Settings for non-admin Users"
|
||||
enabledText="No Aria2 Settings for non-admin Users"
|
||||
@changed="toggle"
|
||||
name="disallow_aria2_settings"
|
||||
></toggleButton>
|
||||
<toggleButton :defaultStatus="pStatus" disabledText="No Aria2 Settings for non-admin Users"
|
||||
enabledText="No Aria2 Settings for non-admin Users" @changed="toggle" name="disallow_aria2_settings">
|
||||
</toggleButton>
|
||||
</div>
|
||||
<customOptions
|
||||
name="admin-aria2-settings"
|
||||
@mounted="render"
|
||||
title="Global Aria2 Settings"
|
||||
path="/apps/ncdownloader/admin/aria2/save"
|
||||
:validOptions="validOptions"
|
||||
>
|
||||
<customOptions name="admin-aria2-settings" @mounted="render" title="Global Aria2 Settings"
|
||||
path="/apps/ncdownloader/admin/aria2/save" :validOptions="validOptions">
|
||||
<template #save>Save Settings</template>
|
||||
</customOptions>
|
||||
</template>
|
||||
@@ -95,50 +79,11 @@ export default {
|
||||
try {
|
||||
let data = this.$el.parentElement.getAttribute("data-settings");
|
||||
data = JSON.parse(data);
|
||||
let options = this.$el.parentElement.getAttribute("data-options");
|
||||
options = JSON.parse(options);
|
||||
this.settings = data;
|
||||
this.pStatus = helper.str2Boolean(data["disallow_aria2_settings"]);
|
||||
let path = "/apps/ncdownloader/admin/save";
|
||||
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,
|
||||
},
|
||||
];
|
||||
this.options = options;
|
||||
} catch (e) {
|
||||
helper.error(e);
|
||||
}
|
||||
|
||||
@@ -98,27 +98,13 @@ export default {
|
||||
try {
|
||||
let data = this.$el.parentElement.getAttribute("data-settings");
|
||||
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.isAdmin = data["is_admin"];
|
||||
this.aria2Version = data["aria2_version"];
|
||||
this.ytdVersion = data["ytdl_version"];
|
||||
this.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,
|
||||
},
|
||||
];
|
||||
this.options = options
|
||||
} catch (e) {
|
||||
helper.error(e);
|
||||
}
|
||||
@@ -126,7 +112,6 @@ export default {
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
.system-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -3,6 +3,6 @@ script("ncdownloader", 'appSettings');
|
||||
style("ncdownloader", 'appSettings');
|
||||
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>
|
||||
@@ -4,6 +4,5 @@ style("ncdownloader", 'appSettings');
|
||||
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>
|
||||
Reference in New Issue
Block a user