public function testGetChartUsage() { $return = array('1'); $this->dataProvider->method('getChartUsage')->with($this->configMock)->willReturn($return); $data = $this->chartService->getChartUsage($this->configMock); $this->assertEquals($return, $data); }
/** * JSON Ajax call * * @NoAdminRequired * @NoCSRFRequired * @param string $id * @return JSONResponse */ public function loadChart($id) { $chart = $this->chartService->getChart($id); $usage = $this->chartService->getChartUsage($chart->getConfig()); $response = new JSONResponse($usage); return $response; }
/** * Show a single chart * * @NoCSRFRequired * @NoAdminRequired * @param string $id * @return TemplateResponse */ public function displayChart($id) { $chartConfigs = $this->configService->getCharts(); foreach($chartConfigs as $config) { if ( $config->getId() == $id ) { break; } } $chart = $this->chartService->getChartByConfig($config); $templateName = 'main'; // will use templates/main.php return new TemplateResponse($this->appName, $templateName, array('chart' => $chart, 'configs' => $chartConfigs, 'requesttoken' => \OC_Util::callRegister())); }
/** * Show a single chart * * @NoCSRFRequired * @NoAdminRequired * @param string $id * @throws \OCA\ocUsageCharts\Exception\ChartServiceException * * @return TemplateResponse */ public function displayChart($id) { $selectedConfig = null; $chartConfigs = $this->configService->getChartsForLoggedInUser(); foreach ($chartConfigs as $config) { if ($config->getId() == $id) { $selectedConfig = $config; break; } } if (is_null($selectedConfig)) { throw new ChartServiceException('No config found for selected ID'); } $chart = $this->chartService->getChartByConfig($selectedConfig); $templateName = 'main'; // will use templates/main.php return new TemplateResponse($this->appName, $templateName, array('chart' => $chart, 'configs' => $chartConfigs, 'requesttoken' => \OC_Util::callRegister())); }