1
0
Fork 0

Oh, broken exec again

This commit is contained in:
Gregory Eremin 2017-11-07 23:58:15 +01:00
parent e53a7e1ae1
commit 51f16c1581
2 changed files with 19 additions and 17 deletions

View File

@ -8,31 +8,33 @@ import './output.css'
export default class Output extends Component {
constructor(props) {
super(props)
this.state = {
job: null,
xhr: null
this.state = {job: null, xhr: null}
}
componentWillReceiveProps(props) {
if (props.jobID && props.jobID !== this.props.jobID) {
this.loadJob(props.jobID)
}
}
componentDidMount() {
let jobID = this.props.jobID
if (jobID !== null) {
this.loadCommandLog(jobID)
this.loadJobDetails(jobID)
}
this.loadJob(this.props.jobID)
}
componentWillUnmount() {
if (this.state.xhr !== null) {
if (this.state.xhr) {
this.state.xhr.abort()
}
}
loadJobDetails(id) {
if (id === null) {
return
loadJob(id) {
if (id) {
this.loadJobDetails(id)
this.loadCommandLog(id)
}
}
loadJobDetails(id) {
httpGET(api("/jobs/" + id),
(status, body) => {
this.setState({job: JSON.parse(body)})
@ -44,8 +46,8 @@ export default class Output extends Component {
}
loadCommandLog(id) {
if (id === null || this.state.xhr !== null) {
return
if (this.state.xhr) {
this.state.xhr.abort()
}
let xhr = httpStreamGET(api("/jobs/" + id + "/log"),

View File

@ -157,7 +157,7 @@ export default class Command extends Component {
function formQuery(form) {
var args = Object.keys(form.flags).map((name) => ["flags[" + name + "]", form.flags[name]])
args.push(["command", form.command])
args.push(["args", form.args])
return args.map((pair) => pair[0] + "=" + encodeURIComponent(pair[1]))
args.unshift(["command", form.command], ["args", form.args])
let param = (pair) => pair[0] + "=" + encodeURIComponent(pair[1])
return args.map(param).join("&")
}