Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14080633
D19799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D19799.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -992,6 +992,9 @@
'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 @@
'DiffusionSymbolController' => 'DiffusionController',
'DiffusionSymbolDatasource' => 'PhabricatorTypeaheadDatasource',
'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery',
+ 'DiffusionSyncLogListController' => 'DiffusionLogController',
+ 'DiffusionSyncLogListView' => 'AphrontView',
+ 'DiffusionSyncLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DiffusionTagListController' => 'DiffusionController',
'DiffusionTagListView' => 'DiffusionView',
'DiffusionTagTableView' => 'DiffusionView',
diff --git a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
--- a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
+++ b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
@@ -118,6 +118,9 @@
$this->getQueryRoutePattern() => 'DiffusionPushLogListController',
'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',
),
+ 'synclog/' => array(
+ $this->getQueryRoutePattern() => 'DiffusionSyncLogListController',
+ ),
'pulllog/' => array(
$this->getQueryRoutePattern() => 'DiffusionPullLogListController',
),
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -370,8 +370,17 @@
$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 @@
$action_view->addAction(
id(new PhabricatorActionView())
->setName(pht('View Pull Logs'))
- ->setIcon('fa-list-alt')
+ ->setIcon('fa-download')
->setHref($pull_uri));
return $action_view;
diff --git a/src/applications/diffusion/controller/DiffusionSyncLogListController.php b/src/applications/diffusion/controller/DiffusionSyncLogListController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/controller/DiffusionSyncLogListController.php
@@ -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/'));
+ }
+
+}
diff --git a/src/applications/diffusion/query/DiffusionSyncLogSearchEngine.php b/src/applications/diffusion/query/DiffusionSyncLogSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/query/DiffusionSyncLogSearchEngine.php
@@ -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);
+ }
+
+}
diff --git a/src/applications/diffusion/view/DiffusionSyncLogListView.php b/src/applications/diffusion/view/DiffusionSyncLogListView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/view/DiffusionSyncLogListView.php
@@ -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;
+ }
+
+}
diff --git a/src/applications/repository/query/PhabricatorRepositorySyncEventQuery.php b/src/applications/repository/query/PhabricatorRepositorySyncEventQuery.php
--- a/src/applications/repository/query/PhabricatorRepositorySyncEventQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositorySyncEventQuery.php
@@ -31,7 +31,7 @@
}
public function newResultObject() {
- return new PhabricatorRepositoryPullEvent();
+ return new PhabricatorRepositorySyncEvent();
}
protected function loadPage() {
diff --git a/src/applications/repository/storage/PhabricatorRepositorySyncEvent.php b/src/applications/repository/storage/PhabricatorRepositorySyncEvent.php
--- a/src/applications/repository/storage/PhabricatorRepositorySyncEvent.php
+++ b/src/applications/repository/storage/PhabricatorRepositorySyncEvent.php
@@ -65,7 +65,7 @@
}
public function setProperty($key, $value) {
- $this->properites[$key] = $value;
+ $this->properties[$key] = $value;
return $this;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 3:29 PM (12 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6778807
Default Alt Text
D19799.diff (11 KB)
Attached To
Mode
D19799: Add a basic web UI for intracluster sync logs
Attached
Detach File
Event Timeline
Log In to Comment