Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lgl
SmartVillages2
Commits
cba7ebfe
Commit
cba7ebfe
authored
Jul 31, 2025
by
Luna Riegel
Browse files
Fix catalogue loading
parent
b88f4cbe
Changes
1
Show whitespace changes
Inline
Side-by-side
src/objectList.vue
View file @
cba7ebfe
...
@@ -119,9 +119,9 @@ let projectStateObject = undefined;
...
@@ -119,9 +119,9 @@ let projectStateObject = undefined;
async
function
loadCataloguesFromConfig
(
config
)
{
async
function
loadCataloguesFromConfig
(
config
)
{
const
configJson
=
JSON
.
parse
(
JSON
.
stringify
(
config
));
const
configJson
=
JSON
.
parse
(
JSON
.
stringify
(
config
));
const
catalogues
=
configJson
.
objectCatalogues
;
const
catalogues
=
Object
.
values
(
configJson
.
objectCatalogues
)
;
for
(
le
t
cat
of
catalogues
)
{
for
(
cons
t
cat
of
catalogues
)
{
const
catJson
=
await
retrieveCatalogueJson
(
cat
.
url
);
const
catJson
=
await
retrieveCatalogueJson
(
cat
.
url
);
if
(
!
catJson
)
continue
;
if
(
!
catJson
)
continue
;
...
@@ -146,11 +146,15 @@ async function retrieveCatalogueJson(link) {
...
@@ -146,11 +146,15 @@ async function retrieveCatalogueJson(link) {
try
{
try
{
const
response
=
await
fetch
(
link
,
{
signal
:
controller
.
signal
});
const
response
=
await
fetch
(
link
,
{
signal
:
controller
.
signal
});
if
(
!
response
.
ok
)
{
if
(
!
response
.
ok
)
{
throw
new
Error
(
`HTTP error
:
${
response
.
status
}
for
catalogue
${
link
}
`
);
throw
new
Error
(
`HTTP error
${
response
.
status
}
for
${
link
}
`
);
}
}
return
await
response
.
json
();
return
await
response
.
json
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
if
(
error
.
name
===
'
AbortError
'
)
{
console
.
warn
(
`Fetch aborted (timeout) for:
${
link
}
`
);
}
else
{
console
.
error
(
`Fetch failed for
${
link
}
:`
,
error
);
}
return
null
;
return
null
;
}
finally
{
}
finally
{
clearTimeout
(
timeout
);
clearTimeout
(
timeout
);
...
@@ -160,24 +164,38 @@ async function retrieveCatalogueJson(link) {
...
@@ -160,24 +164,38 @@ async function retrieveCatalogueJson(link) {
function
getCatalogueEntries
(
json
,
linkPrefix
)
{
function
getCatalogueEntries
(
json
,
linkPrefix
)
{
const
part
=
{};
const
part
=
{};
for
(
let
item
of
json
.
items
)
{
const
subCat
=
item
.
title
;
if
(
!
json
||
!
Array
.
isArray
(
json
.
items
))
{
console
.
warn
(
'
Invalid or missing `json.items`:
'
,
json
);
return
part
;
}
for
(
const
item
of
json
.
items
)
{
const
subCat
=
item
.
title
||
'
Unnamed
'
;
const
entries
=
[];
const
entries
=
[];
for
(
let
entry
of
item
.
predefinedObjects
)
{
if
(
Array
.
isArray
(
item
.
predefinedObjects
))
{
const
info
=
{
for
(
const
entry
of
item
.
predefinedObjects
)
{
title
:
entry
.
title
,
if
(
typeof
entry
!==
'
object
'
||
entry
===
null
)
{
icon
:
linkPrefix
+
entry
.
icon
,
console
.
warn
(
'
Invalid entry:
'
,
entry
);
model
:
linkPrefix
+
entry
.
properties
?.
olcs_modelUrl
,
continue
;
};
entries
.
push
(
info
);
}
}
part
[
subCat
.
toString
()]
=
entries
;
const
title
=
entry
.
title
||
'
Untitled
'
;
const
icon
=
linkPrefix
+
(
entry
.
icon
||
''
);
const
model
=
linkPrefix
+
(
entry
.
properties
?.
olcs_modelUrl
||
''
);
entries
.
push
({
title
,
icon
,
model
});
}
}
else
{
console
.
warn
(
'
Expected array for predefinedObjects, got:
'
,
item
.
predefinedObjects
);
}
part
[
subCat
]
=
entries
;
}
}
return
part
;
return
part
;
}
}
function
uploadModel
()
{
function
uploadModel
()
{
// Create an input element
// Create an input element
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment