Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"url": "git+https://github.com/opencor/webapp.git"
},
"type": "module",
"version": "0.20260416.0",
"version": "0.20260416.1",
"engines": {
"bun": ">=1.2.0"
},
Expand Down Expand Up @@ -83,7 +83,7 @@
"electron-vite": "^5.0.0",
"esbuild": "^0.28.0",
"node-addon-api": "^8.7.0",
"postcss": "^8.5.9",
"postcss": "^8.5.10",
"rollup-plugin-visualizer": "^7.0.1",
"stylelint": "^17.8.0",
"stylelint-config-standard": "^40.0.0",
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 47 additions & 2 deletions src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IOpenCORExpose {

export interface IOpenCOREmits extends /* @vue-ignore */ Record<string, unknown[]> {
externalData: [IOpenCORExternalDataEvent];
file: [IOpenCORFileEvent];
simulationData: [IOpenCORSimulationDataEvent];
}

Expand All @@ -22,16 +23,60 @@ export interface IOpenCORSimulationDataValue {
unit: string;
}

export interface IOpenCORExternalDataEvent {
// External data events.

export interface IOpenCORExternalDataAddedEvent {
type: 'added';
csv: string;
issues: string[];
}
Comment thread
agarny marked this conversation as resolved.

export interface IOpenCORExternalDataIssueEvent {
type: 'issue';
csv: string;
issues: string[];
}
Comment thread
agarny marked this conversation as resolved.

export type IOpenCORExternalDataEvent = IOpenCORExternalDataAddedEvent | IOpenCORExternalDataIssueEvent;

// File events.

export interface IOpenCORFileOpenedEvent {
type: 'opened';
filePath: string;
issues: string[];
}

export interface IOpenCORFileClosedEvent {
type: 'closed';
filePath: string;
issues: string[];
}

export interface IOpenCORFileIssueEvent {
type: 'issue';
filePath: string;
issues: string[];
}

export type IOpenCORFileEvent = IOpenCORFileOpenedEvent | IOpenCORFileClosedEvent | IOpenCORFileIssueEvent;

// Simulation data events.

export type OpenCORSimulationData = Record<string, IOpenCORSimulationDataValue>;

export interface IOpenCORSimulationDataEvent {
export interface IOpenCORSimulationDataUpdatedEvent {
type: 'updated';
simulationData: OpenCORSimulationData;
issues: string[];
}

export interface IOpenCORSimulationDataIssueEvent {
type: 'issue';
simulationData: OpenCORSimulationData;
issues: string[];
}

export type IOpenCORSimulationDataEvent = IOpenCORSimulationDataUpdatedEvent | IOpenCORSimulationDataIssueEvent;

export { default, default as OpenCOR } from './src/components/OpenCOR.vue';
4 changes: 2 additions & 2 deletions src/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"./style.css": "./dist/opencor.css"
},
"version": "0.20260416.0",
"version": "0.20260416.1",
"scripts": {
"build": "vite build && bun scripts/generate.version.js",
"build:lib": "vite build --config vite.lib.config.ts && bunx --bun vue-tsc --project tsconfig.lib.types.json",
Expand Down Expand Up @@ -84,7 +84,7 @@
"@vue/tsconfig": "^0.9.1",
"autoprefixer": "^10.5.0",
"esbuild": "^0.28.0",
"postcss": "^8.5.9",
"postcss": "^8.5.10",
"rollup-plugin-visualizer": "^7.0.1",
"stylelint": "^17.8.0",
"stylelint-config-standard": "^40.0.0",
Expand Down
23 changes: 15 additions & 8 deletions src/renderer/src/AppWithExternalData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,21 @@ const addDataFromFigshareUrl = async (): Promise<void> => {
const onExternalData = (event: IOpenCORExternalDataEvent) => {
console.log('---[External data]---');

if (event.issues.length > 0) {
console.log('Issues:');

event.issues.forEach((issue: string) => {
console.log(` - ${issue}`);
});
} else {
console.log('No issues.');
switch (event.type) {
case 'added':
console.log(`External data added for CSV: ${event.csv}`);
console.log('No issues.');

break;
case 'issue':
console.log(`External data issue for CSV: ${event.csv}`);
console.log('Issues:');

event.issues.forEach((issue: string) => {
console.log(` - ${issue}`);
});

break;
}
};
</script>
Expand Down
27 changes: 16 additions & 11 deletions src/renderer/src/AppWithSimulationData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,24 @@ const untrackAllModelParameters = () => {
const onSimulationData = (event: IOpenCORSimulationDataEvent) => {
console.log('---[Simulation data]---');

for (const modelParameter of Object.keys(event.simulationData)) {
console.log(`Simulation data for "${modelParameter}":`);
console.log(event.simulationData[modelParameter]);
}
switch (event.type) {
case 'updated':
for (const modelParameter of Object.keys(event.simulationData)) {
console.log(`Simulation data for "${modelParameter}":`);
console.log(event.simulationData[modelParameter]);
}

if (event.issues.length > 0) {
console.log('Issues:');
console.log('No issues.');

event.issues.forEach((issue: string) => {
console.log(` - ${issue}`);
});
} else {
console.log('No issues.');
break;
case 'issue':
console.log('Simulation data issue:');

event.issues.forEach((issue: string) => {
console.log(` - ${issue}`);
});

break;
}
};
</script>
Expand Down
13 changes: 12 additions & 1 deletion src/renderer/src/components/ContentsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ const props = defineProps<{
uiEnabled: boolean;
}>();

defineEmits<{
const emit = defineEmits<{
(event: 'error', message: string): void;
(event: 'fileClosed', filePath: string): void;
(event: 'fileOpened', filePath: string): void;
(event: 'simulationData'): void;
}>();

Expand Down Expand Up @@ -179,6 +181,8 @@ const openFile = async (file: locApi.File, wait: boolean = false): Promise<void>

electronApi?.fileOpened(filePath);

emit('fileOpened', filePath);

if (wait) {
await waitForTabsUpdate();
}
Expand All @@ -200,6 +204,8 @@ const closeFile = async (filePath: string): Promise<void> => {
}

electronApi?.fileClosed(filePath);

emit('fileClosed', filePath);
};

const closeCurrentFile = async (): Promise<void> => {
Expand Down Expand Up @@ -231,13 +237,15 @@ const addExternalData = async (

if (!simulationExperimentViews.length) {
return Promise.resolve({
type: 'issue',
csv,
issues: ['No simulation experiment view available.']
});
}

return simulationExperimentViews[0].addExternalData(csv, voiExpression, modelParameters).catch((error: unknown) => {
return {
type: 'issue',
csv,
issues: [common.formatError(error)]
};
Expand All @@ -249,6 +257,7 @@ const addExternalData = async (
const simulationData = (modelParameters: string[]): Promise<IOpenCORSimulationDataEvent> => {
if (!props.simulationOnly) {
return Promise.resolve({
type: 'issue',
simulationData: common.emptySimulationData(modelParameters),
issues: ['Simulation data can only be retrieved in simulation-only mode.']
});
Expand All @@ -258,13 +267,15 @@ const simulationData = (modelParameters: string[]): Promise<IOpenCORSimulationDa

if (!simulationExperimentViews.length) {
return Promise.resolve({
type: 'issue',
simulationData: common.emptySimulationData(modelParameters),
issues: ['No simulation experiment view available.']
});
}

return simulationExperimentViews[0].simulationData(modelParameters).catch((error: unknown) => {
return {
type: 'issue',
simulationData: common.emptySimulationData(modelParameters),
issues: [common.formatError(error)]
};
Expand Down
Loading
Loading