Path: blob/master/src/applications/drydock/view/DrydockLogListView.php
12256 views
<?php12final class DrydockLogListView extends AphrontView {34private $logs;5private $hideBlueprints;6private $hideResources;7private $hideLeases;8private $hideOperations;910public function setHideBlueprints($hide_blueprints) {11$this->hideBlueprints = $hide_blueprints;12return $this;13}1415public function getHideBlueprints() {16return $this->hideBlueprints;17}1819public function setHideResources($hide_resources) {20$this->hideResources = $hide_resources;21return $this;22}2324public function getHideResources() {25return $this->hideResources;26}2728public function setHideLeases($hide_leases) {29$this->hideLeases = $hide_leases;30return $this;31}3233public function getHideLeases() {34return $this->hideLeases;35}3637public function setHideOperations($hide_operations) {38$this->hideOperations = $hide_operations;39return $this;40}4142public function getHideOperations() {43return $this->hideOperations;44}4546public function setLogs(array $logs) {47assert_instances_of($logs, 'DrydockLog');48$this->logs = $logs;49return $this;50}5152public function render() {53$logs = $this->logs;54$viewer = $this->getUser();5556$view = new PHUIObjectItemListView();5758$types = DrydockLogType::getAllLogTypes();5960$rows = array();61foreach ($logs as $log) {62$blueprint_phid = $log->getBlueprintPHID();63if ($blueprint_phid) {64$blueprint = $viewer->renderHandle($blueprint_phid);65} else {66$blueprint = null;67}6869$resource_phid = $log->getResourcePHID();70if ($resource_phid) {71$resource = $viewer->renderHandle($resource_phid);72} else {73$resource = null;74}7576$lease_phid = $log->getLeasePHID();77if ($lease_phid) {78$lease = $viewer->renderHandle($lease_phid);79} else {80$lease = null;81}8283$operation_phid = $log->getOperationPHID();84if ($operation_phid) {85$operation = $viewer->renderHandle($operation_phid);86} else {87$operation = null;88}8990if ($log->isComplete()) {91$type_key = $log->getType();92if (isset($types[$type_key])) {93$type_object = id(clone $types[$type_key])94->setLog($log)95->setViewer($viewer);9697$log_data = $log->getData();9899$type = $type_object->getLogTypeName();100$icon = $type_object->getLogTypeIcon($log_data);101$data = $type_object->renderLogForHTML($log_data);102$data = phutil_escape_html_newlines($data);103} else {104$type = pht('<Unknown: %s>', $type_key);105$data = null;106$icon = 'fa-question-circle red';107}108} else {109$type = phutil_tag('em', array(), pht('Restricted'));110$data = phutil_tag(111'em',112array(),113pht('You do not have permission to view this log event.'));114$icon = 'fa-lock grey';115}116117$rows[] = array(118$blueprint,119$resource,120$lease,121$operation,122id(new PHUIIconView())->setIcon($icon),123$type,124$data,125phabricator_datetime($log->getEpoch(), $viewer),126);127}128129$table = id(new AphrontTableView($rows))130->setDeviceReadyTable(true)131->setHeaders(132array(133pht('Blueprint'),134pht('Resource'),135pht('Lease'),136pht('Operation'),137null,138pht('Type'),139pht('Data'),140pht('Date'),141))142->setColumnVisibility(143array(144!$this->getHideBlueprints(),145!$this->getHideResources(),146!$this->getHideLeases(),147!$this->getHideOperations(),148))149->setColumnClasses(150array(151'',152'',153'',154'',155'icon',156'',157'wide',158'',159));160161return $table;162}163164}165166167