@abi-software/simulationvuer 0.5.4 → 0.5.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/simulationvuer",
3
- "version": "0.5.4",
3
+ "version": "0.5.7",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve --mode static",
package/src/App.vue CHANGED
@@ -7,17 +7,17 @@
7
7
  <p>
8
8
  Instance for an unknown or invalid model:
9
9
  </p>
10
- <SimulationVuer :apiLocation="apiLocation" :entry="noEntry" />
10
+ <SimulationVuer :apiLocation="apiLocation" :id=0 />
11
11
  <hr />
12
12
  <p>
13
13
  Instance showing the simulation of the <a href="https://models.physiomeproject.org/e/611/HumanSAN_Fabbri_Fantini_Wilders_Severi_2017.cellml/view">Fabbri <em>et al.</em> (2017)</a> model:
14
14
  </p>
15
- <SimulationVuer :apiLocation="apiLocation" :entry="normalEntry" />
15
+ <SimulationVuer :apiLocation="apiLocation" :id=135 />
16
16
  <hr />
17
17
  <p>
18
18
  Instance showing the simulation of the <a href="https://models.physiomeproject.org/e/611/HumanSAN_Fabbri_Fantini_Wilders_Severi_2017.cellml/view">Fabbri <em>et al.</em> (2017)</a> + <a href="https://models.physiomeproject.org/workspace/694">Gerstner & Kistler (2002)</a> composite model:
19
19
  </p>
20
- <SimulationVuer :apiLocation="apiLocation" :entry="compositeEntry" style="height: 500px;" />
20
+ <SimulationVuer :apiLocation="apiLocation" :id=157 />
21
21
  <hr />
22
22
  </div>
23
23
  </template>
@@ -33,22 +33,6 @@ export default {
33
33
  data: function () {
34
34
  return {
35
35
  apiLocation: process.env.VUE_APP_API_LOCATION,
36
- noEntry: {
37
- },
38
- normalEntry: {
39
- dataset: "https://sparc.science/datasets/135?type=dataset",
40
- discoverId: 135,
41
- description: "CellML version of the Fabbri et al. 2017 mathematical model of the spontaneous electrical activity of a human sinoatrial node (SAN) pacemaker cell",
42
- name: "Computational analysis of the human sinus node action potential - Model development and effects of mutations",
43
- resource: "https://models.physiomeproject.org/workspace/486/rawfile/55879cbc485e2d4c41f3dc6d60424b849f94c4ee/HumanSAN_Fabbri_Fantini_Wilders_Severi_2017.cellml",
44
- },
45
- compositeEntry: {
46
- dataset: "https://sparc.science/datasets/157?type=dataset",
47
- discoverId: 157,
48
- description: "CellML version of the Fabbri et al. 2017 human sinoatrial node (SAN) cell model and an ODE-based version of the Gerstner & Kistler 2002 brain stem model combined to demonstrate the effect of brain stem activity on heart rate",
49
- name: "Fabbri-based composite SAN model",
50
- resource: "https://models.physiomeproject.org/workspace/698/rawfile/f3fc911063ac72ed44e84c0c5af28df41c25d452/fabbri_et_al_based_composite_SAN_model.sedml",
51
- },
52
36
  };
53
37
  },
54
38
  };
@@ -3,7 +3,7 @@
3
3
  <p v-if="!hasValidSimulationUiInformation && !showUserMessage" class="default error"><span class="error">Error:</span> an unknown or invalid model was provided.</p>
4
4
  <div class="main" v-if="hasValidSimulationUiInformation">
5
5
  <div class="main-left">
6
- <p class="default title">{{title}}</p>
6
+ <p class="default name">{{name}}</p>
7
7
  <el-divider></el-divider>
8
8
  <p class="default input-parameters">Input parameters</p>
9
9
  <div>
@@ -56,12 +56,39 @@ export default {
56
56
  required: true,
57
57
  type: String,
58
58
  },
59
- entry: {
59
+ id: {
60
60
  required: true,
61
- type: Object,
61
+ type: Number,
62
62
  },
63
63
  },
