pollination-react-io 1.58.1 → 1.60.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.
@@ -7,4 +7,6 @@ export declare const usePollinationPanel: () => {
7
7
  getFilesFromDir: (root: any) => PanelMessageOut;
8
8
  fetchLocalRun: (path?: any) => Run;
9
9
  fetchLocalJob: (path?: any) => Job;
10
+ fetchLocalLog: (path?: any) => any;
11
+ fileExplorer: (root: string) => PanelMessageOut;
10
12
  };
@@ -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) {
@@ -38005,12 +38011,17 @@ var usePollinationPanel = function () {
38005
38011
  return;
38006
38012
  return panel.FromFileToBase64(filePath);
38007
38013
  }, [panel]);
38014
+ var fileExplorer = useCallback(function (root) {
38015
+ if (!panel)
38016
+ return;
38017
+ return panel.FileExplorer(root);
38018
+ }, [panel]);
38008
38019
  var fetchLocalRun = useCallback(function (path) {
38009
38020
  if (path === void 0) { path = ''; }
38010
38021
  if (!panel)
38011
38022
  return;
38012
- var message = panel.FetchLocalRun(path);
38013
38023
  try {
38024
+ var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.status]);
38014
38025
  var run = JSON.parse(message.data);
38015
38026
  return run;
38016
38027
  }
@@ -38023,8 +38034,8 @@ var usePollinationPanel = function () {
38023
38034
  if (path === void 0) { path = ''; }
38024
38035
  if (!panel)
38025
38036
  return;
38026
- var message = panel.FetchLocalJob(path);
38027
38037
  try {
38038
+ var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.job]);
38028
38039
  var localJob = JSON.parse(message.data);
38029
38040
  var job = (_a = localJob === null || localJob === void 0 ? void 0 : localJob.LocalJob) === null || _a === void 0 ? void 0 : _a.Job;
38030
38041
  return job;
@@ -38034,13 +38045,28 @@ var usePollinationPanel = function () {
38034
38045
  return undefined;
38035
38046
  }
38036
38047
  }, [panel]);
38048
+ var fetchLocalLog = useCallback(function (path) {
38049
+ if (path === void 0) { path = ''; }
38050
+ if (!panel)
38051
+ return;
38052
+ try {
38053
+ var message = panel.FetchSimulationFile(path, SimulationFileType[SimulationFileType.logs]);
38054
+ return message.data;
38055
+ }
38056
+ catch (error) {
38057
+ // Do nothing. It is written at the end
38058
+ return undefined;
38059
+ }
38060
+ }, [panel]);
38037
38061
  return {
38038
38062
  getFileBase64: getFileBase64,
38039
38063
  saveFileBase64: saveFileBase64,
38040
38064
  fromFileToBase64: fromFileToBase64,
38041
38065
  getFilesFromDir: getFilesFromDir,
38042
38066
  fetchLocalRun: fetchLocalRun,
38043
- fetchLocalJob: fetchLocalJob
38067
+ fetchLocalJob: fetchLocalJob,
38068
+ fetchLocalLog: fetchLocalLog,
38069
+ fileExplorer: fileExplorer
38044
38070
  };
38045
38071
  };
38046
38072
 
