Files

195 lines
12 KiB
PHTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$isUpgrade = $isUpgrade ?? false;
$lockedDatabase = $lockedDatabase ?? null;
$defaultAppDomain = $defaultAppDomain ?? 'localhost';
$defaultHttpPort = $defaultHttpPort ?? '80';
$defaultHttpsPort = $defaultHttpsPort ?? '443';
$defaultEmailCertificates = $defaultEmailCertificates ?? '';
$defaultAssistantOpenAIKey = $defaultAssistantOpenAIKey ?? '';
$defaultDatabase = $defaultDatabase ?? 'mongodb';
$enabledDatabases = $enabledDatabases ?? ['mongodb', 'mariadb', 'postgresql'];
$selectedDatabase = $lockedDatabase ?: $defaultDatabase;
$isDatabaseLocked = !empty($lockedDatabase);
$mongoEnabled = in_array('mongodb', $enabledDatabases, true);
$mariaEnabled = in_array('mariadb', $enabledDatabases, true);
$postgresEnabled = in_array('postgresql', $enabledDatabases, true);
$mongoDisabled = $isDatabaseLocked && $selectedDatabase !== 'mongodb';
$mariaDisabled = $isDatabaseLocked && $selectedDatabase !== 'mariadb';
$postgresDisabled = $isDatabaseLocked && $selectedDatabase !== 'postgresql';
$hostnameValue = htmlspecialchars((string) $defaultAppDomain, ENT_QUOTES, 'UTF-8');
$httpPortValue = htmlspecialchars((string) $defaultHttpPort, ENT_QUOTES, 'UTF-8');
$httpsPortValue = htmlspecialchars((string) $defaultHttpsPort, ENT_QUOTES, 'UTF-8');
$sslEmailValue = htmlspecialchars((string) $defaultEmailCertificates, ENT_QUOTES, 'UTF-8');
$assistantOpenAIKeyValue = htmlspecialchars((string) $defaultAssistantOpenAIKey, ENT_QUOTES, 'UTF-8');
?>
<div class="step-layout" data-step="1">
<div class="stack-xl">
<div class="stack-xxxs">
<h1 class="typography-title-s text-neutral-primary"><?php echo $isUpgrade ? 'Update your app' : 'Setup your app'; ?></h1>
<p class="typography-text-m-400 text-neutral-secondary">
<?php echo $isUpgrade ? 'Review your current settings before updating.' : 'Choose where your app will live and how it will store data'; ?>
</p>
</div>
<div class="stack-xl">
<div class="input-group stack-xs">
<label for="hostname" class="label-text typography-text-m-500 text-neutral-secondary">Hostname</label>
<input
type="text"
id="hostname"
name="hostname"
class="input-field typography-text-m-400 text-neutral-primary"
placeholder="localhost"
value="<?php echo $hostnameValue; ?>"
>
</div>
<div class="input-group stack-xs">
<label class="label-text typography-text-m-500 text-neutral-secondary">Database</label>
<div class="selector-group<?php echo $isDatabaseLocked ? ' is-locked' : ''; ?>">
<?php if ($mongoEnabled) { ?>
<label class="selector-card <?php echo ($selectedDatabase === 'mongodb') ? 'selected' : ''; ?><?php echo $mongoDisabled ? ' is-disabled has-tooltip' : ''; ?>"<?php echo $mongoDisabled ? ' aria-disabled="true"' : ''; ?>>
<input type="radio" name="database" value="mongodb" <?php echo ($selectedDatabase === 'mongodb') ? 'checked' : ''; ?> class="sr-only" <?php echo $mongoDisabled ? 'disabled' : ''; ?>>
<div class="selector-content">
<div class="typography-text-m-500 text-neutral-primary">MongoDB</div>
<div class="typography-text-xs-400 text-neutral-secondary">Document based database</div>
</div>
<img src="installer/icons/mongodb.svg" alt="MongoDB" class="selector-icon">
<?php if ($mongoDisabled) { ?>
<span class="tooltip tooltip-db-locked typography-text-m-400 text-on-invert" role="tooltip" data-tooltip-portal="true">Database cannot be changed after initial setup.</span>
<?php } ?>
</label>
<?php } ?>
<?php if ($mariaEnabled) { ?>
<label class="selector-card <?php echo ($selectedDatabase === 'mariadb') ? 'selected' : ''; ?><?php echo $mariaDisabled ? ' is-disabled has-tooltip' : ''; ?>"<?php echo $mariaDisabled ? ' aria-disabled="true"' : ''; ?>>
<input type="radio" name="database" value="mariadb" <?php echo ($selectedDatabase === 'mariadb') ? 'checked' : ''; ?> class="sr-only" <?php echo $mariaDisabled ? 'disabled' : ''; ?>>
<div class="selector-content">
<div class="typography-text-m-500 text-neutral-primary">MariaDB</div>
<div class="typography-text-xs-400 text-neutral-secondary">Relational SQL database</div>
</div>
<img src="installer/icons/mariadb.svg" alt="MariaDB" class="selector-icon">
<?php if ($mariaDisabled) { ?>
<span class="tooltip tooltip-db-locked typography-text-m-400 text-on-invert" role="tooltip" data-tooltip-portal="true">Database cannot be changed after initial setup.</span>
<?php } ?>
</label>
<?php } ?>
<?php if ($postgresEnabled) { ?>
<label class="selector-card <?php echo ($selectedDatabase === 'postgresql') ? 'selected' : ''; ?><?php echo $postgresDisabled ? ' is-disabled has-tooltip' : ''; ?>"<?php echo $postgresDisabled ? ' aria-disabled="true"' : ''; ?>>
<input type="radio" name="database" value="postgresql" <?php echo ($selectedDatabase === 'postgresql') ? 'checked' : ''; ?> class="sr-only" <?php echo $postgresDisabled ? 'disabled' : ''; ?>>
<div class="selector-content">
<div class="typography-text-m-500 text-neutral-primary">PostgreSQL</div>
<div class="typography-text-xs-400 text-neutral-secondary">Relational SQL database</div>
</div>
<img src="installer/icons/postgresql.svg" alt="PostgreSQL" class="selector-icon">
<?php if ($postgresDisabled) { ?>
<span class="tooltip tooltip-db-locked typography-text-m-400 text-on-invert" role="tooltip" data-tooltip-portal="true">Database cannot be changed after initial setup.</span>
<?php } ?>
</label>
<?php } ?>
</div>
</div>
<div class="accordion">
<button
type="button"
class="accordion-toggle"
aria-expanded="false"
>
<span class="label-text typography-text-m-500 text-neutral-secondary">Advanced settings</span>
<span class="accordion-chevron" data-open="false">
<?php include __DIR__ . '/../../icons/chevron-down.svg'; ?>
</span>
</button>
<div class="accordion-content">
<div class="input-row">
<div class="input-group stack-xs">
<label for="http-port" class="label-text typography-text-m-500 text-neutral-secondary">HTTP port</label>
<input
type="number"
id="http-port"
name="httpPort"
class="input-field typography-text-m-400 text-neutral-primary"
placeholder="<?php echo $httpPortValue; ?>"
value="<?php echo $httpPortValue; ?>"
data-default="<?php echo $httpPortValue; ?>"
min="1"
max="65535"
step="1"
>
</div>
<button type="button" class="button secondary" data-reset-target="http-port" disabled>
<span class="button-text typography-text-m-500">Reset</span>
</button>
</div>
<div class="input-row">
<div class="input-group stack-xs">
<label for="https-port" class="label-text typography-text-m-500 text-neutral-secondary">HTTPS port</label>
<input
type="number"
id="https-port"
name="httpsPort"
class="input-field typography-text-m-400 text-neutral-primary"
placeholder="<?php echo $httpsPortValue; ?>"
value="<?php echo $httpsPortValue; ?>"
data-default="<?php echo $httpsPortValue; ?>"
min="1"
max="65535"
step="1"
>
</div>
<button type="button" class="button secondary" data-reset-target="https-port" disabled>
<span class="button-text typography-text-m-500">Reset</span>
</button>
</div>
<div class="input-row">
<div class="input-group stack-xs">
<label for="ssl-email" class="label-text typography-text-m-500 text-neutral-secondary">SSL certificate email</label>
<input
type="email"
id="ssl-email"
name="sslEmail"
class="input-field typography-text-m-400 text-neutral-primary"
placeholder="you@example.com"
value="<?php echo $sslEmailValue; ?>"
data-default="<?php echo $sslEmailValue; ?>"
>
</div>
<button type="button" class="button secondary" data-reset-target="ssl-email" disabled>
<span class="button-text typography-text-m-500">Reset</span>
</button>
</div>
<div class="input-row">
<div class="input-group stack-xs">
<label for="assistant-openai-key" class="label-text typography-text-m-500 text-neutral-secondary">
OpenAI key
<span class="label-optional typography-text-m-400 text-neutral-tertiary">optional</span>
<span class="tooltip-wrapper">
<button type="button" class="label-info-button" aria-label="OpenAI key info">
<?php include __DIR__ . '/../../icons/info.svg'; ?>
</button>
<span class="tooltip tooltip-assistant typography-text-m-400 text-on-invert" role="tooltip">Add your OpenAI key to enable Appwrite Assistant. The key is stored locally and wont be shared.</span>
</span>
</label>
<input
type="text"
id="assistant-openai-key"
name="assistantOpenAIKey"
class="input-field typography-text-m-400 text-neutral-primary"
placeholder="Enter OpenAI key for Appwrite Assistant"
value="<?php echo $assistantOpenAIKeyValue; ?>"
data-default="<?php echo $assistantOpenAIKeyValue; ?>"
>
</div>
</div>
</div>
</div>
</div>
</div>
</div>