| 129 | })); |
| 130 | }, |
| 131 | fetchDatasets() { |
| 132 | let requestUrl = OC.generateUrl('apps/analytics/dataset'); |
| 133 | let headers = new Headers(); |
| 134 | headers.append('requesttoken', OC.requestToken); |
| 135 | headers.append('OCS-APIREQUEST', 'true'); |
| 136 | |
| 137 | fetch(requestUrl, { |
| 138 | method: 'GET', |
| 139 | headers: headers |
| 140 | }) |
| 141 | .then(response => { |
| 142 | if (!response.ok) { |
| 143 | throw new Error('Dataset request failed'); |
| 144 | } |
| 145 | return response.json(); |
| 146 | }) |
| 147 | .then(data => { |
| 148 | this.items = Array.isArray(data) ? data : []; |
| 149 | }) |
| 150 | .catch(() => { |
| 151 | this.items = []; |
| 152 | }); |
| 153 | }, |
| 154 | fetchDataloads(datasetId) { |
| 155 | if (datasetId === 0) { |
| 156 | this.dataloads = []; |