1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-02 11:42:42 +01:00
phorge-phorge/src/applications/diffusion/view/DiffusionSyncLogListView.php
epriestley 315d857a8a Add a basic web UI for intracluster sync logs
Summary: Depends on D19798. Ref T13216. This puts at least a basic UI on top of sync logs.

Test Plan:
Viewed logs from the web UI and exported data. Note that these syncs are somewhat simulated since I my local cluster is somewhat-faked (i.e., not actually multiple machines).

{F5995899}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13216

Differential Revision: https://secure.phabricator.com/D19799
2018-11-10 04:58:36 -08:00

79 lines
1.8 KiB
PHP

<?php
final class DiffusionSyncLogListView extends AphrontView {
private $logs;
public function setLogs(array $logs) {
assert_instances_of($logs, 'PhabricatorRepositorySyncEvent');
$this->logs = $logs;
return $this;
}
public function render() {
$events = $this->logs;
$viewer = $this->getViewer();
$rows = array();
foreach ($events as $event) {
$repository = $event->getRepository();
$repository_link = phutil_tag(
'a',
array(
'href' => $repository->getURI(),
),
$repository->getDisplayName());
$event_id = $event->getID();
$sync_wait = pht('%sus', new PhutilNumber($event->getSyncWait()));
$device_link = $viewer->renderHandle($event->getDevicePHID());
$from_device_link = $viewer->renderHandle($event->getFromDevicePHID());
$rows[] = array(
$event_id,
$repository_link,
$device_link,
$from_device_link,
$event->getDeviceVersion(),
$event->getFromDeviceVersion(),
$event->getResultType(),
$event->getResultCode(),
phabricator_datetime($event->getEpoch(), $viewer),
$sync_wait,
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Sync'),
pht('Repository'),
pht('Device'),
pht('From Device'),
pht('Version'),
pht('From Version'),
pht('Result'),
pht('Code'),
pht('Date'),
pht('Sync Wait'),
))
->setColumnClasses(
array(
'n',
'',
'',
'',
'n',
'n',
'wide right',
'n',
'right',
'n right',
));
return $table;
}
}