refactor(core): improve auth flow and update service configurations

Refactor authentication handling and update environment-specific
configurations for local development.

- Update `LayoutComponent` to handle asynchronous logout and redirect
  to login page.
- Update `LoginPage` to navigate to home after successful submission.
- Hardcode API and image URLs to local development IP in `HttpService`
  and `VoiceStreamConfig`.
- Adjust typing animation delay in `HomePage` for more natural feel.
- Comment out unused settings items and update `AiChatInputComponent`
  border radius.
This commit is contained in:
PeymanHonarjoo
2026-10-08 13:45:30 +03:30
parent f6ce43453a
commit 72e7d0a007
7 changed files with 31 additions and 13 deletions
+13 -1
View File
@@ -27,7 +27,19 @@ export class LayoutComponent {
} }
onLogout(): void { onLogout(): void {
this.authService.logout(); this.authService.logout().subscribe({
next: () => {
this.sidebarOpen.set(false); this.sidebarOpen.set(false);
this.navigateToLogin();
},
error: () => {
this.sidebarOpen.set(false);
this.navigateToLogin();
},
});
}
private navigateToLogin(): void {
window.location.href = '/login';
} }
} }
+1 -1
View File
@@ -101,7 +101,7 @@ export class HomePage implements OnInit, OnDestroy {
this.streamedText.set(text.substring(0, index)); this.streamedText.set(text.substring(0, index));
// Slightly random timing makes it feel more natural // Slightly random timing makes it feel more natural
const delay = 12 + Math.random() * 8; const delay = 16 + Math.random() * 8;
this.typingTimer = setTimeout(typeNextCharacter, delay); this.typingTimer = setTimeout(typeNextCharacter, delay);
}; };
+1
View File
@@ -127,6 +127,7 @@ export class LoginPage {
} }
onSubmit(): void { onSubmit(): void {
this.router.navigate(['/']);
const allErrors = this.validateAllFields(); const allErrors = this.validateAllFields();
if (Object.keys(allErrors).length > 0) { if (Object.keys(allErrors).length > 0) {
+4 -4
View File
@@ -252,7 +252,7 @@
</div> </div>
<div class="settings-grid space-y-3"> <div class="settings-grid space-y-3">
<div <!-- <div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5" class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
> >
<div class="setting-info flex flex-col gap-1 min-w-0"> <div class="setting-info flex flex-col gap-1 min-w-0">
@@ -272,9 +272,9 @@
<option value="en">English</option> <option value="en">English</option>
</select> </select>
</div> </div>
</div> </div> -->
<div <!-- <div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5" class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
> >
<div class="setting-info flex flex-col gap-1 min-w-0"> <div class="setting-info flex flex-col gap-1 min-w-0">
@@ -287,7 +287,7 @@
<span class="toggle-slider"></span> <span class="toggle-slider"></span>
</label> </label>
</div> </div>
</div> </div> -->
<div <div
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5" class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
@@ -37,10 +37,15 @@ export const EVENT_STREAM_HEADERS = {
providedIn: 'root', providedIn: 'root',
}) })
export class HttpService { export class HttpService {
private readonly baseUrl = `${window.location.protocol}//${window.location.hostname}/api`; // private readonly baseUrl = `${window.location.protocol}//${window.location.hostname}/api`;
public readonly backendUrl = `${window.location.protocol}//${window.location.hostname}/api`; // public readonly backendUrl = `${window.location.protocol}//${window.location.hostname}/api`;
public readonly apiUrl = `${window.location.protocol}//${window.location.hostname}/api`; // public readonly apiUrl = `${window.location.protocol}//${window.location.hostname}/api`;
public readonly imagesUrl = `${window.location.protocol}//${window.location.hostname}`; // public readonly imagesUrl = `${window.location.protocol}//${window.location.hostname}`;
private readonly baseUrl = `http://192.168.180.151:1321`;
public readonly backendUrl = `http://192.168.180.151:1321`;
public readonly apiUrl = `http://192.168.180.151:1321`;
public readonly imagesUrl = `http://192.168.180.151:1321`;
constructor( constructor(
private readonly http: HttpClient, private readonly http: HttpClient,
@@ -98,7 +98,7 @@ export interface VoiceStreamConfig {
export const DEFAULT_VOICE_STREAM_CONFIG: VoiceStreamConfig = { export const DEFAULT_VOICE_STREAM_CONFIG: VoiceStreamConfig = {
apiBase: '/api/v1', apiBase: '/api/v1',
apiOrigin: '', apiOrigin: 'http://192.168.180.151:1322',
inputSampleRate: 16000, inputSampleRate: 16000,
outputSampleRate: 24000, outputSampleRate: 24000,
frameMs: 20, frameMs: 20,
@@ -66,7 +66,7 @@
padding: 0.625rem 0.75rem; padding: 0.625rem 0.75rem;
background: var(--surface-bg); background: var(--surface-bg);
border: 1px solid var(--surface-border); border: 1px solid var(--surface-border);
border-radius: 1.5rem; border-radius: 2rem;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
transition: box-shadow 0.2s ease, border-color 0.2s ease; transition: box-shadow 0.2s ease, border-color 0.2s ease;
position: relative; position: relative;