adding a desktop callback page, for event propogation to desktop windows.

This commit is contained in:
Jason Kulatunga 2023-09-07 08:48:14 -07:00
parent 206d9479fc
commit 0ce1b3f20f
9 changed files with 61 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import {ReportLabsComponent} from './pages/report-labs/report-labs.component';
import {ResourceCreatorComponent} from './pages/resource-creator/resource-creator.component';
import {ExploreComponent} from './pages/explore/explore.component';
import {environment} from '../environments/environment';
import {DesktopCallbackComponent} from './pages/desktop-callback/desktop-callback.component';
const routes: Routes = [
@ -36,6 +37,7 @@ const routes: Routes = [
{ path: 'sources/callback/:source_type', component: MedicalSourcesComponent, canActivate: [ IsAuthenticatedAuthGuard] },
{ path: 'resource/create', component: ResourceCreatorComponent, canActivate: [ IsAuthenticatedAuthGuard] },
{ path: 'desktop/callback/:source_id', component: DesktopCallbackComponent, canActivate: [ IsAuthenticatedAuthGuard] },
{ path: 'patient-profile', component: PatientProfileComponent, canActivate: [ IsAuthenticatedAuthGuard] },
{ path: 'medical-history', component: MedicalHistoryComponent, canActivate: [ IsAuthenticatedAuthGuard] },

View File

@ -36,6 +36,7 @@ import {HTTP_CLIENT_TOKEN} from "./dependency-injection";
import {WidgetsModule} from './widgets/widgets.module';
import { ExploreComponent } from './pages/explore/explore.component';
import {DirectivesModule} from './directives/directives.module';
import { DesktopCallbackComponent } from './pages/desktop-callback/desktop-callback.component';
@NgModule({
declarations: [
@ -53,6 +54,7 @@ import {DirectivesModule} from './directives/directives.module';
ReportLabsComponent,
ResourceCreatorComponent,
ExploreComponent,
DesktopCallbackComponent,
],
imports: [
FormsModule,

View File

@ -0,0 +1 @@
<p>desktop-callback works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DesktopCallbackComponent } from './desktop-callback.component';
describe('DesktopCallbackComponent', () => {
let component: DesktopCallbackComponent;
let fixture: ComponentFixture<DesktopCallbackComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DesktopCallbackComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(DesktopCallbackComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,21 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-desktop-callback',
templateUrl: './desktop-callback.component.html',
styleUrls: ['./desktop-callback.component.scss']
})
export class DesktopCallbackComponent implements OnInit {
//This component is used to redirect the user to the desktop app after they have authenticated with a source
constructor() { }
ngOnInit(): void {
wails.Event.Emit({
name: "wails:fasten-lighthouse:success",
data:
)
}
}

View File

@ -151,7 +151,7 @@ export class LighthouseService {
if(environment.environment_desktop){
//hash based routing
originUrlParts.hash = this.pathJoin([originUrlParts.hash, `callback/${sourceType}`])
originUrlParts.hash = `desktop/callback/${sourceType}`
} else {
//path based routing
originUrlParts.hash = "" //reset hash in-case its present.
@ -174,6 +174,11 @@ export class LighthouseService {
OpenExternalLink(redirectUrlParts.toString(), environment.environment_desktop)
// let openedWindow = window.runtime.BrowserOpenURL(redirectUrlParts.toString());
wails.Event.Once("wails:fasten-lighthouse:success", (code: string) => {
console.log("GOT CODE FROM DESKTOP", code)
})
this.waitForDesktopCodeOrTimeout(null, sourceType).subscribe(async (codeData) => {
//TODO: redirect to the callback url with the code.
console.log("DONE WAITING FOR CODE")

View File

@ -3,7 +3,7 @@ export const environment = {
environment_cloud: false,
environment_desktop: true,
environment_name: "desktop_sandbox",
popup_source_auth: false,
popup_source_auth: true,
lighthouse_api_endpoint_base: 'https://lighthouse.fastenhealth.com/sandbox',

View File

@ -66,7 +66,11 @@ declare global {
// let wails: any
let wails: {
Event: {
Emit: (event: any) => void
Once: (eventName, callback) => void
On: (eventName, callback) => void
}
Call: (options) => Promise<any>
CallByID: (methodID, ...args) => Promise<any>
CallByName: (name, ...args) => Promise<any>