From e06b7d2c36d3a7b7accb00ca19dae4fe74f6cc35 Mon Sep 17 00:00:00 2001 From: Nick Herrera Date: Tue, 19 Jul 2016 14:07:34 -0700 Subject: [PATCH 1/5] fix(client): add `babel-polyfill` to fix an issue with undefined `Promise` in IE fixes #13 --- package.json | 1 + src/client.js | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 60b1068..b3f1505 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "babel-core": "^6.7.2", "babel-loader": "^6.2.4", "babel-plugin-transform-runtime": "^6.6.0", + "babel-polyfill": "^6.9.1", "babel-preset-es2015": "^6.6.0", "expect.js": "~0.3.1", "form-data": "^1.0.0-rc3", diff --git a/src/client.js b/src/client.js index e1940eb..1e8a15c 100644 --- a/src/client.js +++ b/src/client.js @@ -1,6 +1,7 @@ import fetch from 'isomorphic-fetch'; import querystring from 'querystring'; import _ from 'lodash'; +import 'babel-polyfill'; import DocumentAPI from './api/document'; import FileAPI from './api/file'; From 60860d6f0c85fa3edeb0d7272ecd615f8d57afb7 Mon Sep 17 00:00:00 2001 From: Elanna Grossman Date: Wed, 3 Aug 2016 10:46:23 -0700 Subject: [PATCH 2/5] feat(tasks): import TaskAPI to Client script --- src/client.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client.js b/src/client.js index 1e8a15c..0a73a27 100644 --- a/src/client.js +++ b/src/client.js @@ -9,6 +9,7 @@ import RoleAPI from './api/role'; import SchemaAPI from './api/schema'; import UserAPI from './api/user'; import PolicyAPI from './api/policy'; +import TaskAPI from './api/task'; export default class Client { constructor(project, token) { @@ -23,6 +24,7 @@ export default class Client { this.roles = new RoleAPI(this); this.files = new FileAPI(this); this.policy = new PolicyAPI(this); + this.tasks = new TaskAPI(this); } url(endpoint) { From 101bc0dc8215997f807ada7de4b745f720ac8438 Mon Sep 17 00:00:00 2001 From: Elanna Grossman Date: Wed, 3 Aug 2016 10:47:11 -0700 Subject: [PATCH 3/5] feat(tasks): add TaskAPI script to match the `python-montage` wrapper --- src/api/task.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/api/task.js diff --git a/src/api/task.js b/src/api/task.js new file mode 100644 index 0000000..36a90dd --- /dev/null +++ b/src/api/task.js @@ -0,0 +1,25 @@ +export default class TaskAPI { + constructor(client) { + this.client = client; + } + + run(command, image, token, timeLimit) { + const payload = { command }; + + if (image) { + payload.image = image; + } + if (token) { + payload.token = token; + } + if (timeLimit) { + payload.timeLimit = timeLimit; + } + + return this.client.request(`tasks/`, 'POST', payload); + } + + get(task_id) { + return this.client.request(`tasks/${task_id}/`); + } +} From 4d431af7b4f59f25bce3f112751729085a2be0e0 Mon Sep 17 00:00:00 2001 From: Elanna Grossman Date: Wed, 3 Aug 2016 13:27:52 -0700 Subject: [PATCH 4/5] fix(task): update object name to match server-side name --- src/api/task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/task.js b/src/api/task.js index 36a90dd..bcd38a1 100644 --- a/src/api/task.js +++ b/src/api/task.js @@ -13,7 +13,7 @@ export default class TaskAPI { payload.token = token; } if (timeLimit) { - payload.timeLimit = timeLimit; + payload.time_limit = timeLimit; } return this.client.request(`tasks/`, 'POST', payload); From eed576af5246527818c3e44e1188a320f2d03c35 Mon Sep 17 00:00:00 2001 From: Elanna Grossman Date: Tue, 6 Sep 2016 13:20:15 -0700 Subject: [PATCH 5/5] refactor(task): make optional arguments into options object --- src/api/task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/task.js b/src/api/task.js index bcd38a1..1603111 100644 --- a/src/api/task.js +++ b/src/api/task.js @@ -3,7 +3,7 @@ export default class TaskAPI { this.client = client; } - run(command, image, token, timeLimit) { + run(command, { image, token, timeLimit }) { const payload = { command }; if (image) {