Skip to content

Commit cf470f2

Browse files
authored
Merge pull request #4370 from jeclrsg/feat-comms-wsdali-export
feat(comms): add Export function to WsDali service
2 parents 6dce1c7 + 4ef5cce commit cf470f2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/comms/src/services/wsDali.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,37 @@ export {
44
WsDali
55
};
66

7+
export interface ExportRequest {
8+
Path: string;
9+
Safe: boolean;
10+
}
11+
12+
export interface ExportResponse {
13+
filename: string;
14+
content: Blob;
15+
}
16+
717
export class DaliService extends DaliServiceBase {
18+
19+
async Export(request: ExportRequest): Promise<ExportResponse> {
20+
const exportUrl = "/WsDali/Export";
21+
22+
const reqParams = new URLSearchParams();
23+
if (request.Path) {
24+
reqParams.append("Path", request.Path);
25+
}
26+
if (request.Safe !== undefined) {
27+
reqParams.append("Safe", String(request.Safe));
28+
}
29+
30+
const response = await fetch(`${exportUrl}?${reqParams.toString()}`);
31+
const filename = response.headers.get("Content-Disposition");
32+
const content = await response.blob();
33+
34+
return {
35+
filename: filename ? filename.split("filename=")[1] : "WsDali_Export",
36+
content
37+
};
38+
}
39+
840
}

0 commit comments

Comments
 (0)