@@ -48,74 +48,43 @@ qx.Class.define("osparc.data.Converters", {
4848 file [ "location_id" ] ,
4949 ""
5050 ) ;
51- if ( file [ "location_id" ] === 0 || file [ "location_id" ] === "0" ) {
52- // simcore files
53- let parent = fileInTree ;
54- const splitted = file [ "file_uuid" ] . split ( "/" ) ;
55- if ( splitted . length < 3 ) {
56- continue ;
57- }
51+ const isSimcore = file [ "location_id" ] === 0 || file [ "location_id" ] === "0" ;
5852
59- const prjId = splitted [ 0 ] ;
60- const nodeId = splitted [ 1 ] ;
61- const prjLabel = file [ "project_name" ] ;
62- const nodeLabel = file [ "node_name" ] ;
63- const prjItem = this . createDirEntry (
64- prjLabel ,
65- file [ "location_id" ] ,
66- prjId
67- ) ;
68- parent . children . push ( prjItem ) ;
69- parent = prjItem
70- const nodeItem = this . createDirEntry (
71- nodeLabel ,
72- file [ "location_id" ] ,
73- nodeId
74- ) ;
75- parent . children . push ( nodeItem ) ;
76- parent = nodeItem
53+ const splitted = file [ "file_uuid" ] . split ( "/" ) ;
54+ if ( isSimcore && splitted . length < 3 ) {
55+ continue ;
56+ }
7757
78- for ( let j = 2 ; j < splitted . length - 1 ; j ++ ) {
79- const newItem = this . createDirEntry (
80- splitted [ j ] ,
81- file [ "location_id" ] ,
82- parent . path === "" ? splitted [ j ] : parent . path + "/" + splitted [ j ]
83- ) ;
84- parent . children . push ( newItem ) ;
85- parent = newItem ;
58+ // create directories
59+ let parent = fileInTree ;
60+ for ( let j = 0 ; j < splitted . length - 1 ; j ++ ) {
61+ let label = "Unknown" ;
62+ if ( isSimcore && j === 0 ) {
63+ label = file [ "project_name" ] ;
64+ } else if ( isSimcore && j === 1 ) {
65+ label = file [ "node_name" ] ;
66+ } else {
67+ label = splitted [ j ] ;
8668 }
87- let fileInfo = this . createFileEntry (
88- splitted [ splitted . length - 1 ] ,
69+ const newItem = this . createDirEntry (
70+ label ,
8971 file [ "location_id" ] ,
90- splitted [ splitted . length - 1 ] ,
91- file [ "file_id" ] ,
92- file [ "last_modified" ] ,
93- file [ "file_size" ] ) ;
94- parent . children . push ( fileInfo ) ;
95- this . __mergeFileTreeChildren ( children , fileInTree ) ;
96- } else if ( file [ "location_id" ] === 1 || file [ "location_id" ] === "1" ) {
97- // datcore files
98- let parent = fileInTree ;
99- let splitted = file [ "file_uuid" ] . split ( "/" ) ;
100- for ( let j = 0 ; j < splitted . length - 1 ; j ++ ) {
101- const newItem = this . createDirEntry (
102- splitted [ j ] ,
103- file [ "location_id" ] ,
104- parent . path === "" ? splitted [ j ] : parent . path + "/" + splitted [ j ]
105- ) ;
106- parent . children . push ( newItem ) ;
107- parent = newItem ;
108- }
109- let fileInfo = this . createFileEntry (
110- splitted [ splitted . length - 1 ] ,
111- file [ "location_id" ] ,
112- datasetId ,
113- file [ "file_id" ] ,
114- file [ "last_modified" ] ,
115- file [ "file_size" ] ) ;
116- parent . children . push ( fileInfo ) ;
117- this . __mergeFileTreeChildren ( children , fileInTree ) ;
72+ parent . path === "" ? splitted [ j ] : parent . path + "/" + splitted [ j ]
73+ ) ;
74+ parent . children . push ( newItem ) ;
75+ parent = newItem ;
11876 }
77+
78+ // create file
79+ const fileInfo = this . createFileEntry (
80+ splitted [ splitted . length - 1 ] ,
81+ file [ "location_id" ] ,
82+ datasetId ,
83+ file [ "file_id" ] ,
84+ file [ "last_modified" ] ,
85+ file [ "file_size" ] ) ;
86+ parent . children . push ( fileInfo ) ;
87+ this . __mergeFileTreeChildren ( children , fileInTree ) ;
11988 }
12089
12190 return children ;
0 commit comments