pollination-react-io 1.64.0 → 1.65.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 +78 -22
- package/build/index.esm.js.map +1 -1
- package/build/index.js +78 -22
- package/build/index.js.map +1 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Project,
|
1
|
+
import type { Project, ProjectRecipeFilter, UserPrivate } from '@pollination-solutions/pollination-sdk';
|
2
2
|
import { CSSProperties } from 'react';
|
3
3
|
import { APIClient, ProjectJobInfo } from '../hooks';
|
4
4
|
import { Account } from '../SelectAccount/SelectAccount.types';
|
@@ -6,7 +6,7 @@ export declare type CreateStudyProps = {
|
|
6
6
|
style?: CSSProperties;
|
7
7
|
defaultAccount?: Account;
|
8
8
|
defaultProject?: Project;
|
9
|
-
defaultRecipe?:
|
9
|
+
defaultRecipe?: ProjectRecipeFilter;
|
10
10
|
onSuccess?: (projectJobInfo: ProjectJobInfo, isCloud: boolean) => any;
|
11
11
|
authUser?: UserPrivate;
|
12
12
|
client?: APIClient;
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import { ProjectRecipeFilter, UserPrivate } from '@pollination-solutions/pollination-sdk';
|
2
2
|
import { APIClient } from '../hooks';
|
3
3
|
export interface SelectRecipeProps {
|
4
4
|
authUser?: UserPrivate;
|
5
5
|
client?: APIClient;
|
6
6
|
projectName?: string;
|
7
7
|
projectOwner?: string;
|
8
|
-
value?:
|
9
|
-
onChange?: (recipe:
|
8
|
+
value?: ProjectRecipeFilter;
|
9
|
+
onChange?: (recipe: ProjectRecipeFilter) => void;
|
10
10
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { APIClient } from './useAPIClient';
|
2
|
-
import { RecipeInterface } from '@pollination-solutions/pollination-sdk';
|
2
|
+
import { ProjectRecipeFilter, RecipeInterface } from '@pollination-solutions/pollination-sdk';
|
3
3
|
declare global {
|
4
4
|
interface Window {
|
5
5
|
sketchup?: any;
|
@@ -10,6 +10,7 @@ interface JobArgs {
|
|
10
10
|
name: string;
|
11
11
|
recipe: RecipeInterface;
|
12
12
|
description?: string;
|
13
|
+
recipeFilter?: ProjectRecipeFilter;
|
13
14
|
}
|
14
15
|
export interface ProjectJobInfo {
|
15
16
|
accountName: string;
|
@@ -18,6 +19,7 @@ export interface ProjectJobInfo {
|
|
18
19
|
projectDescription?: string;
|
19
20
|
jobName?: string;
|
20
21
|
jobDescription?: string;
|
22
|
+
platform?: string;
|
21
23
|
}
|
22
24
|
export interface LocalConfig {
|
23
25
|
localCPUCount: number;
|
@@ -29,6 +31,6 @@ export interface LocalConfig {
|
|
29
31
|
export declare const useCreateStudy: (accountName: string, projectName: string, client: APIClient) => {
|
30
32
|
host: string;
|
31
33
|
createStudy: ({ name, recipe, description }: JobArgs, data: object, onSuccess?: (projectJobInfo: ProjectJobInfo) => void) => Promise<void>;
|
32
|
-
createLocalStudy: ({ name, description, recipe }: JobArgs, data: object, { localCPUCount, localRunFolder, isLocalJob, cloudProjectName, cloudProjectOwner }: LocalConfig, onSuccess?: (projectJobInfo: ProjectJobInfo) => void, key?: string) => Promise<any>;
|
34
|
+
createLocalStudy: ({ name, description, recipe, recipeFilter }: JobArgs, data: object, { localCPUCount, localRunFolder, isLocalJob, cloudProjectName, cloudProjectOwner }: LocalConfig, onSuccess?: (projectJobInfo: ProjectJobInfo) => void, key?: string) => Promise<any>;
|
33
35
|
};
|
34
36
|
export {};
|
@@ -13,4 +13,5 @@ export declare const usePollinationPanel: () => {
|
|
13
13
|
getPaginatedJob: (projectSlug: string, pageSize: number, curPage: number) => ProjectJobInfo[];
|
14
14
|
getJob: (projectSlug: string) => ProjectJobInfo[];
|
15
15
|
deleteJob: (projectSlug: string, path: string) => any;
|
16
|
+
getPlatforms: (projectSlug: string) => {};
|
16
17
|
};
|
package/build/index.esm.js
CHANGED
@@ -38120,6 +38120,26 @@ var usePollinationPanel = function () {
|
|
38120
38120
|
return undefined;
|
38121
38121
|
}
|
38122
38122
|
};
|
38123
|
+
/**
|
38124
|
+
* Count number of simulation by platform
|
38125
|
+
* @param projectSlug Project slug
|
38126
|
+
* @returns Object with platform count
|
38127
|
+
*/
|
38128
|
+
var getPlatforms = function (projectSlug) {
|
38129
|
+
if (!panel)
|
38130
|
+
return;
|
38131
|
+
var count = {};
|
38132
|
+
try {
|
38133
|
+
var message = panel.GetJob(projectSlug);
|
38134
|
+
var arr = JSON.parse(message.data);
|
38135
|
+
arr.forEach(function (i) { count[i.platform] = (count[i.platform] || 0) + 1; });
|
38136
|
+
return count;
|
38137
|
+
}
|
38138
|
+
catch (error) {
|
38139
|
+
// Do nothing. It is written at the end
|
38140
|
+
return undefined;
|
38141
|
+
}
|
38142
|
+
};
|
38123
38143
|
/**
|
38124
38144
|
* Delete job with the same input/ouput folder from DB
|
38125
38145
|
* @param projectSlug Project slug
|
@@ -38150,7 +38170,8 @@ var usePollinationPanel = function () {
|
|
38150
38170
|
fileExplorer: fileExplorer,
|
38151
38171
|
getPaginatedJob: getPaginatedJob,
|
38152
38172
|
getJob: getJob,
|
38153
|
-
deleteJob: deleteJob
|
38173
|
+
deleteJob: deleteJob,
|
38174
|
+
getPlatforms: getPlatforms
|
38154
38175
|
};
|
38155
38176
|
};
|
38156
38177
|
|
@@ -38322,13 +38343,14 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38322
38343
|
});
|
38323
38344
|
}, [accountName, client, processEntryCloud, projectName]);
|
38324
38345
|
var createLocalStudy = useCallback(function (_a, data, _b, onSuccess, key) {
|
38325
|
-
var name = _a.name, description = _a.description, recipe = _a.recipe;
|
38346
|
+
var name = _a.name, description = _a.description, recipe = _a.recipe, recipeFilter = _a.recipeFilter;
|
38326
38347
|
var localCPUCount = _b.localCPUCount, localRunFolder = _b.localRunFolder, isLocalJob = _b.isLocalJob, cloudProjectName = _b.cloudProjectName, cloudProjectOwner = _b.cloudProjectOwner;
|
38327
38348
|
if (key === void 0) { key = performance.now().toString(); }
|
38328
38349
|
return __awaiter$1(void 0, void 0, void 0, function () {
|
38329
38350
|
var job, jobInfo, response;
|
38330
|
-
|
38331
|
-
|
38351
|
+
var _c;
|
38352
|
+
return __generator$1(this, function (_d) {
|
38353
|
+
switch (_d.label) {
|
38332
38354
|
case 0:
|
38333
38355
|
if (!checkDotNet || !client || !uploadArtifact)
|
38334
38356
|
return [2 /*return*/];
|
@@ -38353,9 +38375,9 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38353
38375
|
// JobInfo mapping
|
38354
38376
|
];
|
38355
38377
|
case 1:
|
38356
|
-
job =
|
38378
|
+
job = _d.sent();
|
38357
38379
|
jobInfo = {
|
38358
|
-
RecipeOwner: '',
|
38380
|
+
RecipeOwner: (_c = recipeFilter.owner) !== null && _c !== void 0 ? _c : 'ladybug-tools',
|
38359
38381
|
Recipe: recipe,
|
38360
38382
|
Job: job,
|
38361
38383
|
IsLocalJob: isLocalJob,
|
@@ -41252,8 +41274,14 @@ var ComboFileSelector = function (_a) {
|
|
41252
41274
|
return (React__default.createElement(SelectCloudArtifacts, { projectOwner: projectOwner, projectName: projectName, value: value, hidden: hidden, fileNameMatch: typeof inputProps.accept === 'string' ?
|
41253
41275
|
".*(".concat(inputProps.accept.replace(/\./g, '').split(', ').join('$|'), "$)") : '.*', onChange: onChange, client: client }));
|
41254
41276
|
case 'get_local':
|
41255
|
-
return (React__default.createElement(SelectLocalArtifactNative, { onChange: handleLocalArtifactSelect, buttonLabel:
|
41256
|
-
|
41277
|
+
return (React__default.createElement(SelectLocalArtifactNative, { onChange: handleLocalArtifactSelect, buttonLabel: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.accept)
|
41278
|
+
? "Select ".concat(inputProps.accept.split(',').length > 1
|
41279
|
+
? 'any of'
|
41280
|
+
: 'an', " ").concat(inputProps.accept, " ").concat(inputProps.accept.split(',').length > 1
|
41281
|
+
? 'file types' : 'file', ".")
|
41282
|
+
: 'Select a file.', fileMatchPattern: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.accept)
|
41283
|
+
? "File types ".concat(inputProps.accept, "|*").concat(inputProps.accept.split(', ').join(';*'))
|
41284
|
+
: 'File types | *.*' }));
|
41257
41285
|
default:
|
41258
41286
|
return (React__default.createElement(FileInput, { onChange: onChange, inputProps: inputProps, accept: typeof inputProps.accept === 'string' ?
|
41259
41287
|
inputProps.accept.split(', ') : undefined }));
|
@@ -42395,7 +42423,7 @@ var SelectRecipe = function (_a) {
|
|
42395
42423
|
var data;
|
42396
42424
|
return __generator$1(this, function (_a) {
|
42397
42425
|
switch (_a.label) {
|
42398
|
-
case 0: return [4 /*yield*/, client.projects.
|
42426
|
+
case 0: return [4 /*yield*/, client.projects.getProjectRecipeFilters(queryConfig)];
|
42399
42427
|
case 1:
|
42400
42428
|
data = (_a.sent()).data;
|
42401
42429
|
setRecipes(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
|
@@ -42418,8 +42446,8 @@ var SelectRecipe = function (_a) {
|
|
42418
42446
|
return;
|
42419
42447
|
}
|
42420
42448
|
// if (selRecipe == null) return
|
42421
|
-
if (selRecipe && selRecipe.
|
42422
|
-
comboBoxRef.current.setInputValue(selRecipe.
|
42449
|
+
if (selRecipe && selRecipe.name) {
|
42450
|
+
comboBoxRef.current.setInputValue(selRecipe.name);
|
42423
42451
|
}
|
42424
42452
|
comboBoxRef.current.selectItem(selRecipe);
|
42425
42453
|
valueRef.current = selRecipe;
|
@@ -42431,12 +42459,11 @@ var SelectRecipe = function (_a) {
|
|
42431
42459
|
return;
|
42432
42460
|
setPageNumber(projectApiRef.current.page + 1);
|
42433
42461
|
}, []);
|
42434
|
-
return (React__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.
|
42462
|
+
return (React__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.createElement("div", { style: {
|
42435
42463
|
display: 'flex',
|
42436
42464
|
alignItems: 'center',
|
42437
42465
|
gap: 8,
|
42438
|
-
}, id: "".concat(item.
|
42439
|
-
React__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: {
|
42466
|
+
}, id: "".concat(item.name, "-").concat(item.tag) }, item.name)); }, setSelected: setSelRecipe, inputProps: {
|
42440
42467
|
placeholder: 'Select a recipe...',
|
42441
42468
|
}, loading: loading, disabled: !authUser || !projectName, footer: (React__default.createElement("div", { key: "footer", style: {
|
42442
42469
|
width: '100%',
|
@@ -44759,15 +44786,15 @@ var RecipeForm = function (_a) {
|
|
44759
44786
|
: React__default.createElement(TextInput, { key: i.name, inputProps: __assign(__assign({}, register(i.name)), { defaultValue: i.default }), reset: function () { return handleReset(i); } });
|
44760
44787
|
case InputType.DAGFileInput:
|
44761
44788
|
return React__default.createElement(Controller, { name: i.name, control: control, defaultValue: i.default, render: function (_a) {
|
44762
|
-
var _b, _c
|
44763
|
-
var
|
44789
|
+
var _b, _c;
|
44790
|
+
var _d = _a.field, value = _d.value, onChange = _d.onChange, field = __rest(_d, ["value", "onChange"]);
|
44764
44791
|
return React__default.createElement(ComboFileSelector, { projectOwner: projectOwner, projectName: projectName, defaultOption: i.extensions &&
|
44765
44792
|
((_b = i.extensions) === null || _b === void 0 ? void 0 : _b.includes('hbjson')) &&
|
44766
44793
|
host !== 'web' ? 'get_model' : 'get_cloud', optionsConfig: {
|
44767
|
-
get_model:
|
44794
|
+
get_model: host !== 'web' && i.extensions && i.extensions.includes('hbjson'),
|
44768
44795
|
get_local: host !== 'web',
|
44769
44796
|
get_file: host === 'web'
|
44770
|
-
}, value: value, onChange: onChange, inputProps: __assign(__assign({}, field), { accept: i.extensions && ((
|
44797
|
+
}, value: value, onChange: onChange, inputProps: __assign(__assign({}, field), { accept: i.extensions && ((_c = i.extensions) === null || _c === void 0 ? void 0 : _c.map(function (e) { return ".".concat(e); }).join(', ')) }), client: client });
|
44771
44798
|
} });
|
44772
44799
|
// Others...
|
44773
44800
|
default:
|
@@ -44852,11 +44879,38 @@ var CreateStudy = function (_a) {
|
|
44852
44879
|
var _d = useState(0), activeTabIndex = _d[0], setActiveTabIndex = _d[1];
|
44853
44880
|
var _e = useState(defaultAccount), selAccount = _e[0], setSelAccount = _e[1];
|
44854
44881
|
var _f = useState(defaultProject), selProject = _f[0], setSelProject = _f[1];
|
44855
|
-
var _g = useState(
|
44882
|
+
var _g = useState(), selRecipe = _g[0], setSelRecipe = _g[1];
|
44883
|
+
var _h = useState(defaultRecipe), selRecipeFilter = _h[0], setSelRecipeFilter = _h[1];
|
44884
|
+
useEffect(function () {
|
44885
|
+
if (!selRecipeFilter) {
|
44886
|
+
setSelRecipe(undefined);
|
44887
|
+
return;
|
44888
|
+
}
|
44889
|
+
// Remove tag from name
|
44890
|
+
var clearName = selRecipeFilter
|
44891
|
+
.name.replace(selRecipeFilter.tag, '')
|
44892
|
+
.slice(0, -1);
|
44893
|
+
// If * use latest
|
44894
|
+
var conditionalTag = selRecipeFilter.tag === '*'
|
44895
|
+
? 'latest'
|
44896
|
+
: selRecipeFilter.tag;
|
44897
|
+
client.recipes.getRecipeByTag({
|
44898
|
+
owner: selRecipeFilter.owner,
|
44899
|
+
name: clearName,
|
44900
|
+
tag: conditionalTag
|
44901
|
+
})
|
44902
|
+
.then(function (d) {
|
44903
|
+
setSelRecipe(d.data.manifest);
|
44904
|
+
}).catch(function (err) {
|
44905
|
+
_t.error('Recipe not found. Try a new tag!', { duration: 2000, position: 'top-center', style: { minWidth: '300px', fontSize: '14px' }
|
44906
|
+
});
|
44907
|
+
setSelRecipe(undefined);
|
44908
|
+
});
|
44909
|
+
}, [selRecipeFilter]);
|
44856
44910
|
// @ts-ignore
|
44857
44911
|
var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
|
44858
44912
|
var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
|
44859
|
-
var
|
44913
|
+
var _j = useCreateStudy(projectOwner, projectSlug, client), host = _j.host, createStudy = _j.createStudy, createLocalStudy = _j.createLocalStudy;
|
44860
44914
|
useEffect(function () {
|
44861
44915
|
if (!selRecipe)
|
44862
44916
|
return;
|
@@ -44874,7 +44928,7 @@ var CreateStudy = function (_a) {
|
|
44874
44928
|
onSuccess(projectJobInfo, true);
|
44875
44929
|
}
|
44876
44930
|
else {
|
44877
|
-
_t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '
|
44931
|
+
_t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '14px' }
|
44878
44932
|
});
|
44879
44933
|
setTimeout(function () {
|
44880
44934
|
window.location.href = "".concat(basePath, "/").concat(projectJobInfo.accountName, "/projects/").concat(projectJobInfo.projectName, "/studies/").concat(projectJobInfo.studyId, "?tab=details&perPage=5&status=null&page=1");
|
@@ -44910,6 +44964,7 @@ var CreateStudy = function (_a) {
|
|
44910
44964
|
name: name,
|
44911
44965
|
recipe: selRecipe,
|
44912
44966
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
44967
|
+
recipeFilter: selRecipeFilter
|
44913
44968
|
}, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
|
44914
44969
|
}
|
44915
44970
|
else {
|
@@ -44948,7 +45003,8 @@ var CreateStudy = function (_a) {
|
|
44948
45003
|
React__default.createElement(SelectProject, { authUser: authUser, client: client, onChange: setSelProject, projectOwner: projectOwner, value: selProject })),
|
44949
45004
|
React__default.createElement(Label, { label: selRecipe && selRecipe.metadata ?
|
44950
45005
|
selRecipe.metadata.name : 'Recipe' },
|
44951
|
-
React__default.createElement(SelectRecipe, { authUser: authUser, client: client, projectOwner: projectOwner, projectName: selProject ? selProject.name : undefined, onChange:
|
45006
|
+
React__default.createElement(SelectRecipe, { authUser: authUser, client: client, projectOwner: projectOwner, projectName: selProject ? selProject.name : undefined, onChange: setSelRecipeFilter, value: selRecipeFilter }),
|
45007
|
+
React__default.createElement(Ie, null)))),
|
44952
45008
|
selRecipe &&
|
44953
45009
|
React__default.createElement(React__default.Fragment, null,
|
44954
45010
|
React__default.createElement(TabPanel, { style: {
|