- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2
 
feat(save_and_load): add import/export methods #249
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
          
     Open
      
      
            MaxNumerique
  wants to merge
  35
  commits into
  next
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
feat/save_and_load
  
      
      
   
  
    
  
  
  
 
  
      
    base: next
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            35 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      aa86c91
              
                feat(save_and_load): add save/load methods to all stores for project …
              
              
                MaxNumerique 5b2b4f3
              
                Apply prepare changes
              
              
                MaxNumerique f4ef491
              
                cartStore becomes geodeStore
              
              
                MaxNumerique 5f3e0c6
              
                Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
              
              
                MaxNumerique e6c54b5
              
                Apply prepare changes
              
              
                MaxNumerique 01a9732
              
                renames and move tests
              
              
                MaxNumerique 0b70454
              
                Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
              
              
                MaxNumerique d577721
              
                persist upload folder
              
              
                MaxNumerique df419ec
              
                renamed app_store store to app
              
              
                MaxNumerique bb9d02d
              
                rm unused var
              
              
                MaxNumerique a93225c
              
                importStore & exportStore refacto
              
              
                MaxNumerique af41f9d
              
                Apply prepare changes
              
              
                MaxNumerique ea63e2b
              
                testes with import/export
              
              
                MaxNumerique 97072b5
              
                Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
              
              
                MaxNumerique 63464b7
              
                Apply prepare changes
              
              
                MaxNumerique 98991cf
              
                test
              
              
                MaxNumerique 6321c8f
              
                Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
              
              
                MaxNumerique 35c75dd
              
                Apply prepare changes
              
              
                MaxNumerique 22a67fe
              
                test
              
              
                MaxNumerique caf5a39
              
                Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
              
              
                MaxNumerique 18fc885
              
                Apply prepare changes
              
              
                MaxNumerique d4a1cd6
              
                exportStores/importStores and createTestingPinia
              
              
                MaxNumerique 8aec8b8
              
                Apply prepare changes
              
              
                MaxNumerique 6a282e4
              
                export working
              
              
                MaxNumerique 196be52
              
                Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
              
              
                MaxNumerique fdf547e
              
                nothing appear in camera
              
              
                MaxNumerique c208b30
              
                Apply prepare changes
              
              
                MaxNumerique 3ef456f
              
                test
              
              
                MaxNumerique 2ca553b
              
                Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
              
              
                MaxNumerique 9fd6c0b
              
                Apply prepare changes
              
              
                MaxNumerique 3806d54
              
                feat(import_project): add 2 buttons : Export and import
              
              
                MaxNumerique 3d04f42
              
                Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
              
              
                MaxNumerique 24eb5b6
              
                test
              
              
                MaxNumerique 9866872
              
                Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
              
              
                MaxNumerique f01890f
              
                Apply prepare changes
              
              
                MaxNumerique File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" | ||
| import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" | ||
| import fileDownload from "js-file-download" | ||
| 
     | 
||
| export function useProjectManager() { | ||
| const geode = useGeodeStore() | ||
| const appStore = useAppStore() | ||
| 
     | 
||
| async function exportProject() { | ||
| geode.start_request() | ||
| try { | ||
| await useInfraStore().create_connection() | ||
| const snapshot = appStore.exportStores() | ||
| const schema = back_schemas.opengeodeweb_back.export_project | ||
| const defaultName = "project.zip" | ||
| 
     | 
||
| await api_fetch( | ||
| { schema, params: { snapshot, filename: defaultName } }, | ||
| { | ||
| response_function: async (response) => { | ||
| const data = response._data | ||
| const downloadName = | ||
                
      
                  MaxNumerique marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| response.headers?.get?.("new-file-name") || defaultName | ||
| fileDownload(data, downloadName) | ||
| }, | ||
| }, | ||
| ) | ||
| } finally { | ||
| geode.stop_request() | ||
| } | ||
| } | ||
| 
     | 
||
| async function importProjectFile(file) { | ||
| geode.start_request() | ||
| try { | ||
| const infra = useInfraStore() | ||
| await infra.create_connection() | ||
| 
     | 
||
| const form = new FormData() | ||
| form.append("file", file, file.name || "project.zip") | ||
| 
     | 
||
| const importPath = | ||
| back_schemas.opengeodeweb_back.import_project?.$id || | ||
| "opengeodeweb_back/import_project" | ||
| 
     | 
||
| const result = await $fetch(importPath, { | ||
| baseURL: geode.base_url, | ||
| method: "POST", | ||
| body: form, | ||
| }) | ||
| 
     | 
||
| await viewer_call({ | ||
| schema: viewer_schemas.opengeodeweb_viewer.import_project, | ||
| params: {}, | ||
| }) | ||
| await viewer_call({ | ||
| schema: viewer_schemas.opengeodeweb_viewer.viewer.reset_visualization, | ||
| params: {}, | ||
| }) | ||
| 
     | 
||
| await appStore.importStores(result.snapshot) | ||
| 
     | 
||
| const dataBaseStore = useDataBaseStore() | ||
| for (const [id, item] of Object.entries(dataBaseStore.items)) { | ||
| const registerSchema = | ||
| item.object_type === "model" | ||
| ? viewer_schemas.opengeodeweb_viewer.model.register | ||
| : viewer_schemas.opengeodeweb_viewer.mesh.register | ||
| await viewer_call({ schema: registerSchema, params: { id } }) | ||
| 
     | 
||
| if (item.vtk_js?.binary_light_viewable) { | ||
| await viewer_call({ | ||
| schema: viewer_schemas.opengeodeweb_viewer.viewer.update_data, | ||
| params: { | ||
| id, | ||
| vtk_js: { | ||
| binary_light_viewable: item.vtk_js.binary_light_viewable, | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
| 
     | 
||
| if (item.viewable_filename) { | ||
| await viewer_call({ | ||
| schema: viewer_schemas.opengeodeweb_viewer.viewer.update_data, | ||
| params: { | ||
| id, | ||
| vtk_js: { viewable_file_name: item.viewable_filename }, | ||
| }, | ||
| }) | ||
| } | ||
| } | ||
| } finally { | ||
| geode.stop_request() | ||
| } | ||
| } | ||
| 
     | 
||
| return { exportProject, importProjectFile } | ||
| } | ||
| 
     | 
||
| export default useProjectManager | ||
            File renamed without changes.
          
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JulienChampagnol que penses tu de cette proposition ?