コード例 #1
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildSideNav('log');
     $query = new DrydockLogQuery();
     $resource_ids = $request->getStrList('resource');
     if ($resource_ids) {
         $query->withResourceIDs($resource_ids);
     }
     $lease_ids = $request->getStrList('lease');
     if ($lease_ids) {
         $query->withLeaseIDs($lease_ids);
     }
     $pager = new AphrontPagerView();
     $pager->setPageSize(500);
     $pager->setOffset($request->getInt('offset'));
     $pager->setURI($request->getRequestURI(), 'offset');
     $logs = $query->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($logs as $log) {
         $rows[] = array($log->getResourceID(), $log->getLeaseID(), phutil_escape_html($log->getMessage()), phabricator_datetime($log->getEpoch(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Resource', 'Lease', 'Message', 'Date'));
     $table->setColumnClasses(array('', '', 'wide', ''));
     $panel = new AphrontPanelView();
     $panel->setHeader('Drydock Logs');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Logs'));
 }
コード例 #2
0
 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved)
 {
     $resource_phids = $saved->getParameter('resourcePHIDs', array());
     $lease_phids = $saved->getParameter('leasePHIDs', array());
     // TODO: Change logs to use PHIDs instead of IDs.
     $resource_ids = array();
     $lease_ids = array();
     if ($resource_phids) {
         $resource_ids = id(new DrydockResourceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($resource_phids)->execute();
         $resource_ids = mpull($resource_ids, 'getID');
     }
     if ($lease_phids) {
         $lease_ids = id(new DrydockLeaseQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($lease_phids)->execute();
         $lease_ids = mpull($lease_ids, 'getID');
     }
     $query = new DrydockLogQuery();
     if ($resource_ids) {
         $query->withResourceIDs($resource_ids);
     }
     if ($lease_ids) {
         $query->withLeaseIDs($lease_ids);
     }
     return $query;
 }