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

Provide feedback that an ontology is being loaded #457

Open
garrettjstevens opened this issue Oct 2, 2024 · 1 comment
Open

Provide feedback that an ontology is being loaded #457

garrettjstevens opened this issue Oct 2, 2024 · 1 comment
Assignees

Comments

@garrettjstevens
Copy link
Contributor

Use the jobsManager in the (Apollo) session to update that an ontology is loading.

We'll have to pass something into the OntologyManager to call updates with, like an update callback. We can then use that callback to adapt to the jobsManager. e.g. something like this:

--- a/packages/jbrowse-plugin-apollo/src/OntologyManager/OntologyStore/index.ts
+++ b/packages/jbrowse-plugin-apollo/src/OntologyManager/OntologyStore/index.ts
@@ -71,6 +71,7 @@ export interface OntologyStoreOptions {
     indexFields?: { displayName: string; jsonPath: string }[]
   }
   maxSearchResults?: number
+  update?(message: string, progress: number): void
 }
 
 export interface PropertiesOptions {
@@ -110,8 +111,8 @@ export default class OntologyStore {
     this.ontologyName = name
     this.ontologyVersion = version
     this.sourceLocation = source
-    this.db = this.prepareDatabase()
     this.options = options ?? {}
+    this.db = this.prepareDatabase()
   }
 
   /**
@@ -176,8 +177,12 @@ export default class OntologyStore {
       return db
     }
 
-    const { sourceLocation, sourceType } = this
+    const { options, sourceLocation, sourceType } = this
     if (sourceType === 'obo-graph-json') {
+      if (options.update) {
+        options.update('Importing', 0)
+      }
+      // add more updates inside `loadOboGraphJson`
       await this.loadOboGraphJson(db)
     } else {
       throw new Error(
--- a/packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts
+++ b/packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts
@@ -42,6 +42,7 @@ import {
 } from '../OntologyManager'
 import { ApolloRootModel } from '../types'
 import { autorun } from 'mobx'
+import { ApolloSessionModel } from './session'
 
 export function clientDataStoreFactory(
   AnnotationFeatureExtended: typeof AnnotationFeatureModel,
@@ -164,8 +165,15 @@ export function clientDataStoreFactory(
                 ) as TextIndexFieldDefinition[],
               ]
               if (!ontologyManager.findOntology(name)) {
+                const session = getSession(
+                  self,
+                ) as unknown as ApolloSessionModel
+                const { jobsManager } = session
+                function update(message: string, progress: Number) {
+                  // adapt `update` to what `jobsManager` expets
+                }
                 ontologyManager.addOntology(name, version, source, {
-                  textIndexing: { indexFields },
+                  textIndexing: { indexFields }, update,
                 })
               }
             }

You can see an example of how jobsManager is used in packages/jbrowse-plugin-apollo/src/components/ImportFeatures.tsx.

@dariober
Copy link
Contributor

See PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants