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/index.js CHANGED
@@ -38116,7 +38116,7 @@ var usePollinationPanel = function () {
38116
38116
  * Fetch local job
38117
38117
  */
38118
38118
  var fetchLocalJob = React.useCallback(function (path, subfolder) {
38119
- var _a;
38119
+ var _a, _b;
38120
38120
  if (path === void 0) { path = ''; }
38121
38121
  if (subfolder === void 0) { subfolder = undefined; }
38122
38122
  if (!panel)
@@ -38125,6 +38125,7 @@ var usePollinationPanel = function () {
38125
38125
  var message = panel.FetchSimulationFile(path, subfolder, SimulationFileType[SimulationFileType.job]);
38126
38126
  var localJob = JSON.parse(message.data);
38127
38127
  var job = (_a = localJob === null || localJob === void 0 ? void 0 : localJob.LocalJob) === null || _a === void 0 ? void 0 : _a.Job;
38128
+ job['author'] = (_b = localJob === null || localJob === void 0 ? void 0 : localJob.LocalJob) === null || _b === void 0 ? void 0 : _b.JobAuthor;
38128
38129
  return job;
38129
38130
  }
38130
38131
  catch (error) {
@@ -38411,11 +38412,11 @@ var useCreateStudy = function (accountName, projectName, client) {
38411
38412
  });
38412
38413
  }, [accountName, client, processEntryCloud, projectName]);
38413
38414
  var createLocalStudy = React.useCallback(function (_a, data, _b, onSuccess, key) {
38414
- var name = _a.name, description = _a.description, recipe = _a.recipe, recipeFilter = _a.recipeFilter;
38415
+ var name = _a.name, description = _a.description, recipe = _a.recipe, recipeFilter = _a.recipeFilter, authUserName = _a.authUserName;
38415
38416
  var localCPUCount = _b.localCPUCount, localRunFolder = _b.localRunFolder, isLocalJob = _b.isLocalJob, cloudProjectName = _b.cloudProjectName, cloudProjectOwner = _b.cloudProjectOwner;
38416
38417
  if (key === void 0) { key = performance.now().toString(); }
38417
38418
  return __awaiter$1(void 0, void 0, void 0, function () {
38418
- var job, jobInfo, response;
38419
+ var job, author, data_1, err_1, jobInfo, response;
38419
38420
  var _c;
38420
38421
  return __generator$1(this, function (_d) {
38421
38422
  switch (_d.label) {
@@ -38440,10 +38441,24 @@ var useCreateStudy = function (accountName, projectName, client) {
38440
38441
  }).catch(function (err) {
38441
38442
  console.error(err);
38442
38443
  })
38443
- // JobInfo mapping
38444
+ // Try getting account
38444
38445
  ];
38445
38446
  case 1:
38446
38447
  job = _d.sent();
38448
+ author = undefined;
38449
+ _d.label = 2;
38450
+ case 2:
38451
+ _d.trys.push([2, 4, , 5]);
38452
+ return [4 /*yield*/, client.accounts.getAccount({ name: authUserName })];
38453
+ case 3:
38454
+ data_1 = (_d.sent()).data;
38455
+ author = data_1;
38456
+ return [3 /*break*/, 5];
38457
+ case 4:
38458
+ err_1 = _d.sent();
38459
+ console.log(err_1);
38460
+ return [3 /*break*/, 5];
38461
+ case 5:
38447
38462
  jobInfo = {
38448
38463
  RecipeOwner: (_c = recipeFilter.owner) !== null && _c !== void 0 ? _c : 'ladybug-tools',
38449
38464
  Recipe: recipe,
@@ -38452,7 +38467,8 @@ var useCreateStudy = function (accountName, projectName, client) {
38452
38467
  ProjectSlug: "".concat(cloudProjectOwner, "/").concat(cloudProjectName),
38453
38468
  LocalCPUNumber: localCPUCount,
38454
38469
  LocalRunFolder: localRunFolder,
38455
- Platform: host
38470
+ Platform: host,
38471
+ JobAuthor: author,
38456
38472
  };
38457
38473
  console.log(jobInfo);
38458
38474
  response = window.parent.chrome.webview.hostObjects.study.RunSimulation(JSON.stringify(jobInfo))
@@ -44968,9 +44984,15 @@ var RecipeForm = function (_a) {
44968
44984
  host !== 'web' &&
44969
44985
  React__default["default"].createElement(ConfigureLocalRun, { onChange: function (localConfig) { return setLocalConfig(localConfig); }, defaultVal: localConfig }),
44970
44986
  React__default["default"].createElement(Ie, null),
44971
- React__default["default"].createElement(Button, { type: 'submit', style: { width: '100%',
44987
+ host === 'web' && React__default["default"].createElement(Button, { type: 'submit', style: { width: '100%',
44988
+ margin: '10px 0 0 0',
44989
+ justifyContent: 'center' }, disabled: isValid !== true, form: recipe.metadata.name }, "Create Study"),
44990
+ host !== 'web' && React__default["default"].createElement(Button, { type: 'submit', style: { width: '100%',
44972
44991
  margin: '10px 0 0 0',
44973
- justifyContent: 'center' }, disabled: isValid !== true, form: recipe.metadata.name }, "Create Study")));
44992
+ justifyContent: 'center' }, disabled: isValid !== true ||
44993
+ localConfig.isLocalJob
44994
+ ? localConfig.localRunFolder == null
44995
+ : false, form: recipe.metadata.name }, "Create Study")));
44974
44996
  };
44975
44997
 
44976
44998
  var defaultStyle = {
@@ -45069,7 +45091,8 @@ var CreateStudy = function (_a) {
45069
45091
  name: name,
45070
45092
  recipe: selRecipe,
45071
45093
  description: description !== null && description !== void 0 ? description : 'Study created from pollination',
45072
- recipeFilter: selRecipeFilter
45094
+ recipeFilter: selRecipeFilter,
45095
+ authUserName: authUser.username
45073
45096
  }, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
45074
45097
  }
45075
45098
  else {
@@ -49028,9 +49051,9 @@ var formatDuration = function (duration) {
49028
49051
  };
49029
49052
  var RunCard = function (_a) {
49030
49053
  var _b;
49031
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
49032
- var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, authUser = _a.authUser, client = _a.client, _o = _a.enableClick, enableClick = _o === void 0 ? true : _o, _p = _a.style, style = _p === void 0 ? {} : _p, _q = _a.getTab, getTab = _q === void 0 ? function (tab) { return undefined; } : _q, _r = _a.defaultTab, defaultTab = _r === void 0 ? RunTabs.details : _r, _s = _a.getValue, getValue = _s === void 0 ? function (run) { return undefined; } : _s, _t = _a.interval, interval = _t === void 0 ? 5000 : _t, _u = _a.canWrite, canWrite = _u === void 0 ? false : _u, _v = _a.localRun, localRun = _v === void 0 ? false : _v, _w = _a.loaderNode, loaderNode = _w === void 0 ? undefined : _w;
49033
- var _x = usePollinationPanel(), fetchLocalRun = _x.fetchLocalRun, fetchLocalJob = _x.fetchLocalJob, fileExplorer = _x.fileExplorer, deleteJob = _x.deleteJob;
49054
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
49055
+ 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;
49056
+ var _1 = usePollinationPanel(), fetchLocalRun = _1.fetchLocalRun, fetchLocalJob = _1.fetchLocalJob, fileExplorer = _1.fileExplorer, deleteJob = _1.deleteJob;
49034
49057
  var disabled = React.useMemo(function () {
49035
49058
  if (!localRun)
49036
49059
  return;
@@ -49040,16 +49063,16 @@ var RunCard = function (_a) {
49040
49063
  * Fetch run
49041
49064
  */
49042
49065
  var fetchJob = useJobs(client).fetchJob;
49043
- var _y = useRuns(client), fetchRun = _y.fetchRun, statusMap = _y.statusMap, getDuration = _y.getDuration, cancelRun = _y.cancelRun;
49044
- var _z = useWindowDimensions(), width = _z.width; _z.height;
49045
- var _0 = React.useState(false), seeDescription = _0[0], setSeeDescription = _0[1];
49046
- var _1 = React.useState(false), seeAction = _1[0], setSeeAction = _1[1];
49047
- var _2 = React.useState(false), stopRefresh = _2[0], setStopRefresh = _2[1];
49048
- var _3 = React.useState(false), isReady = _3[0], setIsReady = _3[1];
49066
+ var _2 = useRuns(client), fetchRun = _2.fetchRun, statusMap = _2.statusMap, getDuration = _2.getDuration, cancelRun = _2.cancelRun;
49067
+ var _3 = useWindowDimensions(), width = _3.width; _3.height;
49068
+ var _4 = React.useState(false), seeDescription = _4[0], setSeeDescription = _4[1];
49069
+ var _5 = React.useState(false), seeAction = _5[0], setSeeAction = _5[1];
49070
+ var _6 = React.useState(false), stopRefresh = _6[0], setStopRefresh = _6[1];
49071
+ var _7 = React.useState(false), isReady = _7[0], setIsReady = _7[1];
49049
49072
  /*
49050
49073
  * From run and stop when it is done
49051
49074
  */
49052
- var _4 = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id, _run['subfolder']]) : undefined, localRun ? fetchLocalRun : fetchRun, {
49075
+ var _8 = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id, _run['subfolder']]) : undefined, localRun ? fetchLocalRun : fetchRun, {
49053
49076
  revalidateOnFocus: false,
49054
49077
  refreshInterval: stopRefresh ? undefined : interval,
49055
49078
  fallbackData: localRun ? undefined : _run,
@@ -49064,7 +49087,7 @@ var RunCard = function (_a) {
49064
49087
  setStopRefresh(true);
49065
49088
  setIsReady(true);
49066
49089
  },
49067
- }), run = _4.data, error = _4.error;
49090
+ }), run = _8.data, error = _8.error;
49068
49091
  var sendRun = React.useCallback(function (run) { return getValue(run); }, [run]);
49069
49092
  /**
49070
49093
  * Fetch job just one time
@@ -49088,9 +49111,9 @@ var RunCard = function (_a) {
49088
49111
  return undefined;
49089
49112
  return run.status.status;
49090
49113
  }, [run]);
49091
- var _5 = React.useState(), study = _5[0], setStudy = _5[1];
49092
- var _6 = React.useState(), localStudy = _6[0], setLocalStudy = _6[1];
49093
- var _7 = React.useState(getDuration(run)), duration = _7[0], setDuration = _7[1];
49114
+ var _9 = React.useState(), study = _9[0], setStudy = _9[1];
49115
+ var _10 = React.useState(), localStudy = _10[0], setLocalStudy = _10[1];
49116
+ var _11 = React.useState(getDuration(run)), duration = _11[0], setDuration = _11[1];
49094
49117
  React.useEffect(function () {
49095
49118
  if (!run)
49096
49119
  return undefined;
@@ -49121,7 +49144,7 @@ var RunCard = function (_a) {
49121
49144
  info: false,
49122
49145
  settings: false,
49123
49146
  };
49124
- var _8 = React.useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _8[0], setHover = _8[1];
49147
+ var _12 = React.useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _12[0], setHover = _12[1];
49125
49148
  var toggleHover = React.useCallback(function (id, value) {
49126
49149
  if (value === void 0) { value = false; }
49127
49150
  setHover(function (prevHover) {
@@ -49293,15 +49316,22 @@ var RunCard = function (_a) {
49293
49316
  React__default["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') : '--'),
49294
49317
  React__default["default"].createElement("div", { className: 'item5' },
49295
49318
  React__default["default"].createElement("span", { style: { marginRight: '0.75rem' } },
49296
- React__default["default"].createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: run ? (_j = run.author) === null || _j === void 0 ? void 0 : _j.picture_url : '', size: 24 })),
49319
+ !localRun && React__default["default"].createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: run ? (_j = run.author) === null || _j === void 0 ? void 0 : _j.picture_url : '', size: 24 }),
49320
+ localRun && run && React__default["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 })),
49297
49321
  React__default["default"].createElement("a", { className: 'link', onClick: function (e) {
49322
+ var _a;
49298
49323
  e.stopPropagation();
49324
+ if (!run)
49325
+ return;
49299
49326
  if (!localRun) {
49300
- if (!run)
49301
- return;
49302
49327
  window.location.href = "/".concat(run.author.name);
49303
49328
  }
49304
- }, 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' } : {} }, run ? ((_l = (_k = run.author) === null || _k === void 0 ? void 0 : _k.display_name) !== null && _l !== void 0 ? _l : (_m = run.author) === null || _m === void 0 ? void 0 : _m.name) : '--')),
49329
+ else {
49330
+ window.location.href = "/".concat((_a = localStudy === null || localStudy === void 0 ? void 0 : localStudy.author) === null || _a === void 0 ? void 0 : _a.name);
49331
+ }
49332
+ }, 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' } : {} },
49333
+ !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),
49334
+ localRun && localStudy && ((_r = (_q = localStudy.author) === null || _q === void 0 ? void 0 : _q.display_name) !== null && _r !== void 0 ? _r : run.author.display_name))),
49305
49335
  React__default["default"].createElement("div", { className: 'item6' },
49306
49336
  React__default["default"].createElement("span", { style: { marginRight: '0.75rem' } },
49307
49337
  React__default["default"].createElement(Avatar, { color: hover.recipe ? '#40a9ff' : undefined, src: run ? run.recipe.metadata.icon : '', size: 24 })),