Skip to content

Commit dcb864f

Browse files
feat: Implement auto-refresh interval settings in the settings panel
1 parent 22f4fd9 commit dcb864f

7 files changed

Lines changed: 105 additions & 4 deletions

File tree

src-tauri/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ fn main() {
4141
alert_count: Mutex::new(0),
4242
last_shown: Mutex::new(None),
4343
config: Mutex::new(config),
44-
dev_tools_open: Mutex::new(false),
4544
})
4645
.setup(|app| {
4746
let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;

src-tauri/src/state.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ pub struct AppState {
66
pub alert_count: Mutex<usize>,
77
pub last_shown: Mutex<Option<Instant>>,
88
pub config: Mutex<AppConfig>,
9-
pub dev_tools_open: Mutex<bool>,
109
}

src/app/app.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
<app-settings-panel
2222
*ngIf="authenticated && currentView === 'settings'"
2323
[username]="username"
24+
[refreshInterval]="refreshIntervalMinutes"
2425
(logout)="logout()"
26+
(refreshIntervalChange)="onRefreshIntervalChange($event)"
2527
></app-settings-panel>
2628

2729
<!-- Repos Selection View -->

src/app/app.component.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,26 @@ export class AppComponent implements OnInit, OnDestroy {
4444
currentView: ViewMode = 'alerts';
4545
error = '';
4646
refreshInterval: any;
47+
refreshIntervalMinutes: number = 60; // Default to 1 hour
4748

4849
constructor(
4950
private tauriService: TauriService,
5051
private translate: TranslateService
5152
) {
5253
translate.setFallbackLang('en');
5354
console.log('APP_CONFIG', APP_CONFIG);
55+
this.loadRefreshIntervalFromStorage();
56+
}
57+
58+
private loadRefreshIntervalFromStorage(): void {
59+
const stored = localStorage.getItem('refreshInterval');
60+
if (stored) {
61+
this.refreshIntervalMinutes = parseInt(stored, 10);
62+
}
63+
}
64+
65+
private saveRefreshIntervalToStorage(): void {
66+
localStorage.setItem('refreshInterval', this.refreshIntervalMinutes.toString());
5467
}
5568

5669
async ngOnInit() {
@@ -241,9 +254,22 @@ export class AppComponent implements OnInit, OnDestroy {
241254

242255
startAutoRefresh() {
243256
this.stopAutoRefresh();
257+
258+
// If interval is 0, don't start auto-refresh
259+
if (this.refreshIntervalMinutes === 0) {
260+
return;
261+
}
262+
263+
const intervalMs = this.refreshIntervalMinutes * 60 * 1000;
244264
this.refreshInterval = setInterval(() => {
245265
this.fetchAlerts();
246-
}, 5 * 60 * 1000);
266+
}, intervalMs);
267+
}
268+
269+
onRefreshIntervalChange(minutes: number): void {
270+
this.refreshIntervalMinutes = minutes;
271+
this.saveRefreshIntervalToStorage();
272+
this.startAutoRefresh();
247273
}
248274

249275
stopAutoRefresh() {

src/app/shared/components/settings-panel/settings-panel.component.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,27 @@
44
<i class="ti ti-user user-icon"></i>
55
<span class="username">{{ username }}</span>
66
</div>
7+
8+
<div class="settings-group">
9+
<label class="settings-label">
10+
<span class="label-text">Auto-refresh interval</span>
11+
<select
12+
class="refresh-select"
13+
[value]="refreshInterval"
14+
(change)="onRefreshIntervalChange($event)"
15+
>
16+
<option value="30">30 minutes</option>
17+
<option value="60">1 hour</option>
18+
<option value="120">2 hours</option>
19+
<option value="240">4 hours</option>
20+
</select>
21+
</label>
22+
</div>
23+
724
<div class="settings-actions">
8-
<button class="danger-btn" (click)="onLogout()"><i class="ti ti-logout"></i> Sign Out</button>
25+
<button class="danger-btn" (click)="onLogout()">
26+
<i class="ti ti-logout"></i> Sign Out
27+
</button>
928
</div>
1029
</div>
1130
</div>

src/app/shared/components/settings-panel/settings-panel.component.scss

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,54 @@ $border-color: #2a2a4a;
4646
flex-direction: column;
4747
gap: 8px;
4848
}
49+
50+
.settings-group {
51+
display: flex;
52+
flex-direction: column;
53+
gap: 8px;
54+
padding: 12px;
55+
background: $bg-primary;
56+
border-radius: 8px;
57+
58+
.settings-label {
59+
display: flex;
60+
flex-direction: column;
61+
gap: 6px;
62+
font-size: 13px;
63+
font-weight: 500;
64+
cursor: pointer;
65+
66+
.label-text {
67+
color: #ffffff;
68+
}
69+
70+
.refresh-select {
71+
padding: 8px 10px;
72+
background: $bg-secondary;
73+
border: 1px solid $border-color;
74+
border-radius: 4px;
75+
color: #ffffff;
76+
font-size: 13px;
77+
cursor: pointer;
78+
transition: all 0.2s;
79+
80+
&:hover {
81+
border-color: #4a90d9;
82+
}
83+
84+
&:focus {
85+
outline: none;
86+
border-color: #4a90d9;
87+
box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
88+
}
89+
90+
option {
91+
background: $bg-secondary;
92+
color: #ffffff;
93+
}
94+
}
95+
}
96+
}
4997
}
5098
}
5199

src/app/shared/components/settings-panel/settings-panel.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
88
})
99
export class SettingsPanelComponent {
1010
@Input() username: string | null = null;
11+
@Input() refreshInterval: number = 60; // in minutes
1112

1213
@Output() logout = new EventEmitter<void>();
14+
@Output() refreshIntervalChange = new EventEmitter<number>();
1315

1416
onLogout(): void {
1517
this.logout.emit();
1618
}
19+
20+
onRefreshIntervalChange(event: Event): void {
21+
const value = parseInt((event.target as HTMLSelectElement).value, 10);
22+
this.refreshInterval = value;
23+
this.refreshIntervalChange.emit(value);
24+
}
1725
}

0 commit comments

Comments
 (0)