pollination-react-io 1.64.1 → 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.
@@ -1,4 +1,4 @@
1
- import type { Project, RecipeInterface, UserPrivate } from '@pollination-solutions/pollination-sdk';
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?: RecipeInterface;
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 { RecipeInterface, UserPrivate } from '@pollination-solutions/pollination-sdk';
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?: RecipeInterface;
9
- onChange?: (recipe: RecipeInterface) => void;
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
  };
@@ -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
- return __generator$1(this, function (_c) {
38331
- switch (_c.label) {
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 = _c.sent();
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,
@@ -42401,7 +42423,7 @@ var SelectRecipe = function (_a) {
42401
42423
  var data;
42402
42424
  return __generator$1(this, function (_a) {
42403
42425
  switch (_a.label) {
42404
- case 0: return [4 /*yield*/, client.projects.getProjectRecipes(queryConfig)];
42426
+ case 0: return [4 /*yield*/, client.projects.getProjectRecipeFilters(queryConfig)];
42405
42427
  case 1:
42406
42428
  data = (_a.sent()).data;
42407
42429
  setRecipes(function (state) { return state ? __spreadArray(__spreadArray([], state, true), data.resources, true) : __spreadArray([], data.resources, true); });
@@ -42424,8 +42446,8 @@ var SelectRecipe = function (_a) {
42424
42446
  return;
42425
42447
  }
42426
42448
  // if (selRecipe == null) return
42427
- if (selRecipe && selRecipe.metadata && selRecipe.metadata.name) {
42428
- comboBoxRef.current.setInputValue(selRecipe.metadata.name);
42449
+ if (selRecipe && selRecipe.name) {
42450
+ comboBoxRef.current.setInputValue(selRecipe.name);
42429
42451
  }
42430
42452
  comboBoxRef.current.selectItem(selRecipe);
42431
42453
  valueRef.current = selRecipe;
@@ -42437,12 +42459,11 @@ var SelectRecipe = function (_a) {
42437
42459
  return;
42438
42460
  setPageNumber(projectApiRef.current.page + 1);
42439
42461
  }, []);
42440
- 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.metadata.name, "-").concat(r.metadata.tag), id: "".concat(r.metadata.name, "-").concat(r.metadata.tag) })); })) !== null && _b !== void 0 ? _b : [], renderItem: function (item) { return (React__default.createElement("div", { style: {
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: {
42441
42463
  display: 'flex',
42442
42464
  alignItems: 'center',
42443
42465
  gap: 8,
42444
- }, id: "".concat(item.metadata.name, "-").concat(item.metadata.tag) },
42445
- 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: {
42446
42467
  placeholder: 'Select a recipe...',
42447
42468
  }, loading: loading, disabled: !authUser || !projectName, footer: (React__default.createElement("div", { key: "footer", style: {
42448
42469
  width: '100%',
@@ -44858,11 +44879,38 @@ var CreateStudy = function (_a) {
44858
44879
  var _d = useState(0), activeTabIndex = _d[0], setActiveTabIndex = _d[1];
44859
44880
  var _e = useState(defaultAccount), selAccount = _e[0], setSelAccount = _e[1];
44860
44881
  var _f = useState(defaultProject), selProject = _f[0], setSelProject = _f[1];
44861
- var _g = useState(defaultRecipe), selRecipe = _g[0], setSelRecipe = _g[1];
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]);
44862
44910
  // @ts-ignore
44863
44911
  var projectOwner = selAccount ? ((_b = selAccount.username) !== null && _b !== void 0 ? _b : selAccount.account_name) : undefined;
44864
44912
  var projectSlug = selProject ? selProject.slug.split('/')[1] : undefined;
44865
- var _h = useCreateStudy(projectOwner, projectSlug, client), host = _h.host, createStudy = _h.createStudy, createLocalStudy = _h.createLocalStudy;
44913
+ var _j = useCreateStudy(projectOwner, projectSlug, client), host = _j.host, createStudy = _j.createStudy, createLocalStudy = _j.createLocalStudy;
44866
44914
  useEffect(function () {
44867
44915
  if (!selRecipe)
44868
44916
  return;
@@ -44880,7 +44928,7 @@ var CreateStudy = function (_a) {
44880
44928
  onSuccess(projectJobInfo, true);
44881
44929
  }
44882
44930
  else {
44883
- _t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '12px' }
44931
+ _t.success('Study submitted!', { duration: 4000, position: 'bottom-left', style: { minWidth: '300px', fontSize: '14px' }
44884
44932
  });
44885
44933
  setTimeout(function () {
44886
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");
@@ -44916,6 +44964,7 @@ var CreateStudy = function (_a) {
44916
44964
  name: name,
44917
44965
  recipe: selRecipe,
44918
44966
  description: description !== null && description !== void 0 ? description : 'Study created from pollination',
44967
+ recipeFilter: selRecipeFilter
44919
44968
  }, jobArgs, localConfig, localConfig.isLocalJob ? _onSuccessLocal : _onSuccessCloud);
44920
44969
  }
44921
44970
  else {
@@ -44954,7 +45003,8 @@ var CreateStudy = function (_a) {
44954
45003
  React__default.createElement(SelectProject, { authUser: authUser, client: client, onChange: setSelProject, projectOwner: projectOwner, value: selProject })),
44955
45004
  React__default.createElement(Label, { label: selRecipe && selRecipe.metadata ?
44956
45005
  selRecipe.metadata.name : 'Recipe' },
44957
- React__default.createElement(SelectRecipe, { authUser: authUser, client: client, projectOwner: projectOwner, projectName: selProject ? selProject.name : undefined, onChange: setSelRecipe, value: selRecipe })))),
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)))),
44958
45008
  selRecipe &&
44959
45009
  React__default.createElement(React__default.Fragment, null,
44960
45010
  React__default.createElement(TabPanel, { style: {