-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from golemfactory/beta
Beta to master
- Loading branch information
Showing
23 changed files
with
509 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
data/project-templates/react-js/src/components/NodeVersionCheck.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useExecutor } from "@golem-sdk/react"; | ||
import { LogLevel, ProposalFilters } from "@golem-sdk/golem-js"; | ||
import { NodeVersionCheckTask } from "./NodeVersionCheckTask.jsx"; | ||
|
||
export function NodeVersionCheck() { | ||
const { executor, initialize, isInitialized, isInitializing, terminate, error } = useExecutor({ | ||
// What do you want to run | ||
package: "golem/node:20-alpine", | ||
|
||
// How much you wish to spend | ||
budget: 0.5, | ||
|
||
// How do you want to select market proposals | ||
proposalFilter: ProposalFilters.limitPriceFilter({ | ||
start: 0.1, | ||
cpuPerSec: 0.1 / 3600, | ||
envPerSec: 0.1 / 3600, | ||
}), | ||
|
||
// Where you want to spend | ||
payment: { | ||
network: "polygon", | ||
}, | ||
|
||
// Control the execution of tasks | ||
maxTaskRetries: 0, | ||
|
||
// Useful for debugging | ||
logLevel: LogLevel.Info, | ||
taskTimeout: 5 * 60 * 1000, | ||
}); | ||
|
||
return ( | ||
<div className="node-version-check-wrapper"> | ||
{error && <div className="text-error">Error: {error.toString()}</div>} | ||
{isInitialized && <NodeVersionCheckTask executor={executor} />} | ||
{isInitializing && <div>Executor is initializing</div>} | ||
{!isInitialized && ( | ||
<button onClick={initialize} className="bg-progress"> | ||
Initialize executor | ||
</button> | ||
)} | ||
{isInitialized && ( | ||
<button onClick={terminate} className="bg-success"> | ||
Finish and pay for work | ||
</button> | ||
)} | ||
</div> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
data/project-templates/react-js/src/components/NodeVersionCheckTask.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useTask } from "@golem-sdk/react"; | ||
import PropTypes from "prop-types"; | ||
|
||
export function NodeVersionCheckTask({ executor }) { | ||
const { isRunning, result, run, error } = useTask(executor); | ||
|
||
const getNodeVersionTask = async (ctx) => { | ||
return (await ctx.run("node -v")).stdout?.toString() ?? "No version information"; | ||
}; | ||
|
||
return ( | ||
<div className="node-version-check-task"> | ||
<button onClick={() => run(getNodeVersionTask)} disabled={isRunning} className="bg-progress"> | ||
Check NodeJS version on provider | ||
</button> | ||
<div className="node-version-check-task-status"> | ||
{isRunning && <div className="text-progress">Task is running...</div>} | ||
{error && <div className="text-error">Task failed: {error.toString()}</div>} | ||
{result && <div className="text-success">Task result: {result}</div>} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
NodeVersionCheckTask.propTypes = { | ||
executor: PropTypes.object, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
data/project-templates/react-ts/src/components/NodeVersionCheck.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useExecutor } from "@golem-sdk/react"; | ||
import { LogLevel, ProposalFilters } from "@golem-sdk/golem-js"; | ||
import { NodeVersionCheckTask } from "./NodeVersionCheckTask"; | ||
|
||
export function NodeVersionCheck() { | ||
const { executor, initialize, isInitialized, isInitializing, terminate, error } = useExecutor({ | ||
// What do you want to run | ||
package: "golem/node:20-alpine", | ||
|
||
// How much you wish to spend | ||
budget: 0.5, | ||
|
||
// How do you want to select market proposals | ||
proposalFilter: ProposalFilters.limitPriceFilter({ | ||
start: 0.1, | ||
cpuPerSec: 0.1 / 3600, | ||
envPerSec: 0.1 / 3600, | ||
}), | ||
|
||
// Where you want to spend | ||
payment: { | ||
network: "polygon", | ||
}, | ||
|
||
// Control the execution of tasks | ||
maxTaskRetries: 0, | ||
|
||
// Useful for debugging | ||
logLevel: LogLevel.Info, | ||
taskTimeout: 5 * 60 * 1000, | ||
}); | ||
|
||
return ( | ||
<div className="node-version-check-wrapper"> | ||
{error && <div className="text-error">Error: {error.toString()}</div>} | ||
{isInitialized && executor && <NodeVersionCheckTask executor={executor} />} | ||
{isInitializing && <div>Executor is initializing</div>} | ||
{!isInitialized && ( | ||
<button onClick={initialize} className="bg-progress"> | ||
Initialize executor | ||
</button> | ||
)} | ||
{isInitialized && ( | ||
<button onClick={terminate} className="bg-success"> | ||
Finish and pay for work | ||
</button> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.