@@ -48723,7 +48749,7 @@ var RunCard = function (_a) {
48723
48749
  var _b;
48724
48750
  var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
48725
48751
  var projectName = _a.projectName, projectOwner = _a.projectOwner, _run = _a.run, style = _a.style, authUser = _a.authUser, client = _a.client, enableClick = _a.enableClick, getTab = _a.getTab, defaultTab = _a.defaultTab, getValue = _a.getValue, _o = _a.interval, interval = _o === void 0 ? 5000 : _o, _p = _a.canWrite, canWrite = _p === void 0 ? false : _p, _q = _a.localRun, localRun = _q === void 0 ? false : _q, _r = _a.loaderNode, loaderNode = _r === void 0 ? undefined : _r;
48726
- var _s = usePollinationPanel(), fetchLocalRun = _s.fetchLocalRun, fetchLocalJob = _s.fetchLocalJob;
48752
+ var _s = usePollinationPanel(), fetchLocalRun = _s.fetchLocalRun, fetchLocalJob = _s.fetchLocalJob, fileExplorer = _s.fileExplorer;
48727
48753
  var disabled = useMemo(function () {
48728
48754
  if (!localRun)
48729
48755
  return;
@@ -48899,9 +48925,14 @@ var RunCard = function (_a) {
48899
48925
  React__default.createElement(FolderOutlined$1, { className: 'link', onClick: function (e) {
48900
48926
  e.stopPropagation();
48901
48927
  getTab(RunTabs.workspace);
48902
- toggleHover(RunTabs.workspace, true);
48903
- toggleHover(RunTabs.details, false);
48904
- toggleHover(RunTabs.debug, false);
48928
+ if (localRun) {
48929
+ fileExplorer(_run.id);
48930
+ }
48931
+ else {
48932
+ toggleHover(RunTabs.workspace, true);
48933
+ toggleHover(RunTabs.details, false);
48934
+ toggleHover(RunTabs.debug, false);
48935
+ }
48905
48936
  }, onMouseOver: function (e) {
48906
48937
  toggleHover('workspaceOver', true);
48907
48938
  }, onMouseLeave: function (e) {
@@ -48915,9 +48946,19 @@ var RunCard = function (_a) {
48915
48946
  return;
48916
48947
  e.stopPropagation();
48917
48948
  getTab(RunTabs.debug);
48918
- toggleHover(RunTabs.workspace, false);
48919
- toggleHover(RunTabs.details, false);
48920
- toggleHover(RunTabs.debug, true);
48949
+ if (localRun) {
48950
+ // 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");
48955
+ fileExplorer(path);
48956
+ }
48957
+ else {
48958
+ toggleHover(RunTabs.workspace, false);
48959
+ toggleHover(RunTabs.details, false);
48960
+ toggleHover(RunTabs.debug, true);
48961
+ }
48921
48962
  }, onMouseOver: function (e) {
48922
48963
  toggleHover('debugOver', true);
48923
48964
  }, onMouseLeave: function (e) {
@@ -49532,6 +49573,7 @@ styleInject(css_248z$2);
49532
49573
  var RunContent = function (_a) {
49533
49574
  var inputData = _a.inputData, projectOwner = _a.projectOwner, projectName = _a.projectName, studyId = _a.studyId, runId = _a.runId, client = _a.client, title = _a.title, style = _a.style, getFileCard = _a.getFileCard, getFolderCard = _a.getFolderCard, _b = _a.isCloud, isCloud = _b === void 0 ? true : _b;
49534
49575
  var _c = useState([]), currData = _c[0], setCurrData = _c[1];
49576
+ var fileExplorer = usePollinationPanel().fileExplorer;
49535
49577
  var _d = useState([]), currParams = _d[0], setCurrParams = _d[1];
49536
49578
  var _e = useState([]), currFiles = _e[0], setCurrFiles = _e[1];
49537
49579
  var _f = useState([]), currFolders = _f[0], setCurrFolders = _f[1];
@@ -49581,14 +49623,9 @@ var RunContent = function (_a) {
49581
49623
  * @param card Folder card props
49582
49624
  */
49583
49625
  var onFolderClicked = function (card) {
49584
- if (isCloud) {
49585
- getFolderCard(card);
49586
- // window.location.href = `/${projectOwner}/projects/${projectName}/studies/${studyId}/runs/${runId}/workspace?path=${card.path}`
49587
- }
49588
- else {
49589
- // TODO: Fix it later when Local is ready
49590
- getFolderCard(card);
49591
- // alert(runId.concat('/').concat(card.path))
49626
+ getFolderCard(card);
49627
+ if (!isCloud) {
49628
+ fileExplorer(card.path);
49592
49629
  }
49593
49630
  };
49594
49631
  return React__default.createElement("div", { className: 'cards-container', style: __assign({}, style) },