Skip to content

Commit

Permalink
Merge pull request #18 from Enet4/imp/3.3.2
Browse files Browse the repository at this point in the history
Add Dicoogle v3.3.2
  • Loading branch information
Enet4 authored Sep 26, 2023
2 parents fd8229c + 0cea300 commit 450256e
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 6 deletions.
2 changes: 1 addition & 1 deletion __tests__/generate-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const helpers = require('yeoman-test');
const child_process = require('child_process');

describe('generator test 2: result-options webplugin project in ECMAScript', () => {
describe('generator test 2: legacy result-options webplugin project in ECMAScript', () => {
/** @type {helpers.RunResult} */
let runResult;

Expand Down
70 changes: 70 additions & 0 deletions __tests__/generate-3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const path = require('path');
const helpers = require('yeoman-test');
const child_process = require('child_process');

describe('generator test 3: result-batch webplugin project in TypeScript', () => {
/** @type {helpers.RunResult} */
let runResult;

beforeEach(async () => {
runResult = await helpers
.create(path.join(__dirname, '..'))
.withPrompts({
appname: "plugin3",
description: "A test plugin (#3)",
slotId: "result-batch",
caption: "Test3",
minimumVersion: "3.3.2",
projectType: "typescript",
license: "MIT",
authorName: "John Doe",
authorEmail: "doe.j@nowhere",
authorGithub: "",
})
.run();
});
afterEach(() => {
if (runResult) {
runResult.restore();
}
});

it('generates correctly', () => {
// contains package.json
runResult.assertJsonFileContent('package.json', {
name: "plugin3",
description: "A test plugin (#3)",
license: "MIT",
scripts: {
"build": /.+/,
},
dicoogle: {
"slot-id": "result-batch",
"caption": "Test3",
"module-file": "module.js"
},
devDependencies: {
webpack: /.+/,
}
});

// has source files and build files
runResult.assertFile([
'src/index.ts',
'webpack.common.js',
'webpack.dev.js',
'webpack.prod.js',
'.gitignore',
'README.md',
]);

runResult.assertFileContent('src/index.ts', 'export default class MyPlugin');
runResult.assertFileContent('src/index.ts', "slot.addEventListener('result-selection-ready', (ev) => {");

// force running npm install on target directory
child_process.execSync('npm install --no-audit', {cwd: runResult.cwd});

// has the output file module.js via `prepare`
runResult.assertFileContent('module.js', 'module.exports');
});
});
4 changes: 2 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ module.exports = class WebpluginGenerator extends Generator {
name: 'minimumVersion',
message: 'Please specify the minimum version of Dicoogle required for this plugin.',
choices: [
{name: '3.3.2', value: '3.3.2'},
{name: '3.1.0', value: '3.1.0'},
{name: '2.5.0 (legacy)', value: '2.5.0'},
{name: '2.4.0 (legacy, more compatible)', value: '2.4.0'}
],
default: '3.1.0'
default: '3.3.2'
},
{
type: 'list',
Expand Down
6 changes: 5 additions & 1 deletion app/templates/src/_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default class MyPlugin {
parent.appendChild(div);<% if (dicoogle.slotId === 'query') { %>
// dispatch a query with `Dicoogle.issueQuery`:
// Dicoogle.issueQuery('CT');
<% } %>
<% } %><% if (dicoogle.slotId === 'result-batch') { %>
// act on results selected
slot.addEventListener('result-selection-ready', (ev) => {
// use ev.detail
});<% } %>
}
<% if (dicoogle.slotId === 'result') { %>
onResult(results) {
Expand Down
6 changes: 5 additions & 1 deletion app/templates/src/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default class MyPlugin {
parent.appendChild(div);<% if (dicoogle.slotId === 'query') { %>
// dispatch a query with `Dicoogle.issueQuery`:
// Dicoogle.issueQuery('CT');
<% } %>
<% } %><% if (dicoogle.slotId === 'result-batch') { %>
// act on results selected
slot.addEventListener('result-selection-ready', (ev) => {
// use ev.detail
});<% } %>
}
<% if (dicoogle.slotId === 'result') { %> onResult(results: SearchPatientResult[]) {
// TODO show results here
Expand Down
26 changes: 25 additions & 1 deletion app/templates/src/_webcore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SearchPatientResult} from 'dicoogle-client';

export type WebPluginType = string;

export type WebcoreEvent = 'load' | 'result' | string;
export type WebcoreEvent = 'load' | 'result' | 'result-selection-ready' | string;

export interface WebPlugin {
name: string,
Expand Down Expand Up @@ -35,9 +35,33 @@ export interface PluginData {
results?: SearchPatientResult[];
[att: string]: any;
}
<% if (semver.get(minimumVersion, '3.1.0')) { %>
export interface ResultSelectionReadyEvent {
detail: ResultSelectionData;
}
<% if (semver.get(minimumVersion, '3.3.2')) { %>
export type ResultSelectionData = {search: {data: SearchDetails}, selected: ResultSelection};

export interface SearchDetails {
results: SearchPatientResult[],
elapsedTime: number,
numResults: number,
}
<% } else { %>
export type ResultSelectionData = ResultSelection;
<% } %><% } %>

export interface ResultSelection {
contents: object[],
level: string,
}

export interface SlotHTMLElement extends HTMLElement {
slotId: string;
pluginName: string;
data?: PluginData;
<% if (semver.get(minimumVersion, '3.1.0')) { %>
addEventListener(eventName: 'result-selection-ready', listener: (ev: ResultSelectionReadyEvent) => void): void;
<% } %>
addEventListener(eventName: string, listener: (ev: Event) => void): void;
}

0 comments on commit 450256e

Please sign in to comment.