Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use /url endpoint to get proper URL to UI #53

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/agent/src/login-form/hooks/UseViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ export const useViewModel = (): LoginFormViewModelInterface => {
},
[agentApi, navigateTo]
),
handleReturnToAssistedMigration: useCallback(() => {
const assistedMigrationUrl = import.meta.env.ASSISTED_MIGRATION_URL || 'http://localhost:3000/migrate/wizard';
window.open(assistedMigrationUrl, '_blank', 'noopener,noreferrer');
handleReturnToAssistedMigration: useCallback(async () => {
const serviceUrl = await agentApi.getServiceUiUrl() || "http://localhost:3000/migrate/wizard";
window.open(serviceUrl, '_blank', 'noopener,noreferrer');
}, []),
handleChangeDataSharingAllowed: useCallback((checked)=>{
console.log(checked);
Expand Down
10 changes: 10 additions & 0 deletions packages/agent-client/src/apis/AgentApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface AgentApiInterface {
): Promise<Either<number, CredentialsError>>;
getStatus(options?: RequestInit): Promise<StatusReply>;
getAgentVersion():Promise<string>;
getServiceUiUrl():Promise<string>;
}

export class AgentApi implements AgentApiInterface {
Expand Down Expand Up @@ -70,4 +71,13 @@ export class AgentApi implements AgentApiInterface {
const statusReply = (await response.json()) as { version: string };
return statusReply.version;
}
async getServiceUiUrl(): Promise<string> {
const request = new Request(this.configuration.basePath + "/url", {
method: "GET"
});

const response = await fetch(request);
const uiReply = (await response.json()) as { url: string };
return uiReply.url;
}
}
Loading