@abi-software/simulationvuer 2.0.11-beta.0 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/simulationvuer.js +27789 -24902
- package/dist/simulationvuer.umd.cjs +71 -51
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +57 -31
- package/src/components/SimulationVuer.vue +68 -28
- package/src/components/libopencor.js +16 -0
- package/src/components.d.ts +0 -3
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
:stepValue="input.stepValue"
|
|
19
19
|
/>
|
|
20
20
|
</div>
|
|
21
|
-
<div class="primary-button">
|
|
22
|
-
<el-button type="primary" size="small" @click="startSimulation()"
|
|
21
|
+
<div class="primary-button" v-if="!libopencorSet">
|
|
22
|
+
<el-button type="primary" size="small" @click="startSimulation()">Run Simulation</el-button>
|
|
23
23
|
</div>
|
|
24
24
|
<div class="secondary-button" v-if="uuid">
|
|
25
25
|
<el-button size="small" @click="runOnOsparc()">Run on oSPARC</el-button>
|
|
26
26
|
</div>
|
|
27
|
-
<div class="secondary-button">
|
|
28
|
-
<el-button size="small" @click="viewDataset()"
|
|
27
|
+
<div class="secondary-button" v-if="!libopencorSet">
|
|
28
|
+
<el-button size="small" @click="viewDataset()">View Dataset</el-button>
|
|
29
29
|
</div>
|
|
30
|
-
<div class="secondary-button">
|
|
31
|
-
<el-button size="small" @click="viewWorkspace()"
|
|
30
|
+
<div class="secondary-button" v-if="libopencorSet && idType === 'pmr_path'">
|
|
31
|
+
<el-button size="small" @click="viewWorkspace()">View Workspace</el-button>
|
|
32
32
|
</div>
|
|
33
33
|
<p class="default note" v-if="uuid">Additional parameters are available on oSPARC</p>
|
|
34
34
|
</div>
|
|
@@ -56,7 +56,7 @@ import SimulationVuerInput from "./SimulationVuerInput.vue";
|
|
|
56
56
|
import { ElButton, ElDivider, ElLoading } from "element-plus";
|
|
57
57
|
import { evaluateValue, finaliseUi, OPENCOR_SOLVER_NAME } from "./common.js";
|
|
58
58
|
import { validJson } from "./json.js";
|
|
59
|
-
import libOpenCOR from "
|
|
59
|
+
import libOpenCOR from "./libopencor.js";
|
|
60
60
|
import { markRaw } from "vue";
|
|
61
61
|
import { create, all } from "mathjs";
|
|
62
62
|
|
|
@@ -66,6 +66,13 @@ const PMR_URL = "https://models.physiomeproject.org/";
|
|
|
66
66
|
|
|
67
67
|
const math = create(all, {});
|
|
68
68
|
|
|
69
|
+
const IdType = Object.freeze({
|
|
70
|
+
DATASET_ID: 'dataset_id',
|
|
71
|
+
DATASET_URL: 'dataset_url',
|
|
72
|
+
PMR_PATH: 'pmr_path',
|
|
73
|
+
RAW_COMBINE_ARCHIVE: 'raw_combine_archive',
|
|
74
|
+
});
|
|
75
|
+
|
|
69
76
|
/**
|
|
70
77
|
* SimulationVuer
|
|
71
78
|
*/
|
|
@@ -89,27 +96,35 @@ export default {
|
|
|
89
96
|
type: String,
|
|
90
97
|
},
|
|
91
98
|
/**
|
|
92
|
-
* The ID
|
|
93
|
-
*
|
|
99
|
+
* The ID for this simulation, i.e. either
|
|
100
|
+
* - the ID (as a number) of a SPARC dataset,
|
|
101
|
+
* - the URL (as a string) of a COMBINE archive located in a SPARC dataset,
|
|
102
|
+
* - the path (as a string) to a COMBINE archive located on PMR, or
|
|
103
|
+
* - a raw COMBINE archive (as a Uint8Array).
|
|
94
104
|
*/
|
|
95
105
|
id: {
|
|
96
|
-
required:
|
|
97
|
-
type: [Number, String],
|
|
98
|
-
default: 0,
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* A COMBINE archive that was passed directly.
|
|
102
|
-
*/
|
|
103
|
-
combineArchive: {
|
|
104
|
-
required: false,
|
|
105
|
-
type: Uint8Array,
|
|
106
|
-
default: undefined,
|
|
106
|
+
required: true,
|
|
107
|
+
type: [Number, String, Uint8Array],
|
|
107
108
|
},
|
|
108
109
|
},
|
|
109
110
|
data: function () {
|
|
111
|
+
// Determine the ID's type.
|
|
112
|
+
|
|
113
|
+
let idType;
|
|
114
|
+
|
|
115
|
+
if (typeof this.id === "number") {
|
|
116
|
+
idType = IdType.DATASET_ID;
|
|
117
|
+
} else if (this.id instanceof Uint8Array) {
|
|
118
|
+
idType = IdType.RAW_COMBINE_ARCHIVE;
|
|
119
|
+
} else if (this.id.startsWith("https://")) {
|
|
120
|
+
idType = IdType.DATASET_URL;
|
|
121
|
+
} else {
|
|
122
|
+
idType = IdType.PMR_PATH;
|
|
123
|
+
}
|
|
124
|
+
|
|
110
125
|
// Retrieve some information about the dataset.
|
|
111
126
|
|
|
112
|
-
if (
|
|
127
|
+
if (idType === IdType.DATASET_ID) {
|
|
113
128
|
const xmlhttp = new XMLHttpRequest();
|
|
114
129
|
|
|
115
130
|
xmlhttp.open("GET", this.apiLocation + "/sim/dataset/" + this.id);
|
|
@@ -131,6 +146,7 @@ export default {
|
|
|
131
146
|
fileManager: undefined,
|
|
132
147
|
hasFinalisedUi: false,
|
|
133
148
|
hasValidSimulationUiInfo: false,
|
|
149
|
+
idType: idType,
|
|
134
150
|
instance: undefined,
|
|
135
151
|
isMounted: false,
|
|
136
152
|
isSimulationValid: true,
|
|
@@ -657,7 +673,7 @@ export default {
|
|
|
657
673
|
created: function () {
|
|
658
674
|
// Try to retrieve the UI information.
|
|
659
675
|
|
|
660
|
-
if (this.
|
|
676
|
+
if (this.idType === IdType.DATASET_ID) {
|
|
661
677
|
this.userMessage = "Retrieving UI information...";
|
|
662
678
|
this.showUserMessage = true;
|
|
663
679
|
|
|
@@ -682,7 +698,33 @@ export default {
|
|
|
682
698
|
};
|
|
683
699
|
xmlhttp.send();
|
|
684
700
|
});
|
|
685
|
-
} else if (this.
|
|
701
|
+
} else if (this.idType === IdType.DATASET_URL) {
|
|
702
|
+
this.userMessage = "Retrieving COMBINE archive...";
|
|
703
|
+
this.showUserMessage = true;
|
|
704
|
+
|
|
705
|
+
// Retrieve the COMBINE archive, extract the simulation UI JSON file from
|
|
706
|
+
// it and then build the simulation UI.
|
|
707
|
+
|
|
708
|
+
this.$nextTick(() => {
|
|
709
|
+
const xmlhttp = new XMLHttpRequest();
|
|
710
|
+
|
|
711
|
+
xmlhttp.open("GET", this.id);
|
|
712
|
+
xmlhttp.responseType = "arraybuffer";
|
|
713
|
+
xmlhttp.onreadystatechange = () => {
|
|
714
|
+
if (xmlhttp.readyState === 4) {
|
|
715
|
+
if (xmlhttp.status === 200) {
|
|
716
|
+
libOpenCOR().then((libopencor) => {
|
|
717
|
+
this.extractAndBuildSimulationUi(libopencor, new Uint8Array(xmlhttp.response));
|
|
718
|
+
});
|
|
719
|
+
} else {
|
|
720
|
+
this.errorMessage = "the COMBINE archive could not be retrieved";
|
|
721
|
+
this.showUserMessage = false;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
xmlhttp.send();
|
|
726
|
+
});
|
|
727
|
+
} else if (this.idType === IdType.PMR_PATH) {
|
|
686
728
|
this.userMessage = "Retrieving COMBINE archive from PMR...";
|
|
687
729
|
this.showUserMessage = true;
|
|
688
730
|
|
|
@@ -701,14 +743,14 @@ export default {
|
|
|
701
743
|
this.extractAndBuildSimulationUi(libopencor, Uint8Array.from(atob(xmlhttp.response), (c) => c.charCodeAt(0)));
|
|
702
744
|
});
|
|
703
745
|
} else {
|
|
704
|
-
this.errorMessage = "the COMBINE archive chould not be retrieved";
|
|
746
|
+
this.errorMessage = "the COMBINE archive chould not be retrieved from PMR";
|
|
705
747
|
this.showUserMessage = false;
|
|
706
748
|
}
|
|
707
749
|
}
|
|
708
750
|
};
|
|
709
751
|
xmlhttp.send(JSON.stringify({ path: this.id }));
|
|
710
752
|
});
|
|
711
|
-
} else
|
|
753
|
+
} else {
|
|
712
754
|
// Extract the simulation UI JSON file from the COMBINE archive and build
|
|
713
755
|
// the simulation UI.
|
|
714
756
|
|
|
@@ -717,11 +759,9 @@ export default {
|
|
|
717
759
|
|
|
718
760
|
this.$nextTick(() => {
|
|
719
761
|
libOpenCOR().then((libopencor) => {
|
|
720
|
-
this.extractAndBuildSimulationUi(libopencor, this.
|
|
762
|
+
this.extractAndBuildSimulationUi(libopencor, this.id);
|
|
721
763
|
});
|
|
722
764
|
});
|
|
723
|
-
} else {
|
|
724
|
-
this.errorMessage = "an non-simulation dataset was provided";
|
|
725
765
|
}
|
|
726
766
|
},
|
|
727
767
|
mounted: function () {
|