cloudmr-ux 4.2.8 → 4.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,19 +42,20 @@ import { AuthenticatedHttpClient } from "../../common/utilities/AuthenticatedReq
42
42
  export var submitJobs = createAsyncThunk("SUBMIT_JOBS", function (_a, thunkAPI) {
43
43
  var jobQueue = _a.jobQueue;
44
44
  return __awaiter(void 0, void 0, void 0, function () {
45
- var endpoints, responses, _i, jobQueue_1, job, job_setup_copy, _b, _c, file, res;
46
- return __generator(this, function (_d) {
47
- switch (_d.label) {
45
+ var endpoints, responses, _i, jobQueue_1, job, job_setup_copy, _b, _c, file, res, error_1, errorData, errorMsg, modeMatch, mode;
46
+ var _d, _e, _f;
47
+ return __generator(this, function (_g) {
48
+ switch (_g.label) {
48
49
  case 0:
49
50
  endpoints = getEndpoints();
50
51
  responses = [];
51
52
  _i = 0, jobQueue_1 = jobQueue;
52
- _d.label = 1;
53
+ _g.label = 1;
53
54
  case 1:
54
- if (!(_i < jobQueue_1.length)) return [3 /*break*/, 4];
55
+ if (!(_i < jobQueue_1.length)) return [3 /*break*/, 6];
55
56
  job = jobQueue_1[_i];
56
57
  if (job === undefined) {
57
- return [3 /*break*/, 3];
58
+ return [3 /*break*/, 5];
58
59
  }
59
60
  console.log(job);
60
61
  console.log(JSON.stringify(job.setup));
@@ -72,6 +73,9 @@ export var submitJobs = createAsyncThunk("SUBMIT_JOBS", function (_a, thunkAPI)
72
73
  console.log(e);
73
74
  }
74
75
  console.log(job_setup_copy);
76
+ _g.label = 2;
77
+ case 2:
78
+ _g.trys.push([2, 4, , 5]);
75
79
  return [4 /*yield*/, AuthenticatedHttpClient.post(endpoints.JOBS_API, job_setup_copy, {
76
80
  headers: {
77
81
  accept: "*/*",
@@ -79,17 +83,35 @@ export var submitJobs = createAsyncThunk("SUBMIT_JOBS", function (_a, thunkAPI)
79
83
  "Content-Type": "application/json"
80
84
  }
81
85
  })];
82
- case 2:
83
- res = _d.sent();
86
+ case 3:
87
+ res = _g.sent();
84
88
  responses.push({
85
89
  id: job.id,
86
90
  status: res.status
87
91
  });
88
- _d.label = 3;
89
- case 3:
92
+ return [3 /*break*/, 5];
93
+ case 4:
94
+ error_1 = _g.sent();
95
+ errorData = (_d = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _d === void 0 ? void 0 : _d.data;
96
+ if (((_f = (_e = errorData === null || errorData === void 0 ? void 0 : errorData.error) === null || _e === void 0 ? void 0 : _e.includes) === null || _f === void 0 ? void 0 : _f.call(_e, 'Monthly limit')) ||
97
+ ((errorData === null || errorData === void 0 ? void 0 : errorData.current_count) !== undefined && (errorData === null || errorData === void 0 ? void 0 : errorData.limit) !== undefined)) {
98
+ errorMsg = (errorData === null || errorData === void 0 ? void 0 : errorData.error) || '';
99
+ modeMatch = errorMsg.match(/(mode_[12])/);
100
+ mode = modeMatch ? modeMatch[1] : undefined;
101
+ return [2 /*return*/, thunkAPI.rejectWithValue({
102
+ error: errorMsg || 'Monthly limit reached',
103
+ current_count: errorData === null || errorData === void 0 ? void 0 : errorData.current_count,
104
+ limit: errorData === null || errorData === void 0 ? void 0 : errorData.limit,
105
+ mode: mode,
106
+ app: (errorData === null || errorData === void 0 ? void 0 : errorData.app) || (errorData === null || errorData === void 0 ? void 0 : errorData.cloudapp_name)
107
+ })];
108
+ }
109
+ // Re-throw other errors
110
+ throw error_1;
111
+ case 5:
90
112
  _i++;
91
113
  return [3 /*break*/, 1];
92
- case 4:
114
+ case 6:
93
115
  // //Update upstream jobs right after submission
94
116
  thunkAPI.dispatch(getUpstreamJobs());
95
117
  // Return whether the submission was successful
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "4.2.8",
3
+ "version": "4.2.9",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",