Commit bc24a2d8 authored by Phil Renaud's avatar Phil Renaud
Browse files

Fetch job spec from URL

parent 50001d11
Branches unavailable
No related merge requests found
Showing with 38 additions and 0 deletions
+38 -0
......@@ -41,6 +41,22 @@ export default class JobEditor extends Component {
}
}
_newSpecURL = '';
/**
* Performs a fetch to the passed URL and returns the content back as raw text
* @param {string} url
*/
@action async fetchFromURL(event) {
event.preventDefault();
if (this._newSpecURL) {
const spec = await fetch(this._newSpecURL).then((response) =>
response.text()
);
this.updateCode(spec);
this._newSpecURL = '';
}
}
_context = null;
parseError = null;
planError = null;
......
......@@ -129,3 +129,18 @@ $dark-bright: lighten($dark, 15%);
background-color: $dark-2;
}
}
.job-from-url {
display: block;
margin-bottom: 1.5rem;
display: grid;
grid-template-columns: 1fr auto;
gap: 0.25rem 1rem;
& > label {
grid-column: -1 / 1;
}
input {
padding: 0.25rem;
width: 100%;
}
}
......@@ -63,6 +63,13 @@
/>
</div>
</div>
<form class="job-from-url" {{on "submit" this.fetchFromURL}}>
<label for="url-input">Or, fetch a valid Nomad job spec from a URL</label>
<Input id="url-input" @type="url" placeholder="https://example.com/job.nomad" @value={{this._newSpecURL}}
/>
<button type="submit">Fetch</button>
</form>
<div class="content is-associative">
<button
class="button is-primary {{if this.plan.isRunning 'is-loading'}}"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment