@abi-software/simulationvuer 3.0.12 → 3.0.14

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.
@@ -44,6 +44,7 @@
44
44
 
45
45
  <script>
46
46
  import { ElInputNumber, ElOption, ElSelect, ElSlider } from "element-plus";
47
+
47
48
  import { updateUi } from "./common.js";
48
49
 
49
50
  export default {
@@ -79,7 +80,7 @@ export default {
79
80
  data: function () {
80
81
  return {
81
82
  isDiscrete: this.possibleValues !== undefined,
82
- labelClasses: "default " + ((this.possibleValues !== undefined) ? "discrete" : "scalar"),
83
+ labelClasses: `default ${this.possibleValues !== undefined ? "discrete" : "scalar"}`,
83
84
  visible: true,
84
85
  vModel: this.defaultValue,
85
86
  };
@@ -26,7 +26,10 @@ export function updateUi(parent) {
26
26
  parent.simulationUiInfo.input.forEach((input) => {
27
27
  ++index;
28
28
 
29
- parent.$refs.simInput[index].visible = (input.visible === undefined) ? true : evaluateValue(parent, input.visible);
29
+ parent.$refs.simInput[index].visible =
30
+ input.visible === undefined
31
+ ? true
32
+ : evaluateValue(parent, input.visible);
30
33
  });
31
34
  });
32
35
  }
@@ -35,21 +38,29 @@ export function finaliseUi(parent) {
35
38
  // Finalise our UI, but only if we haven't already done so, we are mounted,
36
39
  // and we have some valid simulation UI information.
37
40
 
38
- if (!parent.hasFinalisedUi && parent.isMounted && parent.hasValidSimulationUiInfo) {
41
+ if (
42
+ !parent.hasFinalisedUi &&
43
+ parent.isMounted &&
44
+ parent.hasValidSimulationUiInfo
45
+ ) {
39
46
  // Configure the PlotVuer's.
40
47
 
41
- parent.$refs.output.classList.add("x" + parent.simulationUiInfo.output.plots.length);
48
+ parent.$refs.output.classList.add(
49
+ `x${parent.simulationUiInfo.output.plots.length}`,
50
+ );
42
51
 
43
52
  // Initialise the simulation results.
44
53
 
45
54
  let index = -1;
46
55
 
47
56
  parent.simulationUiInfo.output.plots.forEach(() => {
48
- parent.simulationResults[++index] = [{
49
- x: [],
50
- y: [],
51
- type: "scatter",
52
- }];
57
+ parent.simulationResults[++index] = [
58
+ {
59
+ x: [],
60
+ y: [],
61
+ type: "scatter",
62
+ },
63
+ ];
53
64
  });
54
65
 
55
66
  // Make sure that our UI is up to date.
@@ -1,7 +1,5 @@
1
1
  // The Vue build version to load with the `import` command
2
2
  // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3
- import SimulationVuer from './SimulationVuer.vue';
3
+ import SimulationVuer from "./SimulationVuer.vue";
4
4
 
5
- export {
6
- SimulationVuer
7
- };
5
+ export { SimulationVuer };
@@ -1,4 +1,5 @@
1
1
  import { Validator } from "jsonschema";
2
+
2
3
  import { OPENCOR_SOLVER_NAME } from "./common.js";
3
4
 
4
5
  export function validJson(json) {
@@ -224,7 +225,7 @@ export function validJson(json) {
224
225
  const result = validator.validate(json, schema, { nestedErrors: true });
225
226
 
226
227
  if (!result.valid) {
227
- console.warn(result.toString());
228
+ console.warn(`SimulationVuer: JSON: ${result.toString()}`);
228
229
 
229
230
  return false;
230
231
  }
@@ -235,13 +236,15 @@ export function validJson(json) {
235
236
  const inputValid = json.input.every((input) => {
236
237
  if (input.id !== undefined) {
237
238
  if (input.id === "") {
238
- console.warn("JSON: the input id must not be empty.");
239
+ console.warn("SimulationVuer: JSON: the input id must not be empty.");
239
240
 
240
241
  return false;
241
242
  }
242
243
 
243
244
  if (inputIdUsed[input.id] !== undefined) {
244
- console.warn("JSON: the input id must be unique (" + input.id + " is used more than once).");
245
+ console.warn(
246
+ `SimulationVuer: JSON: the input id must be unique (${input.id} is used more than once).`,
247
+ );
245
248
 
246
249
  return false;
247
250
  }
@@ -250,21 +253,25 @@ export function validJson(json) {
250
253
  }
251
254
 
252
255
  if (input.name === "") {
253
- console.warn("JSON: the input name must not be empty.");
256
+ console.warn("SimulationVuer: JSON: the input name must not be empty.");
254
257
 
255
258
  return false;
256
259
  }
257
260
 
258
261
  if (input.possibleValues !== undefined) {
259
- if (!input.possibleValues.every((possibleValue) => {
260
- if (possibleValue.name === "") {
261
- console.warn("JSON: an input possible value must not be empty.");
262
-
263
- return false;
264
- }
265
-
266
- return true;
267
- })) {
262
+ if (
263
+ !input.possibleValues.every((possibleValue) => {
264
+ if (possibleValue.name === "") {
265
+ console.warn(
266
+ "SimulationVuer: JSON: an input possible value must not be empty.",
267
+ );
268
+
269
+ return false;
270
+ }
271
+
272
+ return true;
273
+ })
274
+ ) {
268
275
  return false;
269
276
  }
270
277
 
@@ -273,36 +280,49 @@ export function validJson(json) {
273
280
  });
274
281
  const valueUsed = {};
275
282
 
276
- if (!values.every((value) => {
277
- if (valueUsed[value] !== undefined) {
278
- console.warn("JSON: an input possible value must have a unique value (" + value + " is used more than once).");
283
+ if (
284
+ !values.every((value) => {
285
+ if (valueUsed[value] !== undefined) {
286
+ console.warn(
287
+ `SimulationVuer: JSON: an input possible value must have a unique value (${value} is used more than once).`,
288
+ );
279
289
 
280
- return false;
281
- }
290
+ return false;
291
+ }
282
292
 
283
- valueUsed[value] = true;
293
+ valueUsed[value] = true;
284
294
 
285
- return true;
286
- })) {
295
+ return true;
296
+ })
297
+ ) {
287
298
  return false;
288
299
  }
289
300
 
290
301
  if (!values.includes(input.defaultValue)) {
291
- console.warn("JSON: the input default value (" + input.defaultValue + ") must be one of the possible values (" + values.join(", ") + ").");
302
+ console.warn(
303
+ `SimulationVuer: JSON: the input default value (${input.defaultValue}) must be one of the possible values (${values.join(", ")}).`,
304
+ );
292
305
 
293
306
  return false;
294
307
  }
295
308
  }
296
309
 
297
- if ((input.minimumValue !== undefined) && (input.maximumValue !== undefined)) {
310
+ if (input.minimumValue !== undefined && input.maximumValue !== undefined) {
298
311
  if (input.minimumValue >= input.maximumValue) {
299
- console.warn("JSON: the input minimum value (" + input.minimumValue + ") must be lower than the maximum value (" + input.maximumValue + ").");
312
+ console.warn(
313
+ `SimulationVuer: JSON: the input minimum value (${input.minimumValue}) must be lower than the maximum value (${input.maximumValue}).`,
314
+ );
300
315
 
301
316
  return false;
302
317
  }
303
318
 
304
- if ((input.defaultValue < input.minimumValue) || (input.defaultValue > input.maximumValue)) {
305
- console.warn("JSON: the input default value (" + input.defaultValue + ") must be greater or equal than the minimum value (" + input.minimumValue + ") and lower or equal than the maximum value (" + input.maximumValue + ").");
319
+ if (
320
+ input.defaultValue < input.minimumValue ||
321
+ input.defaultValue > input.maximumValue
322
+ ) {
323
+ console.warn(
324
+ `SimulationVuer: JSON: the input default value (${input.defaultValue}) must be greater or equal than the minimum value (${input.minimumValue}) and lower or equal than the maximum value (${input.maximumValue}).`,
325
+ );
306
326
 
307
327
  return false;
308
328
  }
@@ -310,20 +330,26 @@ export function validJson(json) {
310
330
  const range = input.maximumValue - input.minimumValue;
311
331
 
312
332
  if (input.stepValue !== undefined) {
313
- if ((input.stepValue <= 0) || (input.stepValue > range)) {
314
- console.warn("JSON: the input step value (" + input.stepValue + ") must be greater than zero and lower or equal than the range value (" + range + ").");
333
+ if (input.stepValue <= 0 || input.stepValue > range) {
334
+ console.warn(
335
+ `SimulationVuer: JSON: the input step value (${input.stepValue}) must be greater than zero and lower or equal than the range value (${range}).`,
336
+ );
315
337
 
316
338
  return false;
317
339
  }
318
340
 
319
341
  if (!Number.isInteger(range / input.stepValue)) {
320
- console.warn("JSON: the input step value (" + input.stepValue + ") must be a factor of the range value (" + range + ").");
342
+ console.warn(
343
+ `SimulationVuer: JSON: the input step value (${input.stepValue}) must be a factor of the range value (${range}).`,
344
+ );
321
345
 
322
346
  return false;
323
347
  }
324
348
  } else {
325
349
  if (!Number.isInteger(range)) {
326
- console.warn("JSON: the (default) input step value (1) must be a factor of the range value (" + range + ").");
350
+ console.warn(
351
+ `SimulationVuer: JSON: the (default) input step value (1) must be a factor of the range value (${range}).`,
352
+ );
327
353
 
328
354
  return false;
329
355
  }
@@ -332,7 +358,9 @@ export function validJson(json) {
332
358
 
333
359
  if (input.visible !== undefined) {
334
360
  if (input.visible === "") {
335
- console.warn("JSON: the input visible must not be empty.");
361
+ console.warn(
362
+ "SimulationVuer: JSON: the input visible must not be empty.",
363
+ );
336
364
 
337
365
  return false;
338
366
  }
@@ -351,13 +379,17 @@ export function validJson(json) {
351
379
  const outputDataValid = json.output.data.every((outputData) => {
352
380
  if (outputData.id !== undefined) {
353
381
  if (outputData.id === "") {
354
- console.warn("JSON: the output data id must not be empty.");
382
+ console.warn(
383
+ "SimulationVuer: JSON: the output data id must not be empty.",
384
+ );
355
385
 
356
386
  return false;
357
387
  }
358
388
 
359
389
  if (outputIdUsed[outputData.id] !== undefined) {
360
- console.warn("JSON: the output data id must be unique (" + outputData.id + " is used more than once).");
390
+ console.warn(
391
+ `SimulationVuer: JSON: the output data id must be unique (${outputData.id} is used more than once).`,
392
+ );
361
393
 
362
394
  return false;
363
395
  }
@@ -366,7 +398,9 @@ export function validJson(json) {
366
398
  }
367
399
 
368
400
  if (outputData.name === "") {
369
- console.warn("JSON: the output data name must not be empty.");
401
+ console.warn(
402
+ "SimulationVuer: JSON: the output data name must not be empty.",
403
+ );
370
404
 
371
405
  return false;
372
406
  }
@@ -380,25 +414,33 @@ export function validJson(json) {
380
414
 
381
415
  const outputPlotsValid = json.output.plots.every((outputPlot) => {
382
416
  if (outputPlot.xAxisTitle === "") {
383
- console.warn("JSON: the output plot X axis title must not be empty.");
417
+ console.warn(
418
+ "SimulationVuer: JSON: the output plot X axis title must not be empty.",
419
+ );
384
420
 
385
421
  return false;
386
422
  }
387
423
 
388
424
  if (outputPlot.xValue === "") {
389
- console.warn("JSON: the output plot X value must not be empty.");
425
+ console.warn(
426
+ "SimulationVuer: JSON: the output plot X value must not be empty.",
427
+ );
390
428
 
391
429
  return false;
392
430
  }
393
431
 
394
432
  if (outputPlot.yAxisTitle === "") {
395
- console.warn("JSON: the output plot Y axis title must not be empty.");
433
+ console.warn(
434
+ "SimulationVuer: JSON: the output plot Y axis title must not be empty.",
435
+ );
396
436
 
397
437
  return false;
398
438
  }
399
439
 
400
440
  if (outputPlot.yValue === "") {
401
- console.warn("JSON: the output plot Y value must not be empty.");
441
+ console.warn(
442
+ "SimulationVuer: JSON: the output plot Y value must not be empty.",
443
+ );
402
444
 
403
445
  return false;
404
446
  }
@@ -415,13 +457,17 @@ export function validJson(json) {
415
457
  if (json.parameters !== undefined) {
416
458
  const parametersValid = json.parameters.every((parameter) => {
417
459
  if (parameter.name === "") {
418
- console.warn("JSON: the parameter name must not be empty.");
460
+ console.warn(
461
+ "SimulationVuer: JSON: the parameter name must not be empty.",
462
+ );
419
463
 
420
464
  return false;
421
465
  }
422
466
 
423
467
  if (parameter.value === "") {
424
- console.warn("JSON: the parameter value must not be empty.");
468
+ console.warn(
469
+ "SimulationVuer: JSON: the parameter value must not be empty.",
470
+ );
425
471
 
426
472
  return false;
427
473
  }
@@ -438,57 +484,74 @@ export function validJson(json) {
438
484
 
439
485
  let needOpencorSettings = false;
440
486
 
441
- if (!json.simulation.solvers.every((solver) => {
442
- if (solver.if !== undefined) {
443
- if (solver.if === "") {
444
- console.warn("JSON: a simulation solver if must not be empty.");
487
+ if (
488
+ !json.simulation.solvers.every((solver) => {
489
+ if (solver.if !== undefined) {
490
+ if (solver.if === "") {
491
+ console.warn(
492
+ "SimulationVuer: JSON: a simulation solver if must not be empty.",
493
+ );
445
494
 
446
- return false;
495
+ return false;
496
+ }
447
497
  }
448
- }
449
498
 
450
- if (solver.input !== undefined) {
451
- if (solver.input.name === "") {
452
- console.warn("JSON: a simulation solver input name must not be empty.");
499
+ if (solver.input !== undefined) {
500
+ if (solver.input.name === "") {
501
+ console.warn(
502
+ "SimulationVuer: JSON: a simulation solver input name must not be empty.",
503
+ );
453
504
 
454
- return false;
455
- }
505
+ return false;
506
+ }
456
507
 
457
- if (solver.input.value === "") {
458
- console.warn("JSON: a simulation solver input value must not be empty.");
508
+ if (solver.input.value === "") {
509
+ console.warn(
510
+ "SimulationVuer: JSON: a simulation solver input value must not be empty.",
511
+ );
459
512
 
460
- return false;
513
+ return false;
514
+ }
461
515
  }
462
- }
463
516
 
464
- if (solver.name === "") {
465
- console.warn("JSON: a simulation solver name must not be empty.");
517
+ if (solver.name === "") {
518
+ console.warn(
519
+ "SimulationVuer: JSON: a simulation solver name must not be empty.",
520
+ );
466
521
 
467
- return false;
468
- }
522
+ return false;
523
+ }
469
524
 
470
- needOpencorSettings = needOpencorSettings || (solver.name === OPENCOR_SOLVER_NAME);
525
+ needOpencorSettings =
526
+ needOpencorSettings || solver.name === OPENCOR_SOLVER_NAME;
471
527
 
472
- if (solver.version === "") {
473
- console.warn("JSON: a simulation solver version must not be empty.");
528
+ if (solver.version === "") {
529
+ console.warn(
530
+ "SimulationVuer: JSON: a simulation solver version must not be empty.",
531
+ );
474
532
 
475
- return false;
476
- }
533
+ return false;
534
+ }
477
535
 
478
- return true;
479
- })) {
536
+ return true;
537
+ })
538
+ ) {
480
539
  return false;
481
540
  }
482
541
 
483
- if (needOpencorSettings && (json.simulation.opencor === undefined)) {
484
- console.warn("JSON: the simulation solver for OpenCOR is specified so simulation OpenCOR settings must also be specified.");
542
+ if (needOpencorSettings && json.simulation.opencor === undefined) {
543
+ console.warn(
544
+ "SimulationVuer: JSON: the simulation solver for OpenCOR is specified so simulation OpenCOR settings must also be specified.",
545
+ );
485
546
 
486
547
  return false;
487
548
  }
488
549
 
489
550
  if (json.simulation.opencor !== undefined) {
490
551
  if (json.simulation.opencor.resource === "") {
491
- console.warn("JSON: the simulation OpenCOR resource must not be empty.");
552
+ console.warn(
553
+ "SimulationVuer: JSON: the simulation OpenCOR resource must not be empty.",
554
+ );
492
555
 
493
556
  return false;
494
557
  }
@@ -496,23 +559,31 @@ export function validJson(json) {
496
559
  if (json.simulation.opencor.endingPoint !== undefined) {
497
560
  if (json.simulation.opencor.pointInterval !== undefined) {
498
561
  if (json.simulation.opencor.endingPoint <= 0.0) {
499
- console.warn("JSON: the simulation OpenCOR ending point (" + json.simulation.opencor.endingPoint + ") must be greater than zero.");
562
+ console.warn(
563
+ `SimulationVuer: JSON: the simulation OpenCOR ending point (${json.simulation.opencor.endingPoint}) must be greater than zero.`,
564
+ );
500
565
 
501
566
  return false;
502
567
  }
503
568
 
504
569
  if (json.simulation.opencor.pointInterval <= 0.0) {
505
- console.warn("JSON: the simulation OpenCOR point interval (" + json.simulation.opencor.pointInterval + ") must be greater than zero.");
570
+ console.warn(
571
+ `SimulationVuer: JSON: the simulation OpenCOR point interval (${json.simulation.opencor.pointInterval}) must be greater than zero.`,
572
+ );
506
573
 
507
574
  return false;
508
575
  }
509
576
  } else {
510
- console.warn("JSON: a simulation OpenCOR ending point is specified so a simulation OpenCOR point interval must also be specified.");
577
+ console.warn(
578
+ "SimulationVuer: JSON: a simulation OpenCOR ending point is specified so a simulation OpenCOR point interval must also be specified.",
579
+ );
511
580
 
512
581
  return false;
513
582
  }
514
583
  } else if (json.simulation.opencor.pointInterval !== undefined) {
515
- console.warn("JSON: a simulation OpenCOR point interval is specified so a simulation OpenCOR ending point must also be specified.");
584
+ console.warn(
585
+ "SimulationVuer: JSON: a simulation OpenCOR point interval is specified so a simulation OpenCOR ending point must also be specified.",
586
+ );
516
587
 
517
588
  return false;
518
589
  }
package/src/main.js CHANGED
@@ -1,7 +1,8 @@
1
+ import ElementPlus from "element-plus";
1
2
  import { createApp } from "vue";
2
3
  import * as VueRouter from "vue-router";
4
+
3
5
  import App from "./App.vue";
4
- import ElementPlus from "element-plus";
5
6
 
6
7
  const routes = [{ path: "/", component: App }];
7
8
  const router = VueRouter.createRouter({
package/vite.config.js CHANGED
@@ -1,10 +1,13 @@
1
- import path from "path";
2
- import { resolve } from "node:path";
3
- const pathSrc = path.resolve(__dirname, "./src");
4
- import { defineConfig } from "vite";
5
1
  import vue from "@vitejs/plugin-vue";
6
- import Components from "unplugin-vue-components/vite";
2
+
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
7
5
  import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
6
+ import Components from "unplugin-vue-components/vite";
7
+ import { defineConfig } from "vite";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const pathSrc = path.resolve(__dirname, "./src");
8
11
 
9
12
  export default defineConfig(({ command, mode }) => {
10
13
  const config = {
@@ -60,7 +63,9 @@ export default defineConfig(({ command, mode }) => {
60
63
  if (mode === "app") {
61
64
  config.base = "./";
62
65
 
63
- ["build", "define", "resolve", "server"].forEach(key => delete config[key]);
66
+ for (const key of ["build", "define", "resolve", "server"]) {
67
+ delete config[key];
68
+ }
64
69
  }
65
70
 
66
71
  return config;