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
You need to sign in or sign up before continuing.
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;
async
function
loadCataloguesFromConfig
(
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
);
if
(
!
catJson
)
continue
;
...
...
@@ -146,11 +146,15 @@ async function retrieveCatalogueJson(link) {
try
{
const
response
=
await
fetch
(
link
,
{
signal
:
controller
.
signal
});
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
();
}
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
;
}
finally
{
clearTimeout
(
timeout
);
...
...
@@ -160,24 +164,38 @@ async function retrieveCatalogueJson(link) {
function
getCatalogueEntries
(
json
,
linkPrefix
)
{
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
=
[];
for
(
let
entry
of
item
.
predefinedObjects
)
{
const
info
=
{
title
:
entry
.
title
,
icon
:
linkPrefix
+
entry
.
icon
,
model
:
linkPrefix
+
entry
.
properties
?.
olcs_modelUrl
,
};
entries
.
push
(
info
);
if
(
Array
.
isArray
(
item
.
predefinedObjects
))
{
for
(
const
entry
of
item
.
predefinedObjects
)
{
if
(
typeof
entry
!==
'
object
'
||
entry
===
null
)
{
console
.
warn
(
'
Invalid entry:
'
,
entry
);
continue
;
}
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
;
}
}
function
uploadModel
()
{
// 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