Oh, broken exec again
This commit is contained in:
parent
e53a7e1ae1
commit
51f16c1581
|
@ -8,31 +8,33 @@ import './output.css'
|
||||||
export default class Output extends Component {
|
export default class Output extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {job: null, xhr: null}
|
||||||
job: null,
|
}
|
||||||
xhr: null
|
|
||||||
|
componentWillReceiveProps(props) {
|
||||||
|
if (props.jobID && props.jobID !== this.props.jobID) {
|
||||||
|
this.loadJob(props.jobID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let jobID = this.props.jobID
|
this.loadJob(this.props.jobID)
|
||||||
if (jobID !== null) {
|
|
||||||
this.loadCommandLog(jobID)
|
|
||||||
this.loadJobDetails(jobID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (this.state.xhr !== null) {
|
if (this.state.xhr) {
|
||||||
this.state.xhr.abort()
|
this.state.xhr.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadJobDetails(id) {
|
loadJob(id) {
|
||||||
if (id === null) {
|
if (id) {
|
||||||
return
|
this.loadJobDetails(id)
|
||||||
|
this.loadCommandLog(id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadJobDetails(id) {
|
||||||
httpGET(api("/jobs/" + id),
|
httpGET(api("/jobs/" + id),
|
||||||
(status, body) => {
|
(status, body) => {
|
||||||
this.setState({job: JSON.parse(body)})
|
this.setState({job: JSON.parse(body)})
|
||||||
|
@ -44,8 +46,8 @@ export default class Output extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadCommandLog(id) {
|
loadCommandLog(id) {
|
||||||
if (id === null || this.state.xhr !== null) {
|
if (this.state.xhr) {
|
||||||
return
|
this.state.xhr.abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
let xhr = httpStreamGET(api("/jobs/" + id + "/log"),
|
let xhr = httpStreamGET(api("/jobs/" + id + "/log"),
|
||||||
|
|
|
@ -157,7 +157,7 @@ export default class Command extends Component {
|
||||||
|
|
||||||
function formQuery(form) {
|
function formQuery(form) {
|
||||||
var args = Object.keys(form.flags).map((name) => ["flags[" + name + "]", form.flags[name]])
|
var args = Object.keys(form.flags).map((name) => ["flags[" + name + "]", form.flags[name]])
|
||||||
args.push(["command", form.command])
|
args.unshift(["command", form.command], ["args", form.args])
|
||||||
args.push(["args", form.args])
|
let param = (pair) => pair[0] + "=" + encodeURIComponent(pair[1])
|
||||||
return args.map((pair) => pair[0] + "=" + encodeURIComponent(pair[1]))
|
return args.map(param).join("&")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue