Skip to content

Commit 4c08c47

Browse files
committed
refactor: big refactor, Workflow instead of WorkflowDefition, link to divaservices
1 parent 2735eb4 commit 4c08c47

20 files changed

+288
-288
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"file-saver": "^2.0.2",
2727
"jointjs": "^3.0.4",
2828
"jquery": "^3.4.1",
29+
"mime-types": "^2.1.25",
2930
"node-fetch": "^2.6.0",
3031
"path": "^0.12.7",
3132
"select2": "^4.0.9",

src/api/example.xml

+71-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<WorkflowDefinition>
1+
<Workflow>
22
<Id>20</Id>
33
<Information>
44
<Name>Workflow 1</Name>
55
<Description>de</Description>
66
</Information>
7-
<Steps>
7+
<!-- <Steps>
88
<Step>
99
<Id>8o04tkrnz</Id>
1010
<No>0</No>
@@ -47,5 +47,73 @@
4747
</Parameter>
4848
</Inputs>
4949
</Step>
50+
</Steps> -->
51+
<Steps>
52+
<Step>
53+
<No>0</No>
54+
<Name>OtsuBinarizationFolder</Name>
55+
<Service>
56+
<Key>45</Key>
57+
</Service>
58+
<Inputs/>
59+
</Step>
60+
<Step>
61+
<No>1</No>
62+
<Name>OtsuBinarization</Name>
63+
<Service>
64+
<Key>0</Key>
65+
</Service>
66+
<Inputs>
67+
<Data>
68+
<Name>inputImage</Name>
69+
<Value>
70+
<WorkflowStep>
71+
<Ref>2</Ref>
72+
<ServiceOutputName>sauvolaBinaryImage</ServiceOutputName>
73+
</WorkflowStep>
74+
</Value>
75+
</Data>
76+
<Data>
77+
<Name>inputImage</Name>
78+
<Value>
79+
<WorkflowStep>
80+
<Ref>3</Ref>
81+
<ServiceOutputName>grayImage</ServiceOutputName>
82+
</WorkflowStep>
83+
</Value>
84+
</Data>
85+
</Inputs>
86+
</Step>
87+
<Step>
88+
<No>2</No>
89+
<Name>SauvolaBinarization</Name>
90+
<Service>
91+
<Key>2</Key>
92+
</Service>
93+
<Inputs>
94+
<Parameter>
95+
<Name>radius</Name>
96+
<Value>543</Value>
97+
</Parameter>
98+
</Inputs>
99+
</Step>
100+
<Step>
101+
<No>3</No>
102+
<Name>Grayification</Name>
103+
<Service>
104+
<Key>13</Key>
105+
</Service>
106+
<Inputs>
107+
<Data>
108+
<Name>inputImage</Name>
109+
<Value>
110+
<WorkflowStep>
111+
<Ref>2</Ref>
112+
<ServiceOutputName>sauvolaBinaryImage</ServiceOutputName>
113+
</WorkflowStep>
114+
</Value>
115+
</Data>
116+
</Inputs>
117+
</Step>
50118
</Steps>
51-
</WorkflowDefinition>
119+
</Workflow>

src/api/services.xml

+1-1
Large diffs are not rendered by default.

src/config.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
export const {
44
HOST = "/",
5-
API = "http://divaservices.unifr.ch/api/v2/",
65
WEBSERVICES_XML_FILEPATH = "api/services.xml",
7-
INPUTS_DATA_XML_FILEPATH = "api/inputData.xml",
8-
USERNAME = "",
9-
PASSWORD = "",
106
SERVICES_API = "",
11-
COLLECTIONS_API = "http://134.21.72.190:8080/collections",
12-
BASE_URL = "http://diufvm17.unifr.ch:8080/exist/projects/diae/"
7+
COLLECTIONS_API_ENDPOINT = "api/collections",
8+
WORKFLOWS_API_ENDPOINT = "workflows",
9+
WORKFLOWS_EXECUTION_ENDPOINT = "exec",
10+
BASE_URL = "http://diufvm17.unifr.ch:8080/exist/projects/diae"
1311
} = process.env;
12+
13+
export const WORKFLOWS_EXECUTION = `${BASE_URL}/${WORKFLOWS_EXECUTION_ENDPOINT}`;
14+
export const COLLECTIONS_API = `${BASE_URL}/${COLLECTIONS_API_ENDPOINT}`;
15+
export const WORKFLOWS_API = `${BASE_URL}/${WORKFLOWS_API_ENDPOINT}`;

src/js/api/requests.js

