@abi-software/simulationvuer 0.5.5 → 0.5.6

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.
@@ -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>
@@ -52,16 +52,39 @@ export default {
52
52
  SimulationVuerInput,
53
53
  },
54
54
  props: {
55
- apiLocation: {
55
+ id: {
56
56
  required: true,
57
- type: String,
58
- },
59
- entry: {
60
- required: true,
61
- type: Object,
57
+ type: Number,
62
58
  },
63
59
  },
64
60
  data: function() {
61
+ let xmlhttp = new XMLHttpRequest();
62
+ let name = undefined;
63
+ let resource = undefined;
64
+
65
+ xmlhttp.open("GET", process.env.VUE_APP_API_LOCATION + "dataset_info/using_pennsieve_identifier?identifier=" + this.id, false);
66
+ xmlhttp.setRequestHeader("Content-type", "application/json");
67
+ xmlhttp.send();
68
+
69
+ if (xmlhttp.status === 200) {
70
+ let datasetInfo = JSON.parse(xmlhttp.responseText).result[0];
71
+
72
+ if (datasetInfo !== undefined) {
73
+ name = datasetInfo.name;
74
+
75
+ let isSedmlResource = false;
76
+
77
+ datasetInfo.additionalLinks.forEach(function(el) {
78
+ if (el.description == "SED-ML file") {
79
+ isSedmlResource = true;
80
+ resource = el.uri;
81
+ } else if (!isSedmlResource && (el.description == "CellML file")) {
82
+ resource = el.uri;
83
+ }
84
+ });
85
+ }
86
+ }
87
+
65
88
  return {
66
89
  errorMessage: "",
67
90
  firstScalarInput: [],
@@ -70,12 +93,13 @@ export default {
70
93
  isMounted: false,
71
94
  isSimulationValid: true,
72
95
  layout: [],
96
+ name: name,
97
+ resource: resource,
73
98
  showUserMessage: false,
74
99
  simulationData: [],
75
100
  simulationDataId: {},
76
101
  simulationUiInformation: {},
77
102
  userMessage: "",
78
- title: (this.entry !== undefined)?this.entry.name:"",
79
103
  ui: null,
80
104
  };
81
105
  },
@@ -84,14 +108,14 @@ export default {
84
108
  window.open("https://osparc.io/", "_blank");
85
109
  },
86
110
  viewDataset() {
87
- window.open(this.entry.dataset, "_blank");
111
+ window.open(`https://sparc.science/datasets/${this.id}?type=dataset`, "_blank");
88
112
  },
89
113
  runSimulation() {
90
114
  this.userMessage = "Loading simulation results...";
91
115
  this.showUserMessage = true;
92
116
 
93
117
  let request = {
94
- model_url: this.entry.resource,
118
+ model_url: this.resource,
95
119
  json_config: {},
96
120
  };
97
121
 
@@ -131,7 +155,7 @@ export default {
131
155
 
132
156
  let xmlhttp = new XMLHttpRequest();
133
157
 
134
- xmlhttp.open("POST", this.apiLocation + "/simulation", true);
158
+ xmlhttp.open("POST", process.env.VUE_APP_API_LOCATION + "simulation", true);
135
159
  xmlhttp.setRequestHeader("Content-type", "application/json");
136
160
  xmlhttp.onreadystatechange = () => {
137
161
  if (xmlhttp.readyState === 4) {
@@ -178,15 +202,9 @@ export default {
178
202
  },
179
203
  },
180
204
  created: function() {
181
- let url = document.createElement("a");
182
-
183
- url.href = this.entry.dataset;
184
-
185
- let datasetId = url.pathname.replace("/datasets/", "");
186
-
187
- if (datasetId !== "/undefined") {
188
- // Let people know that we are retrieving our UI information.
205
+ // Try to retrieve the UI information, but only if we have a resource.
189
206
 
207
+ if (this.resource !== undefined) {
190
208
  this.userMessage = "Retrieving UI information...";
191
209
  this.showUserMessage = true;
192
210
 
@@ -194,38 +212,38 @@ export default {
194
212
 
195
213
  let xmlhttp = new XMLHttpRequest();
196
214
 
197
- xmlhttp.open("GET", this.apiLocation + "/simulation_ui_file/" + datasetId, true);
215
+ xmlhttp.open("GET", process.env.VUE_APP_API_LOCATION + "simulation_ui_file/" + this.id, true);
198
216
  xmlhttp.setRequestHeader("Content-type", "application/json");
199
217
  xmlhttp.onreadystatechange = () => {
200
218
  if (xmlhttp.readyState === 4) {
201
- // Keep track of the simulation UI information.
202
-
203
- this.simulationUiInformation = JSON.parse(xmlhttp.responseText);
219
+ this.showUserMessage = false;
204
220
 
205
- // Make sure that the simulation UI information is valid.
221
+ if (xmlhttp.status === 200) {
222
+ // Keep track of the simulation UI information.
206
223
 
207
- this.hasValidSimulationUiInformation = validJson(this.simulationUiInformation);
224
+ this.simulationUiInformation = JSON.parse(xmlhttp.responseText);
208
225
 
209
- if (!this.hasValidSimulationUiInformation) {
210
- this.showUserMessage = false;
226
+ // Make sure that the simulation UI information is valid.
211
227
 
212
- return;
213
- }
228
+ this.hasValidSimulationUiInformation = validJson(this.simulationUiInformation);
214
229
 
215
- // Initialise our UI.
230
+ if (!this.hasValidSimulationUiInformation) {
231
+ return;
232
+ }
216
233
 
217
- initialiseUi(this);
234
+ // Initialise our UI.
218
235
 
219
- // Finalise our UI.
220
- // Note: we try both here and in the mounded() function since we have no
221
- // idea how long it's going to take to retrieve the simulation UI
222
- // information.
236
+ initialiseUi(this);
223
237
 
224
- this.$nextTick(() => {
225
- finaliseUi(this);
238
+ // Finalise our UI.
239
+ // Note: we try both here and in the mounded() function since we have no
240
+ // idea how long it's going to take to retrieve the simulation UI
241
+ // information.
226
242
 
227
- this.showUserMessage = false;
228
- });
243
+ this.$nextTick(() => {
244
+ finaliseUi(this);
245
+ });
246
+ }
229
247
  }
230
248
  };
231
249
  xmlhttp.send();
@@ -336,18 +354,18 @@ p.default {
336
354
  p.error {
337
355
  margin-left: 16px;
338
356
  }
339
- p.note {
340
- font-size: 12px;
341
- line-height: 16px;
342
- }
343
- p.title,
357
+ p.name,
344
358
  p.input-parameters {
345
359
  margin-top: 0;
346
360
  font-weight: 500 /* Medium */;
347
361
  }
348
- p.title {
362
+ p.name {
349
363
  line-height: 20px;
350
364
  }
365
+ p.note {
366
+ font-size: 12px;
367
+ line-height: 16px;
368
+ }
351
369
  span.error {
352
370
  font-weight: 500 /* Medium */;
353
371
  }