feat: add support for app source selection with GitHub and raw compose options

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Jakub Dorfman 2026-04-29 15:39:34 +02:00
parent e7c0b56473
commit 009b8016bb
2 changed files with 169 additions and 6 deletions

View file

@ -297,11 +297,11 @@
<label>Domains</label>
<div class="domain-tags" id="domainTags"></div>
<div class="domain-input-row">
<input id="domainInput" placeholder="whoami.srazka.com" />
<button class="btn-sm" id="addDomainBtn">Add</button>
<input id="domainInput" placeholder="whoami.srazka.com" />
<button class="btn-sm" id="addDomainBtn">Add</button>
</div>
<p style="font-size:.75rem;color:var(--muted);margin-top:4px;">
Supports wildcards: <code>*.example.com</code>
Supports wildcards: <code>*.example.com</code>
</p>
<div class="row">
@ -318,6 +318,37 @@
</div>
</div>
<label for="createSource">App Source</label>
<select id="createSource">
<option value="default" selected>Default (whoami)</option>
<option value="raw">Raw Compose</option>
<option value="github">GitHub Repository</option>
</select>
<div id="sourceRaw" style="display:none; margin-top:10px;">
<label for="createCompose">Compose YAML</label>
<textarea id="createCompose" rows="8" placeholder="services:\n app:\n image: nginx\n ports:\n - '127.0.0.1:18080:80'"></textarea>
</div>
<div id="sourceGithub" style="display:none; margin-top:10px;">
<label for="createGithubUrl">Repository URL</label>
<input id="createGithubUrl" placeholder="https://github.com/user/repo" />
<div class="row" style="margin-top:8px;">
<div>
<label for="createGithubBranch">Branch</label>
<input id="createGithubBranch" placeholder="main" value="main" />
</div>
<div>
<label for="createGithubPat">PAT (Optional)</label>
<input id="createGithubPat" type="password" placeholder="ghp_..." autocomplete="new-password" />
</div>
</div>
<p style="font-size:.75rem;color:var(--muted);margin-top:4px;">
Requires <code>compose.yaml</code> at the root.
</p>
</div>
<div class="btn-group" style="margin-top:14px;">
<button class="btn-primary" id="createBtn">Create App</button>
</div>
@ -423,22 +454,42 @@ domainInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") { e.preventDefault(); document.getElementById("addDomainBtn").click(); }
});
// ─── Create app ───
const sourceSelect = document.getElementById("createSource");
const sourceRaw = document.getElementById("sourceRaw");
const sourceGithub = document.getElementById("sourceGithub");
sourceSelect.addEventListener("change", () => {
sourceRaw.style.display = sourceSelect.value === "raw" ? "block" : "none";
sourceGithub.style.display = sourceSelect.value === "github" ? "block" : "none";
});
document.getElementById("createBtn").onclick = async () => {
const name = document.getElementById("name").value.trim();
const port = Number(document.getElementById("port").value);
const auth = document.getElementById("auth").value === "true";
const domains = [...domainTags];
const source_type = sourceSelect.value;
const compose_content = document.getElementById("createCompose").value;
const github_url = document.getElementById("createGithubUrl").value.trim();
const github_branch = document.getElementById("createGithubBranch").value.trim();
const github_pat = document.getElementById("createGithubPat").value.trim();
if (!name) { setStatus("Name is required.", true); return; }
if (!domains.length) { setStatus("At least one domain is required.", true); return; }
if (!port || port < 1024 || port > 65535) { setStatus("Port must be 1024-65535.", true); return; }
if (source_type === "raw" && !compose_content.trim()) { setStatus("Compose YAML is required for raw source.", true); return; }
if (source_type === "github" && !github_url) { setStatus("Repository URL is required for GitHub source.", true); return; }
try {
setStatus(`Creating ${name}...`);
await api.init({ name, domain: domains.join(","), port, auth });
await api.init({ name, domain: domains.join(","), port, auth, source_type, compose_content, github_url, github_branch, github_pat });
setStatus(`Created ${name}.`);
document.getElementById("name").value = "";
document.getElementById("createCompose").value = "";
document.getElementById("createGithubUrl").value = "";
document.getElementById("createGithubPat").value = "";
domainTags.length = 0;
renderDomainTags();
await loadApps();