| 152 | }); |
| 153 | }, |
| 154 | fetchDataloads(datasetId) { |
| 155 | if (datasetId === 0) { |
| 156 | this.dataloads = []; |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | let requestUrl = OC.generateUrl('apps/analytics/dataload') + '?' + new URLSearchParams({ |
| 161 | datasetId: datasetId |
| 162 | }); |
| 163 | let headers = new Headers(); |
| 164 | headers.append('requesttoken', OC.requestToken); |
| 165 | headers.append('OCS-APIREQUEST', 'true'); |
| 166 | |
| 167 | fetch(requestUrl, { |
| 168 | method: 'GET', |
| 169 | headers: headers |
| 170 | }) |
| 171 | .then(response => { |
| 172 | if (!response.ok) { |
| 173 | throw new Error('Dataload request failed'); |
| 174 | } |
| 175 | return response.json(); |
| 176 | }) |
| 177 | .then(data => { |
| 178 | this.dataloads = Array.isArray(data.dataloads) ? data.dataloads : []; |
| 179 | }) |
| 180 | .catch(() => { |
| 181 | this.dataloads = []; |
| 182 | }); |
| 183 | }, |
| 184 | }, |
| 185 | }; |
| 186 | |