Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/view/DrydockLogListView.php
<?php | <?php | ||||
final class DrydockLogListView extends AphrontView { | final class DrydockLogListView extends AphrontView { | ||||
private $logs; | private $logs; | ||||
private $hideBlueprints; | |||||
private $hideResources; | |||||
private $hideLeases; | |||||
private $hideOperations; | |||||
public function setHideBlueprints($hide_blueprints) { | |||||
$this->hideBlueprints = $hide_blueprints; | |||||
return $this; | |||||
} | |||||
public function getHideBlueprints() { | |||||
return $this->hideBlueprints; | |||||
} | |||||
public function setHideResources($hide_resources) { | |||||
$this->hideResources = $hide_resources; | |||||
return $this; | |||||
} | |||||
public function getHideResources() { | |||||
return $this->hideResources; | |||||
} | |||||
public function setHideLeases($hide_leases) { | |||||
$this->hideLeases = $hide_leases; | |||||
return $this; | |||||
} | |||||
public function getHideLeases() { | |||||
return $this->hideLeases; | |||||
} | |||||
public function setHideOperations($hide_operations) { | |||||
$this->hideOperations = $hide_operations; | |||||
return $this; | |||||
} | |||||
public function getHideOperations() { | |||||
return $this->hideOperations; | |||||
} | |||||
public function setLogs(array $logs) { | public function setLogs(array $logs) { | ||||
assert_instances_of($logs, 'DrydockLog'); | assert_instances_of($logs, 'DrydockLog'); | ||||
$this->logs = $logs; | $this->logs = $logs; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
Show All 22 Lines | foreach ($logs as $log) { | ||||
$lease_phid = $log->getLeasePHID(); | $lease_phid = $log->getLeasePHID(); | ||||
if ($lease_phid) { | if ($lease_phid) { | ||||
$lease = $viewer->renderHandle($lease_phid); | $lease = $viewer->renderHandle($lease_phid); | ||||
} else { | } else { | ||||
$lease = null; | $lease = null; | ||||
} | } | ||||
$operation_phid = $log->getOperationPHID(); | |||||
if ($operation_phid) { | |||||
$operation = $viewer->renderHandle($operation_phid); | |||||
} else { | |||||
$operation = null; | |||||
} | |||||
if ($log->isComplete()) { | if ($log->isComplete()) { | ||||
$type_key = $log->getType(); | $type_key = $log->getType(); | ||||
if (isset($types[$type_key])) { | if (isset($types[$type_key])) { | ||||
$type_object = id(clone $types[$type_key]) | $type_object = id(clone $types[$type_key]) | ||||
->setLog($log) | ->setLog($log) | ||||
->setViewer($viewer); | ->setViewer($viewer); | ||||
$log_data = $log->getData(); | $log_data = $log->getData(); | ||||
Show All 15 Lines | foreach ($logs as $log) { | ||||
pht('You do not have permission to view this log event.')); | pht('You do not have permission to view this log event.')); | ||||
$icon = 'fa-lock grey'; | $icon = 'fa-lock grey'; | ||||
} | } | ||||
$rows[] = array( | $rows[] = array( | ||||
$blueprint, | $blueprint, | ||||
$resource, | $resource, | ||||
$lease, | $lease, | ||||
$operation, | |||||
id(new PHUIIconView())->setIcon($icon), | id(new PHUIIconView())->setIcon($icon), | ||||
$type, | $type, | ||||
$data, | $data, | ||||
phabricator_datetime($log->getEpoch(), $viewer), | phabricator_datetime($log->getEpoch(), $viewer), | ||||
); | ); | ||||
} | } | ||||
$table = id(new AphrontTableView($rows)) | $table = id(new AphrontTableView($rows)) | ||||
->setDeviceReadyTable(true) | ->setDeviceReadyTable(true) | ||||
->setHeaders( | ->setHeaders( | ||||
array( | array( | ||||
pht('Blueprint'), | pht('Blueprint'), | ||||
pht('Resource'), | pht('Resource'), | ||||
pht('Lease'), | pht('Lease'), | ||||
pht('Operation'), | |||||
null, | null, | ||||
pht('Type'), | pht('Type'), | ||||
pht('Data'), | pht('Data'), | ||||
pht('Date'), | pht('Date'), | ||||
)) | )) | ||||
->setColumnVisibility( | |||||
array( | |||||
!$this->getHideBlueprints(), | |||||
!$this->getHideResources(), | |||||
!$this->getHideLeases(), | |||||
!$this->getHideOperations(), | |||||
)) | |||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'', | '', | ||||
'', | '', | ||||
'', | '', | ||||
'', | |||||
'icon', | 'icon', | ||||
'', | '', | ||||
'wide', | 'wide', | ||||
'', | '', | ||||
)); | )); | ||||
return $table; | return $table; | ||||
} | } | ||||
} | } |