Skip to content

Commit d0d1433

Browse files
committed
fix(app): Support "url" url parameter
1 parent 013b612 commit d0d1433

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/app.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Actions, Mutations } from 'simput/src/stores/types';
1919

2020
import registerDefaultProperties from 'simput/src/components/properties/registerDefaults';
2121
import HookManager from 'simput/src/core/HookManager';
22+
import ReaderFactory from 'simput/src/io/ReaderFactory';
2223

2324
Vue.use(Vuetify);
2425

@@ -70,10 +71,26 @@ export function createViewer() {
7071

7172
return {
7273
processURLArgs() {
73-
const { type } = vtkURLExtract.extractURLParameters();
74-
if (type) {
74+
const { url, type } = vtkURLExtract.extractURLParameters();
75+
if (url || type) {
7576
// don't flash landing
7677
Store.commit(Mutations.SHOW_APP);
78+
}
79+
80+
// try URL first, then load type
81+
if (url) {
82+
return ReaderFactory.downloadDataset('data.zip', url).then((result) => {
83+
const { dataset } = result;
84+
if (dataset.type && dataset.data) {
85+
Store.commit(Mutations.SET_MODEL, {
86+
type: dataset.type,
87+
data: dataset.data,
88+
});
89+
return Store.dispatch(Actions.LOAD_TEMPLATE, dataset.type);
90+
}
91+
return Promise.reject(new Error('No model found in download'));
92+
});
93+
} else if (type) {
7794
Store.commit(Mutations.SET_MODEL, {
7895
type,
7996
data: {},

0 commit comments

Comments
 (0)