pollination-react-io 1.67.1 → 1.68.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.
@@ -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;
@@ -20,6 +21,7 @@ export interface ProjectJobInfo {
20
21
  jobName?: string;
21
22
  jobDescription?: string;
22
23
  platform?: string;
24
+ subfolder?: string;
23
25
  }
24
26
  export interface LocalConfig {
25
27
  localCPUCount: number;
@@ -31,6 +33,6 @@ export interface LocalConfig {
31
33
  export declare const useCreateStudy: (accountName: string, projectName: string, client: APIClient) => {
32
34
  host: string;
33
35
  createStudy: ({ name, recipe, description }: JobArgs, data: object, onSuccess?: (projectJobInfo: ProjectJobInfo) => void) => Promise<void>;
34
- 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>;
35
37
  };
36
38
  export {};
@@ -6,12 +6,12 @@ export declare const usePollinationPanel: () => {
6
6
  saveFileBase64: (key: string, file: File | Blob, subFolder: string, fileName: string) => Promise<PanelMessageOut>;
7
7
  fromFileToBase64: (filePath: string) => PanelMessageOut;
8
8
  getFilesFromDir: (root: any) => PanelMessageOut;
9
- fetchLocalRun: (path?: any) => Run;
10
- fetchLocalJob: (path?: any) => Job;
11
- fetchLocalLog: (path?: any) => any;
9
+ fetchLocalRun: (path?: any, subfolder?: any) => Run;
10
+ fetchLocalJob: (path?: any, subfolder?: any) => Job;
11
+ fetchLocalLog: (path?: any, subfolder?: any) => any;
12
12
  fileExplorer: (root: string) => PanelMessageOut;
13
13
  getPaginatedJob: (projectSlug: string, pageSize: number, curPage: number) => ProjectJobInfo[];
14
14
  getJob: (projectSlug: string) => ProjectJobInfo[];
15
- deleteJob: (projectSlug: string, path: string) => any;
15
+ deleteJob: (projectSlug: string, path: string, subfolder: string) => any;
16
16
  getPlatforms: (projectSlug: string) => {};
17
17
  };
@@ -38072,12 +38072,13 @@ var usePollinationPanel = function () {
38072
38072
  /**
38073
38073
  * Fetch local run
38074
38074
  */
38075
- var fetchLocalRun = useCallback(function (path) {
38075
+ var fetchLocalRun = useCallback(function (path, subfolder) {
38076
38076
  if (path === void 0) { path = ''; }
38077
+ if (subfolder === void 0) { subfolder = undefined; }
38077
38078
  if (!panel)
38078
38079
  return;
38079
38080
  try {
38080
- var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.status]);
38081
+ var message = panel.FetchSimulationFile(path, subfolder, SimulationFileType[SimulationFileType.status]);
38081
38082
  var run = JSON.parse(message.data);
38082
38083
  return run;
38083
38084
  }
@@ -38088,15 +38089,17 @@ var usePollinationPanel = function () {
38088
38089
  /**
38089
38090
  * Fetch local job
38090
38091
  */
38091
- var fetchLocalJob = useCallback(function (path) {
38092
- var _a;
38092
+ var fetchLocalJob = useCallback(function (path, subfolder) {
38093
+ var _a, _b;
38093
38094
  if (path === void 0) { path = ''; }
38095
+ if (subfolder === void 0) { subfolder = undefined; }
38094
38096
  if (!panel)
38095
38097
  return;
38096
38098
  try {
38097
- var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.job]);
38099
+ var message = panel.FetchSimulationFile(path, subfolder, SimulationFileType[SimulationFileType.job]);
38098
38100
  var localJob = JSON.parse(message.data);
38099
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;
38100
38103
  return job;
38101
38104
  }
38102
38105
  catch (error) {
@@ -38107,12 +38110,13 @@ var usePollinationPanel = function () {
38107
38110
  /**
38108
38111
  * Fetch local log
38109
38112
  */
38110
- var fetchLocalLog = useCallback(function (path) {
38113
+ var fetchLocalLog = useCallback(function (path, subfolder) {
38111
38114
  if (path === void 0) { path = ''; }
38115
+ if (subfolder === void 0) { subfolder = undefined; }
38112
38116
  if (!panel)
38113
38117
  return;
38114
38118
  try {
38115
- var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.logs]);
38119
+ var message = panel.FetchSimulationFile(path, subfolder, SimulationFileType[SimulationFileType.logs]);
38116
38120
  return message.data;
38117
38121
  }
38118
38122
  catch (error) {
@@ -38182,13 +38186,14 @@ var usePollinationPanel = function () {
38182
38186
  * Delete job with the same input/ouput folder from DB
38183
38187
  * @param projectSlug Project slug
38184
38188
  * @param path Location where files are
38189
+ * @param subfolder Subfolder
38185
38190
  * @returns Message with number of deleted records
38186
38191
  */
38187
- var deleteJob = function (projectSlug, path) {
38192
+ var deleteJob = function (projectSlug, path, subfolder) {
38188
38193
  if (!panel)
38189
38194
  return;
38190
38195
  try {
38191
- var message = panel.DeleteJob(projectSlug, path);
38196
+ var message = panel.DeleteJob(projectSlug, path, subfolder);
38192
38197
  var count = JSON.parse(message.data);
38193
38198
  return count;
38194
38199
  }
@@ -38381,11 +38386,11 @@ var useCreateStudy = function (accountName, projectName, client) {
38381
38386
  });
38382
38387
  }, [accountName, client, processEntryCloud, projectName]);
38383
38388
  var createLocalStudy = useCallback(function (_a, data, _b, onSuccess, key) {
38384
- 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;
38385
38390
  var localCPUCount = _b.localCPUCount, localRunFolder = _b.localRunFolder, isLocalJob = _b.isLocalJob, cloudProjectName = _b.cloudProjectName, cloudProjectOwner = _b.cloudProjectOwner;
38386
38391
  if (key === void 0) { key = performance.now().toString(); }
38387
38392
  return __awaiter$1(void 0, void 0, void 0, function () {
38388
- var job, jobInfo, response;
38393
+ var job, author, data_1, err_1, jobInfo, response;
38389
38394
  var _c;
38390
38395
  return __generator$1(this, function (_d) {
38391
38396
  switch (_d.label) {
@@ -38410,10 +38415,24 @@ var useCreateStudy = function (accountName, projectName, client) {
38410
38415
  }).catch(function (err) {
38411
38416
  console.error(err);
38412
38417
  })
38413
- // JobInfo mapping
38418
+ // Try getting account
38414
38419
  ];
38415
38420
  case 1:
38416
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:
38417
38436
  jobInfo = {
38418
38437
  RecipeOwner: (_c = recipeFilter.owner) !== null && _c !== void 0 ? _c : 'ladybug-tools',
38419
38438
  Recipe: recipe,
@@ -38422,7 +38441,8 @@ var useCreateStudy = function (accountName, projectName, client) {
38422
38441
  ProjectSlug: "".concat(cloudProjectOwner, "/").concat(cloudProjectName),
38423
38442
  LocalCPUNumber: localCPUCount,
38424
38443
  LocalRunFolder: localRunFolder,
38425
- Platform: host
38444
+ Platform: host,
38445
+ JobAuthor: author,
38426
38446
  };
38427
38447
  console.log(jobInfo);
38428
38448
  response = window.parent.chrome.webview.hostObjects.study.RunSimulation(JSON.stringify(jobInfo))
@@ -44938,9 +44958,15 @@ var RecipeForm = function (_a) {
44938
44958
  host !== 'web' &&
44939
44959
  React__default.createElement(ConfigureLocalRun, { onChange: function (localConfig) { return setLocalConfig(localConfig); }, defaultVal: localConfig }),
44940
44960
  React__default.createElement(Ie, null),
44941
- 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%',
44942
44965
  margin: '10px 0 0 0',
44943
- justifyContent: 'center' }, disabled: isValid !== true, form: recipe.metadata.name }, "Create Study")));
44966
+ justifyContent: 'center' }, disabled: isValid !== true ||
44967
+ localConfig.isLocalJob
44968
+ ? localConfig.localRunFolder == null
44969
+ : false, form: recipe.metadata.name }, "Create Study")));
44944
44970
  };
44945
44971
 
44946
44972
  var defaultStyle = {
@@ -45039,7 +45065,8 @@ var CreateStudy = function (_a) {
45039
45065
  name: name,
45040
45066
  recipe: selRecipe,
45041
45067
  description: description !== null && description !== void 0 ? description : 'Study created from pollination',
45042
- recipeFilter: selRecipeFilter
45068
+ recipeFilter: selRecipeFilter,
45069
+ authUserName: authUser.username
45043
45070
  }, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
45044
45071
  }
45045
45072
  else {
@@ -48998,9 +49025,9 @@ var formatDuration = function (duration) {
48998
49025
  };
48999
49026
  var RunCard = function (_a) {
49000
49027
  var _b;
49001
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
49002
- 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;
49003
- var _x = usePollinationPanel(), fetchLocalRun = _x.fetchLocalRun, fetchLocalJob = _x.fetchLocalJob, fileExplorer = _x.fileExplorer, deleteJob = _x.deleteJob;
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;
49004
49031
  var disabled = useMemo(function () {
49005
49032
  if (!localRun)
49006
49033
  return;
@@ -49010,23 +49037,23 @@ var RunCard = function (_a) {
49010
49037
  * Fetch run
49011
49038
  */
49012
49039
  var fetchJob = useJobs(client).fetchJob;
49013
- var _y = useRuns(client), fetchRun = _y.fetchRun, statusMap = _y.statusMap, getDuration = _y.getDuration, cancelRun = _y.cancelRun;
49014
- var _z = useWindowDimensions(), width = _z.width; _z.height;
49015
- var _0 = useState(false), seeDescription = _0[0], setSeeDescription = _0[1];
49016
- var _1 = useState(false), seeAction = _1[0], setSeeAction = _1[1];
49017
- var _2 = useState(false), stopRefresh = _2[0], setStopRefresh = _2[1];
49018
- var _3 = useState(false), isReady = _3[0], setIsReady = _3[1];
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];
49019
49046
  /*
49020
49047
  * From run and stop when it is done
49021
49048
  */
49022
- var _4 = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id]) : undefined, localRun ? fetchLocalRun : fetchRun, {
49049
+ var _8 = useSWR(authUser && _run ? (!localRun ? [projectOwner, projectName, _run.id] : [_run.id, _run['subfolder']]) : undefined, localRun ? fetchLocalRun : fetchRun, {
49023
49050
  revalidateOnFocus: false,
49024
49051
  refreshInterval: stopRefresh ? undefined : interval,
49025
49052
  fallbackData: localRun ? undefined : _run,
49026
49053
  errorRetryCount: 3,
49027
49054
  onSuccess: function (run, key, config) {
49028
49055
  if (localRun) {
49029
- var jobInfo = fetchLocalJob(_run.id);
49056
+ var jobInfo = fetchLocalJob(_run.id, _run['subfolder']);
49030
49057
  setLocalStudy(jobInfo);
49031
49058
  } // It is written at the end of the simulation
49032
49059
  sendRun(run);
@@ -49034,7 +49061,7 @@ var RunCard = function (_a) {
49034
49061
  setStopRefresh(true);
49035
49062
  setIsReady(true);
49036
49063
  },
49037
- }), run = _4.data, error = _4.error;
49064
+ }), run = _8.data, error = _8.error;
49038
49065
  var sendRun = useCallback(function (run) { return getValue(run); }, [run]);
49039
49066
  /**
49040
49067
  * Fetch job just one time
@@ -49058,9 +49085,9 @@ var RunCard = function (_a) {
49058
49085
  return undefined;
49059
49086
  return run.status.status;
49060
49087
  }, [run]);
49061
- var _5 = useState(), study = _5[0], setStudy = _5[1];
49062
- var _6 = useState(), localStudy = _6[0], setLocalStudy = _6[1];
49063
- var _7 = useState(getDuration(run)), duration = _7[0], setDuration = _7[1];
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];
49064
49091
  useEffect(function () {
49065
49092
  if (!run)
49066
49093
  return undefined;
@@ -49091,7 +49118,7 @@ var RunCard = function (_a) {
49091
49118
  info: false,
49092
49119
  settings: false,
49093
49120
  };
49094
- var _8 = useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _8[0], setHover = _8[1];
49121
+ var _12 = useState(__assign(__assign({}, initialValues), (_b = {}, _b[defaultTab] = true, _b))), hover = _12[0], setHover = _12[1];
49095
49122
  var toggleHover = useCallback(function (id, value) {
49096
49123
  if (value === void 0) { value = false; }
49097
49124
  setHover(function (prevHover) {
@@ -49141,7 +49168,7 @@ var RunCard = function (_a) {
49141
49168
  window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id, "/runs/").concat(run.id);
49142
49169
  }
49143
49170
  else {
49144
- window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/localStudies/").concat(localStudyURLname, "/?path=").concat(_run.id);
49171
+ window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/localStudies/").concat(localStudyURLname, "/?path=").concat(_run.id, "&subfolder=").concat(_run['subfolder']);
49145
49172
  }
49146
49173
  } },
49147
49174
  React__default.createElement("div", { className: 'item1' },
@@ -49212,7 +49239,9 @@ var RunCard = function (_a) {
49212
49239
  getTab(RunTabs.debug);
49213
49240
  if (localRun) {
49214
49241
  // Get study name
49215
- var path = "".concat(_run.id, "/").concat(localStudyURLname, "/__logs__/logs.log");
49242
+ var path = !_run['subfolder']
49243
+ ? "".concat(_run.id, "/").concat(localStudyURLname, "/__logs__/logs.log")
49244
+ : "".concat(_run.id, "/").concat(_run['subfolder'], "/").concat(localStudyURLname, "/__logs__/logs.log");
49216
49245
  fileExplorer(path);
49217
49246
  }
49218
49247
  else {
@@ -49261,15 +49290,22 @@ var RunCard = function (_a) {
49261
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') : '--'),
49262
49291
  React__default.createElement("div", { className: 'item5' },
49263
49292
  React__default.createElement("span", { style: { marginRight: '0.75rem' } },
49264
- 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 && localStudy && React__default.createElement(Avatar, { color: hover.author ? '#40a9ff' : undefined, src: (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 })),
49265
49295
  React__default.createElement("a", { className: 'link', onClick: function (e) {
49296
+ var _a;
49266
49297
  e.stopPropagation();
49298
+ if (!run)
49299
+ return;
49267
49300
  if (!localRun) {
49268
- if (!run)
49269
- return;
49270
49301
  window.location.href = "/".concat(run.author.name);
49271
49302
  }
49272
- }, 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) : '--')),
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))),
49273
49309
  React__default.createElement("div", { className: 'item6' },
49274
49310
  React__default.createElement("span", { style: { marginRight: '0.75rem' } },
49275
49311
  React__default.createElement(Avatar, { color: hover.recipe ? '#40a9ff' : undefined, src: run ? run.recipe.metadata.icon : '', size: 24 })),
@@ -49319,9 +49355,9 @@ var RunCard = function (_a) {
49319
49355
  e.stopPropagation();
49320
49356
  if (!run)
49321
49357
  return;
49322
- var count = deleteJob("".concat(projectOwner, "/").concat(projectName), _run.id);
49358
+ var count = deleteJob("".concat(projectOwner, "/").concat(projectName), _run.id, _run['subfolder']);
49323
49359
  if (count > 0) {
49324
- if (window.location.href.includes("?path=".concat(_run.id))) {
49360
+ if (window.location.href.includes("?path=")) {
49325
49361
  window.history.back();
49326
49362
  }
49327
49363
  else {