removed backend fiield
This commit is contained in:
@@ -108,17 +108,12 @@ type DocumentPreviewImageResponse = {
|
||||
imageBase64: string;
|
||||
};
|
||||
|
||||
type RuntimeEnv = {
|
||||
PRIVATECHAT_CLIENT_SERVER_URL?: string;
|
||||
};
|
||||
|
||||
function readDefaultServerUrl(): string {
|
||||
const runtimeWindow = typeof window === 'undefined'
|
||||
? undefined
|
||||
: (window as Window & typeof globalThis & { __PRIVATECHAT_ENV__?: RuntimeEnv });
|
||||
const configuredUrl = runtimeWindow?.__PRIVATECHAT_ENV__?.PRIVATECHAT_CLIENT_SERVER_URL?.trim();
|
||||
if (typeof window !== 'undefined' && window.location.origin) {
|
||||
return window.location.origin.replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
return configuredUrl?.replace(/\/+$/, '') || 'http://localhost:3000';
|
||||
return 'http://localhost:3000';
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -138,7 +133,7 @@ export class ChatSessionService {
|
||||
private static readonly typingHeartbeatMs = 900;
|
||||
private static readonly incomingCallRingtoneFileName = 'SymphonyDing.mp3';
|
||||
|
||||
readonly serverUrl = signal(this.readStorage('privatechat.serverUrl') ?? readDefaultServerUrl());
|
||||
readonly serverUrl = signal(readDefaultServerUrl());
|
||||
readonly currentUser = signal<UserProfile | null>(this.readUserStorage());
|
||||
readonly accessKeys = signal<AccessKeySummary[]>([]);
|
||||
readonly peers = signal<PeerSummary[]>([]);
|
||||
@@ -319,21 +314,6 @@ export class ChatSessionService {
|
||||
}
|
||||
}
|
||||
|
||||
setServerUrl(url: string): void {
|
||||
const normalized = url.trim().replace(/\/+$/, '');
|
||||
|
||||
if (!normalized) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.serverUrl.set(normalized);
|
||||
this.writeStorage('privatechat.serverUrl', normalized);
|
||||
|
||||
if (this.currentUser()) {
|
||||
void this.connectWebSocket();
|
||||
}
|
||||
}
|
||||
|
||||
selectPeer(peerId: string): void {
|
||||
this.activePeerId.set(peerId);
|
||||
this.clearUnreadPeer(peerId);
|
||||
|
||||
@@ -53,22 +53,11 @@
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h2 class="h3 mb-1">Connect to the signaling backend</h2>
|
||||
<p class="text-secondary mb-0">Use the Fastify server for authentication and peer discovery.</p>
|
||||
<p class="text-secondary mb-0">Use the current browser host for authentication and peer discovery.</p>
|
||||
</div>
|
||||
<span class="badge rounded-pill text-bg-dark">Angular + Bootstrap</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="serverUrl">Backend URL</label>
|
||||
<input
|
||||
id="serverUrl"
|
||||
name="serverUrl"
|
||||
class="form-control form-control-lg"
|
||||
[(ngModel)]="serverUrl"
|
||||
placeholder="http://localhost:3000"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="btn-group mb-4 w-100" role="group" aria-label="Authentication mode">
|
||||
<button
|
||||
class="btn"
|
||||
@@ -177,49 +166,28 @@
|
||||
}
|
||||
} @else {
|
||||
<section class="row g-4 align-items-stretch">
|
||||
<div class="col-lg-5">
|
||||
<div class="col-12">
|
||||
<div class="panel p-4 h-100">
|
||||
<div class="d-flex justify-content-between align-items-start gap-3 mb-3">
|
||||
<div class="d-flex justify-content-between align-items-start gap-3 mb-4">
|
||||
<div>
|
||||
<h2 class="h3 mb-1">Connection settings</h2>
|
||||
<p class="text-secondary mb-0">Manage the backend endpoint used for auth and signaling.</p>
|
||||
<h2 class="h3 mb-1">Account tools</h2>
|
||||
<p class="text-secondary mb-0">This session uses the current browser host for auth and signaling.</p>
|
||||
</div>
|
||||
@if (session.isApprovalAdmin()) {
|
||||
<a class="btn btn-sm btn-outline-light" routerLink="/approvals">Approvals</a>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!embeddedMode) {
|
||||
<label class="form-label" for="connectedServerUrl">Backend URL</label>
|
||||
<div class="input-group mb-3">
|
||||
<input
|
||||
id="connectedServerUrl"
|
||||
class="form-control"
|
||||
[(ngModel)]="serverUrl"
|
||||
(blur)="applyServerUrl()"
|
||||
/>
|
||||
<button class="btn btn-outline-secondary" type="button" (click)="applyServerUrl()">Apply</button>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="empty-state p-4 text-center text-secondary">
|
||||
Backend settings are managed by the native app in embedded mode.
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="small status-pill mt-3">{{ session.status() }}</div>
|
||||
<div class="small status-pill mb-3">{{ session.status() }}</div>
|
||||
|
||||
@if (session.error()) {
|
||||
<div class="alert alert-danger mt-4 mb-0">{{ session.error() }}</div>
|
||||
<div class="alert alert-danger mb-3">{{ session.error() }}</div>
|
||||
}
|
||||
|
||||
@if (session.notice()) {
|
||||
<div class="alert alert-success mt-4 mb-0">{{ session.notice() }}</div>
|
||||
<div class="alert alert-success mb-4">{{ session.notice() }}</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-7">
|
||||
<div class="panel p-4 h-100">
|
||||
<section class="access-key-panel user-search-panel mb-4">
|
||||
<div class="d-flex justify-content-between align-items-start gap-3 mb-3">
|
||||
<div>
|
||||
|
||||
@@ -19,7 +19,6 @@ export class HomePageComponent {
|
||||
authMode: 'login' | 'register' = 'login';
|
||||
readonly embeddedMode =
|
||||
typeof window !== 'undefined' && window.localStorage.getItem('privatechat.embeddedMode') === '1';
|
||||
serverUrl = '';
|
||||
displayName = '';
|
||||
username = '';
|
||||
password = '';
|
||||
@@ -50,8 +49,6 @@ export class HomePageComponent {
|
||||
});
|
||||
|
||||
constructor(readonly session: ChatSessionService) {
|
||||
this.serverUrl = session.serverUrl();
|
||||
|
||||
if (this.embeddedMode) {
|
||||
effect(() => {
|
||||
const currentUser = this.session.currentUser();
|
||||
@@ -95,8 +92,6 @@ export class HomePageComponent {
|
||||
}
|
||||
|
||||
async submitAuth(): Promise<void> {
|
||||
this.applyServerUrl();
|
||||
|
||||
if (this.authMode === 'register') {
|
||||
const authenticated = await this.session.register(this.username, this.password, this.displayName);
|
||||
this.password = '';
|
||||
@@ -111,10 +106,6 @@ export class HomePageComponent {
|
||||
await this.session.login(this.username, this.password);
|
||||
}
|
||||
|
||||
applyServerUrl(): void {
|
||||
this.session.setServerUrl(this.serverUrl);
|
||||
}
|
||||
|
||||
async logout(): Promise<void> {
|
||||
await this.session.logout();
|
||||
this.authMode = 'login';
|
||||
@@ -123,7 +114,6 @@ export class HomePageComponent {
|
||||
}
|
||||
|
||||
async loginWithAccessKey(): Promise<void> {
|
||||
this.applyServerUrl();
|
||||
await this.session.loginWithAccessKey(this.username);
|
||||
this.password = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user