Skip to content

Commit

Permalink
WIP #617 Fixed client calls
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyWhitaker committed Aug 4, 2016
1 parent 0838786 commit 571aee4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/visualizers/panels/ForgeActionButton/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ define([
.filter(job => this.isRunning(job)) // get running jobs
.forEach(job => this.stopJob(job)); // stop them

this.client.setAttributes(execNode, 'status', 'canceled');
this.client.setAttributes(execNode.getId(), 'status', 'canceled');
this.client.completeTransaction();
}
}
Expand Down
23 changes: 15 additions & 8 deletions src/visualizers/panels/ForgeActionButton/ForgeActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,15 @@ define([
});
};

ForgeActionButton.prototype.isRunning = function() {
var node = this.client.getNode(this._currentNodeId),
baseId = node.getBaseId(),
base = this.client.getNode(baseId),
type = base.getAttribute('name');
ForgeActionButton.prototype.isRunning = function(node) {
var baseId,
base,
type;

node = node || this.client.getNode(this._currentNodeId);
baseId = node.getBaseId();
base = this.client.getNode(baseId);
type = base.getAttribute('name');

if (type === 'Execution') {
return node.getAttribute('status') === 'running';
Expand All @@ -374,18 +378,21 @@ define([

ForgeActionButton.prototype.stopJob = function(job) {
var jobHash,
jobId,
secret;

job = job || this.client.getNode(this._currentNodeId);
jobId = job.getId();
jobHash = job.getAttribute('jobId');
secret = job.getAttribute('secret');
if (!jobHash || !secret) {
this.logger.error('Cannot stop job. Missing jobHash or secret');
return;
}

this.client.delAttributes(job, 'jobId');
this.client.delAttributes(job, 'secret');
this.client.setAttributes(job, 'status', 'canceled');
this.client.delAttributes(jobId, 'jobId');
this.client.delAttributes(jobId, 'secret');
this.client.setAttributes(jobId, 'status', 'canceled');

return this._executor.cancelJob(jobHash, secret)
.then(() => this.logger.info(`${jobHash} has been cancelled!`))
Expand Down

0 comments on commit 571aee4

Please sign in to comment.