pollination-react-io 1.59.0 → 1.61.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>;
@@ -7,5 +8,7 @@ export declare const usePollinationPanel: () => {
7
8
  getFilesFromDir: (root: any) => PanelMessageOut;
8
9
  fetchLocalRun: (path?: any) => Run;
9
10
  fetchLocalJob: (path?: any) => Job;
11
+ fetchLocalLog: (path?: any) => any;
10
12
  fileExplorer: (root: string) => PanelMessageOut;
13
+ getPaginatedJob: (projectSlug: string, pageSize: number, curPage: number) => ProjectJobInfo[];
11
14
  };
@@ -37950,6 +37950,12 @@ function formatBytes(bytes, decimals) {
37950
37950
  return "".concat(parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), " ").concat(sizes[i]);
37951
37951
  }
37952
37952
 
37953
+ var SimulationFileType;
37954
+ (function (SimulationFileType) {
37955
+ SimulationFileType[SimulationFileType["status"] = 0] = "status";
37956
+ SimulationFileType[SimulationFileType["job"] = 1] = "job";
37957
+ SimulationFileType[SimulationFileType["logs"] = 2] = "logs";
37958
+ })(SimulationFileType || (SimulationFileType = {}));
37953
37959
  function blobToBase64(blob) {
37954
37960
  return __awaiter$1(this, void 0, void 0, function () {
37955
37961
  return __generator$1(this, function (_a) {
@@ -37970,6 +37976,9 @@ var usePollinationPanel = function () {
37970
37976
  var panel = useMemo(function () {
37971
37977
  return checkPollinationPanel() && window.parent.chrome.webview.hostObjects.sync.study;
37972
37978
  }, []);
37979
+ /**
37980
+ * From base64 to file
37981
+ */
37973
37982
  var saveFileBase64 = useCallback(function (key, file, subFolder, fileName) { return __awaiter$1(void 0, void 0, void 0, function () {
37974
37983
  var base64;
37975
37984
  return __generator$1(this, function (_a) {
@@ -37988,6 +37997,9 @@ var usePollinationPanel = function () {
37988
37997
  }
37989
37998
  });
37990
37999
  }); }, [panel]);
38000
+ /**
38001
+ * Select a file and generate base64 representation
38002
+ */
37991
38003
  var getFileBase64 = useCallback(function (key, accept) {
37992
38004
  if (key === void 0) { key = performance.now().toString(); }
37993
38005
  if (accept === void 0) { accept = 'HBJSON|*.hbjson'; }
@@ -37995,27 +38007,39 @@ var usePollinationPanel = function () {
37995
38007
  return;
37996
38008
  return panel.GetArtifactAsBase64(key, accept);
37997
38009
  }, [panel]);
38010
+ /**
38011
+ * Get file paths from dir
38012
+ */
37998
38013
  var getFilesFromDir = useCallback(function (root) {
37999
38014
  if (!panel)
38000
38015
  return;
38001
38016
  return panel.GetFilePaths(root);
38002
38017
  }, [panel]);
38018
+ /**
38019
+ * From file path to base64
38020
+ */
38003
38021
  var fromFileToBase64 = useCallback(function (filePath) {
38004
38022
  if (!panel)
38005
38023
  return;
38006
38024
  return panel.FromFileToBase64(filePath);
38007
38025
  }, [panel]);
38026
+ /**
38027
+ * Run file explorer
38028
+ */
38008
38029
  var fileExplorer = useCallback(function (root) {
38009
38030
  if (!panel)
38010
38031
  return;
38011
38032
  return panel.FileExplorer(root);
38012
38033
  }, [panel]);
38034
+ /**
38035
+ * Fetch local run
38036
+ */
38013
38037
  var fetchLocalRun = useCallback(function (path) {
38014
38038
  if (path === void 0) { path = ''; }
38015
38039
  if (!panel)
38016
38040
  return;
38017
- var message = panel.FetchLocalRun(path);
38018
38041
  try {
38042
+ var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.status]);
38019
38043
  var run = JSON.parse(message.data);
38020
38044
  return run;
38021
38045
  }
@@ -38023,13 +38047,16 @@ var usePollinationPanel = function () {
38023
38047
  throw error;
38024
38048
  }
38025
38049
  }, [panel]);
38050
+ /**
38051
+ * Fetch local job
38052
+ */
38026
38053
  var fetchLocalJob = useCallback(function (path) {
38027
38054
  var _a;
38028
38055
  if (path === void 0) { path = ''; }
38029
38056
  if (!panel)
38030
38057
  return;
38031
- var message = panel.FetchLocalJob(path);
38032
38058
  try {
38059
+ var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.job]);
38033
38060
  var localJob = JSON.parse(message.data);
38034
38061
  var job = (_a = localJob === null || localJob === void 0 ? void 0 : localJob.LocalJob) === null || _a === void 0 ? void 0 : _a.Job;
38035
38062
  return job;
@@ -38039,6 +38066,42 @@ var usePollinationPanel = function () {
38039
38066
  return undefined;
38040
38067
  }
38041
38068
  }, [panel]);
38069
+ /**
38070
+ * Fetch local log
38071
+ */
38072
+ var fetchLocalLog = useCallback(function (path) {
38073
+ if (path === void 0) { path = ''; }
38074
+ if (!panel)
38075
+ return;
38076
+ try {
38077
+ var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.logs]);
38078
+ return message.data;
38079
+ }
38080
+ catch (error) {
38081
+ // Do nothing. It is written at the end
38082
+ return undefined;
38083
+ }
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
+ };
38042
38105
  return {
38043
38106
  getFileBase64: getFileBase64,
38044
38107
  saveFileBase64: saveFileBase64,
@@ -38046,7 +38109,9 @@ var usePollinationPanel = function () {
38046
38109
  getFilesFromDir: getFilesFromDir,
38047
38110
  fetchLocalRun: fetchLocalRun,
38048
38111
  fetchLocalJob: fetchLocalJob,
38049
- fileExplorer: fileExplorer
38112
+ fetchLocalLog: fetchLocalLog,
38113
+ fileExplorer: fileExplorer,
38114
+ getPaginatedJob: getPaginatedJob
38050
38115
  };
38051
38116
  };
38052
38117
 
@@ -48926,9 +48991,19 @@ var RunCard = function (_a) {
48926
48991
  return;
48927
48992
  e.stopPropagation();
48928
48993
  getTab(RunTabs.debug);
48929
- toggleHover(RunTabs.workspace, false);
48930
- toggleHover(RunTabs.details, false);
48931
- toggleHover(RunTabs.debug, true);
48994
+ if (localRun) {
48995
+ // Get study name
48996
+ var cleanName = localStudy.name
48997
+ .replace(/[^a-zA-Z0-9]/g, '')
48998
+ .replace(/[ ()]/g, '');
48999
+ var path = "".concat(_run.id, "/").concat(cleanName, "/__logs__/logs.log");
49000
+ fileExplorer(path);
49001
+ }
49002
+ else {
49003
+ toggleHover(RunTabs.workspace, false);
49004
+ toggleHover(RunTabs.details, false);
49005
+ toggleHover(RunTabs.debug, true);
49006
+ }
48932
49007
  }, onMouseOver: function (e) {
48933
49008
  toggleHover('debugOver', true);
48934
49009
  }, onMouseLeave: function (e) {
@@ -50496,5 +50571,5 @@ var RunTable = function (_a) {
50496
50571
  React__default.createElement(ChevronRight$1, null)))))));
50497
50572
  };
50498
50573
 
50499
- 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 };
50574
+ 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 };
50500
50575
  //# sourceMappingURL=index.esm.js.map