ebta-workflow-prod 1.1.3 → 4.0.1
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.
- package/.eslintrc.js +7 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +3 -0
- package/README.md +26 -0
- package/build/2983859c0d77824ec8db.svg +1 -0
- package/build/4168d659d55fd94368bc.svg +1 -0
- package/build/641b2c17e92b0e885b9f.svg +1 -0
- package/build/882445a26a4f3964786f.svg +1 -0
- package/build/activitypack.json +1 -1
- package/build/b280e967312a55101032.svg +1 -0
- package/build/main.js +2 -2
- package/build/main.js.LICENSE.txt +99 -0
- package/certs/localhost+2-key.pem +28 -0
- package/certs/localhost+2.pem +26 -0
- package/index.html +58 -0
- package/package.json +43 -7
- package/public/img/background.svg +3 -3
- package/public/img/compass.svg +3 -3
- package/public/img/grab.svg +3 -3
- package/public/img/grabbing.svg +3 -3
- package/public/img/sprites.svg +14 -14
- package/src/activities/AppendObjects.ts +40 -0
- package/src/activities/Base64ToFile.ts +56 -0
- package/src/activities/CreateGraphicLayer.ts +85 -0
- package/src/activities/DrapGeometry.ts +99 -0
- package/src/activities/GetElementByDataLayoutID.ts +58 -0
- package/src/activities/GetSesionStorage.ts +36 -0
- package/src/activities/GetTaskStatus.ts +56 -0
- package/src/activities/GetUserToken.ts +102 -0
- package/src/activities/GetvGISDetails copy.ts +110 -0
- package/src/activities/GetvGISDetails.ts +110 -0
- package/src/activities/HTMLextractor.ts +188 -0
- package/src/activities/LegendCreator.ts +155 -0
- package/src/activities/MergeObjects.ts +61 -0
- package/src/activities/PDFMapGenerator.ts +729 -0
- package/src/activities/RequestChecker.ts +94 -0
- package/src/activities/Sample.ts +41 -0
- package/src/activities/SetSessionStorage.ts +57 -0
- package/src/activities/SliceLine.ts +61 -0
- package/src/elements/AttributeFilter.tsx +1867 -0
- package/src/elements/CircularSlider.tsx +67 -0
- package/src/elements/CsColorPicker.tsx +140 -0
- package/src/elements/DropDownMenu.tsx +282 -0
- package/src/elements/HeaderwithHelp.tsx +178 -0
- package/src/elements/ItemSearcher.tsx +1035 -0
- package/src/elements/ItemSearcher_v2.tsx +1071 -0
- package/src/elements/LineChartMui.tsx +50 -0
- package/src/elements/MenueBar.tsx +118 -0
- package/src/elements/MultipleAutoCompleteCS.tsx +145 -0
- package/src/elements/SingleAutoCompleteCS.tsx +133 -0
- package/src/elements/TableRadioGoup.tsx +163 -0
- package/src/elements/Timeline.tsx +104 -0
- package/src/elements/ToggleButtonGroup.tsx +129 -0
- package/src/elements/Viewer360.tsx +71 -0
- package/src/elements/modules/AttributeFilterEasyComp.tsx +253 -0
- package/src/index.ts +41 -0
- package/src/main.ts +15 -0
- package/src/styles/imageSlider.css +34 -0
- package/tsconfig.json +12 -0
- package/uuid.js +7 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
2
|
+
|
|
3
|
+
/** An interface that defines the inputs of the activity. */
|
|
4
|
+
interface GetElementByDataLayoutIDInputs {
|
|
5
|
+
/**
|
|
6
|
+
* @displayName Data Layout ID
|
|
7
|
+
* @description The data-layout-id of the element to find.
|
|
8
|
+
* @required
|
|
9
|
+
*/
|
|
10
|
+
dataLayoutId: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @displayName CSS Styles
|
|
14
|
+
* @description The CSS styles to inject into the element.
|
|
15
|
+
* @required
|
|
16
|
+
*/
|
|
17
|
+
cssStyles: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** An interface that defines the outputs of the activity. */
|
|
21
|
+
interface GetElementByDataLayoutIDOutputs {
|
|
22
|
+
/**
|
|
23
|
+
* @description A message indicating the result of the activity.
|
|
24
|
+
*/
|
|
25
|
+
result: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @displayName Get Element By DataLayout ID
|
|
30
|
+
* @category EBTA Utilities
|
|
31
|
+
* @description Get Element By DataLayout ID and inject CSS styles V1.
|
|
32
|
+
*/
|
|
33
|
+
export default class GetElementByDataLayoutIDActivity
|
|
34
|
+
implements IActivityHandler
|
|
35
|
+
{
|
|
36
|
+
/** Perform the execution logic of the activity. */
|
|
37
|
+
execute(
|
|
38
|
+
inputs: GetElementByDataLayoutIDInputs
|
|
39
|
+
): GetElementByDataLayoutIDOutputs {
|
|
40
|
+
const { dataLayoutId, cssStyles } = inputs;
|
|
41
|
+
const element = document.querySelector(
|
|
42
|
+
`[data-layout-id="${dataLayoutId}"]`
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (!element) {
|
|
46
|
+
return {
|
|
47
|
+
result: `Element with data-layout-id="${dataLayoutId}" not found.`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Inject the CSS styles
|
|
52
|
+
element.setAttribute("style", cssStyles);
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
result: `CSS styles injected into element with data-layout-id="${dataLayoutId}".`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
2
|
+
|
|
3
|
+
/** An interface that defines the inputs of the activity. */
|
|
4
|
+
interface GetSessionStorageItemActivityInputs {
|
|
5
|
+
/**
|
|
6
|
+
* @displayName keyName
|
|
7
|
+
* @description A string containing the name of the key you want to retrieve from SessionStorage
|
|
8
|
+
* @required
|
|
9
|
+
*/
|
|
10
|
+
keyName: string;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** An interface that defines the outputs of the activity. */
|
|
15
|
+
interface GetSessionStorageItemActivityOutputs {
|
|
16
|
+
/**
|
|
17
|
+
* @description the returned keyValue from SessionStorage
|
|
18
|
+
*/
|
|
19
|
+
result: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @displayName Get SessionStorage Item
|
|
24
|
+
* @category EBTA Utilities
|
|
25
|
+
* @description Get an item from browser SessionStorage object 1.1
|
|
26
|
+
*/
|
|
27
|
+
export default class GetSessionStorageItemActivity implements IActivityHandler {
|
|
28
|
+
/** Perform the execution logic of the activity. */
|
|
29
|
+
async execute(inputs: GetSessionStorageItemActivityInputs): Promise<GetSessionStorageItemActivityOutputs> {
|
|
30
|
+
const { keyName } = inputs;
|
|
31
|
+
const keyValue = sessionStorage.getItem(keyName);
|
|
32
|
+
return {
|
|
33
|
+
result: `${keyValue}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
/** An interface that defines the inputs of the activity. */
|
|
5
|
+
interface GetTaskStatusInputs {
|
|
6
|
+
/**
|
|
7
|
+
* @displayName job url
|
|
8
|
+
* @description Job url to get the status of.
|
|
9
|
+
* @required
|
|
10
|
+
*/
|
|
11
|
+
jobUrl: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @displayName Token
|
|
15
|
+
* @description Token to access the task.
|
|
16
|
+
*/
|
|
17
|
+
token?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** An interface that defines the outputs of the activity. */
|
|
21
|
+
interface GetTaskStatusOutputs {
|
|
22
|
+
/**
|
|
23
|
+
* @description The result of the activity.
|
|
24
|
+
*/
|
|
25
|
+
result: object;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const getTaskStatus = async (jobUrl: string, token: string) => {
|
|
29
|
+
const url = `${jobUrl}?f=json&token=${token}`;
|
|
30
|
+
let jobStatus = 'Processing';
|
|
31
|
+
let jobresult = {};
|
|
32
|
+
while (jobStatus === 'Processing') {
|
|
33
|
+
const response = await axios.get(url);
|
|
34
|
+
jobStatus = response.data.status;
|
|
35
|
+
jobresult = response.data;
|
|
36
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return jobresult;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @displayName GetTaskStatus
|
|
45
|
+
* @category Geocortex
|
|
46
|
+
* @description Get ArcGIS Online Task Status
|
|
47
|
+
*/
|
|
48
|
+
export default class GetTaskStatusActivity implements IActivityHandler {
|
|
49
|
+
/** Perform the execution logic of the activity. */
|
|
50
|
+
async execute(inputs: GetTaskStatusInputs): Promise<GetTaskStatusOutputs> {
|
|
51
|
+
const result = await getTaskStatus(inputs.jobUrl, inputs.token || '');
|
|
52
|
+
return {
|
|
53
|
+
result: result
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface Auth {
|
|
5
|
+
appId: string;
|
|
6
|
+
refreshToken: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** An interface that defines the inputs of the activity. */
|
|
10
|
+
interface GetUserTokenInputs {
|
|
11
|
+
/**
|
|
12
|
+
* @displayName Portal Url
|
|
13
|
+
* @description The second input to the activity.
|
|
14
|
+
*/
|
|
15
|
+
portalurl?: string; // Ensure this is the correct type
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** An interface that defines the outputs of the activity. */
|
|
19
|
+
interface GetUserTokenOutputs {
|
|
20
|
+
/**
|
|
21
|
+
* @description The result of the activity.
|
|
22
|
+
*/
|
|
23
|
+
access_token: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @displayName Get User Token
|
|
28
|
+
* @category EBTA Utilities
|
|
29
|
+
* @description Get User Token 1.2
|
|
30
|
+
*/
|
|
31
|
+
export default class GetUserTokenActivity implements IActivityHandler {
|
|
32
|
+
/** Perform the execution logic of the activity. */
|
|
33
|
+
async execute(inputs: GetUserTokenInputs): Promise<GetUserTokenOutputs> {
|
|
34
|
+
// Your existing code here
|
|
35
|
+
|
|
36
|
+
console.log("GetUserTokenActivity version: 1.2");
|
|
37
|
+
const authData = sessionStorage.getItem("esriJSAPIOAuth");
|
|
38
|
+
|
|
39
|
+
let auth:Auth = {
|
|
40
|
+
appId: 'your_client_id',
|
|
41
|
+
refreshToken: 'your_refresh_token'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (authData !== null) {
|
|
45
|
+
const parsedAuthData = JSON.parse(authData);
|
|
46
|
+
const portalAuth = parsedAuthData?.['/']?.[inputs.portalurl || 'https://www.arcgis.com'];
|
|
47
|
+
if (typeof portalAuth === 'object') {
|
|
48
|
+
auth = portalAuth;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const url = "https://www.arcgis.com/sharing/rest/oauth2/token";
|
|
54
|
+
if (auth) {
|
|
55
|
+
|
|
56
|
+
const myHeaders = new Headers();
|
|
57
|
+
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
|
|
58
|
+
|
|
59
|
+
const urlencoded = new URLSearchParams();
|
|
60
|
+
urlencoded.append("client_id", (auth.appId));
|
|
61
|
+
urlencoded.append("refresh_token", auth.refreshToken);
|
|
62
|
+
urlencoded.append("grant_type", "refresh_token");
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
const requestOptions = {
|
|
66
|
+
method: "POST",
|
|
67
|
+
headers: myHeaders,
|
|
68
|
+
body: urlencoded.toString()
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const response = await fetch(url, requestOptions);
|
|
74
|
+
console.log(response)
|
|
75
|
+
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return response.json()
|
|
81
|
+
.then(responseData => {
|
|
82
|
+
const data = responseData;
|
|
83
|
+
return { access_token: data.access_token };
|
|
84
|
+
|
|
85
|
+
})
|
|
86
|
+
.catch(error => {
|
|
87
|
+
console.error('Error processing response:', error);
|
|
88
|
+
throw error;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error("Error fetching access token:", error);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
// Handle the case where auth is null
|
|
97
|
+
console.error("Authentication data is missing.");
|
|
98
|
+
// You can throw an error or handle it as per your application's requirement
|
|
99
|
+
throw new Error("Authentication data is missing.");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
2
|
+
|
|
3
|
+
/** An interface that defines the inputs of the activity. */
|
|
4
|
+
interface GetvGISDetailsInputs {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @displayName Assignee Email
|
|
9
|
+
* @description The email of the assignee.
|
|
10
|
+
* @required
|
|
11
|
+
*/
|
|
12
|
+
assigneeEmail: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @displayName Creator Email
|
|
16
|
+
* @description The email of the creator.
|
|
17
|
+
* @required
|
|
18
|
+
*/
|
|
19
|
+
creatorEmail: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @displayName Due Date
|
|
23
|
+
* @description The due date for the task.
|
|
24
|
+
* @required
|
|
25
|
+
*/
|
|
26
|
+
dueDate: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @displayName Polygon
|
|
30
|
+
* @description The polygon coordinates.
|
|
31
|
+
* @required
|
|
32
|
+
*/
|
|
33
|
+
polygon: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @displayName Name
|
|
37
|
+
* @description The name of the task.
|
|
38
|
+
* @required
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @displayName Bearer Token
|
|
44
|
+
* @description The bearer token for authorization.
|
|
45
|
+
* @required
|
|
46
|
+
*/
|
|
47
|
+
bearerToken: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @displayName file
|
|
51
|
+
* @description The bearer token for authorization.
|
|
52
|
+
*/
|
|
53
|
+
file: Blob;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** An interface that defines the outputs of the activity. */
|
|
57
|
+
interface GetvGISDetailsOutputs {
|
|
58
|
+
/**
|
|
59
|
+
* @description The result of the activity.
|
|
60
|
+
*/
|
|
61
|
+
result: object;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @displayName Get vGIS Details
|
|
66
|
+
* @category Geocortex
|
|
67
|
+
* @description Get vGIS Details v1.1
|
|
68
|
+
*/
|
|
69
|
+
export default class GetvGISDetailsActivity implements IActivityHandler {
|
|
70
|
+
/** Perform the execution logic of the activity. */
|
|
71
|
+
async execute(inputs: GetvGISDetailsInputs): Promise<GetvGISDetailsOutputs> {
|
|
72
|
+
try {
|
|
73
|
+
const myHeaders = new Headers();
|
|
74
|
+
myHeaders.append("Authorization", `Bearer ${inputs.bearerToken}`);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const formdata = new FormData();
|
|
78
|
+
formdata.append("assigneeEmail", inputs.assigneeEmail);
|
|
79
|
+
formdata.append("creatorEmail", inputs.creatorEmail);
|
|
80
|
+
formdata.append("dueDate", inputs.dueDate);
|
|
81
|
+
formdata.append("polygon", inputs.polygon);
|
|
82
|
+
formdata.append("name", inputs.name);
|
|
83
|
+
if (inputs.file) {
|
|
84
|
+
formdata.append("file", inputs.file, "file");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const requestOptions = {
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: myHeaders,
|
|
90
|
+
body: formdata,
|
|
91
|
+
redirect: "follow" as RequestRedirect,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const response = await fetch("https://external-api-vgis.meemim.com/api/custom/59307/dig-permit", requestOptions);
|
|
95
|
+
const resultText = await response.json();
|
|
96
|
+
return {
|
|
97
|
+
result: resultText,
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error("Error in fetching data from vGIS")
|
|
101
|
+
return {
|
|
102
|
+
result: {
|
|
103
|
+
IssueUrl: null,
|
|
104
|
+
ViewpointUrl: null,
|
|
105
|
+
QrCodeUrl: null,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
2
|
+
|
|
3
|
+
/** An interface that defines the inputs of the activity. */
|
|
4
|
+
interface GetvGISDetailsInputs {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @displayName Assignee Email
|
|
9
|
+
* @description The email of the assignee.
|
|
10
|
+
* @required
|
|
11
|
+
*/
|
|
12
|
+
assigneeEmail: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @displayName Creator Email
|
|
16
|
+
* @description The email of the creator.
|
|
17
|
+
* @required
|
|
18
|
+
*/
|
|
19
|
+
creatorEmail: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @displayName Due Date
|
|
23
|
+
* @description The due date for the task.
|
|
24
|
+
* @required
|
|
25
|
+
*/
|
|
26
|
+
dueDate: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @displayName Polygon
|
|
30
|
+
* @description The polygon coordinates.
|
|
31
|
+
* @required
|
|
32
|
+
*/
|
|
33
|
+
polygon: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @displayName Name
|
|
37
|
+
* @description The name of the task.
|
|
38
|
+
* @required
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @displayName Bearer Token
|
|
44
|
+
* @description The bearer token for authorization.
|
|
45
|
+
* @required
|
|
46
|
+
*/
|
|
47
|
+
bearerToken: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @displayName file
|
|
51
|
+
* @description The bearer token for authorization.
|
|
52
|
+
*/
|
|
53
|
+
file: Blob;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** An interface that defines the outputs of the activity. */
|
|
57
|
+
interface GetvGISDetailsOutputs {
|
|
58
|
+
/**
|
|
59
|
+
* @description The result of the activity.
|
|
60
|
+
*/
|
|
61
|
+
result: object;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @displayName Get vGIS Details
|
|
66
|
+
* @category EBTA Utilities
|
|
67
|
+
* @description Get vGIS Details v1.1
|
|
68
|
+
*/
|
|
69
|
+
export default class GetvGISDetailsActivity implements IActivityHandler {
|
|
70
|
+
/** Perform the execution logic of the activity. */
|
|
71
|
+
async execute(inputs: GetvGISDetailsInputs): Promise<GetvGISDetailsOutputs> {
|
|
72
|
+
try {
|
|
73
|
+
const myHeaders = new Headers();
|
|
74
|
+
myHeaders.append("Authorization", `Bearer ${inputs.bearerToken}`);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const formdata = new FormData();
|
|
78
|
+
formdata.append("assigneeEmail", inputs.assigneeEmail);
|
|
79
|
+
formdata.append("creatorEmail", inputs.creatorEmail);
|
|
80
|
+
formdata.append("dueDate", inputs.dueDate);
|
|
81
|
+
formdata.append("polygon", inputs.polygon);
|
|
82
|
+
formdata.append("name", inputs.name);
|
|
83
|
+
if (inputs.file) {
|
|
84
|
+
formdata.append("file", inputs.file, "file");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const requestOptions = {
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: myHeaders,
|
|
90
|
+
body: formdata,
|
|
91
|
+
redirect: "follow" as RequestRedirect,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const response = await fetch("https://external-api-vgis.meemim.com/api/custom/59307/dig-permit", requestOptions);
|
|
95
|
+
const resultText = await response.json();
|
|
96
|
+
return {
|
|
97
|
+
result: resultText,
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error("Error in fetching data from vGIS")
|
|
101
|
+
return {
|
|
102
|
+
result: {
|
|
103
|
+
IssueUrl: null,
|
|
104
|
+
ViewpointUrl: null,
|
|
105
|
+
QrCodeUrl: null,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/* eslint-disable prefer-const */
|
|
2
|
+
import type { IActivityHandler } from "@vertigis/workflow";
|
|
3
|
+
import html2canvas from 'html2canvas';
|
|
4
|
+
/** An interface that defines the inputs of the activity. */
|
|
5
|
+
interface HTMLextractorInputs {
|
|
6
|
+
/**
|
|
7
|
+
* @displayName CSS Selector
|
|
8
|
+
* @description The string of css selector.
|
|
9
|
+
* @required
|
|
10
|
+
*/
|
|
11
|
+
selector: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @displayName Request
|
|
15
|
+
* @description Chose one from the following requests: "getImage","getProperty"
|
|
16
|
+
*/
|
|
17
|
+
request?: "getImage" | "getProperty";
|
|
18
|
+
/**
|
|
19
|
+
* @displayName Additional Value(optional)
|
|
20
|
+
* @description Additional value: If request is getProperty, put in property name like width; If request is getImage, put in whiteBackground to force background to be white
|
|
21
|
+
*/
|
|
22
|
+
value?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** An interface that defines the outputs of the activity. */
|
|
26
|
+
interface HTMLextractorOutputs {
|
|
27
|
+
/**
|
|
28
|
+
* @description The result of the activity.
|
|
29
|
+
*/
|
|
30
|
+
result: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @displayName Extract HTML Element by CSS Selector
|
|
36
|
+
* @category EBTA Utilities
|
|
37
|
+
* @description Extract screenshot or attribute of HTML component by a css selector
|
|
38
|
+
*/
|
|
39
|
+
function convertSVGTagstoIMG(container) {
|
|
40
|
+
let svgElements: NodeListOf<SVGElement> = container.querySelectorAll('svg[role="img"]');
|
|
41
|
+
let SVGDom = Array.from(svgElements).filter(svg => {
|
|
42
|
+
let svgElement = svg;
|
|
43
|
+
let gTag = svgElement.querySelector('g');
|
|
44
|
+
return gTag && gTag.querySelector('image');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
SVGDom.forEach(svg => {
|
|
49
|
+
let svgElement = svg;
|
|
50
|
+
// Create a new <img> element
|
|
51
|
+
let img = document.createElement('img');
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
let imageDOM = svgElement.querySelector('image');
|
|
55
|
+
if (imageDOM) {
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
let imageurl = imageDOM.getAttribute('href');
|
|
59
|
+
|
|
60
|
+
// Transfer the relevant attributes
|
|
61
|
+
img.alt = imageDOM.getAttribute('alt') || '';
|
|
62
|
+
img.src = imageurl || ''; // Use xlink:href for the src
|
|
63
|
+
img.width = parseInt(imageDOM.getAttribute('width') || '0');
|
|
64
|
+
img.height = parseInt(imageDOM.getAttribute('height') || '0');
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
svg.parentNode!.replaceChild(img, svg);
|
|
68
|
+
} else {
|
|
69
|
+
console.log('No image found inside svg.');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
console.log('IMG conversion finished');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async function captureElementByCSSToFile(css: string,mode?:string): Promise<string> {
|
|
77
|
+
// Query the DOM for the first element with the specified class name
|
|
78
|
+
const element :HTMLElement = document.querySelector(css)!;
|
|
79
|
+
if (!element) {
|
|
80
|
+
throw new Error(`Element with selector ${css} not found`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// Ensure all external images have the crossOrigin attribute set
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
convertSVGTagstoIMG(element)
|
|
89
|
+
const images:NodeListOf<HTMLImageElement> = element.querySelectorAll('img[src]') ;
|
|
90
|
+
images.forEach((img) => {
|
|
91
|
+
if (!img.crossOrigin) {
|
|
92
|
+
img.crossOrigin = 'anonymous';
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
let originalStyles
|
|
97
|
+
let children : NodeListOf<HTMLElement> = element.querySelectorAll('*');
|
|
98
|
+
let originalChildStyles:{element: HTMLElement, backgroundColor: string, color: string}[] = [];
|
|
99
|
+
if (mode=='whiteBackground'){
|
|
100
|
+
originalStyles= {
|
|
101
|
+
backgroundColor: element.style.backgroundColor,
|
|
102
|
+
color: element.style.color
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
// Reverse the dark mode styles
|
|
107
|
+
element.style.backgroundColor = 'white';
|
|
108
|
+
element.style.color = 'black';
|
|
109
|
+
|
|
110
|
+
// Apply the same style changes to all children, and backup the original
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
children.forEach(child => {
|
|
114
|
+
originalChildStyles.push({
|
|
115
|
+
element: child,
|
|
116
|
+
backgroundColor: child.style.backgroundColor,
|
|
117
|
+
color: child.style.color
|
|
118
|
+
});
|
|
119
|
+
child.style.backgroundColor = 'white';
|
|
120
|
+
child.style.color = 'black';
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// Capture the element using html2canvas with useCORS option
|
|
129
|
+
const canvas = await html2canvas(element, {
|
|
130
|
+
useCORS: true,
|
|
131
|
+
logging: true,
|
|
132
|
+
backgroundColor: '#ffffff',
|
|
133
|
+
allowTaint: true ,
|
|
134
|
+
scale:2.5
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Convert the canvas to Base64 image
|
|
138
|
+
let imageBase64 = canvas.toDataURL("image/jpeg");
|
|
139
|
+
|
|
140
|
+
if (mode=='whiteBackground'){
|
|
141
|
+
// Revert to the original styles
|
|
142
|
+
element.style.backgroundColor = originalStyles.backgroundColor;
|
|
143
|
+
element.style.color = originalStyles.color;
|
|
144
|
+
|
|
145
|
+
// Revert the styles of all children
|
|
146
|
+
originalChildStyles.forEach(({ element, backgroundColor, color }) => {
|
|
147
|
+
element.style.backgroundColor = backgroundColor;
|
|
148
|
+
element.style.color = color;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
return imageBase64;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
throw new Error(`Failed to capture legend screenshot: ${(error as Error).message}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @displayName HTMLextractor
|
|
162
|
+
* @category Custom Activities
|
|
163
|
+
* @description Extract screenshot or attribute of HTML component by a css selector
|
|
164
|
+
*/
|
|
165
|
+
export default class HTMLextractorActivity implements IActivityHandler {
|
|
166
|
+
/** Perform the execution logic of the activity. */
|
|
167
|
+
async execute(inputs: HTMLextractorInputs): Promise<HTMLextractorOutputs> {
|
|
168
|
+
|
|
169
|
+
const element :HTMLElement = document.querySelector(inputs.selector)!;
|
|
170
|
+
console.log('HTML element:')
|
|
171
|
+
console.log(element)
|
|
172
|
+
let result
|
|
173
|
+
if (!element) {
|
|
174
|
+
throw new Error(`Element with query: ' ${inputs.selector} ' not found`);
|
|
175
|
+
}
|
|
176
|
+
if(inputs.request=='getProperty'){
|
|
177
|
+
const computedStyle = window.getComputedStyle(element);
|
|
178
|
+
result=inputs.value? computedStyle[inputs.value]:'cannot get property'
|
|
179
|
+
}
|
|
180
|
+
else if(inputs.request=='getImage'){
|
|
181
|
+
result = await captureElementByCSSToFile(inputs.selector,inputs.value);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
result: result
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|