mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
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
This commit is contained in:
parent
1d7c960531
commit
315d857a8a
8 changed files with 272 additions and 4 deletions
|
@ -992,6 +992,9 @@ phutil_register_library_map(array(
|
|||
'DiffusionSymbolController' => 'applications/diffusion/controller/DiffusionSymbolController.php',
|
||||
'DiffusionSymbolDatasource' => 'applications/diffusion/typeahead/DiffusionSymbolDatasource.php',
|
||||
'DiffusionSymbolQuery' => 'applications/diffusion/query/DiffusionSymbolQuery.php',
|
||||
'DiffusionSyncLogListController' => 'applications/diffusion/controller/DiffusionSyncLogListController.php',
|
||||
'DiffusionSyncLogListView' => 'applications/diffusion/view/DiffusionSyncLogListView.php',
|
||||
'DiffusionSyncLogSearchEngine' => 'applications/diffusion/query/DiffusionSyncLogSearchEngine.php',
|
||||
'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php',
|
||||
'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php',
|
||||
'DiffusionTagTableView' => 'applications/diffusion/view/DiffusionTagTableView.php',
|
||||
|
@ -6367,6 +6370,9 @@ phutil_register_library_map(array(
|
|||
'DiffusionSymbolController' => 'DiffusionController',
|
||||
'DiffusionSymbolDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery',
|
||||
'DiffusionSyncLogListController' => 'DiffusionLogController',
|
||||
'DiffusionSyncLogListView' => 'AphrontView',
|
||||
'DiffusionSyncLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'DiffusionTagListController' => 'DiffusionController',
|
||||
'DiffusionTagListView' => 'DiffusionView',
|
||||
'DiffusionTagTableView' => 'DiffusionView',
|
||||
|
|
|
@ -118,6 +118,9 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
|
|||
$this->getQueryRoutePattern() => 'DiffusionPushLogListController',
|
||||
'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',
|
||||
),
|
||||
'synclog/' => array(
|
||||
$this->getQueryRoutePattern() => 'DiffusionSyncLogListController',
|
||||
),
|
||||
'pulllog/' => array(
|
||||
$this->getQueryRoutePattern() => 'DiffusionPullLogListController',
|
||||
),
|
||||
|
|
|
@ -370,8 +370,17 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$action_view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View Push Logs'))
|
||||
->setIcon('fa-list-alt')
|
||||
->setIcon('fa-upload')
|
||||
->setHref($push_uri));
|
||||
|
||||
$pull_uri = $this->getApplicationURI(
|
||||
'synclog/?repositories='.$repository->getPHID());
|
||||
|
||||
$action_view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View Sync Logs'))
|
||||
->setIcon('fa-exchange')
|
||||
->setHref($pull_uri));
|
||||
}
|
||||
|
||||
$pull_uri = $this->getApplicationURI(
|
||||
|
@ -380,7 +389,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$action_view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View Pull Logs'))
|
||||
->setIcon('fa-list-alt')
|
||||
->setIcon('fa-download')
|
||||
->setHref($pull_uri));
|
||||
|
||||
return $action_view;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionSyncLogListController
|
||||
extends DiffusionLogController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
return id(new DiffusionSyncLogSearchEngine())
|
||||
->setController($this)
|
||||
->buildResponse();
|
||||
}
|
||||
|
||||
protected function buildApplicationCrumbs() {
|
||||
return parent::buildApplicationCrumbs()
|
||||
->addTextCrumb(pht('Sync Logs'), $this->getApplicationURI('synclog/'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionSyncLogSearchEngine
|
||||
extends PhabricatorApplicationSearchEngine {
|
||||
|
||||
public function getResultTypeDescription() {
|
||||
return pht('Sync Logs');
|
||||
}
|
||||
|
||||
public function getApplicationClassName() {
|
||||
return 'PhabricatorDiffusionApplication';
|
||||
}
|
||||
|
||||
public function newQuery() {
|
||||
return new PhabricatorRepositorySyncEventQuery();
|
||||
}
|
||||
|
||||
protected function buildQueryFromParameters(array $map) {
|
||||
$query = $this->newQuery();
|
||||
|
||||
if ($map['repositoryPHIDs']) {
|
||||
$query->withRepositoryPHIDs($map['repositoryPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['createdStart'] || $map['createdEnd']) {
|
||||
$query->withEpochBetween(
|
||||
$map['createdStart'],
|
||||
$map['createdEnd']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function buildCustomSearchFields() {
|
||||
return array(
|
||||
id(new PhabricatorSearchDatasourceField())
|
||||
->setDatasource(new DiffusionRepositoryDatasource())
|
||||
->setKey('repositoryPHIDs')
|
||||
->setAliases(array('repository', 'repositories', 'repositoryPHID'))
|
||||
->setLabel(pht('Repositories'))
|
||||
->setDescription(
|
||||
pht('Search for sync logs for specific repositories.')),
|
||||
id(new PhabricatorSearchDateField())
|
||||
->setLabel(pht('Created After'))
|
||||
->setKey('createdStart'),
|
||||
id(new PhabricatorSearchDateField())
|
||||
->setLabel(pht('Created Before'))
|
||||
->setKey('createdEnd'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function newExportFields() {
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$fields = array(
|
||||
id(new PhabricatorPHIDExportField())
|
||||
->setKey('repositoryPHID')
|
||||
->setLabel(pht('Repository PHID')),
|
||||
id(new PhabricatorStringExportField())
|
||||
->setKey('repository')
|
||||
->setLabel(pht('Repository')),
|
||||
id(new PhabricatorPHIDExportField())
|
||||
->setKey('devicePHID')
|
||||
->setLabel(pht('Device PHID')),
|
||||
id(new PhabricatorPHIDExportField())
|
||||
->setKey('fromDevicePHID')
|
||||
->setLabel(pht('From Device PHID')),
|
||||
id(new PhabricatorIntExportField())
|
||||
->setKey('deviceVersion')
|
||||
->setLabel(pht('Device Version')),
|
||||
id(new PhabricatorIntExportField())
|
||||
->setKey('fromDeviceVersion')
|
||||
->setLabel(pht('From Device Version')),
|
||||
id(new PhabricatorStringExportField())
|
||||
->setKey('result')
|
||||
->setLabel(pht('Result')),
|
||||
id(new PhabricatorIntExportField())
|
||||
->setKey('code')
|
||||
->setLabel(pht('Code')),
|
||||
id(new PhabricatorEpochExportField())
|
||||
->setKey('date')
|
||||
->setLabel(pht('Date')),
|
||||
id(new PhabricatorIntExportField())
|
||||
->setKey('syncWait')
|
||||
->setLabel(pht('Sync Wait')),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
protected function newExportData(array $events) {
|
||||
$viewer = $this->requireViewer();
|
||||
|
||||
$export = array();
|
||||
foreach ($events as $event) {
|
||||
$repository = $event->getRepository();
|
||||
$repository_phid = $repository->getPHID();
|
||||
$repository_name = $repository->getDisplayName();
|
||||
|
||||
$map = array(
|
||||
'repositoryPHID' => $repository_phid,
|
||||
'repository' => $repository_name,
|
||||
'devicePHID' => $event->getDevicePHID(),
|
||||
'fromDevicePHID' => $event->getFromDevicePHID(),
|
||||
'deviceVersion' => $event->getDeviceVersion(),
|
||||
'fromDeviceVersion' => $event->getFromDeviceVersion(),
|
||||
'result' => $event->getResultType(),
|
||||
'code' => $event->getResultCode(),
|
||||
'date' => $event->getEpoch(),
|
||||
'syncWait' => $event->getSyncWait(),
|
||||
);
|
||||
|
||||
$export[] = $map;
|
||||
}
|
||||
|
||||
return $export;
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
return '/diffusion/synclog/'.$path;
|
||||
}
|
||||
|
||||
protected function getBuiltinQueryNames() {
|
||||
return array(
|
||||
'all' => pht('All Sync Logs'),
|
||||
);
|
||||
}
|
||||
|
||||
public function buildSavedQueryFromBuiltin($query_key) {
|
||||
$query = $this->newSavedQuery();
|
||||
$query->setQueryKey($query_key);
|
||||
|
||||
switch ($query_key) {
|
||||
case 'all':
|
||||
return $query;
|
||||
}
|
||||
|
||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||
}
|
||||
|
||||
protected function renderResultList(
|
||||
array $logs,
|
||||
PhabricatorSavedQuery $query,
|
||||
array $handles) {
|
||||
|
||||
$table = id(new DiffusionSyncLogListView())
|
||||
->setViewer($this->requireViewer())
|
||||
->setLogs($logs);
|
||||
|
||||
return id(new PhabricatorApplicationSearchResultView())
|
||||
->setTable($table);
|
||||
}
|
||||
|
||||
}
|
79
src/applications/diffusion/view/DiffusionSyncLogListView.php
Normal file
79
src/applications/diffusion/view/DiffusionSyncLogListView.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,7 @@ final class PhabricatorRepositorySyncEventQuery
|
|||
}
|
||||
|
||||
public function newResultObject() {
|
||||
return new PhabricatorRepositoryPullEvent();
|
||||
return new PhabricatorRepositorySyncEvent();
|
||||
}
|
||||
|
||||
protected function loadPage() {
|
||||
|
|
|
@ -65,7 +65,7 @@ final class PhabricatorRepositorySyncEvent
|
|||
}
|
||||
|
||||
public function setProperty($key, $value) {
|
||||
$this->properites[$key] = $value;
|
||||
$this->properties[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue