/**
  * Return the chart data you want to return based on the ChartConfig
  *
  * @return array
  */
 public function getChartUsage()
 {
     $return = array();
     if ($this->user->isAdminUser($this->user->getSignedInUsername())) {
         $users = $this->users->getSystemUsers();
         foreach ($users as $username) {
             $return[$username] = $this->getCollectionByUsername($username);
         }
     } else {
         $username = $this->chartConfig->getUsername();
         $return[$username] = $this->getCollectionByUsername($username);
     }
     return $return;
 }
 /**
  * Return the chart data you want to return based on the ChartConfig
  *
  * @param User $user
  * @param ActivityUsageRepository|StorageUsageRepository $repository
  * @param ChartConfig $chartConfig
  * @return mixed
  */
 public function getChartUsage(User $user, $repository, ChartConfig $chartConfig)
 {
     if ($user->isAdminUser($user->getSignedInUsername())) {
         $data = $repository->findAllPerMonth();
     } else {
         $data = $repository->findAllPerMonth($chartConfig->getUsername());
     }
     return $data;
 }
 /**
  * Entry point for the chart system
  *
  * @NoCSRFRequired
  * @NoAdminRequired
  * @return TemplateResponse|RedirectResponse
  */
 public function frontpage()
 {
     if (!empty($this->useApi) && $this->user->isAdminUser($this->user->getSignedInUsername())) {
         $templateName = 'kibana';
         return new TemplateResponse($this->appName, $templateName, array('url' => $this->useApi, 'requesttoken' => \OC_Util::callRegister()));
     }
     $this->createDefaultChartsForLoggedInUser();
     $charts = $this->configService->getChartsForLoggedInUser();
     $id = $charts[0]->getId();
     $url = \OCP\Util::linkToRoute('ocusagecharts.chart.display_chart', array('id' => $id));
     return new RedirectResponse($url);
 }