pollination-react-io 1.60.0 → 1.62.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.
@@ -12,4 +12,5 @@ export * from './useRuns';
12
12
  export * from './useSendHbjson';
13
13
  export * from './useSendMessage';
14
14
  export * from './useWindowDimensions';
15
+ export * from './usePollinationPanel';
15
16
  export * from './utilities';
@@ -1,5 +1,6 @@
1
1
  import { PanelMessageOut } from './types';
2
2
  import { Job, Run } from '@pollination-solutions/pollination-sdk';
3
+ import { ProjectJobInfo } from './useCreateStudy';
3
4
  export declare const usePollinationPanel: () => {
4
5
  getFileBase64: (key?: any, accept?: any) => PanelMessageOut;
5
6
  saveFileBase64: (key: string, file: File | Blob, subFolder: string, fileName: string) => Promise<PanelMessageOut>;
@@ -9,4 +10,6 @@ export declare const usePollinationPanel: () => {
9
10
  fetchLocalJob: (path?: any) => Job;
10
11
  fetchLocalLog: (path?: any) => any;
11
12
  fileExplorer: (root: string) => PanelMessageOut;
13
+ getPaginatedJob: (projectSlug: string, pageSize: number, curPage: number) => ProjectJobInfo[];
14
+ getJob: (projectSlug: string) => ProjectJobInfo[];
12
15
  };
@@ -37976,6 +37976,9 @@ var usePollinationPanel = function () {
37976
37976
  var panel = useMemo(function () {
37977
37977
  return checkPollinationPanel() && window.parent.chrome.webview.hostObjects.sync.study;
37978
37978
  }, []);
37979
+ /**
37980
+ * From base64 to file
37981
+ */
37979
37982
  var saveFileBase64 = useCallback(function (key, file, subFolder, fileName) { return __awaiter$1(void 0, void 0, void 0, function () {
37980
37983
  var base64;
37981
37984
  return __generator$1(this, function (_a) {
@@ -37994,6 +37997,9 @@ var usePollinationPanel = function () {
37994
37997
  }
37995
37998
  });
37996
37999
  }); }, [panel]);
38000
+ /**
38001
+ * Select a file and generate base64 representation
38002
+ */
37997
38003
  var getFileBase64 = useCallback(function (key, accept) {
37998
38004
  if (key === void 0) { key = performance.now().toString(); }
37999
38005
  if (accept === void 0) { accept = 'HBJSON|*.hbjson'; }
@@ -38001,21 +38007,33 @@ var usePollinationPanel = function () {
38001
38007
  return;
38002
38008
  return panel.GetArtifactAsBase64(key, accept);
38003
38009
  }, [panel]);
38010
+ /**
38011
+ * Get file paths from dir
38012
+ */
38004
38013
  var getFilesFromDir = useCallback(function (root) {
38005
38014
  if (!panel)
38006
38015
  return;
38007
38016
  return panel.GetFilePaths(root);
38008
38017
  }, [panel]);
38018
+ /**
38019
+ * From file path to base64
38020
+ */
38009
38021
  var fromFileToBase64 = useCallback(function (filePath) {
38010
38022
  if (!panel)
38011
38023
  return;
38012
38024
  return panel.FromFileToBase64(filePath);
38013
38025
  }, [panel]);
38026
+ /**
38027
+ * Run file explorer
38028
+ */
38014
38029
  var fileExplorer = useCallback(function (root) {
38015
38030
  if (!panel)
38016
38031
  return;
38017
38032
  return panel.FileExplorer(root);
38018
38033
  }, [panel]);
38034
+ /**
38035
+ * Fetch local run
38036
+ */
38019
38037
  var fetchLocalRun = useCallback(function (path) {
38020
38038
  if (path === void 0) { path = ''; }
38021
38039
  if (!panel)
@@ -38029,6 +38047,9 @@ var usePollinationPanel = function () {
38029
38047
  throw error;
38030
38048
  }
38031
38049
  }, [panel]);
38050
+ /**
38051
+ * Fetch local job
38052
+ */
38032
38053
  var fetchLocalJob = useCallback(function (path) {
38033
38054
  var _a;
38034
38055
  if (path === void 0) { path = ''; }
@@ -38045,6 +38066,9 @@ var usePollinationPanel = function () {
38045
38066
  return undefined;
38046
38067
  }
38047
38068
  }, [panel]);
38069
+ /**
38070
+ * Fetch local log
38071
+ */
38048
38072
  var fetchLocalLog = useCallback(function (path) {
38049
38073
  if (path === void 0) { path = ''; }
38050
38074
  if (!panel)
@@ -38058,6 +38082,44 @@ var usePollinationPanel = function () {
38058
38082
  return undefined;
38059
38083
  }
38060
38084
  }, [panel]);
38085
+ /**
38086
+ * Get array of ProjectJobInfo from DB
38087
+ * @param projectSlug Project slug <USER/PROJECT_NAME>
38088
+ * @param pageSize Page size
38089
+ * @param curPage Current page
38090
+ * @returns Array of ProjectJobInfo
38091
+ */
38092
+ var getPaginatedJob = function (projectSlug, pageSize, curPage) {
38093
+ if (!panel)
38094
+ return;
38095
+ try {
38096
+ var message = panel.GetPaginatedJob(projectSlug, pageSize, curPage);
38097
+ var arr = JSON.parse(message.data);
38098
+ return arr;
38099
+ }
38100
+ catch (error) {
38101
+ // Do nothing. It is written at the end
38102
+ return undefined;
38103
+ }
38104
+ };
38105
+ /**
38106
+ * Get array of ProjectJobInfo from DB
38107
+ * @param projectSlug Project slug
38108
+ * @returns Array of ProjectJobInfo
38109
+ */
38110
+ var getJob = function (projectSlug) {
38111
+ if (!panel)
38112
+ return;
38113
+ try {
38114
+ var message = panel.GetJob(projectSlug);
38115
+ var arr = JSON.parse(message.data);
38116
+ return arr;
38117
+ }
38118
+ catch (error) {
38119
+ // Do nothing. It is written at the end
38120
+ return undefined;
38121
+ }
38122
+ };
38061
38123
  return {
38062
38124
  getFileBase64: getFileBase64,
38063
38125
  saveFileBase64: saveFileBase64,
@@ -38066,7 +38128,9 @@ var usePollinationPanel = function () {
38066
38128
  fetchLocalRun: fetchLocalRun,
38067
38129
  fetchLocalJob: fetchLocalJob,
38068
38130
  fetchLocalLog: fetchLocalLog,
38069
- fileExplorer: fileExplorer
38131
+ fileExplorer: fileExplorer,
38132
+ getPaginatedJob: getPaginatedJob,
38133
+ getJob: getJob
38070
38134
  };
38071
38135
  };
38072
38136
 
@@ -48855,6 +48919,13 @@ var RunCard = function (_a) {
48855
48919
  var _a;
48856
48920
  setHover(__assign(__assign({}, initialValues), (_a = {}, _a[defaultTab] = true, _a)));
48857
48921
  }, [defaultTab]);
48922
+ var localStudyURLname = useMemo(function () {
48923
+ if (!localStudy)
48924
+ return;
48925
+ return localStudy.name
48926
+ .replace(/[^a-zA-Z0-9]/g, '')
48927
+ .replace(/[ ()]/g, '');
48928
+ }, [localStudy]);
48858
48929
  /**
48859
48930
  * Rendering - if error
48860
48931
  */
@@ -48882,6 +48953,9 @@ var RunCard = function (_a) {
48882
48953
  if (!localRun) {
48883
48954
  window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/studies/").concat(study.id, "/runs/").concat(run.id);
48884
48955
  }
48956
+ else {
48957
+ window.location.href = "/".concat(projectOwner, "/projects/").concat(projectName, "/localStudies/").concat(localStudyURLname, "/?path=").concat(_run.id);
48958
+ }
48885
48959
  } },
48886
48960
  React__default.createElement("div", { className: 'item1' },
48887
48961
  React__default.createElement("button", { className: 'link', style: { all: 'unset', cursor: 'pointer', marginRight: '0.75rem' }, title: 'Go to account page', onMouseOver: function (e) { return toggleHover('account', true); }, onMouseLeave: function (e) { return toggleHover('account', false); }, onClick: function (e) {
@@ -48948,10 +49022,7 @@ var RunCard = function (_a) {
48948
49022
  getTab(RunTabs.debug);
48949
49023
  if (localRun) {
48950
49024
  // Get study name
48951
- var cleanName = localStudy.name
48952
- .replace(/[^a-zA-Z0-9]/g, '')
48953
- .replace(/[ ()]/g, '');
48954
- var path = "".concat(_run.id, "/").concat(cleanName, "/__logs__/logs.log");
49025
+ var path = "".concat(_run.id, "/").concat(localStudyURLname, "/__logs__/logs.log");
48955
49026
  fileExplorer(path);
48956
49027
  }
48957
49028
  else {
@@ -50526,5 +50597,5 @@ var RunTable = function (_a) {
50526
50597
  React__default.createElement(ChevronRight$1, null)))))));
50527
50598
  };
50528
50599
 
50529
- export { APIClient, AuthUser, Avatar, Button, ComboBox, ComboFileSelector, ConditionalWrapper, ConfigureLocalRun, CreateStudy, Dropdown, FileInput, FilePreview, FormInput, GetGeometry, GetModel, InputDescription, Label, Logo, NumberInput, RadioList, RecipeForm, RunCard, RunDetails, RunRow, RunTable, SelectAccount, SelectCloudArtifacts, SelectLocalArtifacts, SelectProject, SelectRecipe, SelectRun, SelectStudy, SendGeometry, SendModel, SendResults, SettingsButton, StudyCard, TextInput, Tooltip, _defaultConfig, checkDotNet, checkPollinationPanel, checkRuby, formatBytes, getHost, recipeLinkFromSource, sendMessageDotNet, sendMessageRuby, useAPIClient, useArtifacts, useCreateStudy, useGetGeometry, useGetHbjson, useHbjsontoVTK, useJobs, useManageSettings, useRunCommand, useRuns, useSendHbjson, useSendMessage, useWindowDimensions };
50600
+ export { APIClient, AuthUser, Avatar, Button, ComboBox, ComboFileSelector, ConditionalWrapper, ConfigureLocalRun, CreateStudy, Dropdown, FileInput, FilePreview, FormInput, GetGeometry, GetModel, InputDescription, Label, Logo, NumberInput, RadioList, RecipeForm, RunCard, RunDetails, RunRow, RunTable, SelectAccount, SelectCloudArtifacts, SelectLocalArtifacts, SelectProject, SelectRecipe, SelectRun, SelectStudy, SendGeometry, SendModel, SendResults, SettingsButton, StudyCard, TextInput, Tooltip, _defaultConfig, checkDotNet, checkPollinationPanel, checkRuby, formatBytes, getHost, recipeLinkFromSource, sendMessageDotNet, sendMessageRuby, useAPIClient, useArtifacts, useCreateStudy, useGetGeometry, useGetHbjson, useHbjsontoVTK, useJobs, useManageSettings, usePollinationPanel, useRunCommand, useRuns, useSendHbjson, useSendMessage, useWindowDimensions };
50530
50601
  //# sourceMappingURL=index.esm.js.map