/** * Update all charts for one specific user * @param string $userName */ private function updateChartsForUser($userName) { $charts = $this->configService->getChartsByUsername($userName); foreach ($charts as $chartConfig) { $this->updateChart($chartConfig); } }
/** * 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())); }
/** * @param $id * @return mixed * @throws \OCA\ocUsageCharts\Exception\ChartServiceException */ public function getChart($id) { $config = $this->config->getChartConfigById($id); return $this->getChartByConfig($config); }