Adds Jitsi URL for loading the config.js and doing checks

main
Yasen Pramatarov 2024-08-27 21:18:27 +03:00
parent 666f3ca98b
commit 1780233778
4 changed files with 34 additions and 7 deletions

View File

@ -29,7 +29,7 @@ return [
// system info
'version' => '0.1.1',
// development has verbose error messages, production has not
'environment' => 'production',
'environment' => 'development',
// *************************************
// Maintained by the app, edit with care
@ -37,9 +37,20 @@ return [
'platforms' => [
'0' => [
'name' => 'meet.example.com',
'name' => 'meet1',
'jitsi_url' => 'https://meet.example.com',
'jilo_database' => '../../jilo/jilo.db',
],
'1' => [
'name' => 'meet2.example.com',
'jitsi_url' => 'https://test2.example.com',
'jilo_database' => '../../jilo/jilo2.db',
],
'2' => [
'name' => 'test3',
'jitsi_url' => 'https://test3.example.com',
'jilo_database' => '../../jilo/jilo2.db',
],
],
];

View File

@ -14,8 +14,9 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// new platform adding
if (isset($_POST['new']) && $_POST['new'] === 'true') {
$newPlatform = [
'name' => $_POST['name'],
'jilo_database' => $_POST['jilo_database'],
'name' => $_POST['name'],
'jitsi_url' => $_POST['jitsi_url'],
'jilo_database' => $_POST['jilo_database'],
];
// Determine the next available index for the new platform
@ -40,12 +41,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$platform = $_POST['platform'];
$config['platforms'][$platform]['name'] = $_POST['name'];
$config['platforms'][$platform]['jitsi_url'] = $_POST['jitsi_url'];
$config['platforms'][$platform]['jilo_database'] = $_POST['jilo_database'];
$platformsArray = formatArray($config['platforms'][$platform], 3);
$updatedContent = preg_replace(
"/\s*'$platform'\s*=>\s*\[\s*'name'\s*=>\s*'[^']*',\s*'jilo_database'\s*=>\s*'[^']*',\s*\],/s",
"/\s*'$platform'\s*=>\s*\[\s*'name'\s*=>\s*'[^']*',\s*'jitsi_url'\s*=>\s*'[^']*,\s*'jilo_database'\s*=>\s*'[^']*',\s*\],/s",
"",
$content
);
@ -57,12 +59,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$platform = $_POST['platform'];
$config['platforms'][$platform]['name'] = $_POST['name'];
$config['platforms'][$platform]['jitsi_url'] = $_POST['jitsi_url'];
$config['platforms'][$platform]['jilo_database'] = $_POST['jilo_database'];
$platformsArray = formatArray($config['platforms'][$platform], 3);
$updatedContent = preg_replace(
"/\s*'$platform'\s*=>\s*\[\s*'name'\s*=>\s*'[^']*',\s*'jilo_database'\s*=>\s*'[^']*',\s*\],/s",
"/\s*'$platform'\s*=>\s*\[\s*'name'\s*=>\s*'[^']*',\s*'jitsi_url'\s*=>\s*'[^']*',\s*'jilo_database'\s*=>\s*'[^']*',\s*\],/s",
"\n '{$platform}' => {$platformsArray},",
$content
);

View File

@ -19,7 +19,18 @@
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="name" class="form-label">jilo_database</label>
<label for="jitsi_url" class="form-label">Jitsi URL</label>
<span class="text-danger" style="margin-right: -12px;">*</span>
</div>
<div class="col-md-8">
<input class="form-control" type="text" name="jitsi_url" value="https://" required />
<p class="text-start"><small>URL of the Jitsi Meet (used for checks and for loading config.js)</small></p>
</div>
</div>
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="jilo_database" class="form-label">jilo_database</label>
<span class="text-danger" style="margin-right: -12px;">*</span>
</div>
<div class="col-md-8">

View File

@ -15,6 +15,8 @@
<input class="form-control" type="text" name="<?= htmlspecialchars($config_item) ?>" value="<?= htmlspecialchars($config_value ?? '')?>" required />
<?php if ($config_item === 'name') { ?>
<p class="text-start"><small>descriptive name for the platform</small></p>
<?php } elseif ($config_item === 'jitsi_url') { ?>
<p class="text-start"><small>URL of the Jitsi Meet (used for checks and for loading config.js)</small></p>
<?php } elseif ($config_item === 'jilo_database') { ?>
<p class="text-start"><small>path to the database file (relative to the app root)</small></p>
<?php } ?>