UNPKG

jupyterlab-slurm

Version:

A JupyterLab extension to interface with the Slurm workload manager.

74 lines 4.38 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importStar(require("react")); const react_bootstrap_1 = require("react-bootstrap"); class JobSubmitModal extends react_1.Component { constructor(props) { super(props); this.state = { inputType: 'path', filepath: '', inlineScript: '', }; } changeInputType(inputType) { this.setState({ inputType, filepath: '', inlineScript: '' }); } updateFilepath(filepath) { this.setState({ filepath }); } updateInlineScript(inlineScript) { this.setState({ inlineScript }); } handleSubmit() { const { inputType, filepath, inlineScript } = this.state; const input = inputType === 'path' ? filepath : inlineScript; this.props.submitJob(input, inputType); } render() { const { show, onHide } = this.props; const { inputType } = this.state; return (react_1.default.createElement(react_bootstrap_1.Modal, { show: show, size: "lg", onHide: onHide, centered: true }, react_1.default.createElement(react_bootstrap_1.Modal.Header, { closeButton: true }, react_1.default.createElement(react_bootstrap_1.Modal.Title, null, "Submit a Batch Job")), react_1.default.createElement(react_bootstrap_1.Modal.Body, null, react_1.default.createElement(react_bootstrap_1.Form.Group, { controlId: "mode-selector" }, react_1.default.createElement(react_bootstrap_1.Form.Label, null, "Script type"), react_1.default.createElement(react_bootstrap_1.Form.Control, { as: "select", onChange: e => this.changeInputType(e.target.value), value: this.state.inputType, disabled: this.props.disabled }, react_1.default.createElement("option", { value: "path" }, "File"), react_1.default.createElement("option", { value: "contents" }, "Text input"))), inputType === 'path' && react_1.default.createElement(react_bootstrap_1.Form.Group, { controlId: "filepath-input" }, react_1.default.createElement(react_bootstrap_1.Form.Label, null, "File path"), react_1.default.createElement(react_bootstrap_1.Form.Control, { type: "text", placeholder: "path to file", onChange: (e) => this.updateFilepath(e.target.value), disabled: this.props.disabled })), inputType !== 'path' && react_1.default.createElement(react_bootstrap_1.Form.Group, null, react_1.default.createElement(react_bootstrap_1.Form.Label, null, "Enter your Slurm script here"), react_1.default.createElement(react_bootstrap_1.Form.Control, { as: "textarea", rows: 10, onChange: e => this.updateInlineScript(e.target.value), disabled: this.props.disabled })), react_1.default.createElement("div", null, this.props.error)), react_1.default.createElement(react_bootstrap_1.Modal.Footer, null, react_1.default.createElement(react_bootstrap_1.Button, { variant: "secondary", onClick: onHide, disabled: this.props.disabled }, "Close"), react_1.default.createElement(react_bootstrap_1.Button, { variant: "primary", onClick: this.handleSubmit.bind(this), disabled: this.props.disabled }, "Submit Job")))); } } exports.default = JobSubmitModal; //# sourceMappingURL=JobSubmitModal.js.map