1
0
Files
auto-git-gui/settings.html
Victor Giers 8f897ae4df auto-git:
[change] settings.html
2025-05-25 00:16:54 +02:00

288 lines
9.0 KiB
HTML

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Einstellungen</title>
<style>
/* Grund-Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
width: 100%; height: 100%;
overflow-x: hidden;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
transition: background 0.5s ease;
}
/* Sky-Mode Hintergrund */
body.sky {
background: linear-gradient(120deg, #8ecae6 0%, #38bdf8 70%, #fff 100%);
}
/* Night-Mode (rosa) */
body.night {
background: linear-gradient(120deg, #fbc2eb 0%, #a6c1ee 70%, #fff 100%);
}
/* Dialog-Box */
.dialog {
position: relative;
z-index: 10;
width: 420px;
background: rgba(255,255,255,0.93);
border-radius: 5px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
padding: 1.8rem 2.2rem;
display: flex; flex-direction: column; gap: 1.2rem;
}
.close-btn {
background: none; border: none;
font-size: 1.6rem; cursor: pointer;
color: #64748b;
transition: color 0.2s;
}
.close-btn:hover { color: #0f172a; }
/* Optionen */
.options { display: flex; flex-direction: column; gap: 1.0rem; }
label {
display: flex; align-items: center; font-size: 1.05rem;
color: #1e293b;
}
label.option input {
margin-right: 0.8rem;
width: 1.3em; height: 1.3em;
accent-color: #38bdf8;
}
.row {
display: flex; align-items: center; justify-content: space-between;
}
.row > span {
flex: 1;
color: #1e293b;
font-weight: 600;
}
.row > input,
.row > select {
flex: 1;
margin-left: 0.8rem;
padding: 0.4em 0.6em;
border: 1.2px solid #cbd5e1;
border-radius: 6px;
font-size: 1rem;
color: #334155;
background: #f8fafc;
transition: border-color 0.2s, box-shadow 0.2s;
}
.row > input:focus,
.row > select:focus {
border-color: #38bdf8;
box-shadow: 0 0 0 2px rgba(56,189,248,0.3);
outline: none;
}
/* Buttons */
.buttons {
display: flex; justify-content: flex-end; gap: 1rem;
margin-top: 1.4rem;
}
button.action {
padding: 0.5em 1.3em;
font-size: 1rem;
font-weight: 600;
border: none; border-radius: 6px;
cursor: pointer;
transition: background 0.2s;
}
#cancelBtn {
background: #e2e8f0;
color: #475569;
}
#cancelBtn:hover {
background: #cbd5e1;
color: #1e293b;
}
#okBtn {
background: #38bdf8;
color: #fff;
}
#okBtn:hover {
background: #0ea5e9;
}
/* Infotext */
.ollama-info {
font-size: 0.95rem;
color: #dc2626;
text-align: center;
margin-top: 0.8rem;
}
</style>
<script>
window.addEventListener('DOMContentLoaded', async () => {
// Elemente holen
const cbSky = document.getElementById('skymode');
const cbSkip = document.getElementById('skipPrompt');
const thresholdInput = document.getElementById('intelligentCommitThresholdInput');
const ok = document.getElementById('okBtn');
const cancel = document.getElementById('cancelBtn');
const close = document.getElementById('closeBtn');
const cbAutostart = document.getElementById('autostart');
const cbCloseToTray= document.getElementById('closeToTray');
const [initialAutostart, initialCloseToTray] = await Promise.all([
window.settingsAPI.getAutostart(),
window.settingsAPI.getCloseToTray()
]);
cbAutostart.checked = initialAutostart;
cbCloseToTray.checked = initialCloseToTray;
// Initialwerte parallel laden
const [initialSky, initialSkip, initialThreshold] = await Promise.all([
window.settingsAPI.getSkyMode(),
window.settingsAPI.getSkipPrompt(),
window.electronAPI.getIntelligentCommitThreshold()
]);
// Inputs setzen
cbSky.checked = initialSky;
cbSkip.checked = initialSkip;
thresholdInput.value = initialThreshold;
// **Vorschau**: Sky-Mode sofort übernehmen
cbSky.addEventListener('change', async () => {
await window.settingsAPI.setSkyMode(cbSky.checked);
});
// OK: alles final speichern
ok.addEventListener('click', async () => {
await window.settingsAPI.setSkipPrompt(cbSkip.checked);
await window.settingsAPI.setAutostart(cbAutostart.checked);
await window.settingsAPI.setCloseToTray(cbCloseToTray.checked);
// SkyMode haben wir ja schon beim Change gesetzt
// Threshold speichern (immer Wert aus Feld nehmen!)
let threshold = parseInt(thresholdInput.value, 10);
if (isNaN(threshold)) threshold = 10;
if (threshold < 1) threshold = 1;
if (threshold > 1000) threshold = 1000;
await window.settingsAPI.setIntelligentCommitThreshold(threshold);
// Dropdowns speichern
const commitSel = document.getElementById('commitModelSelect');
const readmeSel = document.getElementById('readmeModelSelect');
if (commitSel) await window.settingsAPI.setCommitModel(commitSel.value);
if (readmeSel) await window.settingsAPI.setReadmeModel(readmeSel.value);
window.settingsAPI.close();
});
// Cancel / Close: SkyMode zurücksetzen, dann schließen
const rollback = async () => {
await window.settingsAPI.setSkyMode(initialSky);
window.settingsAPI.close();
};
cancel.addEventListener('click', rollback);
close.addEventListener('click', rollback);
const container = document.getElementById('ollama-model-selectors');
const res = await window.electronAPI.ollamaList();
if (res.status === 'no-cli') {
container.innerHTML = `
<div style="color:red;font-weight:bold;margin:1em 0;">
!! You need to install Ollama to use intelligent message & README generation !!
</div>`;
return;
}
if (res.status === 'error') {
container.innerHTML = `<div style="color:orange">Error fetching models: ${res.msg}</div>`;
return;
}
// Liste der Modell-Namen extrahieren
const names = res.models.map(m => m.name || m.model).filter(Boolean);
const qwen = names.filter(n => /^qwen2\.5-coder(:[\w\-.]+)?$/.test(n));
if (!qwen.length) {
// keine qwen2.5-coder → Pull-Buttons
container.innerHTML = `
<button id="pullCommitModelBtn" style="margin-bottom:8px;">
ollama pull qwen2.5-coder:7b
</button><br>
<button id="pullReadmeModelBtn">
ollama pull qwen2.5-coder:32b
</button>`;
document.getElementById('pullCommitModelBtn').onclick = async () => {
await window.electronAPI.ollamaPull('qwen2.5-coder:7b');
location.reload();
};
document.getElementById('pullReadmeModelBtn').onclick = async () => {
await window.electronAPI.ollamaPull('qwen2.5-coder:32b');
location.reload();
};
return;
}
// Dropdowns aufbauen
const makeOpts = (arr, sel) =>
arr.map(m => `<option ${m===sel?'selected':''}>${m}</option>`).join('');
// Default-Auswahl aus Settings (oder erstes gefundenes)
const commitDefault = qwen.find(m=>m.includes('7b'))||qwen[0];
const readmeDefault= qwen.find(m=>m.includes('32b'))||qwen[0];
const currentCommit = await window.settingsAPI.getCommitModel?.() || commitDefault;
const currentReadme= await window.settingsAPI.getReadmeModel?.() || readmeDefault;
container.innerHTML = `
<label>Model for commit message generation:
<select id="commitModelSelect">
${makeOpts(qwen, currentCommit)}
</select>
</label><br>
<label>Model for README generation:
<select id="readmeModelSelect">
${makeOpts(qwen, currentReadme)}
</select>
</label>`;
});
</script>
</head>
<body class="sky">
<div class="dialog">
<div class="options">
<label class="option">
<input type="checkbox" id="skymode" />
Sky Mode
</label>
<label class="option">
<input type="checkbox" id="skipPrompt" />
Skip prompt asking to remove .git folder if it has only one commit and no changes
</label>
<label class="block mb-2 font-semibold">
Intelligent commit after
<input type="number" id="intelligentCommitThresholdInput" min="1" max="1000" value="10" step="1" class="border rounded px-2 py-1 w-20 mx-1">
lines of diff
</label>
<div class="options">
<!-- Hier kommt das Model-Selector-HTML rein -->
<div id="ollama-model-selectors"></div>
</div>
<label class="option">
<input type="checkbox" id="autostart" />
Launch on System start
</label>
<label class="option">
<input type="checkbox" id="closeToTray" checked />
Close to Tray
</label>
<!-- Weitere Optionen in Zukunft hier hinzufügen -->
</div>
<div class="buttons">
<button id="cancelBtn">Cancel</button>
<button id="okBtn">OK</button>
</div>
</div>
</body>
</html>