|
1 | | -import {V2} from "../openapi"; |
2 | | -import {handleErrors} from "./common"; |
| 1 | +import { V2 } from "../openapi"; |
| 2 | +import { handleErrors } from "./common"; |
3 | 3 |
|
4 | 4 | export const RECEIVE_LISTENERS = "RECEIVE_LISTENERS"; |
5 | 5 |
|
6 | | -export function fetchListeners(skip=0, limit=21, category=null, label=null){ |
| 6 | +export function fetchListeners( |
| 7 | + skip = 0, |
| 8 | + limit = 21, |
| 9 | + category = null, |
| 10 | + label = null |
| 11 | +) { |
7 | 12 | return (dispatch) => { |
8 | 13 | // TODO: Parameters for dates? paging? |
9 | | - return V2.ListenersService.getListenersApiV2ListenersGet(skip, limit, category, label) |
10 | | - .then(json => { |
| 14 | + return V2.ListenersService.getListenersApiV2ListenersGet( |
| 15 | + skip, |
| 16 | + limit, |
| 17 | + category, |
| 18 | + label |
| 19 | + ) |
| 20 | + .then((json) => { |
11 | 21 | dispatch({ |
12 | 22 | type: RECEIVE_LISTENERS, |
13 | 23 | listeners: json, |
14 | 24 | receivedAt: Date.now(), |
15 | 25 | }); |
16 | 26 | }) |
17 | | - .catch(reason => { |
18 | | - dispatch(handleErrors(reason, fetchListeners(skip, limit, category, label))); |
| 27 | + .catch((reason) => { |
| 28 | + dispatch( |
| 29 | + handleErrors(reason, fetchListeners(skip, limit, category, label)) |
| 30 | + ); |
19 | 31 | }); |
20 | | - |
21 | 32 | }; |
22 | 33 | } |
23 | 34 |
|
24 | 35 | export const SEARCH_LISTENERS = "SEARCH_LISTENERS"; |
25 | 36 |
|
26 | | -export function queryListeners(text, skip=0, limit=21){ |
| 37 | +export function queryListeners(text, skip = 0, limit = 21) { |
27 | 38 | return (dispatch) => { |
28 | 39 | // TODO: Parameters for dates? paging? |
29 | | - return V2.ListenersService.searchListenersApiV2ListenersSearchGet(text, skip, limit) |
30 | | - .then(json => { |
| 40 | + return V2.ListenersService.searchListenersApiV2ListenersSearchGet( |
| 41 | + text, |
| 42 | + skip, |
| 43 | + limit |
| 44 | + ) |
| 45 | + .then((json) => { |
31 | 46 | dispatch({ |
32 | 47 | type: SEARCH_LISTENERS, |
33 | 48 | listeners: json, |
34 | 49 | receivedAt: Date.now(), |
35 | 50 | }); |
36 | 51 | }) |
37 | | - .catch(reason => { |
| 52 | + .catch((reason) => { |
38 | 53 | dispatch(handleErrors(reason, queryListeners(text, skip, limit))); |
39 | 54 | }); |
40 | | - |
41 | 55 | }; |
42 | 56 | } |
43 | 57 |
|
44 | 58 | export const RECEIVE_LISTENER_CATEGORIES = "RECEIVE_LISTENER_CATEGORIES"; |
45 | | -export function fetchListenerCategories(){ |
| 59 | + |
| 60 | +export function fetchListenerCategories() { |
46 | 61 | return (dispatch) => { |
47 | 62 | return V2.ListenersService.listCategoriesApiV2ListenersCategoriesGet() |
48 | | - .then(json => { |
| 63 | + .then((json) => { |
49 | 64 | dispatch({ |
50 | 65 | type: RECEIVE_LISTENER_CATEGORIES, |
51 | 66 | categories: json, |
52 | 67 | receivedAt: Date.now(), |
53 | 68 | }); |
54 | 69 | }) |
55 | | - .catch(reason => { |
| 70 | + .catch((reason) => { |
56 | 71 | dispatch(handleErrors(reason, fetchListenerCategories())); |
57 | 72 | }); |
58 | | - } |
| 73 | + }; |
59 | 74 | } |
60 | 75 |
|
61 | 76 | export const RECEIVE_LISTENER_LABELS = "RECEIVE_LISTENER_LABELS"; |
62 | | -export function fetchListenerLabels(){ |
| 77 | + |
| 78 | +export function fetchListenerLabels() { |
63 | 79 | return (dispatch) => { |
64 | 80 | return V2.ListenersService.listDefaultLabelsApiV2ListenersDefaultLabelsGet() |
65 | | - .then(json => { |
| 81 | + .then((json) => { |
66 | 82 | dispatch({ |
67 | 83 | type: RECEIVE_LISTENER_LABELS, |
68 | 84 | labels: json, |
69 | 85 | receivedAt: Date.now(), |
70 | 86 | }); |
71 | 87 | }) |
72 | | - .catch(reason => { |
| 88 | + .catch((reason) => { |
73 | 89 | dispatch(handleErrors(reason, fetchListenerLabels())); |
74 | 90 | }); |
75 | | - } |
| 91 | + }; |
76 | 92 | } |
77 | 93 |
|
78 | | - |
79 | 94 | export const RECEIVE_LISTENER_JOBS = "RECEIVE_LISTENER_JOBS"; |
80 | | -export function fetchListenerJobs(listenerId, status, userId=null, fileId=null, datasetId = null, |
81 | | - created, skip=0, limit=100){ |
| 95 | + |
| 96 | +export function fetchListenerJobs( |
| 97 | + listenerId, |
| 98 | + status, |
| 99 | + userId = null, |
| 100 | + fileId = null, |
| 101 | + datasetId = null, |
| 102 | + created, |
| 103 | + skip = 0, |
| 104 | + limit = 100 |
| 105 | +) { |
82 | 106 | return (dispatch) => { |
83 | | - return V2.JobsService.getAllJobSummaryApiV2JobsGet(listenerId, status, userId, fileId, datasetId, created, |
84 | | - skip, limit) |
85 | | - .then(json => { |
| 107 | + return V2.JobsService.getAllJobSummaryApiV2JobsGet( |
| 108 | + listenerId, |
| 109 | + status, |
| 110 | + userId, |
| 111 | + fileId, |
| 112 | + datasetId, |
| 113 | + created, |
| 114 | + skip, |
| 115 | + limit |
| 116 | + ) |
| 117 | + .then((json) => { |
86 | 118 | dispatch({ |
87 | 119 | type: RECEIVE_LISTENER_JOBS, |
88 | 120 | jobs: json, |
89 | 121 | receivedAt: Date.now(), |
90 | 122 | }); |
91 | 123 | }) |
92 | | - .catch(reason => { |
93 | | - dispatch(handleErrors(reason, fetchListenerLabels(listenerId, status, userId=null, fileId=null, |
94 | | - datasetId = null, created, skip=0, limit=100))); |
| 124 | + .catch((reason) => { |
| 125 | + dispatch( |
| 126 | + handleErrors( |
| 127 | + reason, |
| 128 | + fetchListenerLabels( |
| 129 | + listenerId, |
| 130 | + status, |
| 131 | + (userId = null), |
| 132 | + (fileId = null), |
| 133 | + (datasetId = null), |
| 134 | + created, |
| 135 | + (skip = 0), |
| 136 | + (limit = 100) |
| 137 | + ) |
| 138 | + ) |
| 139 | + ); |
95 | 140 | }); |
96 | | - } |
| 141 | + }; |
97 | 142 | } |
98 | 143 |
|
99 | | - |
100 | 144 | export const FETCH_JOB_SUMMARY = "FETCH_JOB_SUMMARY"; |
101 | | -export function fetchJobSummary(jobId){ |
| 145 | + |
| 146 | +export function fetchJobSummary(jobId) { |
102 | 147 | return (dispatch) => { |
103 | 148 | return V2.JobsService.getJobSummaryApiV2JobsJobIdSummaryGet(jobId) |
104 | | - .then(json => { |
| 149 | + .then((json) => { |
105 | 150 | dispatch({ |
106 | 151 | type: FETCH_JOB_SUMMARY, |
107 | 152 | currJobSummary: json, |
108 | 153 | receivedAt: Date.now(), |
109 | 154 | }); |
110 | 155 | }) |
111 | | - .catch(reason => { |
| 156 | + .catch((reason) => { |
112 | 157 | dispatch(handleErrors(reason, fetchListenerLabels())); |
113 | 158 | }); |
114 | | - } |
| 159 | + }; |
115 | 160 | } |
116 | 161 |
|
| 162 | +export const RESET_JOB_SUMMARY = "RESET_JOB_SUMMARY"; |
| 163 | + |
| 164 | +export function resetJobSummary() { |
| 165 | + return (dispatch) => { |
| 166 | + dispatch({ |
| 167 | + type: RESET_JOB_SUMMARY, |
| 168 | + currJobSummary: {}, |
| 169 | + receivedAt: Date.now(), |
| 170 | + }); |
| 171 | + }; |
| 172 | +} |
117 | 173 |
|
118 | 174 | export const FETCH_JOB_UPDATES = "FETCH_JOB_UPDATES"; |
119 | | -export function fetchJobUpdates(jobId){ |
| 175 | + |
| 176 | +export function fetchJobUpdates(jobId) { |
120 | 177 | return (dispatch) => { |
121 | 178 | return V2.JobsService.getJobUpdatesApiV2JobsJobIdUpdatesGet(jobId) |
122 | | - .then(json => { |
| 179 | + .then((json) => { |
123 | 180 | dispatch({ |
124 | 181 | type: FETCH_JOB_UPDATES, |
125 | 182 | currJobUpdates: json, |
126 | 183 | receivedAt: Date.now(), |
127 | 184 | }); |
128 | 185 | }) |
129 | | - .catch(reason => { |
| 186 | + .catch((reason) => { |
130 | 187 | dispatch(handleErrors(reason, fetchListenerLabels())); |
131 | 188 | }); |
132 | | - } |
| 189 | + }; |
| 190 | +} |
| 191 | + |
| 192 | +export const RESET_JOB_UPDATES = "RESET_JOB_UPDATES"; |
| 193 | + |
| 194 | +export function resetJobUpdates() { |
| 195 | + return (dispatch) => { |
| 196 | + dispatch({ |
| 197 | + type: RESET_JOB_UPDATES, |
| 198 | + currJobUpdates: [], |
| 199 | + receivedAt: Date.now(), |
| 200 | + }); |
| 201 | + }; |
133 | 202 | } |
0 commit comments