pollination-react-io 1.67.2 → 1.68.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/useCreateStudy.d.ts +2 -1
- package/build/index.esm.js +57 -27
- package/build/index.esm.js.map +1 -1
- package/build/index.js +57 -27
- package/build/index.js.map +1 -1
- package/package.json +1 -1
@@ -11,6 +11,7 @@ interface JobArgs {
|
|
11
11
|
recipe: RecipeInterface;
|
12
12
|
description?: string;
|
13
13
|
recipeFilter?: ProjectRecipeFilter;
|
14
|
+
authUserName?: string;
|
14
15
|
}
|
15
16
|
export interface ProjectJobInfo {
|
16
17
|
accountName: string;
|
@@ -32,6 +33,6 @@ export interface LocalConfig {
|
|
32
33
|
export declare const useCreateStudy: (accountName: string, projectName: string, client: APIClient) => {
|
33
34
|
host: string;
|
34
35
|
createStudy: ({ name, recipe, description }: JobArgs, data: object, onSuccess?: (projectJobInfo: ProjectJobInfo) => void) => Promise<void>;
|
35
|
-
createLocalStudy: ({ name, description, recipe, recipeFilter }: JobArgs, data: object, { localCPUCount, localRunFolder, isLocalJob, cloudProjectName, cloudProjectOwner }: LocalConfig, onSuccess?: (projectJobInfo: ProjectJobInfo) => void, key?: string) => Promise<any>;
|
36
|
+
createLocalStudy: ({ name, description, recipe, recipeFilter, authUserName }: JobArgs, data: object, { localCPUCount, localRunFolder, isLocalJob, cloudProjectName, cloudProjectOwner }: LocalConfig, onSuccess?: (projectJobInfo: ProjectJobInfo) => void, key?: string) => Promise<any>;
|
36
37
|
};
|
37
38
|
export {};
|
package/build/index.esm.js
CHANGED
@@ -38090,7 +38090,7 @@ var usePollinationPanel = function () {
|
|
38090
38090
|
* Fetch local job
|
38091
38091
|
*/
|
38092
38092
|
var fetchLocalJob = useCallback(function (path, subfolder) {
|
38093
|
-
var _a;
|
38093
|
+
var _a, _b;
|
38094
38094
|
if (path === void 0) { path = ''; }
|
38095
38095
|
if (subfolder === void 0) { subfolder = undefined; }
|
38096
38096
|
if (!panel)
|
@@ -38099,6 +38099,7 @@ var usePollinationPanel = function () {
|
|
38099
38099
|
var message = panel.FetchSimulationFile(path, subfolder, SimulationFileType[SimulationFileType.job]);
|
38100
38100
|
var localJob = JSON.parse(message.data);
|
38101
38101
|
var job = (_a = localJob === null || localJob === void 0 ? void 0 : localJob.LocalJob) === null || _a === void 0 ? void 0 : _a.Job;
|
38102
|
+
job['author'] = (_b = localJob === null || localJob === void 0 ? void 0 : localJob.LocalJob) === null || _b === void 0 ? void 0 : _b.JobAuthor;
|
38102
38103
|
return job;
|
38103
38104
|
}
|
38104
38105
|
catch (error) {
|
@@ -38385,11 +38386,11 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38385
38386
|
});
|
38386
38387
|
}, [accountName, client, processEntryCloud, projectName]);
|
38387
38388
|
var createLocalStudy = useCallback(function (_a, data, _b, onSuccess, key) {
|
38388
|
-
var name = _a.name, description = _a.description, recipe = _a.recipe, recipeFilter = _a.recipeFilter;
|
38389
|
+
var name = _a.name, description = _a.description, recipe = _a.recipe, recipeFilter = _a.recipeFilter, authUserName = _a.authUserName;
|
38389
38390
|
var localCPUCount = _b.localCPUCount, localRunFolder = _b.localRunFolder, isLocalJob = _b.isLocalJob, cloudProjectName = _b.cloudProjectName, cloudProjectOwner = _b.cloudProjectOwner;
|
38390
38391
|
if (key === void 0) { key = performance.now().toString(); }
|
38391
38392
|
return __awaiter$1(void 0, void 0, void 0, function () {
|
38392
|
-
var job, jobInfo, response;
|
38393
|
+
var job, author, data_1, err_1, jobInfo, response;
|
38393
38394
|
var _c;
|
38394
38395
|
return __generator$1(this, function (_d) {
|
38395
38396
|
switch (_d.label) {
|
@@ -38414,10 +38415,24 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38414
38415
|
}).catch(function (err) {
|
38415
38416
|
console.error(err);
|
38416
38417
|
})
|
38417
|
-
//
|
38418
|
+
// Try getting account
|
38418
38419
|
];
|
38419
38420
|
case 1:
|
38420
38421
|
job = _d.sent();
|
38422
|
+
author = undefined;
|
38423
|
+
_d.label = 2;
|
38424
|
+
case 2:
|
38425
|
+
_d.trys.push([2, 4, , 5]);
|
38426
|
+
return [4 /*yield*/, client.accounts.getAccount({ name: authUserName })];
|
38427
|
+
case 3:
|
38428
|
+
data_1 = (_d.sent()).data;
|
38429
|
+
author = data_1;
|
38430
|
+
return [3 /*break*/, 5];
|
38431
|
+
case 4:
|
38432
|
+
err_1 = _d.sent();
|
38433
|
+
console.log(err_1);
|
38434
|
+
return [3 /*break*/, 5];
|
38435
|
+
case 5:
|
38421
38436
|
jobInfo = {
|
38422
38437
|
RecipeOwner: (_c = recipeFilter.owner) !== null && _c !== void 0 ? _c : 'ladybug-tools',
|
38423
38438
|
Recipe: recipe,
|
@@ -38426,7 +38441,8 @@ var useCreateStudy = function (accountName, projectName, client) {
|
|
38426
38441
|
ProjectSlug: "".concat(cloudProjectOwner, "/").concat(cloudProjectName),
|
38427
38442
|
LocalCPUNumber: localCPUCount,
|
38428
38443
|
LocalRunFolder: localRunFolder,
|
38429
|
-
Platform: host
|
38444
|
+
Platform: host,
|
38445
|
+
JobAuthor: author,
|
38430
38446
|
};
|
38431
38447
|
console.log(jobInfo);
|
38432
38448
|
response = window.parent.chrome.webview.hostObjects.study.RunSimulation(JSON.stringify(jobInfo))
|
@@ -44942,9 +44958,15 @@ var RecipeForm = function (_a) {
|
|
44942
44958
|
host !== 'web' &&
|
44943
44959
|
React__default.createElement(ConfigureLocalRun, { onChange: function (localConfig) { return setLocalConfig(localConfig); }, defaultVal: localConfig }),
|
44944
44960
|
React__default.createElement(Ie, null),
|
44945
|
-
React__default.createElement(Button, { type: 'submit', style: { width: '100%',
|
44961
|
+
host === 'web' && React__default.createElement(Button, { type: 'submit', style: { width: '100%',
|
44962
|
+
margin: '10px 0 0 0',
|
44963
|
+
justifyContent: 'center' }, disabled: isValid !== true, form: recipe.metadata.name }, "Create Study"),
|
44964
|
+
host !== 'web' && React__default.createElement(Button, { type: 'submit', style: { width: '100%',
|
44946
44965
|
margin: '10px 0 0 0',
|
44947
|
-
justifyContent: 'center' }, disabled: isValid !== true
|
44966
|
+
justifyContent: 'center' }, disabled: isValid !== true ||
|
44967
|
+
localConfig.isLocalJob
|
44968
|
+
? localConfig.localRunFolder == null
|
44969
|
+
: false, form: recipe.metadata.name }, "Create Study")));
|
44948
44970
|
};
|
44949
44971
|
|
44950
44972
|
var defaultStyle = {
|
@@ -45043,7 +45065,8 @@ var CreateStudy = function (_a) {
|
|
45043
45065
|
name: name,
|
45044
45066
|
recipe: selRecipe,
|
45045
45067
|
description: description !== null && description !== void 0 ? description : 'Study created from pollination',
|
45046
|
-
recipeFilter: selRecipeFilter
|
45068
|
+
recipeFilter: selRecipeFilter,
|
45069
|
+
authUserName: authUser.username
|
45047
45070
|
}, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
|
45048
45071
|
}
|
45049
45072
|
else {
|
@@ -49002,9 +49025,9 @@ var formatDuration = function (duration) {
|
|
49002
49025
|
};
|
49003
49026
|
var RunCard = function (_a) {
|
49004
49027
|
var _b;
|
49005
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
49006
|
-
var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, authUser = _a.authUser, client = _a.client,
|
49007
|
-
var
|
49028
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
49029
|
+
var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, authUser = _a.authUser, client = _a.client, _s = _a.enableClick, enableClick = _s === void 0 ? true : _s, _t = _a.style, style = _t === void 0 ? {} : _t, _u = _a.getTab, getTab = _u === void 0 ? function (tab) { return undefined; } : _u, _v = _a.defaultTab, defaultTab = _v === void 0 ? RunTabs.details : _v, _w = _a.getValue, getValue = _w === void 0 ? function (run) { return undefined; } : _w, _x = _a.interval, interval = _x === void 0 ? 5000 : _x, _y = _a.canWrite, canWrite = _y === void 0 ? false : _y, _z = _a.localRun, localRun = _z === void 0 ? false : _z, _0 = _a.loaderNode, loaderNode = _0 === void 0 ? undefined : _0;
|
49030
|
+
var _1 = usePollinationPanel(), fetchLocalRun = _1.fetchLocalRun, fetchLocalJob = _1.fetchLocalJob, fileExplorer = _1.fileExplorer, deleteJob = _1.deleteJob;
|
49008
49031
|
var disabled = useMemo(function () {
|
49009
49032
|
if (!localRun)
|
49010
49033
|
return;
|
@@ -49014,16 +49037,16 @@ var RunCard = function (_a) {
|
|
49014
49037
|
* Fetch run
|
49015
49038
|
*/
|
49016
49039
|
var fetchJob = useJobs(client).fetchJob;
|
49017
|
-
var
|
49018
|
-
var
|
49019
|
-
var
|
49020
|
-
var
|
49021
|
-
var
|
49022
|
-
var
|
49040
|
+
var _2 = useRuns(client), fetchRun = _2.fetchRun, statusMap = _2.statusMap, getDuration = _2.getDuration, cancelRun = _2.cancelRun;
|
49041
|
+
var _3 = useWindowDimensions(), width = _3.width; _3.height;
|
49042
|
+
var _4 = useState(false), seeDescription = _4[0], setSeeDescription = _4[1];
|
49043
|
+
var _5 = useState(false), seeAction = _5[0], setSeeAction = _5[1];
|
49044
|
+
var _6 = useState(false), stopRefresh = _6[0], setStopRefresh = _6[1];
|
49045
|
+
var _7 = useState(false), isReady = _7[0], setIsReady = _7[1];
|
49023
49046
|
/*
|
49024
49047
|
* From run and stop when it is done
|
49025
49048
|
*/
|
49026
|
-
var
|
49049
|
+
var _8 = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id, _run['subfolder']]) : undefined, localRun ? fetchLocalRun : fetchRun, {
|
49027
49050
|
revalidateOnFocus: false,
|
49028
49051
|
refreshInterval: stopRefresh ? undefined : interval,
|
49029
49052
|
fallbackData: localRun ? undefined : _run,
|
@@ -49038,7 +49061,7 @@ var RunCard = function (_a) {
|
|
49038
49061
|
setStopRefresh(true);
|
49039
49062
|
setIsReady(true);
|
49040
49063
|
},
|
49041
|
-
}), run =
|
49064
|
+
}), run = _8.data, error = _8.error;
|
49042
49065
|
var sendRun = useCallback(function (run) { return getValue(run); }, [run]);
|
49043
49066
|
/**
|
49044
49067
|
* Fetch job just one time
|
@@ -49062,9 +49085,9 @@ var RunCard = function (_a) {
|
|
49062
49085
|
return undefined;
|
49063
49086
|
return run.status.status;
|
49064
49087
|
}, [run]);
|
49065
|
-
var
|
49066
|
-
var
|
49067
|
-
var
|
49088
|
+
var _9 = useState(), study = _9[0], setStudy = _9[1];
|
49089
|
+
var _10 = useState(), localStudy = _10[0], setLocalStudy = _10[1];
|
49090
|
+
var _11 = useState(getDuration(run)), duration = _11[0], setDuration = _11[1];
|
49068
49091
|
useEffect(function () {
|
49069
49092
|
if (!run)
|
49070
49093
|
return undefined;
|
@@ -49095,7 +49118,7 @@ var RunCard = function (_a) {
|
|
49095
49118
|
info: false,
|
49096
49119
|
settings: false,
|
49097
49120
|
};
|
49098
|
-
var
|
49121
|
+
var _12 = useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _12[0], setHover = _12[1];
|
49099
49122
|
var toggleHover = useCallback(function (id, value) {
|
49100
49123
|
if (value === void 0) { value = false; }
|
49101
49124
|
setHover(function (prevHover) {
|
@@ -49267,15 +49290,22 @@ var RunCard = function (_a) {
|
|
49267
49290
|
React__default.createElement("div", { className: 'item4', title: run && dayjs_min(run.status.started_at).format('[on] MMM DD YYYY [at] hh:mm') }, run ? dayjs_min(run.status.started_at).format('[on] MMM DD YYYY') : '--'),
|
49268
49291
|
React__default.createElement("div", { className: 'item5' },
|
49269
49292
|
React__default.createElement("span", { style: { marginRight: '0.75rem' } },
|
49270
|
-
React__default.createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: run ? (_j = run.author) === null || _j === void 0 ? void 0 : _j.picture_url : '', size: 24 })
|
49293
|
+
!localRun && React__default.createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: run ? (_j = run.author) === null || _j === void 0 ? void 0 : _j.picture_url : '', size: 24 }),
|
49294
|
+
localRun && run && React__default.createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: (localStudy && (localStudy === null || localStudy === void 0 ? void 0 : localStudy.author)) ? (_k = localStudy.author) === null || _k === void 0 ? void 0 : _k.picture_url : (_l = run.author) === null || _l === void 0 ? void 0 : _l.picture_url, size: 24 })),
|
49271
49295
|
React__default.createElement("a", { className: 'link', onClick: function (e) {
|
49296
|
+
var _a;
|
49272
49297
|
e.stopPropagation();
|
49298
|
+
if (!run)
|
49299
|
+
return;
|
49273
49300
|
if (!localRun) {
|
49274
|
-
if (!run)
|
49275
|
-
return;
|
49276
49301
|
window.location.href = "/".concat(run.author.name);
|
49277
49302
|
}
|
49278
|
-
|
49303
|
+
else {
|
49304
|
+
window.location.href = "/".concat((_a = localStudy === null || localStudy === void 0 ? void 0 : localStudy.author) === null || _a === void 0 ? void 0 : _a.name);
|
49305
|
+
}
|
49306
|
+
}, title: 'Go to author page', target: '_blank', rel: 'noreferrer', onMouseOver: function (e) { return toggleHover('author', true); }, onMouseLeave: function (e) { return toggleHover('author', false); }, style: hover.author ? { color: '#40a9ff' } : {} },
|
49307
|
+
!localRun && run && ((_o = (_m = run.author) === null || _m === void 0 ? void 0 : _m.display_name) !== null && _o !== void 0 ? _o : (_p = run.author) === null || _p === void 0 ? void 0 : _p.name),
|
49308
|
+
localRun && localStudy && ((_r = (_q = localStudy.author) === null || _q === void 0 ? void 0 : _q.display_name) !== null && _r !== void 0 ? _r : run.author.display_name))),
|
49279
49309
|
React__default.createElement("div", { className: 'item6' },
|
49280
49310
|
React__default.createElement("span", { style: { marginRight: '0.75rem' } },
|
49281
49311
|
React__default.createElement(Avatar, { color: hover.recipe ? '#40a9ff' : undefined, src: run ? run.recipe.metadata.icon : '', size: 24 })),
|