UI: add reconnect + URL password for gateway auth
This commit is contained in:
committed by
Peter Steinberger
parent
b253b9c3a0
commit
765d7771c8
@@ -247,6 +247,7 @@ export function renderApp(state: AppViewState) {
|
||||
state.applySettings({ ...state.settings, sessionKey: next });
|
||||
},
|
||||
onRefresh: () => state.loadOverview(),
|
||||
onReconnect: () => state.connect(),
|
||||
})
|
||||
: nothing}
|
||||
|
||||
|
||||
@@ -664,11 +664,19 @@ export class ClawdbotApp extends LitElement {
|
||||
if (!window.location.search) return;
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const token = params.get("token")?.trim();
|
||||
if (!token) return;
|
||||
if (!this.settings.token) {
|
||||
const password = params.get("password")?.trim();
|
||||
let changed = false;
|
||||
if (token && !this.settings.token) {
|
||||
this.applySettings({ ...this.settings, token });
|
||||
params.delete("token");
|
||||
changed = true;
|
||||
}
|
||||
params.delete("token");
|
||||
if (password) {
|
||||
this.password = password;
|
||||
params.delete("password");
|
||||
changed = true;
|
||||
}
|
||||
if (!changed) return;
|
||||
const url = new URL(window.location.href);
|
||||
url.search = params.toString();
|
||||
window.history.replaceState({}, "", url.toString());
|
||||
|
||||
@@ -20,6 +20,7 @@ export type OverviewProps = {
|
||||
onPasswordChange: (next: string) => void;
|
||||
onSessionKeyChange: (next: string) => void;
|
||||
onRefresh: () => void;
|
||||
onReconnect: () => void;
|
||||
};
|
||||
|
||||
export function renderOverview(props: OverviewProps) {
|
||||
@@ -84,7 +85,8 @@ export function renderOverview(props: OverviewProps) {
|
||||
</div>
|
||||
<div class="row" style="margin-top: 14px;">
|
||||
<button class="btn" @click=${() => props.onRefresh()}>Refresh</button>
|
||||
<span class="muted">Reconnect to apply changes.</span>
|
||||
<button class="btn" @click=${() => props.onReconnect()}>Reconnect</button>
|
||||
<span class="muted">Reconnect to apply URL/password changes.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user