@next-libs/cmdb-instances 7.20.4 → 7.20.6
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/dist/cjs/instance-detail/components/instances-attachment-display/instances-attachment-display.js +5 -2
- package/dist/cjs/instance-detail/components/instances-attachment-display/instances-attachment-display.js.map +1 -1
- package/dist/esm/instance-detail/components/instances-attachment-display/instances-attachment-display.js +5 -2
- package/dist/esm/instance-detail/components/instances-attachment-display/instances-attachment-display.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _icons = require("@ant-design/icons");
|
|
10
10
|
var _jsBase = require("js-base64");
|
|
11
11
|
var _cmdbUtils = require("@next-libs/cmdb-utils");
|
|
12
|
+
var _constants = require("../../../constants");
|
|
12
13
|
var _instancesAttachmentDisplayModule = _interopRequireDefault(require("./instances-attachment-display.module.css"));
|
|
13
14
|
function InstancesAttachmentDisplay(props) {
|
|
14
15
|
const {
|
|
@@ -18,7 +19,7 @@ function InstancesAttachmentDisplay(props) {
|
|
|
18
19
|
const handleDownload = file => {
|
|
19
20
|
const domain = `${window.location.origin}/next`;
|
|
20
21
|
const link = document.createElement("a");
|
|
21
|
-
link.href = `${domain}/${file.url}`;
|
|
22
|
+
link.href = `${domain}/${file.url}?fileName=${file.name}`;
|
|
22
23
|
link.download = file.name;
|
|
23
24
|
document.body.appendChild(link);
|
|
24
25
|
link.click();
|
|
@@ -26,8 +27,10 @@ function InstancesAttachmentDisplay(props) {
|
|
|
26
27
|
};
|
|
27
28
|
// 预览
|
|
28
29
|
const handlePreview = file => {
|
|
30
|
+
var _file$url;
|
|
29
31
|
const domain = `${window.location.origin}/next`;
|
|
30
|
-
const url =
|
|
32
|
+
const checksum = (_file$url = file.url) === null || _file$url === void 0 ? void 0 : _file$url.slice(_constants.DownloadFileUrl.length + 1, file.url.length);
|
|
33
|
+
const url = `${domain}/${file.url}?checksum=${checksum}&fileName=${file.name}&fullfilename=${file.name}`;
|
|
31
34
|
const previewUrl = `${domain}/api/gateway/file_previewer.preview.PreviewFile/onlinePreview?url=${encodeURIComponent(_jsBase.Base64.encode(url)
|
|
32
35
|
// window.btoa(url)
|
|
33
36
|
)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances-attachment-display.js","names":["InstancesAttachmentDisplay","props","value","handleDownload","file","domain","window","location","origin","link","document","createElement","href","url","
|
|
1
|
+
{"version":3,"file":"instances-attachment-display.js","names":["InstancesAttachmentDisplay","props","value","handleDownload","file","domain","window","location","origin","link","document","createElement","href","url","name","download","body","appendChild","click","removeChild","handlePreview","checksum","slice","DownloadFileUrl","length","previewUrl","encodeURIComponent","Base64","encode","open","map","isPreview","FileUtils","sizeCompare","supportFileType","id","styles","attachmentItem","marginRight","attachmentText","attachmentSpan","attachmentIconItem"],"sources":["../../../../../src/instance-detail/components/instances-attachment-display/instances-attachment-display.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n EyeOutlined,\n DownloadOutlined,\n FileTextOutlined,\n} from \"@ant-design/icons\";\nimport { Base64 } from \"js-base64\";\nimport { FileUtils } from \"@next-libs/cmdb-utils\";\nimport { DownloadFileUrl } from \"../../../constants\";\nimport styles from \"./instances-attachment-display.module.css\";\n\ninterface InstancesAttachmentDisplayProps {\n value?: Record<string, any>[];\n}\n\nexport function InstancesAttachmentDisplay(\n props: InstancesAttachmentDisplayProps\n): React.ReactElement {\n const { value } = props;\n // 下载\n const handleDownload = (file: any): void => {\n const domain = `${window.location.origin}/next`;\n const link = document.createElement(\"a\");\n link.href = `${domain}/${file.url}?fileName=${file.name}`;\n link.download = file.name;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n };\n // 预览\n const handlePreview = (file: any): void => {\n const domain = `${window.location.origin}/next`;\n const checksum = file.url?.slice(\n DownloadFileUrl.length + 1,\n file.url.length\n );\n const url = `${domain}/${file.url}?checksum=${checksum}&fileName=${file.name}&fullfilename=${file.name}`;\n const previewUrl = `${domain}/api/gateway/file_previewer.preview.PreviewFile/onlinePreview?url=${encodeURIComponent(\n Base64.encode(url)\n // window.btoa(url)\n )}`;\n window.open(previewUrl, \"_blank\");\n };\n return (\n <>\n {value?.map((file: any) => {\n // 是否支持预览\n const isPreview =\n !FileUtils.sizeCompare(file, 100) && FileUtils.supportFileType(file);\n return (\n <div key={file.id} className={styles.attachmentItem}>\n <span>\n <FileTextOutlined style={{ marginRight: \"6px\" }} />\n <span className={styles.attachmentText}>{file.name}</span>\n </span>\n <span className={styles.attachmentSpan}>\n {isPreview && (\n <EyeOutlined\n className={styles.attachmentIconItem}\n onClick={() => handlePreview(file)}\n />\n )}\n <DownloadOutlined\n className={styles.attachmentIconItem}\n onClick={() => handleDownload(file)}\n />\n </span>\n </div>\n );\n })}\n </>\n );\n}\n"],"mappings":";;;;;;;AAAA;AACA;AAKA;AACA;AACA;AACA;AAMO,SAASA,0BAA0B,CACxCC,KAAsC,EAClB;EACpB,MAAM;IAAEC;EAAM,CAAC,GAAGD,KAAK;EACvB;EACA,MAAME,cAAc,GAAIC,IAAS,IAAW;IAC1C,MAAMC,MAAM,GAAI,GAAEC,MAAM,CAACC,QAAQ,CAACC,MAAO,OAAM;IAC/C,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,GAAG,CAAC;IACxCF,IAAI,CAACG,IAAI,GAAI,GAAEP,MAAO,IAAGD,IAAI,CAACS,GAAI,aAAYT,IAAI,CAACU,IAAK,EAAC;IACzDL,IAAI,CAACM,QAAQ,GAAGX,IAAI,CAACU,IAAI;IACzBJ,QAAQ,CAACM,IAAI,CAACC,WAAW,CAACR,IAAI,CAAC;IAC/BA,IAAI,CAACS,KAAK,EAAE;IACZR,QAAQ,CAACM,IAAI,CAACG,WAAW,CAACV,IAAI,CAAC;EACjC,CAAC;EACD;EACA,MAAMW,aAAa,GAAIhB,IAAS,IAAW;IAAA;IACzC,MAAMC,MAAM,GAAI,GAAEC,MA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;MACrC,OAAO,EAAE,MAAMtC,cAAc,CAACC,IAAI;IAAE,EACpC,CACG,CACH;EAEV,CAAC,CAAC,CACD;AAEP"}
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { EyeOutlined, DownloadOutlined, FileTextOutlined } from "@ant-design/icons";
|
|
3
3
|
import { Base64 } from "js-base64";
|
|
4
4
|
import { FileUtils } from "@next-libs/cmdb-utils";
|
|
5
|
+
import { DownloadFileUrl } from "../../../constants";
|
|
5
6
|
import styles from "./instances-attachment-display.module.css";
|
|
6
7
|
export function InstancesAttachmentDisplay(props) {
|
|
7
8
|
var {
|
|
@@ -11,7 +12,7 @@ export function InstancesAttachmentDisplay(props) {
|
|
|
11
12
|
var handleDownload = file => {
|
|
12
13
|
var domain = "".concat(window.location.origin, "/next");
|
|
13
14
|
var link = document.createElement("a");
|
|
14
|
-
link.href = "".concat(domain, "/").concat(file.url);
|
|
15
|
+
link.href = "".concat(domain, "/").concat(file.url, "?fileName=").concat(file.name);
|
|
15
16
|
link.download = file.name;
|
|
16
17
|
document.body.appendChild(link);
|
|
17
18
|
link.click();
|
|
@@ -19,8 +20,10 @@ export function InstancesAttachmentDisplay(props) {
|
|
|
19
20
|
};
|
|
20
21
|
// 预览
|
|
21
22
|
var handlePreview = file => {
|
|
23
|
+
var _file$url;
|
|
22
24
|
var domain = "".concat(window.location.origin, "/next");
|
|
23
|
-
var url =
|
|
25
|
+
var checksum = (_file$url = file.url) === null || _file$url === void 0 ? void 0 : _file$url.slice(DownloadFileUrl.length + 1, file.url.length);
|
|
26
|
+
var url = "".concat(domain, "/").concat(file.url, "?checksum=").concat(checksum, "&fileName=").concat(file.name, "&fullfilename=").concat(file.name);
|
|
24
27
|
var previewUrl = "".concat(domain, "/api/gateway/file_previewer.preview.PreviewFile/onlinePreview?url=").concat(encodeURIComponent(Base64.encode(url)
|
|
25
28
|
// window.btoa(url)
|
|
26
29
|
));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances-attachment-display.js","names":["React","EyeOutlined","DownloadOutlined","FileTextOutlined","Base64","FileUtils","styles","InstancesAttachmentDisplay","props","value","handleDownload","file","domain","window","location","origin","link","document","createElement","href","url","
|
|
1
|
+
{"version":3,"file":"instances-attachment-display.js","names":["React","EyeOutlined","DownloadOutlined","FileTextOutlined","Base64","FileUtils","DownloadFileUrl","styles","InstancesAttachmentDisplay","props","value","handleDownload","file","domain","window","location","origin","link","document","createElement","href","url","name","download","body","appendChild","click","removeChild","handlePreview","checksum","slice","length","previewUrl","encodeURIComponent","encode","open","map","isPreview","sizeCompare","supportFileType","id","attachmentItem","marginRight","attachmentText","attachmentSpan","attachmentIconItem"],"sources":["../../../../../src/instance-detail/components/instances-attachment-display/instances-attachment-display.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n EyeOutlined,\n DownloadOutlined,\n FileTextOutlined,\n} from \"@ant-design/icons\";\nimport { Base64 } from \"js-base64\";\nimport { FileUtils } from \"@next-libs/cmdb-utils\";\nimport { DownloadFileUrl } from \"../../../constants\";\nimport styles from \"./instances-attachment-display.module.css\";\n\ninterface InstancesAttachmentDisplayProps {\n value?: Record<string, any>[];\n}\n\nexport function InstancesAttachmentDisplay(\n props: InstancesAttachmentDisplayProps\n): React.ReactElement {\n const { value } = props;\n // 下载\n const handleDownload = (file: any): void => {\n const domain = `${window.location.origin}/next`;\n const link = document.createElement(\"a\");\n link.href = `${domain}/${file.url}?fileName=${file.name}`;\n link.download = file.name;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n };\n // 预览\n const handlePreview = (file: any): void => {\n const domain = `${window.location.origin}/next`;\n const checksum = file.url?.slice(\n DownloadFileUrl.length + 1,\n file.url.length\n );\n const url = `${domain}/${file.url}?checksum=${checksum}&fileName=${file.name}&fullfilename=${file.name}`;\n const previewUrl = `${domain}/api/gateway/file_previewer.preview.PreviewFile/onlinePreview?url=${encodeURIComponent(\n Base64.encode(url)\n // window.btoa(url)\n )}`;\n window.open(previewUrl, \"_blank\");\n };\n return (\n <>\n {value?.map((file: any) => {\n // 是否支持预览\n const isPreview =\n !FileUtils.sizeCompare(file, 100) && FileUtils.supportFileType(file);\n return (\n <div key={file.id} className={styles.attachmentItem}>\n <span>\n <FileTextOutlined style={{ marginRight: \"6px\" }} />\n <span className={styles.attachmentText}>{file.name}</span>\n </span>\n <span className={styles.attachmentSpan}>\n {isPreview && (\n <EyeOutlined\n className={styles.attachmentIconItem}\n onClick={() => handlePreview(file)}\n />\n )}\n <DownloadOutlined\n className={styles.attachmentIconItem}\n onClick={() => handleDownload(file)}\n />\n </span>\n </div>\n );\n })}\n </>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,WAAW,EACXC,gBAAgB,EAChBC,gBAAgB,QACX,mBAAmB;AAC1B,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,OAAOC,MAAM,MAAM,2CAA2C;AAM9D,OAAO,SAASC,0BAA0B,CACxCC,KAAsC,EAClB;EACpB,IAAM;IAAEC;EAAM,CAAC,GAAGD,KAAK;EACvB;EACA,IAAME,cAAc,GAAIC,IAAS,IAAW;IAC1C,IAAMC,MAAM,aAAMC,MAAM,CAACC,QAAQ,CAACC,MAAM,UAAO;IAC/C,IAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,GAAG,CAAC;IACxCF,IAAI,CAACG,IAAI,aAAMP,MAAM,cAAID,IAAI,CAACS,GAAG,uBAAaT,IAAI,CAACU,IAAI,CAAE;IACzDL,IAAI,CAACM,QAAQ,GAAGX,IAAI,CAACU,IAAI;IACzBJ,QAAQ,CAACM,IAAI,CAACC,WAAW,CAACR,IAAI,CAAC;IAC/BA,IAAI,CAACS,KAAK,EAAE;IACZR,QAAQ,CAACM,IAAI,CAACG,WAAW,CAACV,IAAI,CAAC;EACjC,CAAC;EACD;EACA,IAAMW,aAAa,GAAIh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AgB;MACf,SAAS,EAAEL,MAAM,CAACsC,kBAAmB;MACrC,OAAO,EAAE,MAAMlC,cAAc,CAACC,IAAI;IAAE,EACpC,CACG,CACH;EAEV,CAAC,CAAC,CACD;AAEP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-libs/cmdb-instances",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.6",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-libs/tree/master/libs/cmdb-instances",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"immutability-helper": "^3.1.1",
|
|
52
52
|
"marked": "^2.1.3"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "a9b01a2ccbf51b3466102b7879183bf24b91a29d"
|
|
55
55
|
}
|