pollination-react-io 1.64.1 → 1.66.0
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/CreateStudy/CreateStudy.types.d.ts +2 -2
- package/build/SelectRecipe/SelectRecipe.types.d.ts +3 -3
- package/build/hooks/useCreateStudy.d.ts +4 -2
- package/build/hooks/usePollinationPanel.d.ts +1 -0
- package/build/index.esm.js +104 -17
- package/build/index.esm.js.map +1 -1
- package/build/index.js +104 -17
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
@@ -38146,6 +38146,26 @@ var usePollinationPanel = function () {
|
|
38146
38146
|
return undefined;
|
38147
38147
|
}
|
38148
38148
|
};
|
38149
|
+
/**
|
38150
|
+
* Count number of simulation by platform
|
38151
|
+
* @param projectSlug Project slug
|
38152
|
+
* @returns Object with platform count
|
38153
|
+
*/
|
38154
|
+
var getPlatforms = function (projectSlug) {
|
38155
|
+
if (!panel)
|
38156
|
+
return;
|
38157
|
+
var count = {};
|
38158
|
+
try {
|
38159
|
+
var message = panel.GetJob(projectSlug);
|
38160
|
+
var arr = JSON.parse(message.data);
|
38161
|
+
arr.forEach(function (i) { count[i.platform] = (count[i.platform] || 0) + 1; });
|
38162
|
+
return count;
|
38163
|
+
}
|
38164
|
+
catch (error) {
|
38165
|
+
// Do nothing. It is written at the end
|
38166
|
+
return undefined;
|
38167
|
+
}
|
38168
|
+
};
|
38149
38169
|
/**
|
38150
38170
|
* Delete job with the same input/ouput folder from DB
|
38151
38171
|
* @param projectSlug Project slug
|
@@ -38176,7 +38196,8 @@ var usePollinationPanel = function () {
|
|
38176
38196
|
fileExplorer: fileExplorer,
|
38177
38197
|
getPaginatedJob: getPaginatedJob,
|
38178
38198
|
getJob: getJob,
|
38179
|
-
deleteJob: deleteJob
|
38199
|
+
deleteJob: deleteJob,
|
38200
|
+
getPlatforms: getPlatforms
|
38180
38201
|
};
|
38181
38202
|
};
|
38182
38203
|
|
@@ -38348,13 +38369,14 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38348
38369
|
});
|
38349
38370
|
}, [accountName, client, processEntryCloud, projectName]);
|
38350
38371
|
var createLocalStudy = React.useCallback(function (_a, data, _b, onSuccess, key) {
|
38351
|
-
var name = _a.name, description = _a.description, recipe = _a.recipe;
|
38372
|
+
var name = _a.name, description = _a.description, recipe = _a.recipe, recipeFilter = _a.recipeFilter;
|
38352
38373
|
var localCPUCount = _b.localCPUCount, localRunFolder = _b.localRunFolder, isLocalJob = _b.isLocalJob, cloudProjectName = _b.cloudProjectName, cloudProjectOwner = _b.cloudProjectOwner;
|
38353
38374
|
if (key === void 0) { key = performance.now().toString(); }
|
38354
38375
|
return __awaiter$1(void 0, void 0, void 0, function () {
|
38355
38376
|
var job, jobInfo, response;
|
38356
|
-
|
38357
|
-
|
38377
|
+
var _c;
|
38378
|
+
return __generator$1(this, function (_d) {
|
38379
|
+
switch (_d.label) {
|
38358
38380
|
case 0:
|
38359
38381
|
if (!checkDotNet || !client || !uploadArtifact)
|
38360
38382
|
return [2 /*return*/];
|
@@ -38379,9 +38401,9 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38379
38401
|
// JobInfo mapping
|
38380
38402
|
];
|
38381
38403
|
case 1:
|
38382
|
-
job =
|
38404
|
+
job = _d.sent();
|
38383
38405
|
jobInfo = {
|
38384
|
-
RecipeOwner: '',
|
38406
|
+
RecipeOwner: (_c = recipeFilter.owner) !== null && _c !== void 0 ? _c : 'ladybug-tools',
|
38385
38407
|
Recipe: recipe,
|
38386
38408
|
Job: job,
|
38387
38409
|
IsLocalJob: isLocalJob,
|
@@ -42427,7 +42449,7 @@ var SelectRecipe = function (_a) {
|
|
42427
42449
|
var data;
|
42428
42450
|
return __generator$1(this, function (_a) {
|
42429
42451
|
switch (_a.label) {
|
42430
|
-
case 0: return [4 /*yield*/, client.projects.
|
42452
|
+
case 0: return [4 /*yield*/, client.projects.getProjectRecipeFilters(queryConfig)];
|
42431
42453
|
case 1:
|
42432
42454
|
data = (_a.sent()).data;
|
42433
42455
|
setRecipes(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
|
@@ -42450,8 +42472,8 @@ var SelectRecipe = function (_a) {
|
|
42450
42472
|
return;
|
42451
42473
|
}
|
42452
42474
|
// if (selRecipe == null) return
|
42453
|
-
if (selRecipe && selRecipe.
|
42454
|
-
comboBoxRef.current.setInputValue(selRecipe.
|
42475
|
+
if (selRecipe && selRecipe.name) {
|
42476
|
+
comboBoxRef.current.setInputValue(selRecipe.name);
|
42455
42477
|
}
|
42456
42478
|
comboBoxRef.current.selectItem(selRecipe);
|
42457
42479
|
valueRef.current = selRecipe;
|
@@ -42463,12 +42485,11 @@ var SelectRecipe = function (_a) {
|
|
42463
42485
|
return;
|
42464
42486
|
setPageNumber(projectApiRef.current.page + 1);
|
42465
42487
|
}, []);
|
42466
|
-
return (React__default["default"].createElement(ComboBox, { ref: comboBoxRef, items: (_b = recipes === null || recipes === void 0 ? void 0 : recipes.map(function (r, i) { return (__assign(__assign({}, r), { name: "".concat(r.
|
42488
|
+
return (React__default["default"].createElement(ComboBox, { ref: comboBoxRef, items: (_b = recipes === null || recipes === void 0 ? void 0 : recipes.map(function (r, i) { return (__assign(__assign({}, r), { name: "".concat(r.name, "-").concat(r.tag), id: "".concat(r.name, "-").concat(r.tag) })); })) !== null && _b !== void 0 ? _b : [], onClear: function () { return setSelRecipe(undefined); }, renderItem: function (item) { return (React__default["default"].createElement("div", { style: {
|
42467
42489
|
display: 'flex',
|
42468
42490
|
alignItems: 'center',
|
42469
42491
|
gap: 8,
|
42470
|
-
}, id: "".concat(item.
|
42471
|
-
React__default["default"].createElement(Avatar, { src: item.metadata.icon, alt: item.metadata.name, fallback: item.metadata.name, size: 24 }), "".concat(item.metadata.name, "-").concat(item.metadata.tag))); }, setSelected: setSelRecipe, inputProps: {
|
42492
|
+
}, id: "".concat(item.name, "-").concat(item.tag) }, item.name)); }, setSelected: setSelRecipe, inputProps: {
|
42472
42493
|
placeholder: 'Select a recipe...',
|
42473
42494
|
}, loading: loading, disabled: !authUser || !projectName, footer: (React__default["default"].createElement("div", { key: "footer", style: {
|
42474
42495
|
width: '100%',
|
@@ -44694,6 +44715,7 @@ var InputType;
|
|
44694
44715
|
var RecipeForm = function (_a) {
|
44695
44716
|
var _b, _c;
|
44696
44717
|
var recipe = _a.recipe, projectName = _a.projectName, projectOwner = _a.projectOwner, client = _a.client, onSubmit = _a.onSubmit, _d = _a.style, style = _d === void 0 ? {} : _d;
|
44718
|
+
var getJob = usePollinationPanel().getJob;
|
44697
44719
|
/**
|
44698
44720
|
* Input mapping
|
44699
44721
|
*/
|
@@ -44737,7 +44759,8 @@ var RecipeForm = function (_a) {
|
|
44737
44759
|
var _e = useForm({
|
44738
44760
|
resolver: Oe(schema),
|
44739
44761
|
mode: 'onChange'
|
44740
|
-
}), control = _e.control, register = _e.register, handleSubmit = _e.handleSubmit, resetField = _e.resetField, _f = _e.formState, errors = _f.errors, isValid = _f.isValid;
|
44762
|
+
}), control = _e.control, register = _e.register, handleSubmit = _e.handleSubmit, resetField = _e.resetField, watch = _e.watch, _f = _e.formState, errors = _f.errors, isValid = _f.isValid;
|
44763
|
+
var watchStudyName = watch('study-name');
|
44741
44764
|
/**
|
44742
44765
|
* Form actions
|
44743
44766
|
* @param data Output data
|
@@ -44810,6 +44833,40 @@ var RecipeForm = function (_a) {
|
|
44810
44833
|
* Local study
|
44811
44834
|
*/
|
44812
44835
|
var _g = React.useState(__assign(__assign({}, _defaultConfig), { cloudProjectName: projectName, cloudProjectOwner: projectOwner })), localConfig = _g[0], setLocalConfig = _g[1];
|
44836
|
+
/**
|
44837
|
+
* Warning for local study folder
|
44838
|
+
*/
|
44839
|
+
var localStudyWarning = React.useMemo(function () {
|
44840
|
+
if (host === 'web' || !localConfig.isLocalJob
|
44841
|
+
|| !localConfig.localRunFolder || !watchStudyName)
|
44842
|
+
return;
|
44843
|
+
var jobs = getJob("".concat(projectOwner, "/").concat(projectName));
|
44844
|
+
var studyName = watchStudyName
|
44845
|
+
.replace(/[^a-zA-Z0-9]/g, '')
|
44846
|
+
.replace(/[ ()]/g, '');
|
44847
|
+
var folderCheck = "".concat(localConfig.localRunFolder, "\\").concat(studyName);
|
44848
|
+
var status = jobs
|
44849
|
+
.filter(function (j) { return j.studyId === folderCheck; }).length !== 0;
|
44850
|
+
return status;
|
44851
|
+
}, [localConfig, watchStudyName]);
|
44852
|
+
React.useEffect(function () {
|
44853
|
+
if (!localStudyWarning)
|
44854
|
+
return;
|
44855
|
+
n$1("Study with the same name and Local run folder detected. \n If the study will be submitted it will override the previous data. \n You can change the study name or Local run folder to avoid the loss of data.", {
|
44856
|
+
duration: 8000,
|
44857
|
+
position: 'top-center',
|
44858
|
+
icon: '⚠️',
|
44859
|
+
style: { fontSize: '14px' },
|
44860
|
+
iconTheme: {
|
44861
|
+
primary: '#000',
|
44862
|
+
secondary: '#fff',
|
44863
|
+
},
|
44864
|
+
ariaProps: {
|
44865
|
+
role: 'alert',
|
44866
|
+
'aria-live': 'assertive',
|
44867
|
+
},
|
44868
|
+
});
|
44869
|
+
}, [localStudyWarning]);
|
44813
44870
|
return React__default["default"].createElement("form", { id: recipe.metadata.name, onSubmit: handleSubmit(_onSubmit, onErrors) },
|
44814
44871
|
React__default["default"].createElement("div", { className: 'cards-container-recipe', style: __assign(__assign({}, style), { padding: '20px' }) },
|
44815
44872
|
React__default["default"].createElement("div", { style: { margin: '0 0 20px 0' } },
|
@@ -44868,6 +44925,7 @@ var RecipeForm = function (_a) {
|
|
44868
44925
|
React__default["default"].createElement("div", { style: { margin: '10px 0 0 0' } },
|
44869
44926
|
host !== 'web' &&
|
44870
44927
|
React__default["default"].createElement(ConfigureLocalRun, { onChange: function (localConfig) { return setLocalConfig(localConfig); }, defaultVal: localConfig }),
|
44928
|
+
React__default["default"].createElement(Ie, null),
|
44871
44929
|
React__default["default"].createElement(Button, { type: 'submit', style: { width: '100%',
|
44872
44930
|
margin: '10px 0 0 0',
|
44873
44931
|
justifyContent: 'center' }, disabled: isValid !== true, form: recipe.metadata.name }, "Create Study")));
|
@@ -44884,11 +44942,38 @@ var CreateStudy = function (_a) {
|
|
44884
44942
|
var _d = React.useState(0), activeTabIndex = _d[0], setActiveTabIndex = _d[1];
|
44885
44943
|
var _e = React.useState(defaultAccount), selAccount = _e[0], setSelAccount = _e[1];
|
44886
44944
|
var _f = React.useState(defaultProject), selProject = _f[0], setSelProject = _f[1];
|
44887
|
-
var _g = React.useState(
|
44945
|
+
var _g = React.useState(), selRecipe = _g[0], setSelRecipe = _g[1];
|
44946
|
+
var _h = React.useState(defaultRecipe), selRecipeFilter = _h[0], setSelRecipeFilter = _h[1];
|
44947
|
+
React.useEffect(function () {
|
44948
|
+
if (!selRecipeFilter) {
|
44949
|
+
setSelRecipe(undefined);
|
44950
|
+
return;
|
44951
|
+
}
|
44952
|
+
// Remove tag from name
|
44953
|
+
var clearName = selRecipeFilter
|
44954
|
+
.name.replace(selRecipeFilter.tag, '')
|
44955
|
+
.slice(0, -1);
|
44956
|
+
// If * use latest
|
44957
|
+
var conditionalTag = selRecipeFilter.tag === '*'
|
44958
|
+
? 'latest'
|
44959
|
+
: selRecipeFilter.tag;
|
44960
|
+
client.recipes.getRecipeByTag({
|
44961
|
+
owner: selRecipeFilter.owner,
|
44962
|
+
name: clearName,
|
44963
|
+
tag: conditionalTag
|
44964
|
+
})
|
44965
|
+
.then(function (d) {
|
44966
|
+
setSelRecipe(d.data.manifest);
|
44967
|
+
}).catch(function (err) {
|
44968
|
+
_t.error('Recipe not found. Try a new tag!', { duration: 2000, position: 'top-center', style: { minWidth: '300px', fontSize: '14px' }
|
44969
|
+
});
|
44970
|
+
setSelRecipe(undefined);
|
44971
|
+
});
|
44972
|
+
}, [selRecipeFilter]);
|
44888
44973
|
// @ts-ignore
|
44889
44974
|
var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
|
44890
44975
|
var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
|
44891
|
-
var
|
44976
|
+
var _j = useCreateStudy(projectOwner, projectSlug, client), host = _j.host, createStudy = _j.createStudy, createLocalStudy = _j.createLocalStudy;
|
44892
44977
|
React.useEffect(function () {
|
44893
44978
|
if (!selRecipe)
|
44894
44979
|
return;
|
@@ -44906,7 +44991,7 @@ var CreateStudy = function (_a) {
|
|
44906
44991
|
onSuccess(projectJobInfo, true);
|
44907
44992
|
}
|
44908
44993
|
else {
|
44909
|
-
_t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '
|
44994
|
+
_t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '14px' }
|
44910
44995
|
});
|
44911
44996
|
setTimeout(function () {
|
44912
44997
|
window.location.href = "".concat(basePath, "/").concat(projectJobInfo.accountName, "/projects/").concat(projectJobInfo.projectName, "/studies/").concat(projectJobInfo.studyId, "?tab=details&perPage=5&status=null&page=1");
|
@@ -44942,6 +45027,7 @@ var CreateStudy = function (_a) {
|
|
44942
45027
|
name: name,
|
44943
45028
|
recipe: selRecipe,
|
44944
45029
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
45030
|
+
recipeFilter: selRecipeFilter
|
44945
45031
|
}, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
|
44946
45032
|
}
|
44947
45033
|
else {
|
@@ -44980,7 +45066,8 @@ var CreateStudy = function (_a) {
|
|
44980
45066
|
React__default["default"].createElement(SelectProject, { authUser: authUser, client: client, onChange: setSelProject, projectOwner: projectOwner, value: selProject })),
|
44981
45067
|
React__default["default"].createElement(Label, { label: selRecipe && selRecipe.metadata ?
|
44982
45068
|
selRecipe.metadata.name : 'Recipe' },
|
44983
|
-
React__default["default"].createElement(SelectRecipe, { authUser: authUser, client: client, projectOwner: projectOwner, projectName: selProject ? selProject.name : undefined, onChange:
|
45069
|
+
React__default["default"].createElement(SelectRecipe, { authUser: authUser, client: client, projectOwner: projectOwner, projectName: selProject ? selProject.name : undefined, onChange: setSelRecipeFilter, value: selRecipeFilter }),
|
45070
|
+
React__default["default"].createElement(Ie, null)))),
|
44984
45071
|
selRecipe &&
|
44985
45072
|
React__default["default"].createElement(React__default["default"].Fragment, null,
|
44986
45073
|
React__default["default"].createElement(TabPanel, { style: {
|