+55-139
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import fetch from "node-fetch";
22
import { app } from "../app";
33
import { Decorators } from "divaservices-utils";
44
import {
5-
USERNAME,
6-
PASSWORD,
75
SERVICES_API,
86
WEBSERVICES_XML_FILEPATH,
9-
COLLECTIONS_API
7+
COLLECTIONS_API,
8+
WORKFLOWS_API
109
} from "../../config";
1110

1211
export const getServicesAPI = async () => {
@@ -21,7 +20,7 @@ export const getServicesAPI = async () => {
2120
return xml;
2221
};
2322

24-
export const sendWorkflowSteps = xml => {
23+
export const sendWorkflowSteps = async (xml, installation = false) => {
2524
// const xhr = new XMLHttpRequest();
2625
// xhr.open(
2726
// "POST",
@@ -34,36 +33,67 @@ export const sendWorkflowSteps = xml => {
3433
// xhr.setRequestHeader("password", PASSWORD);
3534
// xhr.send(xml);
3635

37-
fetch(
38-
"http://diufvm17.unifr.ch:8080/exist/projects/diae/api/workflow/save?id=" +
39-
app.workflowId,
40-
{
41-
method: "POST",
42-
body: xml,
43-
headers: {
44-
"Content-Type": "text/xml",
45-
username: USERNAME,
46-
password: PASSWORD
47-
}
36+
const install = installation ? "install=true&" : "";
37+
38+
return await fetch(`${WORKFLOWS_API}/save?${install}id=${app.workflowId}`, {
39+
method: "POST",
40+
body: xml,
41+
headers: {
42+
"Content-Type": "text/xml"
4843
}
49-
);
44+
});
5045
};
5146

5247
export const openWorkflowFromId = async id => {
5348
let xml;
5449
if (process.env.NODE_ENV === "production") {
55-
const workflow = await fetch(
56-
"http://diufvm17.unifr.ch:8080/exist/projects/diae/api/workflow?id=" + id,
57-
{
58-
headers: {
59-
"Content-Type": "text/xml"
60-
}
50+
const workflow = await fetch(`${WORKFLOWS_API}?id=${id}`, {
51+
headers: {
52+
"Content-Type": "text/xml"
6153
}
62-
);
54+
});
6355
xml = await workflow.text();
6456
} else {
65-
const filepath = "api/example.xml";
66-
xml = (await import(`!!raw-loader!../../${filepath}`)).default;
57+
xml = `<Workflow>
58+
<Id>116</Id>
59+
<Information>
60+
<Name>new rofklow</Name>
61+
<Author/>
62+
</Information>
63+
<Steps>
64+
<Step>
65+
<No>0</No>
66+
<Name>OcropusBinarization</Name>
67+
<Service>
68+
<Key>6</Key>
69+
</Service>
70+
<Inputs>
71+
<Data>
72+
<Name>inputImage</Name>
73+
<Path>qwertz/2299942_0.jpg</Path>
74+
</Data>
75+
</Inputs>
76+
</Step>
77+
<Step>
78+
<No>1</No>
79+
<Name>OtsuBinarization</Name>
80+
<Service>
81+
<Key>0</Key>
82+
</Service>
83+
<Inputs>
84+
<Data>
85+
<Name>inputImage</Name>
86+
<Value>
87+
<WorkflowStep>
88+
<Ref>0</Ref>
89+
<ServiceOutputName>ocropusBinaryImage</ServiceOutputName>
90+
</WorkflowStep>
91+
</Value>
92+
</Data>
93+
</Inputs>
94+
</Step>
95+
</Steps>
96+
</Workflow>`;
6797
}
6898
return xml;
6999
};
@@ -248,120 +278,6 @@ export const getCollectionsAPI = async () => {
248278
</File>
249279
</Files>
250280
</Collection>
251-
<Collection>
252-
<Id>134</Id>
253-
<Url>http://134.21.72.190:8080/collections/qwertz</Url>
254-
<Author/>
255-
<Name>qwertz</Name>
256-
<Files>
257-
<File>
258-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
259-
<Identifier>qwertz/2299942_0.jpg</Identifier>
260-
<Options>
261-
<Mime-type>image/jpeg</Mime-type>
262-
</Options>
263-
</File>
264-
<File>
265-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
266-
<Identifier>qwertz/2299942_0.jpg</Identifier>
267-
<Options>
268-
<Mime-type>image/jpeg</Mime-type>
269-
</Options>
270-
</File>
271-
<File>
272-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
273-
<Identifier>qwertz/2299942_0.jpg</Identifier>
274-
<Options>
275-
<Mime-type>image/jpeg</Mime-type>
276-
</Options>
277-
</File>
278-
<File>
279-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299913_0.jpg</Url>
280-
<Identifier>qwertz/2299913_0.jpg</Identifier>
281-
<Options>
282-
<Mime-type>image/jpeg</Mime-type>
283-
</Options>
284-
</File>
285-
<File>
286-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299918_0.jpg</Url>
287-
<Identifier>qwertz/2299918_0.jpg</Identifier>
288-
<Options>
289-
<Mime-type>image/jpeg</Mime-type>
290-
</Options>
291-
</File>
292-
<File>
293-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299907_0.jpg</Url>
294-
<Identifier>qwertz/2299907_0.jpg</Identifier>
295-
<Options>
296-
<Mime-type>image/jpeg</Mime-type>
297-
</Options>
298-
</File>
299-
<File>
300-
<Url>http://134.21.72.190:8080/files/qwertz/original/2986434_0.jpg</Url>
301-
<Identifier>qwertz/2986434_0.jpg</Identifier>
302-
<Options>
303-
<Mime-type>image/jpeg</Mime-type>
304-
</Options>
305-
</File>
306-
</Files>
307-
</Collection>
308-
<Collection>
309-
<Id>134</Id>
310-
<Url>http://134.21.72.190:8080/collections/qwertz</Url>
311-
<Author/>
312-
<Name>qwertz</Name>
313-
<Files>
314-
<File>
315-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
316-
<Identifier>qwertz/2299942_0.jpg</Identifier>
317-
<Options>
318-
<Mime-type>image/jpeg</Mime-type>
319-
</Options>
320-
</File>
321-
<File>
322-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
323-
<Identifier>qwertz/2299942_0.jpg</Identifier>
324-
<Options>
325-
<Mime-type>image/jpeg</Mime-type>
326-
</Options>
327-
</File>
328-
<File>
329-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299942_0.jpg</Url>
330-
<Identifier>qwertz/2299942_0.jpg</Identifier>
331-
<Options>
332-
<Mime-type>image/jpeg</Mime-type>
333-
</Options>
334-
</File>
335-
<File>
336-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299913_0.jpg</Url>
337-
<Identifier>qwertz/2299913_0.jpg</Identifier>
338-
<Options>
339-
<Mime-type>image/jpeg</Mime-type>
340-
</Options>
341-
</File>
342-
<File>
343-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299918_0.jpg</Url>
344-
<Identifier>qwertz/2299918_0.jpg</Identifier>
345-
<Options>
346-
<Mime-type>image/jpeg</Mime-type>
347-
</Options>
348-
</File>
349-
<File>
350-
<Url>http://134.21.72.190:8080/files/qwertz/original/2299907_0.jpg</Url>
351-
<Identifier>qwertz/2299907_0.jpg</Identifier>
352-
<Options>
353-
<Mime-type>image/jpeg</Mime-type>
354-
</Options>
355-
</File>
356-
<File>
357-
<Url>http://134.21.72.190:8080/files/qwertz/original/2986434_0.jpg</Url>
358-
<Identifier>qwertz/2986434_0.jpg</Identifier>
359-
<Options>
360-
<Mime-type>image/jpeg</Mime-type>
361-
</Options>
362-
</File>
363-
</Files>
364-
</Collection>
365281
<Collection>
366282
<Id>134</Id>
367283
<Url>http://134.21.72.190:8080/collections/qwertz</Url>

src/js/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export let app;
265265

266266
this.$nextTick(() => {
267267
initPaperEvents();
268-
initKeyboardEvents();
268+
initKeyboardEvents(); // WARNiNG promise
269269

270270
if (process.env.NODE_ENV === "production") {
271271
// check id, if there is no id, go back to workflows

src/js/constants/constants.js

+2
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,5 @@ export const Shortcuts = {
184184
key: "y"
185185
}
186186
};
187+
188+
export const DRAGGABLE_GROUP_NAME = "files";

src/js/constants/globals.js

-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Decorators } from "divaservices-utils";
22
import { getServicesAPI } from "../api/requests";
3-
// import { INPUTS_DATA_XML_FILEPATH } from "../../config";
4-
// import { dataTestDecorator } from "./dataTestDecorator";
53
import { DATATEST_TYPE } from "./constants";
64

75
export let webservices;
@@ -12,13 +10,6 @@ const _initWebservices = async () => {
1210
webservices = await Decorators.webservicesDecorator(xml);
1311
};
1412

15-
// const _initDataInputsOld = async () => {
16-
// const inputDataFilePath = INPUTS_DATA_XML_FILEPATH;
17-
// const inputDataXml = (await import(`!!raw-loader!../../${inputDataFilePath}`))
18-
// .default;
19-
// dataInputs = await dataTestDecorator(inputDataXml);
20-
// };
21-
2213
const _initDataInputs = async () => {
2314
dataInputs = [
2415
...new Set( // remove duplicates

0 commit comments

Comments
 (0)