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 });
|
state.applySettings({ ...state.settings, sessionKey: next });
|
||||||
},
|
},
|
||||||
onRefresh: () => state.loadOverview(),
|
onRefresh: () => state.loadOverview(),
|
||||||
|
onReconnect: () => state.connect(),
|
||||||
})
|
})
|
||||||
: nothing}
|
: nothing}
|
||||||
|
|
||||||
|
|||||||
@@ -664,11 +664,19 @@ export class ClawdbotApp extends LitElement {
|
|||||||
if (!window.location.search) return;
|
if (!window.location.search) return;
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const token = params.get("token")?.trim();
|
const token = params.get("token")?.trim();
|
||||||
if (!token) return;
|
const password = params.get("password")?.trim();
|
||||||
if (!this.settings.token) {
|
let changed = false;
|
||||||
|
if (token && !this.settings.token) {
|
||||||
this.applySettings({ ...this.settings, token });
|
this.applySettings({ ...this.settings, token });
|
||||||
}
|
|
||||||
params.delete("token");
|
params.delete("token");
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (password) {
|
||||||
|
this.password = password;
|
||||||
|
params.delete("password");
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (!changed) return;
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.search = params.toString();
|
url.search = params.toString();
|
||||||
window.history.replaceState({}, "", url.toString());
|
window.history.replaceState({}, "", url.toString());
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export type OverviewProps = {
|
|||||||
onPasswordChange: (next: string) => void;
|
onPasswordChange: (next: string) => void;
|
||||||
onSessionKeyChange: (next: string) => void;
|
onSessionKeyChange: (next: string) => void;
|
||||||
onRefresh: () => void;
|
onRefresh: () => void;
|
||||||
|
onReconnect: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function renderOverview(props: OverviewProps) {
|
export function renderOverview(props: OverviewProps) {
|
||||||
@@ -84,7 +85,8 @@ export function renderOverview(props: OverviewProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="row" style="margin-top: 14px;">
|
<div class="row" style="margin-top: 14px;">
|
||||||
<button class="btn" @click=${() => props.onRefresh()}>Refresh</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user