-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-tracker.html
More file actions
831 lines (718 loc) · 37.1 KB
/
git-tracker.html
File metadata and controls
831 lines (718 loc) · 37.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Git Tracker - Repository Status Dashboard</title>
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAQQSURBVFhHr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uDHI+HCvtaFVfnRn5HMPFK3m8J58aI1xoNE8kfMhj/WwGg1gYh1/Xk/rBjzNYoGPt3y5gQNcP6JGI3hHPIJDJe3ZWUJO7Y+o62VJa4lBT3eTGf3GDqAnNdw48yTqhpz4/J1Fs58VRgPjEQ5jJjZt7mJJjEU8oYmKSZCmJAUc2l27I+eX6l8GCNN7sWXpWlkS35DzZ+dIE6nJ6FJGKPSO1AOXJ3u5a5cPBmgFLQO2sxWQzHzRjsznEXs+f2CyAG4PYDCo0apyoPLQfgxYnaioqzjKHdQNeBwGAP4WmJvA3Q5ZI6gzruzaXvMqzw5HQJBnNjuQcek43kzLgGFfI8pLt7ITPTjA5wbstwD3FHC3gi0CtBLQCrCKrYzc+z1YIGbfPBywz3E5JFMTtTt6c7/vP9TmFGFwwfgAGKsCNALQaOCBPwRF7c1l3AEdd8CAI+BWHFjVBGoJtA7QEmglUAtoKbTFkxeOFO7QnePeP9E6YB1JVHRVfJi3pexbdqgBmhTb7vS++lO8qTZfXQT4SrfP9YqCo48RgxnKuCRV5YIlH5RqKnKPn+COHwrEIjRqODTxO5W5Ry9xn3/r/wBVaZQwJK4a7AAAAABJRU5ErkJggg==">
<link rel="stylesheet" href="shared/shared.css">
<style>
/* Git-specific CSS variables */
:root {
--git-ahead: #4CAF50;
--git-behind: #FF9800;
--git-diverged: #f44336;
--git-uptodate: #2196F3;
}
[data-theme="dark"] {
--git-ahead: #5cb85c;
--git-behind: #f39c12;
--git-diverged: #e74c3c;
--git-uptodate: #3498db;
}
/* Git-specific styles */
.repos-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
gap: 20px;
margin-top: 20px;
}
.repo-card {
border: 1px solid var(--border-color);
border-radius: 10px;
padding: 20px;
background: var(--card-bg);
color: var(--text-primary);
transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease;
}
.repo-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px var(--card-hover-shadow);
}
.repo-title {
font-size: 1.4em;
font-weight: bold;
color: var(--text-primary);
margin-bottom: 5px;
border-bottom: 2px solid #667eea;
padding-bottom: 5px;
display: flex;
align-items: center;
gap: 10px;
}
.repo-path {
color: var(--text-secondary);
font-size: 0.85em;
margin-bottom: 10px;
word-break: break-all;
font-family: 'Courier New', monospace;
background: var(--button-secondary);
padding: 4px 8px;
border-radius: 4px;
}
.repo-info {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 8px;
margin-bottom: 15px;
}
.info-item {
background: var(--input-bg);
padding: 8px 12px;
border-radius: 5px;
border-left: 3px solid #667eea;
font-size: 0.9em;
}
.info-label {
font-weight: bold;
color: var(--text-light-bg);
font-size: 0.8em;
}
.info-value {
color: var(--text-light-bg-secondary);
font-size: 0.85em;
margin-top: 2px;
}
.git-status {
display: flex;
gap: 10px;
margin-bottom: 15px;
flex-wrap: wrap;
}
.status-badge {
padding: 4px 8px;
border-radius: 12px;
font-size: 0.75em;
font-weight: 500;
}
.status-ahead { background: var(--git-ahead); color: white; }
.status-behind { background: var(--git-behind); color: white; }
.status-diverged { background: var(--git-diverged); color: white; }
.status-uptodate { background: var(--git-uptodate); color: white; }
.status-clean { background: #4CAF50; color: white; }
.status-dirty { background: #FF9800; color: white; }
.status-untracked { background: #9C27B0; color: white; }
.branch-info {
background: var(--input-bg);
padding: 10px;
border-radius: 6px;
margin-bottom: 15px;
border-left: 4px solid var(--button-primary);
}
.branch-name {
font-weight: bold;
color: var(--button-primary);
margin-bottom: 5px;
}
.branch-details {
font-size: 0.9em;
color: var(--text-secondary);
}
.commit-info {
background: var(--input-bg);
padding: 10px;
border-radius: 6px;
margin-bottom: 15px;
border-left: 4px solid #9C27B0;
}
.commit-hash {
font-family: 'Courier New', monospace;
font-size: 0.8em;
color: var(--text-secondary);
}
.commit-message {
font-weight: 500;
color: var(--text-primary);
margin: 5px 0;
}
.commit-details {
font-size: 0.85em;
color: var(--text-secondary);
}
.repo-actions {
display: flex;
gap: 8px;
flex-wrap: wrap;
align-items: center;
}
.open-github {
background: #333;
color: white;
}
.open-github:hover {
background: #555;
}
.pull-btn {
background: #4CAF50;
color: white;
}
.pull-btn:hover {
background: #45a049;
}
.push-btn {
background: #FF9800;
color: white;
}
.push-btn:hover {
background: #F57C00;
}
.fetch-btn {
background: #2196F3;
color: white;
}
.fetch-btn:hover {
background: #1976D2;
}
.actions-status {
background: var(--input-bg);
padding: 8px;
border-radius: 4px;
margin-bottom: 10px;
border-left: 4px solid #4CAF50;
}
.actions-failed {
background: var(--input-bg);
border-left-color: #f44336;
}
.actions-pending {
background: var(--input-bg);
border-left-color: #FF9800;
}
.github-icon {
width: 20px;
height: 20px;
opacity: 0.7;
}
.stat-item.total-repos .stat-number {
font-size: 2em;
}
@media (max-width: 768px) {
.repos-grid {
grid-template-columns: 1fr;
}
.repo-info {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<!-- Navigation Bar -->
<div class="navigation-bar">
<div class="nav-container">
<a href="project-tracker.html" class="nav-item">🗂️ Project Tracker</a>
<a href="claude-tracker.html" class="nav-item">🤖 Claude Tracker</a>
<a href="git-tracker.html" class="nav-item active">🔀 Git Tracker</a>
<div class="nav-buttons">
<button type="button" class="back-to-top-btn" onclick="scrollToTop()" title="Back to top">
⬆️
</button>
<button type="button" class="theme-toggle" onclick="toggleTheme()" title="Toggle dark/light mode">
<span class="theme-icon">🌙</span>
</button>
</div>
</div>
</div>
<div class="container">
<h1>🔀 Git Tracker</h1>
<div class="subtitle">Repository status dashboard • Branch tracking • GitHub integration</div>
<div class="controls">
<button type="button" class="refresh-btn" onclick="refreshRepos()">🔄 Refresh</button>
<button type="button" class="tag-btn" onclick="toggleTagManager()">🏷️ Manage Tags</button>
<button type="button" class="settings-btn" onclick="toggleDirectoryManager()">⚙️ Directories</button>
<input type="text" class="search-box" placeholder="🔍 Search repositories by name, technology, branch, status, or path..." onkeyup="filterRepos()" id="searchInput">
</div>
<div class="stats" id="stats">
<!-- Stats will be dynamically generated: Total Repos + Top 10 Tags -->
</div>
<div id="loading" class="loading" style="display: none;">Loading repositories...</div>
<div id="repos" class="repos-grid"></div>
<div id="noResults" class="no-results" style="display: none;">No repositories match your search criteria.</div>
<!-- Tag Management Modal -->
<div id="tagModal" class="modal modal-hidden">
<div class="modal-content">
<div class="modal-header">
<h2>🏷️ Manage Repository Tags</h2>
<button type="button" class="modal-close" onclick="toggleTagManager()" title="Close">×</button>
</div>
<div class="modal-body">
<p class="tip-box">
💡 <strong>Tip:</strong> Manage tags used across all your repositories. Tags help categorize and filter repositories effectively.
</p>
<div class="tag-input-section">
<input type="text" id="newTagInput" class="tag-input" placeholder="Enter new tag name..." maxlength="20">
<button type="button" onclick="addNewTag()" class="tag-add-btn">+ Add Tag</button>
</div>
<div class="predefined-tags">
<h4>Quick Add Common Tags:</h4>
<span class="predefined-tag" onclick="addPredefinedTag('frontend')">frontend</span>
<span class="predefined-tag" onclick="addPredefinedTag('backend')">backend</span>
<span class="predefined-tag" onclick="addPredefinedTag('fullstack')">fullstack</span>
<span class="predefined-tag" onclick="addPredefinedTag('mobile')">mobile</span>
<span class="predefined-tag" onclick="addPredefinedTag('desktop')">desktop</span>
<span class="predefined-tag" onclick="addPredefinedTag('research')">research</span>
<span class="predefined-tag" onclick="addPredefinedTag('experimental')">experimental</span>
<span class="predefined-tag" onclick="addPredefinedTag('archived')">archived</span>
<span class="predefined-tag" onclick="addPredefinedTag('personal')">personal</span>
<span class="predefined-tag" onclick="addPredefinedTag('work')">work</span>
<span class="predefined-tag" onclick="addPredefinedTag('education')">education</span>
<span class="predefined-tag" onclick="addPredefinedTag('game')">game</span>
<span class="predefined-tag" onclick="addPredefinedTag('tool')">tool</span>
<span class="predefined-tag" onclick="addPredefinedTag('library')">library</span>
<span class="predefined-tag" onclick="addPredefinedTag('framework')">framework</span>
</div>
<div class="directory-section">
<h3>Current Tags</h3>
<div id="currentTags" class="tag-grid">
<!-- Tags will be dynamically populated here -->
</div>
</div>
<div class="directory-section">
<h3>Repository Tag Assignment</h3>
<p style="color: var(--text-secondary); font-size: 14px; margin-bottom: 15px;">
Select repositories and assign/remove tags. Click on tags to toggle selection.
</p>
<div id="projectTagAssignment">
<!-- Repository list for tag assignment will be populated here -->
</div>
</div>
</div>
<div class="modal-footer">
<div style="flex: 1; color: var(--text-secondary); font-size: 14px;" id="changesSummary">
No unsaved changes
</div>
<button type="button" onclick="saveTagChanges()" class="finish-btn">💾 Save All Changes</button>
<button type="button" onclick="toggleTagManager()" class="cancel-btn">Cancel</button>
</div>
</div>
</div>
<!-- Directory Management Modal -->
<div id="directoryModal" class="modal modal-hidden">
<div class="modal-content">
<div class="modal-header">
<h2>⚙️ Manage Repository Directories</h2>
<button type="button" class="modal-close" onclick="toggleDirectoryManager()" title="Close without refreshing">×</button>
</div>
<div class="modal-body">
<p class="tip-box">
💡 <strong>Tip:</strong> Add/remove repositories without automatic refreshes. Click "Finish & Refresh Repositories" when you're done to see changes.
</p>
<div class="directory-section">
<h3>Current Directories</h3>
<div id="currentDirectories" class="directory-list">
<!-- Will be populated by JavaScript -->
</div>
</div>
<div class="directory-section">
<h3>Add Individual Repository Directory</h3>
<div class="add-directory-form">
<input type="text" id="newDirectoryPath" placeholder="Enter path (Windows or Linux format)" class="directory-input">
<button type="button" onclick="addDirectory()" class="add-btn">➕ Add Repository</button>
</div>
<p class="help-text">
ℹ️ <strong>Cross-platform paths supported:</strong><br>
• Linux/macOS: <code>/home/user/my-repo</code><br>
• Windows: <code>C:\Users\User\my-repo</code> or <code>C:/Users/User/my-repo</code><br>
• Relative: <code>../my-repo</code> or <code>./repos/my-project</code><br>
Add the path to a specific repository directory, not parent directories containing multiple repositories.
</p>
</div>
</div>
<div class="modal-footer">
<div style="flex: 1; color: var(--text-secondary); font-size: 14px;" id="directoryChangesSummary">
Ready to manage directories
</div>
<button type="button" onclick="finishDirectoryManagement()" class="finish-btn">🔄 Finish & Refresh Repositories</button>
<button type="button" onclick="toggleDirectoryManager()" class="cancel-btn">Cancel</button>
</div>
</div>
</div>
</div>
<script src="shared/shared.js"></script>
<script>
// Repository data will be loaded from backend API
let reposData = [];
let filteredRepos = [];
let activeTagFilter = null;
let currentFilter = 'all';
function renderRepos() {
const reposContainer = document.getElementById('repos');
const noResultsDiv = document.getElementById('noResults');
if (filteredRepos.length === 0) {
reposContainer.innerHTML = '';
noResultsDiv.style.display = 'block';
return;
}
noResultsDiv.style.display = 'none';
reposContainer.innerHTML = filteredRepos.map(repo => {
const statusBadges = generateStatusBadges(repo);
const actionsStatus = generateActionsStatus(repo);
const ePath = escapeJsStr(repo.path);
const eRemoteUrl = escapeJsStr(repo.remoteUrl || '');
return `
<div class="repo-card">
<div class="repo-title">
${repo.isGitHub ? '<svg class="github-icon" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>' : '📁'}
${escapeHtml(repo.name)}
</div>
<div class="repo-path">${escapeHtml(repo.path)}</div>
<div class="git-status">
${statusBadges}
</div>
${repo.currentBranch ? `
<div class="branch-info">
<div class="branch-name">🌿 ${escapeHtml(repo.currentBranch)}</div>
<div class="branch-details">
${escapeHtml(repo.branchStatus || 'Status unknown')}
${repo.totalBranches ? ` • ${repo.totalBranches} total branches` : ''}
</div>
</div>
` : ''}
${repo.lastCommit ? `
<div class="commit-info">
<div class="commit-hash">📝 ${escapeHtml(repo.lastCommit.hash)}</div>
<div class="commit-message">${escapeHtml(repo.lastCommit.message)}</div>
<div class="commit-details">
${escapeHtml(repo.lastCommit.author)} • ${escapeHtml(repo.lastCommit.date)}
</div>
</div>
` : ''}
${actionsStatus}
<div class="repo-info">
<div class="info-item">
<div class="info-label">Remote</div>
<div class="info-value">${repo.remoteUrl ? (repo.isGitHub ? 'GitHub' : 'Other') : 'Local Only'}</div>
</div>
<div class="info-item">
<div class="info-label">Last Activity</div>
<div class="info-value">${escapeHtml(repo.lastActivity || 'Unknown')}</div>
</div>
<div class="info-item">
<div class="info-label">.gitignore</div>
<div class="info-value">${repo.hasGitignore ? '✅ Yes' : '❌ No'}</div>
</div>
</div>
<div class="repo-actions">
<button class="action-btn refresh-btn" onclick="refreshRepo('${ePath}')" title="Refresh this repository's git status and information">🔄 Refresh</button>
<button class="action-btn open-github" onclick="openFolder('${ePath}')" title="Open repository directory in file explorer">📁 Open</button>
${repo.isGitHub ? `<button class="action-btn open-github" onclick="openGitHub('${eRemoteUrl}')" title="Open GitHub repository in browser">🔗 GitHub</button>` : ''}
<button class="action-btn fetch-btn" onclick="gitFetch('${ePath}')" title="Copy 'git fetch' command to clipboard">📥 Fetch</button>
${repo.aheadCount > 0 ? `<button class="action-btn push-btn" onclick="gitPush('${ePath}')" title="Copy 'git push' command to clipboard">📤 Push</button>` : ''}
${repo.behindCount > 0 ? `<button class="action-btn pull-btn" onclick="gitPull('${ePath}')" title="Copy 'git pull' command to clipboard">📥 Pull</button>` : ''}
</div>
</div>
`;
}).join('');
}
function generateStatusBadges(repo) {
const badges = [];
if (repo.aheadCount > 0) {
badges.push(`<span class="status-badge status-ahead">↑ ${repo.aheadCount} ahead</span>`);
}
if (repo.behindCount > 0) {
badges.push(`<span class="status-badge status-behind">↓ ${repo.behindCount} behind</span>`);
}
if (repo.aheadCount > 0 && repo.behindCount > 0) {
badges.push(`<span class="status-badge status-diverged">⚡ diverged</span>`);
}
if (repo.aheadCount === 0 && repo.behindCount === 0 && repo.remoteUrl) {
badges.push(`<span class="status-badge status-uptodate">✓ up to date</span>`);
}
if (repo.workingTreeClean === false) {
badges.push(`<span class="status-badge status-dirty">${repo.uncommittedChanges || 0} uncommitted</span>`);
}
if (repo.untrackedFiles > 0) {
badges.push(`<span class="status-badge status-untracked">${repo.untrackedFiles} untracked</span>`);
}
if (repo.workingTreeClean === true && repo.aheadCount === 0) {
badges.push(`<span class="status-badge status-clean">✓ clean</span>`);
}
return badges.join('');
}
function generateActionsStatus(repo) {
if (!repo.githubActions) return '';
const status = repo.githubActions.status;
let className = 'actions-status';
let icon = '✅';
let text = 'Actions Passed';
if (status === 'failure') {
className = 'actions-status actions-failed';
icon = '❌';
text = 'Actions Failed';
} else if (status === 'pending') {
className = 'actions-status actions-pending';
icon = '⏳';
text = 'Actions Pending';
}
return `
<div class="${className}">
<div style="font-weight: 500;">${icon} ${text}</div>
<div style="font-size: 0.85em; color: var(--text-secondary); margin-top: 2px;">
${repo.githubActions.workflowName || 'GitHub Actions'} • ${repo.githubActions.lastRun || 'Recently'}
</div>
</div>
`;
}
function filterRepos() {
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
filteredRepos = reposData.filter(repo => {
const matchesSearch = searchTerm === '' ||
repo.name.toLowerCase().includes(searchTerm) ||
repo.path.toLowerCase().includes(searchTerm) ||
(repo.currentBranch && repo.currentBranch.toLowerCase().includes(searchTerm));
const matchesFilter = currentFilter === 'all' ||
(currentFilter === 'ahead' && repo.aheadCount > 0) ||
(currentFilter === 'behind' && repo.behindCount > 0) ||
(currentFilter === 'dirty' && repo.workingTreeClean === false) ||
(currentFilter === 'github' && repo.isGitHub);
return matchesSearch && matchesFilter;
});
renderRepos();
updateStats();
}
function updateStats() {
const statsContainer = document.getElementById('stats');
// Count all tags from all repos (not just filtered)
const tagCounts = {};
reposData.forEach(repo => {
if (repo.tags && repo.tags.length > 0) {
repo.tags.forEach(tag => {
tagCounts[tag] = (tagCounts[tag] || 0) + 1;
});
}
});
// Sort tags by count and get top 10
const sortedTags = Object.entries(tagCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 10);
// Clear and rebuild stats container
statsContainer.innerHTML = '';
// Add Total Repos first
const totalDiv = document.createElement('div');
totalDiv.className = 'stat-item total-repos';
totalDiv.innerHTML = `
<div class="stat-number">${filteredRepos.length}</div>
<div class="stat-label">Total Repos</div>
`;
statsContainer.appendChild(totalDiv);
// Add top 10 tags
sortedTags.forEach(([tag, count]) => {
const tagDiv = document.createElement('div');
tagDiv.className = `stat-item tag-filter ${activeTagFilter === tag ? 'active' : ''}`;
tagDiv.setAttribute('data-tag', tag);
tagDiv.innerHTML = `
<div class="stat-number">${count}</div>
<div class="stat-label">${escapeHtml(tag.charAt(0).toUpperCase() + tag.slice(1))}</div>
`;
tagDiv.addEventListener('click', () => filterByTag(tag));
statsContainer.appendChild(tagDiv);
});
}
function filterByTag(tag) {
const searchInput = document.getElementById('searchInput');
if (activeTagFilter === tag) {
// If clicking the same tag, clear the filter
activeTagFilter = null;
searchInput.value = '';
} else {
// Set new tag filter
activeTagFilter = tag;
searchInput.value = tag;
}
filterRepos();
updateStats(); // Refresh to update active states
}
// Load repositories from backend API
let gitScanPollAttempts = 0;
async function loadReposFromAPI() {
try {
showNotification('🔍 Scanning git repositories...', 'info');
const response = await fetch(`${API_BASE_URL}/git/repos`);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
if (data.success) {
reposData = data.repositories;
filterRepos();
updateStats();
if (!data.fromCache) {
// First background scan pass not done yet — poll until it lands.
gitScanPollAttempts++;
if (gitScanPollAttempts <= 40) {
showNotification(`🔄 Scanning git repos in the background (${reposData.length} so far)…`, 'info');
setTimeout(loadReposFromAPI, 8000);
} else {
showNotification('⚠️ Git scan is taking a while — reload to check again.', 'warning');
}
} else {
gitScanPollAttempts = 0;
showNotification(`✅ Found ${reposData.length} git repositories!`, 'success');
}
} else {
throw new Error(data.error || 'Unknown API error');
}
} catch (error) {
console.warn('Failed to load repositories from API:', error.message);
showNotification(`⚠️ Backend offline - ${error.message}`, 'error');
// Show empty state
reposData = [];
filterRepos();
updateStats();
}
}
async function refreshRepos() {
const loadingDiv = document.getElementById('loading');
const reposContainer = document.getElementById('repos');
loadingDiv.style.display = 'block';
reposContainer.innerHTML = '';
gitScanPollAttempts = 0;
await loadReposFromAPI();
loadingDiv.style.display = 'none';
}
// Action functions
function openGitHub(remoteUrl) {
if (remoteUrl) {
// Convert git URL to web URL
let webUrl = remoteUrl
.replace('git@github.com:', 'https://github.com/')
.replace('.git', '');
const command = `# Open in browser: ${webUrl}`;
navigator.clipboard.writeText(webUrl).then(() => {
showNotification('🔗 GitHub URL copied to clipboard', 'success');
});
}
}
function refreshRepo(path) {
const button = event.target;
const originalText = button.textContent;
const originalWidth = button.offsetWidth;
// Set fixed width to prevent layout jumping
button.style.width = originalWidth + 'px';
button.textContent = '🔄 Refreshing...';
button.style.background = '#2196F3';
button.disabled = true;
// Call API to refresh just this repository
fetch(`${API_BASE_URL}/git/repos?path=${encodeURIComponent(path)}`)
.then(response => response.json())
.then(data => {
// Update just this repo in the global array
const repoIndex = reposData.findIndex(r => r.path === path);
if (repoIndex !== -1 && data.repositories && data.repositories.length > 0) {
reposData[repoIndex] = data.repositories[0];
filterRepos(); // Re-render to show updated data
}
setTimeout(() => {
button.textContent = '✅ Updated!';
setTimeout(() => {
button.textContent = originalText;
button.style.background = '#17a2b8';
button.style.width = ''; // Remove fixed width
button.disabled = false;
}, 1500);
}, 500);
})
.catch(error => {
console.error('Error refreshing repository:', error);
button.textContent = '❌ Error';
setTimeout(() => {
button.textContent = originalText;
button.style.background = '#17a2b8';
button.style.width = ''; // Remove fixed width
button.disabled = false;
}, 2000);
});
}
function gitFetch(path) {
const command = `cd "${path}" && git fetch`;
navigator.clipboard.writeText(command).then(() => {
showNotification('📥 Git fetch command copied', 'info');
});
}
function gitPull(path) {
const command = `cd "${path}" && git pull`;
navigator.clipboard.writeText(command).then(() => {
showNotification('📥 Git pull command copied', 'info');
});
}
function gitPush(path) {
const command = `cd "${path}" && git push`;
navigator.clipboard.writeText(command).then(() => {
showNotification('📤 Git push command copied', 'info');
});
}
// Initialize the page
document.addEventListener('DOMContentLoaded', async () => {
initializeTheme();
console.log('Git Tracker page loaded, loading repositories...');
await loadReposFromAPI();
currentFilter = 'all';
filterRepos();
});
// Tag Management System
let allTags = new Set();
let projectTagChanges = new Map();
function loadTagManager() {
// Since Git Tracker doesn't have repository tags yet, we'll create a placeholder system
// This can be enhanced to work with actual git repositories
renderCurrentTags();
renderProjectTagAssignment();
updateChangesSummary();
}
function renderCurrentTags() {
const container = document.getElementById('currentTags');
const tagsArray = Array.from(allTags).sort();
container.innerHTML = tagsArray.map(tag => `
<div class="tag-item">
<span class="tag-name">${escapeHtml(tag)}</span>
<button class="tag-remove" onclick="removeTag('${escapeJsStr(tag)}')" title="Delete tag">×</button>
</div>
`).join('');
}
function renderProjectTagAssignment() {
const container = document.getElementById('projectTagAssignment');
// For now, we'll show a message about repository tag support
container.innerHTML = `
<div style="text-align: center; padding: 20px; color: var(--text-secondary);">
<h4>Repository Tag System</h4>
<p>Repository tagging will be available in a future update.</p>
<p>This will allow you to tag repositories for better organization and filtering.</p>
</div>
`;
}
function saveTagChanges() {
// Save tags (implementation would depend on backend)
alert('Tag changes saved! (Repository tagging will be available in a future update)');
toggleTagManager();
}
function updateChangesSummary() {
const summary = document.getElementById('changesSummary');
summary.textContent = `${allTags.size} tags available`;
}
function finishDirectoryManagement() {
toggleDirectoryManager();
refreshRepos(); // Refresh repositories with new directory configuration
}
// Keyboard shortcuts
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 'r') {
e.preventDefault();
refreshRepos();
}
});
</script>
</body>
</html>