pollination-react-io 1.77.4 → 1.78.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/build/hooks/useRuns.d.ts +1 -0
- package/build/index.esm.js +139 -40
- package/build/index.esm.js.map +1 -1
- package/build/index.js +139 -40
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/hooks/useRuns.d.ts
CHANGED
package/build/index.esm.js
CHANGED
@@ -40841,6 +40841,13 @@ var useRuns = function (client) {
|
|
40841
40841
|
return dayjs_min.duration(dayjs_min().utc()
|
40842
40842
|
.diff(dayjs_min(status.started_at).utc())); // if cloudjob -> utc(true)
|
40843
40843
|
};
|
40844
|
+
var getTrigger = function (item) {
|
40845
|
+
var _a;
|
40846
|
+
if (!((_a = item === null || item === void 0 ? void 0 : item.status) === null || _a === void 0 ? void 0 : _a.finished_at))
|
40847
|
+
return;
|
40848
|
+
var days = dayjs_min().diff(item.status.finished_at, 'days');
|
40849
|
+
return days >= 14;
|
40850
|
+
};
|
40844
40851
|
var listRuns = useCallback(function (projectOwner, projectName, jobId, page, perPage, statusFilter) {
|
40845
40852
|
if (!client || !client.runs)
|
40846
40853
|
return;
|
@@ -40887,6 +40894,7 @@ var useRuns = function (client) {
|
|
40887
40894
|
statusMap: statusMap,
|
40888
40895
|
getSummaryColor: getSummaryColor,
|
40889
40896
|
getDuration: getDuration,
|
40897
|
+
getTrigger: getTrigger
|
40890
40898
|
};
|
40891
40899
|
};
|
40892
40900
|
|
@@ -54852,6 +54860,19 @@ var FileUnknownFilled = function FileUnknownFilled(props, ref) {
|
|
54852
54860
|
FileUnknownFilled.displayName = 'FileUnknownFilled';
|
54853
54861
|
var FileUnknownFilled$1 = /*#__PURE__*/React.forwardRef(FileUnknownFilled);
|
54854
54862
|
|
54863
|
+
// This icon file is generated automatically.
|
54864
|
+
var FileZipFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M854.6 288.7c6 6 9.4 14.1 9.4 22.6V928c0 17.7-14.3 32-32 32H192c-17.7 0-32-14.3-32-32V96c0-17.7 14.3-32 32-32h424.7c8.5 0 16.7 3.4 22.7 9.4l215.2 215.3zM790.2 326L602 137.8V326h188.2zM296 136v64h64v-64h-64zm64 64v64h64v-64h-64zm-64 64v64h64v-64h-64zm64 64v64h64v-64h-64zm-64 64v64h64v-64h-64zm64 64v64h64v-64h-64zm-64 64v64h64v-64h-64zm0 64v160h128V584H296zm48 48h32v64h-32v-64z" } }] }, "name": "file-zip", "theme": "filled" };
|
54865
|
+
var FileZipFilledSvg = FileZipFilled$2;
|
54866
|
+
|
54867
|
+
var FileZipFilled = function FileZipFilled(props, ref) {
|
54868
|
+
return /*#__PURE__*/React.createElement(AntdIcon, _objectSpread2$1(_objectSpread2$1({}, props), {}, {
|
54869
|
+
ref: ref,
|
54870
|
+
icon: FileZipFilledSvg
|
54871
|
+
}));
|
54872
|
+
};
|
54873
|
+
FileZipFilled.displayName = 'FileZipFilled';
|
54874
|
+
var FileZipFilled$1 = /*#__PURE__*/React.forwardRef(FileZipFilled);
|
54875
|
+
|
54855
54876
|
// This icon file is generated automatically.
|
54856
54877
|
var FolderFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32z" } }] }, "name": "folder", "theme": "filled" };
|
54857
54878
|
var FolderFilledSvg = FolderFilled$2;
|
@@ -55943,6 +55964,8 @@ var getFileIcon = function (size, type) {
|
|
55943
55964
|
case 'svg':
|
55944
55965
|
case 'hdr':
|
55945
55966
|
return React__default.createElement(FileImageFilled$1, { style: { fontSize: size, color: '#862E9C' } });
|
55967
|
+
case 'zip':
|
55968
|
+
return React__default.createElement(FileZipFilled$1, { style: { fontSize: size, color: '#f2b24d' } });
|
55946
55969
|
default:
|
55947
55970
|
return React__default.createElement(FileUnknownFilled$1, { style: { fontSize: size } });
|
55948
55971
|
}
|
@@ -55953,6 +55976,11 @@ var CADtypeEnum;
|
|
55953
55976
|
CADtypeEnum[CADtypeEnum["HBJSON"] = 0] = "HBJSON";
|
55954
55977
|
CADtypeEnum[CADtypeEnum["VSF"] = 1] = "VSF";
|
55955
55978
|
})(CADtypeEnum || (CADtypeEnum = {}));
|
55979
|
+
/**
|
55980
|
+
* Download a file
|
55981
|
+
* @param blob Blob to convert
|
55982
|
+
* @param fileName File name to download
|
55983
|
+
*/
|
55956
55984
|
var download = function (blob, fileName) {
|
55957
55985
|
var file = new File([blob], fileName);
|
55958
55986
|
var a = document.createElement('a');
|
@@ -55965,38 +55993,83 @@ var download = function (blob, fileName) {
|
|
55965
55993
|
a.click();
|
55966
55994
|
};
|
55967
55995
|
var FileCard = function (_a) {
|
55968
|
-
var _b
|
55969
|
-
var projectOwner = _a.projectOwner, projectName = _a.projectName, client = _a.client, run = _a.run, label = _a.label, path = _a.path, file = _a.file, description = _a.description, onClicked = _a.onClicked,
|
55996
|
+
var _b;
|
55997
|
+
var projectOwner = _a.projectOwner, projectName = _a.projectName, client = _a.client, run = _a.run, label = _a.label, path = _a.path, file = _a.file, description = _a.description, onClicked = _a.onClicked, _c = _a.isCloud, isCloud = _c === void 0 ? true : _c;
|
55970
55998
|
var host = getHost();
|
55971
55999
|
var fromFileToBase64 = usePollinationPanel().fromFileToBase64;
|
55972
|
-
var
|
55973
|
-
var
|
55974
|
-
var
|
55975
|
-
|
55976
|
-
var
|
55977
|
-
var
|
55978
|
-
var
|
56000
|
+
var _d = useVSFToHTML(), loading = _d.loading, html = _d.html, fetchHTML = _d.fetchHTML;
|
56001
|
+
var downloadArtifact = useArtifacts(projectOwner, projectName, client).downloadArtifact;
|
56002
|
+
var _e = useState(false), open = _e[0], setOpen = _e[1];
|
56003
|
+
// Hover effects
|
56004
|
+
var _f = useState(false), infoOver = _f[0], setInfoOver = _f[1];
|
56005
|
+
var _g = useState(false), downloadOver = _g[0], setDownloadOver = _g[1];
|
56006
|
+
var _h = useState(false), htmlOver = _h[0], setHtmlOver = _h[1];
|
56007
|
+
var _j = useState(true), isLoading = _j[0], setIsLoading = _j[1];
|
56008
|
+
var _k = useState(false), isInactive = _k[0], setIsInactive = _k[1];
|
55979
56009
|
// Data to use for CAD injections
|
55980
|
-
var
|
56010
|
+
var _l = useState(), CADdata = _l[0], setCADdata = _l[1];
|
55981
56011
|
// File to send to parent
|
55982
|
-
var
|
55983
|
-
//
|
55984
|
-
|
55985
|
-
//
|
55986
|
-
|
55987
|
-
|
55988
|
-
|
55989
|
-
|
55990
|
-
|
55991
|
-
|
55992
|
-
|
55993
|
-
|
55994
|
-
|
56012
|
+
var _m = useState(), currFile = _m[0], setCurrFile = _m[1];
|
56013
|
+
// HTML integration
|
56014
|
+
var _o = useState(false), hasHtml = _o[0], setHasHtml = _o[1];
|
56015
|
+
// ZIP integration
|
56016
|
+
var _p = useState(), innerName = _p[0], setInnerName = _p[1];
|
56017
|
+
/**
|
56018
|
+
* Get file name to use
|
56019
|
+
*/
|
56020
|
+
var filename = useMemo(function () {
|
56021
|
+
if (!path)
|
56022
|
+
return;
|
56023
|
+
return innerName !== null && innerName !== void 0 ? innerName : path.split('/').reverse()[0];
|
56024
|
+
}, [path, innerName]);
|
56025
|
+
/**
|
56026
|
+
* Get file from a ZIP file.
|
56027
|
+
* 1 zip = 1 file for now
|
56028
|
+
*/
|
56029
|
+
var getFileFromZip = useCallback(function (file) {
|
55995
56030
|
if (!file)
|
55996
56031
|
return;
|
56032
|
+
var archive = new jszip_min();
|
56033
|
+
archive.loadAsync(file)
|
56034
|
+
.then(function (zip) { return __awaiter$1(void 0, void 0, void 0, function () {
|
56035
|
+
var entries, listOfPromises, promiseOfList;
|
56036
|
+
return __generator$1(this, function (_a) {
|
56037
|
+
entries = Object.keys(zip.files).map(function (name) { return zip.files[name]; });
|
56038
|
+
listOfPromises = entries.map(function (entry) {
|
56039
|
+
return entry
|
56040
|
+
.async('blob')
|
56041
|
+
.then(function (blob) { return [entry.name, blob]; });
|
56042
|
+
});
|
56043
|
+
promiseOfList = Promise.all(listOfPromises);
|
56044
|
+
promiseOfList.then(function (list) {
|
56045
|
+
list.forEach(function (_a) {
|
56046
|
+
var name = _a[0], f = _a[1];
|
56047
|
+
// 1 zip = 1 file
|
56048
|
+
// I assume text/plain
|
56049
|
+
setInnerName(name);
|
56050
|
+
var blob = f.slice(0, f.size, 'text/plain');
|
56051
|
+
setCurrFile(blob);
|
56052
|
+
if (name.endsWith('vsf')) {
|
56053
|
+
setHasHtml(true);
|
56054
|
+
fetchHTML(blob);
|
56055
|
+
setCADintegration(blob, name);
|
56056
|
+
}
|
56057
|
+
});
|
56058
|
+
});
|
56059
|
+
return [2 /*return*/];
|
56060
|
+
});
|
56061
|
+
}); });
|
56062
|
+
}, [file]);
|
56063
|
+
/**
|
56064
|
+
* Get CAD data to use with the panel
|
56065
|
+
*/
|
56066
|
+
var setCADintegration = useCallback(function (file, name) {
|
56067
|
+
if (name === void 0) { name = undefined; }
|
56068
|
+
if (!file || !filename)
|
56069
|
+
return;
|
55997
56070
|
if (host === 'web')
|
55998
56071
|
return;
|
55999
|
-
if (
|
56072
|
+
if (filename.endsWith('hbjson')
|
56000
56073
|
&& host === 'rhino') {
|
56001
56074
|
var reader_1 = new FileReader();
|
56002
56075
|
reader_1.readAsText(file);
|
@@ -56009,7 +56082,7 @@ var FileCard = function (_a) {
|
|
56009
56082
|
});
|
56010
56083
|
};
|
56011
56084
|
}
|
56012
|
-
else if (
|
56085
|
+
else if ((filename.endsWith('vsf') || (name === null || name === void 0 ? void 0 : name.endsWith('vsf')))
|
56013
56086
|
&& (host === 'rhino' || host === 'revit')) {
|
56014
56087
|
var reader_2 = new FileReader();
|
56015
56088
|
reader_2.readAsText(file);
|
@@ -56022,7 +56095,7 @@ var FileCard = function (_a) {
|
|
56022
56095
|
});
|
56023
56096
|
};
|
56024
56097
|
}
|
56025
|
-
}, [file]);
|
56098
|
+
}, [file, filename]);
|
56026
56099
|
/**
|
56027
56100
|
* Fetch file from cloud
|
56028
56101
|
*/
|
@@ -56035,15 +56108,32 @@ var FileCard = function (_a) {
|
|
56035
56108
|
setCurrFile(undefined);
|
56036
56109
|
setCADintegration(undefined);
|
56037
56110
|
setIsLoading(false);
|
56111
|
+
setHasHtml(false);
|
56112
|
+
setInnerName(undefined);
|
56038
56113
|
return;
|
56039
56114
|
}
|
56040
56115
|
res.blob()
|
56041
56116
|
.then(function (blob) {
|
56042
|
-
|
56043
|
-
if (
|
56044
|
-
|
56117
|
+
// File is a ZIP
|
56118
|
+
if (blob.type === 'application/zip') {
|
56119
|
+
getFileFromZip(blob);
|
56120
|
+
}
|
56121
|
+
else {
|
56122
|
+
setCurrFile(blob);
|
56123
|
+
setInnerName(undefined);
|
56124
|
+
if (path === null || path === void 0 ? void 0 : path.endsWith('vsf')) {
|
56125
|
+
setHasHtml(true);
|
56126
|
+
fetchHTML(blob); // HTML button
|
56127
|
+
setCADintegration(blob);
|
56128
|
+
}
|
56129
|
+
else if (path === null || path === void 0 ? void 0 : path.endsWith('hbjson')) {
|
56130
|
+
setHasHtml(false);
|
56131
|
+
setCADintegration(blob);
|
56132
|
+
}
|
56133
|
+
else {
|
56134
|
+
setHasHtml(false);
|
56135
|
+
}
|
56045
56136
|
}
|
56046
|
-
setCADintegration(blob);
|
56047
56137
|
setIsLoading(false);
|
56048
56138
|
setIsInactive(false);
|
56049
56139
|
});
|
@@ -56054,11 +56144,6 @@ var FileCard = function (_a) {
|
|
56054
56144
|
setIsInactive(true);
|
56055
56145
|
});
|
56056
56146
|
};
|
56057
|
-
var filename = useMemo(function () {
|
56058
|
-
if (!path)
|
56059
|
-
return;
|
56060
|
-
return path.split('/').reverse()[0];
|
56061
|
-
}, [path]);
|
56062
56147
|
/**
|
56063
56148
|
* Read local file as base64 - Panel only
|
56064
56149
|
*/
|
@@ -56124,12 +56209,11 @@ var FileCard = function (_a) {
|
|
56124
56209
|
React__default.createElement("div", { style: { float: 'left', margin: '0 8px 0 0' } }, !isLoading ? React__default.createElement("div", { title: !isInactive
|
56125
56210
|
? 'Open the viewer'
|
56126
56211
|
: 'File is missing. Check run workspace' },
|
56127
|
-
React__default.createElement("span", { style: { margin: '0 8px 0 0' } }, path && getFileIcon(18, ((
|
56128
|
-
.reverse()[0]) === null || _b === void 0 ? void 0 : _b.split('.')) === null || _c === void 0 ? void 0 : _c.pop()) || '')),
|
56212
|
+
React__default.createElement("span", { style: { margin: '0 8px 0 0' } }, path && filename && getFileIcon(18, ((_b = filename === null || filename === void 0 ? void 0 : filename.split('.')) === null || _b === void 0 ? void 0 : _b.pop()) || '')),
|
56129
56213
|
label)
|
56130
56214
|
: React__default.createElement(LoadingIcon, { size: 14 })),
|
56131
56215
|
!isLoading && React__default.createElement("div", { style: { textAlign: 'right' } },
|
56132
|
-
(filename &&
|
56216
|
+
(filename && hasHtml) && (loading ? React__default.createElement(LoadingIcon, { size: 14 }) :
|
56133
56217
|
(React__default.createElement("button", { style: { all: 'unset', margin: '0 0 0 8px' }, title: 'Download HTML', onMouseOver: function () { return setHtmlOver(true); }, onMouseLeave: function () { return setHtmlOver(false); }, onClick: function (event) {
|
56134
56218
|
if (!html)
|
56135
56219
|
return;
|
@@ -56199,11 +56283,13 @@ styleInject(css_248z$2);
|
|
56199
56283
|
|
56200
56284
|
var RunContent = function (_a) {
|
56201
56285
|
var inputData = _a.inputData, projectOwner = _a.projectOwner, projectName = _a.projectName, run = _a.run, client = _a.client, title = _a.title, style = _a.style, getFileCard = _a.getFileCard, getFolderCard = _a.getFolderCard, _b = _a.isCloud, isCloud = _b === void 0 ? true : _b;
|
56286
|
+
var getTrigger = useRuns(client).getTrigger;
|
56202
56287
|
var _c = useState([]), currData = _c[0], setCurrData = _c[1];
|
56203
56288
|
var fileExplorer = usePollinationPanel().fileExplorer;
|
56204
56289
|
var _d = useState([]), currParams = _d[0], setCurrParams = _d[1];
|
56205
56290
|
var _e = useState([]), currFiles = _e[0], setCurrFiles = _e[1];
|
56206
56291
|
var _f = useState([]), currFolders = _f[0], setCurrFolders = _f[1];
|
56292
|
+
var trigger = useMemo(function () { return isCloud ? getTrigger(run) : false; }, [run, isCloud]);
|
56207
56293
|
useEffect(function () { return setCurrData(inputData); }, [inputData]);
|
56208
56294
|
useEffect(function () {
|
56209
56295
|
if (!currData || currData.length == 0)
|
@@ -56212,15 +56298,28 @@ var RunContent = function (_a) {
|
|
56212
56298
|
var files = [];
|
56213
56299
|
var folders = [];
|
56214
56300
|
currData.forEach(function (i) {
|
56301
|
+
var _a, _b, _c, _d;
|
56215
56302
|
switch (i.type) {
|
56216
56303
|
case 'StepFileInput':
|
56304
|
+
files.push({ run: run, label: i.name,
|
56305
|
+
path: (_a = i.source) === null || _a === void 0 ? void 0 : _a.path, description: i.description });
|
56306
|
+
break;
|
56217
56307
|
case 'StepFileOutput':
|
56308
|
+
var filePath = trigger
|
56309
|
+
? "outputs/".concat(i.name, "/").concat(run.id, ".zip")
|
56310
|
+
: (_b = i.source) === null || _b === void 0 ? void 0 : _b.path;
|
56218
56311
|
files.push({ run: run, label: i.name,
|
56219
|
-
path:
|
56312
|
+
path: filePath, description: i.description });
|
56220
56313
|
break;
|
56221
56314
|
case 'StepFolderInput':
|
56315
|
+
folders.push({ label: i.name, path: (_c = i.source) === null || _c === void 0 ? void 0 : _c.path,
|
56316
|
+
description: i.description });
|
56317
|
+
break;
|
56222
56318
|
case 'StepFolderOutput':
|
56223
|
-
|
56319
|
+
var folderPath = trigger
|
56320
|
+
? "outputs/".concat(i.name)
|
56321
|
+
: (_d = i.source) === null || _d === void 0 ? void 0 : _d.path;
|
56322
|
+
folders.push({ label: i.name, path: folderPath,
|
56224
56323
|
description: i.description });
|
56225
56324
|
break;
|
56226
56325
|
default:
|