Add visual indicator for relocated folders and update commit logic to handle missing folders
This commit is contained in:
21
index.html
21
index.html
@@ -84,6 +84,23 @@
|
|||||||
border-style: solid !important;
|
border-style: solid !important;
|
||||||
border-color: gold !important;
|
border-color: gold !important;
|
||||||
}
|
}
|
||||||
|
.needs-relocation {
|
||||||
|
opacity: 0.5;
|
||||||
|
pointer-events: auto; /* Wichtig: trotzdem klickbar lassen! */
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.needs-relocation::after {
|
||||||
|
content: "!";
|
||||||
|
color: #e11d48;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.2em;
|
||||||
|
position: absolute;
|
||||||
|
left: 8px;
|
||||||
|
top: 8px;
|
||||||
|
background: #fff1f2;
|
||||||
|
border-radius: 50%;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
#currentTitle {
|
#currentTitle {
|
||||||
/* erlauben, dass der Text umbricht */
|
/* erlauben, dass der Text umbricht */
|
||||||
@@ -211,11 +228,11 @@
|
|||||||
<!-- Interaction Bar -->
|
<!-- Interaction Bar -->
|
||||||
<div class="w-full h-16 flex items-center p-4 interaction-bar"
|
<div class="w-full h-16 flex items-center p-4 interaction-bar"
|
||||||
style="background: var(--bg-sidebar); border-top: 1px solid var(--border)">
|
style="background: var(--bg-sidebar); border-top: 1px solid var(--border)">
|
||||||
<button id="commitBtn"
|
<!--<button id="commitBtn"
|
||||||
class="ml-auto px-4 py-2 border rounded font-semibold"
|
class="ml-auto px-4 py-2 border rounded font-semibold"
|
||||||
style="background: var(--accent); color: #fff; border-color: var(--border)">
|
style="background: var(--accent); color: #fff; border-color: var(--border)">
|
||||||
Commit
|
Commit
|
||||||
</button>
|
</button>-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="renderer.js"></script>
|
<script src="renderer.js"></script>
|
||||||
|
|||||||
85
main.js
85
main.js
@@ -18,13 +18,45 @@ const store = new Store({
|
|||||||
skipGitPrompt: true,
|
skipGitPrompt: true,
|
||||||
intelligentCommitThreshold: 20,
|
intelligentCommitThreshold: 20,
|
||||||
autostart: false,
|
autostart: false,
|
||||||
closeToTray: true
|
closeToTray: true,
|
||||||
|
needsRelocation: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let tray = null;
|
let tray = null;
|
||||||
let isQuiting = false;
|
let isQuiting = false;
|
||||||
|
|
||||||
|
|
||||||
|
function updateMissingFolders(win) {
|
||||||
|
let folders = store.get('folders') || [];
|
||||||
|
let updatedFolders = [];
|
||||||
|
let anyChanged = false;
|
||||||
|
|
||||||
|
folders = folders.map(f => {
|
||||||
|
const missing = !fs.existsSync(f.path);
|
||||||
|
const needsRelocation = f.needsRelocation || false;
|
||||||
|
if (needsRelocation !== missing) {
|
||||||
|
anyChanged = true;
|
||||||
|
updatedFolders.push({ ...f, needsRelocation: missing });
|
||||||
|
return { ...f, needsRelocation: missing };
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (anyChanged) {
|
||||||
|
store.set('folders', folders);
|
||||||
|
// Für jeden betroffenen Folder Event schicken:
|
||||||
|
updatedFolders.forEach(folderObj => {
|
||||||
|
win.webContents.send('folders-location-updated', folderObj);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMissingFolders();
|
||||||
|
setInterval(updateMissingFolders, 3000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createTray(win) {
|
function createTray(win) {
|
||||||
const iconPath = path.join(__dirname, 'assets/icon/trayicon.png');
|
const iconPath = path.join(__dirname, 'assets/icon/trayicon.png');
|
||||||
const icon = nativeImage.createFromPath(iconPath);
|
const icon = nativeImage.createFromPath(iconPath);
|
||||||
@@ -731,10 +763,17 @@ app.whenReady().then(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Zähle Commits
|
// Zähle Commits
|
||||||
ipcMain.handle('get-commit-count', async (_e, folderObj) => {
|
ipcMain.handle('get-commit-count', async (_e, folderObj) => {
|
||||||
const git = simpleGit(folderObj.path);
|
try {
|
||||||
const log = await git.log();
|
if (folderObj.needsRelocation || !fs.existsSync(folderObj.path)) {
|
||||||
return log.total; // Anzahl der Commits
|
return 0;
|
||||||
|
}
|
||||||
|
const git = simpleGit(folderObj.path);
|
||||||
|
const log = await git.log();
|
||||||
|
return log.total;
|
||||||
|
} catch (err) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prüfe, ob es ungestagte Änderungen gibt
|
// Prüfe, ob es ungestagte Änderungen gibt
|
||||||
@@ -756,22 +795,28 @@ app.whenReady().then(() => {
|
|||||||
|
|
||||||
// Commits holen
|
// Commits holen
|
||||||
ipcMain.handle('get-commits', async (_e, folderObj) => {
|
ipcMain.handle('get-commits', async (_e, folderObj) => {
|
||||||
const git = simpleGit(folderObj.path);
|
try {
|
||||||
// alle Commits holen
|
if (folderObj.needsRelocation || !fs.existsSync(folderObj.path)) {
|
||||||
const log = await git.log(['--all']);
|
// Folder nicht vorhanden, geben wir leere Liste zurück
|
||||||
// aktuellen HEAD‐Hash ermitteln
|
return { head: null, commits: [] };
|
||||||
const fullHead = (await git.revparse(['--verify', 'HEAD'])).trim();
|
}
|
||||||
const head = fullHead.substring(0, 7);
|
const git = simpleGit(folderObj.path);
|
||||||
return {
|
const log = await git.log(['--all']);
|
||||||
head,
|
const fullHead = (await git.revparse(['--verify', 'HEAD'])).trim();
|
||||||
commits: log.all.map(c => ({
|
const head = fullHead.substring(0, 7);
|
||||||
hash: c.hash.substring(0, 7),
|
return {
|
||||||
date: c.date,
|
head,
|
||||||
message: c.message
|
commits: log.all.map(c => ({
|
||||||
}))
|
hash: c.hash.substring(0, 7),
|
||||||
};
|
date: c.date,
|
||||||
|
message: c.message
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
// Im Fehlerfall (z.B. Verzeichnis gelöscht)
|
||||||
|
return { head: null, commits: [] };
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Diff
|
// Diff
|
||||||
ipcMain.handle('diff-commit', async (_e, folderObj, hash) => {
|
ipcMain.handle('diff-commit', async (_e, folderObj, hash) => {
|
||||||
const git = simpleGit(folderObj.path);
|
const git = simpleGit(folderObj.path);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
onTrayToggleMonitoring: (callback) => ipcRenderer.on('tray-toggle-monitoring', callback),
|
onTrayToggleMonitoring: (callback) => ipcRenderer.on('tray-toggle-monitoring', callback),
|
||||||
onTrayRemoveFolder: (callback) => ipcRenderer.on('tray-remove-folder', callback),
|
onTrayRemoveFolder: (callback) => ipcRenderer.on('tray-remove-folder', callback),
|
||||||
onTrayAddFolder: (callback) => ipcRenderer.on('tray-add-folder', callback),
|
onTrayAddFolder: (callback) => ipcRenderer.on('tray-add-folder', callback),
|
||||||
|
onFoldersLocationUpdated: (callback) => ipcRenderer.on('folders-location-updated', (e, folderObj) => callback(folderObj)),
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on('repo-updated', (_e, folder) => {
|
ipcRenderer.on('repo-updated', (_e, folder) => {
|
||||||
|
|||||||
15
renderer.js
15
renderer.js
@@ -260,6 +260,9 @@ folders.forEach(folderObj => {
|
|||||||
const folder = folderObj.path;
|
const folder = folderObj.path;
|
||||||
titleEl.textContent = folder;
|
titleEl.textContent = folder;
|
||||||
const { head, commits } = await window.electronAPI.getCommits(folderObj);
|
const { head, commits } = await window.electronAPI.getCommits(folderObj);
|
||||||
|
if (!commits || !commits.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
contentList.innerHTML = commits.map(c => `
|
contentList.innerHTML = commits.map(c => `
|
||||||
<li class="w-full p-3 mb-2 bg-white border border-gray-200 rounded shadow-sm
|
<li class="w-full p-3 mb-2 bg-white border border-gray-200 rounded shadow-sm
|
||||||
@@ -452,7 +455,7 @@ folders.forEach(folderObj => {
|
|||||||
window.electronAPI.showFolderContextMenu(titleEl.textContent);
|
window.electronAPI.showFolderContextMenu(titleEl.textContent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
const commitBtn = document.getElementById('commitBtn');
|
const commitBtn = document.getElementById('commitBtn');
|
||||||
commitBtn.addEventListener('click', async () => {
|
commitBtn.addEventListener('click', async () => {
|
||||||
const folderObj = await window.electronAPI.getSelected();
|
const folderObj = await window.electronAPI.getSelected();
|
||||||
@@ -475,7 +478,7 @@ folders.forEach(folderObj => {
|
|||||||
commitBtn.disabled = false;
|
commitBtn.disabled = false;
|
||||||
commitBtn.textContent = 'Commit';
|
commitBtn.textContent = 'Commit';
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
window.electronAPI.onTrayToggleMonitoring(async (_e, folderPath) => {
|
window.electronAPI.onTrayToggleMonitoring(async (_e, folderPath) => {
|
||||||
const folders = await window.electronAPI.getFolders();
|
const folders = await window.electronAPI.getFolders();
|
||||||
@@ -514,4 +517,12 @@ folders.forEach(folderObj => {
|
|||||||
if (sel) await renderContent(sel);
|
if (sel) await renderContent(sel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.electronAPI.onFoldersLocationUpdated(folderObj => {
|
||||||
|
const selector = `[data-folder-path="${folderObj.path.replace(/"/g, '\\"')}"]`;
|
||||||
|
const li = document.querySelector(selector);
|
||||||
|
if (li) {
|
||||||
|
li.classList.toggle('needs-relocation', folderObj.needsRelocation);
|
||||||
|
// evtl. noch ein !-Icon sichtbar machen
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user