I am using owncloud 10 and want to develop an app with the app framework that uses hooks to send data to a backend service. I want the url of this backend service to be editable in a settings page.
My question is: how do i save this value properly?
Do i have to use OCP\Config::setSystemValue() to save the value?
If yes, how do i this? Do i have to write a javascript function?
This is the main.php:
<h1>Configure the settings of the connector here</h1>
<br>
<div>
IP-Address of backend service: <input type="text" name="ip" id="ip_address_field"><br>
Port number of backend service: <input type="number" id="port_field" name="port"><br>
<button name="save" onclick="sendValues()">Click me!</button>
</div>
This is the PageController.php
class PageController extends Controller
{
private $logger;
public function __construct($AppName, IRequest $request, ILogger $logger)
{
parent::__construct($AppName, $request);
$this->logger = $logger;
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index()
{
//returns templates/main.php
return new TemplateResponse('my-owncloud-app', 'main');
}
}
This is the JavaScript file:
$(document).ready(function () {
function sendValues() {
const ip = document.getElementById('ip_address_field').innerText
const port = document.getElementById('port_field').innerText
console.debug(ip)
}
});
What do I have to do in the js file? Do i have to call another php file and pass the values or can i save the values right here?
Is this even the right approach to save values like this? Or is there a different way to do this?