* Preview the data * * @param $type * @param $options * @return DataResponse|NotFoundResponse * @throws Exception */
($type, $options)
| 217 | * @throws Exception |
| 218 | */ |
| 219 | #[NoAdminRequired] |
| 220 | public function readPreview($type, $options) { |
| 221 | $reportMetadata = []; |
| 222 | $array = json_decode($options, true); |
| 223 | foreach ($array as $key => $value) { |
| 224 | $array[$key] = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); |
| 225 | } |
| 226 | $reportMetadata['link'] = json_encode($array); |
| 227 | $reportMetadata['type'] = $type; |
| 228 | $reportMetadata['dataset'] = 0; |
| 229 | $reportMetadata['filteroptions'] = ''; |
| 230 | $reportMetadata['user_id'] = $this->userId; |
| 231 | $reportMetadata['id'] = 0; |
| 232 | |
| 233 | $result = $this->getData($reportMetadata); |
| 234 | unset($result['options'], $result['dimensions'], $result['filterApplied'], $result['thresholds']); |
| 235 | $result['data'] = array_slice($result['data'], 0, 1); |
| 236 | |
| 237 | return new DataResponse($result, HTTP::STATUS_OK); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | /** |