64
64
  data: function() {
65
+ let xmlhttp = new XMLHttpRequest();
66
+ let name = undefined;
67
+ let resource = undefined;
68
+
69
+ xmlhttp.open("GET", this.apiLocation + "dataset_info/using_pennsieve_identifier?identifier=" + this.id, false);
70
+ xmlhttp.setRequestHeader("Content-type", "application/json");
71
+ xmlhttp.send();
72
+
73
+ if (xmlhttp.status === 200) {
74
+ let datasetInfo = JSON.parse(xmlhttp.responseText).result[0];
75
+
76
+ if (datasetInfo !== undefined) {
77
+ name = datasetInfo.name;
78
+
79
+ let isSedmlResource = false;
80
+
81
+ datasetInfo.additionalLinks.forEach(function(el) {
82
+ if (el.description == "SED-ML file") {
83
+ isSedmlResource = true;
84
+ resource = el.uri;
85
+ } else if (!isSedmlResource && (el.description == "CellML file")) {
86
+ resource = el.uri;
87
+ }
88
+ });
89
+ }
90
+ }
91
+
65
92
  return {
66
93
  errorMessage: "",
67
94
  firstScalarInput: [],
@@ -70,12 +97,13 @@ export default {
70
97
  isMounted: false,
71
98
  isSimulationValid: true,
72
99
  layout: [],
100
+ name: name,
101
+ resource: resource,
73
102
  showUserMessage: false,
74
103
  simulationData: [],
75
104
  simulationDataId: {},
76
105
  simulationUiInformation: {},
77
106
  userMessage: "",
78
- title: (this.entry !== undefined)?this.entry.name:"",
79
107
  ui: null,
80
108
  };
81
109
  },
@@ -84,14 +112,14 @@ export default {
84
112
  window.open("https://osparc.io/", "_blank");
85
113
  },
86
114
  viewDataset() {
87
- window.open(this.entry.dataset, "_blank");
115
+ window.open(`https://sparc.science/datasets/${this.id}?type=dataset`, "_blank");
88
116
  },
89
117
  runSimulation() {
90
118
  this.userMessage = "Loading simulation results...";
91
119
  this.showUserMessage = true;
92
120
 
93
121
  let request = {
94
- model_url: this.entry.resource,
122
+ model_url: this.resource,
95
123
  json_config: {},
96
124
  };
97
125
 
@@ -131,7 +159,7 @@ export default {
131
159
 
132
160
  let xmlhttp = new XMLHttpRequest();
133
161
 
134
- xmlhttp.open("POST", this.apiLocation + "/simulation", true);
162
+ xmlhttp.open("POST", this.apiLocation + "simulation", true);
135
163
  xmlhttp.setRequestHeader("Content-type", "application/json");
136
164
  xmlhttp.onreadystatechange = () => {
137
165
  if (xmlhttp.readyState === 4) {
@@ -178,48 +206,52 @@ export default {
178
206
  },
179
207
  },
180
208
  created: function() {
181
- this.userMessage = "Retrieving UI information...";
182
- this.showUserMessage = true;
209
+ // Try to retrieve the UI information, but only if we have a resource.
183
210
 
184
- // Retrieve the simulation UI file for the given dataset.
211
+ if (this.resource !== undefined) {
212
+ this.userMessage = "Retrieving UI information...";
213
+ this.showUserMessage = true;
185
214
 
186
- let xmlhttp = new XMLHttpRequest();
215
+ // Retrieve the simulation UI file for the given dataset.
187
216
 
188
- xmlhttp.open("GET", this.apiLocation + "/simulation_ui_file/" + this.entry.discoverId, true);
189
- xmlhttp.setRequestHeader("Content-type", "application/json");
190
- xmlhttp.onreadystatechange = () => {
191
- if (xmlhttp.readyState === 4) {
192
- // Keep track of the simulation UI information.
217
+ let xmlhttp = new XMLHttpRequest();
193
218
 
194
- this.simulationUiInformation = JSON.parse(xmlhttp.responseText);
219
+ xmlhttp.open("GET", this.apiLocation + "simulation_ui_file/" + this.id, true);
220
+ xmlhttp.setRequestHeader("Content-type", "application/json");
221
+ xmlhttp.onreadystatechange = () => {
222
+ if (xmlhttp.readyState === 4) {
223
+ this.showUserMessage = false;
195
224
 
196
- // Make sure that the simulation UI information is valid.
225
+ if (xmlhttp.status === 200) {
226
+ // Keep track of the simulation UI information.
197
227
 
198
- this.hasValidSimulationUiInformation = validJson(this.simulationUiInformation);
228
+ this.simulationUiInformation = JSON.parse(xmlhttp.responseText);
199
229
 
200
- if (!this.hasValidSimulationUiInformation) {
201
- this.showUserMessage = false;
230
+ // Make sure that the simulation UI information is valid.
202
231
 
203
- return;
204
- }
232
+ this.hasValidSimulationUiInformation = validJson(this.simulationUiInformation);
205
233
 
206
- // Initialise our UI.
234
+ if (!this.hasValidSimulationUiInformation) {
235
+ return;
236
+ }
207
237
 
208
- initialiseUi(this);
238
+ // Initialise our UI.
209
239
 
210
- // Finalise our UI.
211
- // Note: we try both here and in the mounded() function since we have no
212
- // idea how long it's going to take to retrieve the simulation UI
213
- // information.
240
+ initialiseUi(this);
214
241
 
215
- this.$nextTick(() => {
216
- finaliseUi(this);
242
+ // Finalise our UI.
243
+ // Note: we try both here and in the mounded() function since we have no
244
+ // idea how long it's going to take to retrieve the simulation UI
245
+ // information.
217
246
 
218
- this.showUserMessage = false;
219
- });
220
- }
221
- };
222
- xmlhttp.send();
247
+ this.$nextTick(() => {
248
+ finaliseUi(this);
249
+ });
250
+ }
251
+ }
252
+ };
253
+ xmlhttp.send();
254
+ }
223
255
  },
224
256
  mounted: function() {
225
257
  // Finalise our UI.
@@ -326,18 +358,18 @@ p.default {
326
358
  p.error {
327
359
  margin-left: 16px;
328
360
  }
329
- p.note {
330
- font-size: 12px;
331
- line-height: 16px;
332
- }
333
- p.title,
361
+ p.name,
334
362
  p.input-parameters {
335
363
  margin-top: 0;
336
364
  font-weight: 500 /* Medium */;
337
365
  }
338
- p.title {
366
+ p.name {
339
367
  line-height: 20px;
340
368
  }
369
+ p.note {
370
+ font-size: 12px;
371
+ line-height: 16px;
372
+ }
341
373
  span.error {
342
374
  font-weight: 500 /* Medium */;
343
375
  }