mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-16 03:42:41 +01:00
5caf9fb6da
Summary: this has a single side nav now. added a Utilites section below the methods which houses Logs and Token. On logs I ended up deleting this whole concept of "view" and the existing side nav -- I think there were plans to add a way to filter down to subset of the conduit calls. For logs, I envision that being a separate first class tool when / if we think we need additional complexity. On token I made the form FULL so it was like the rest of the views in this page. Test Plan: looks good! clicked on a few methods and it worked! clicked on the logs and they were there! clicked on the pager within the logs and it worked! checked out the token page and it looked good too. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T631 Differential Revision: https://secure.phabricator.com/D1499
109 lines
3 KiB
PHP
109 lines
3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright 2012 Facebook, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
* @group conduit
|
|
*/
|
|
class PhabricatorConduitLogController extends PhabricatorConduitController {
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
|
|
$conn_table = new PhabricatorConduitConnectionLog();
|
|
$call_table = new PhabricatorConduitMethodCallLog();
|
|
|
|
$conn_r = $call_table->establishConnection('r');
|
|
|
|
$pager = new AphrontPagerView();
|
|
$pager->setOffset($request->getInt('page'));
|
|
$calls = $call_table->loadAllWhere(
|
|
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
|
|
$pager->getOffset(),
|
|
$pager->getPageSize() + 1);
|
|
$calls = $pager->sliceResults($calls);
|
|
$pager->setURI(new PhutilURI('/conduit/log/'), 'page');
|
|
$pager->setEnableKeyboardShortcuts(true);
|
|
|
|
$min = $pager->getOffset() + 1;
|
|
$max = ($min + count($calls) - 1);
|
|
|
|
$conn_ids = array_filter(mpull($calls, 'getConnectionID'));
|
|
$conns = array();
|
|
if ($conn_ids) {
|
|
$conns = $conn_table->loadAllWhere(
|
|
'id IN (%Ld)',
|
|
$conn_ids);
|
|
}
|
|
|
|
$table = $this->renderCallTable($calls, $conns);
|
|
$panel = new AphrontPanelView();
|
|
$panel->setHeader('Conduit Method Calls ('.$min.'-'.$max.')');
|
|
$panel->appendChild($table);
|
|
$panel->appendChild($pager);
|
|
|
|
$this->setFilter('log');
|
|
|
|
return $this->buildStandardPageResponse(
|
|
$panel,
|
|
array(
|
|
'title' => 'Conduit Logs',
|
|
));
|
|
}
|
|
|
|
private function renderCallTable(array $calls, array $conns) {
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$rows = array();
|
|
foreach ($calls as $call) {
|
|
$conn = idx($conns, $call->getConnectionID());
|
|
if (!$conn) {
|
|
// If there's no connection, use an empty object.
|
|
$conn = new PhabricatorConduitConnectionLog();
|
|
}
|
|
$rows[] = array(
|
|
$call->getConnectionID(),
|
|
phutil_escape_html($conn->getUserName()),
|
|
phutil_escape_html($call->getMethod()),
|
|
phutil_escape_html($call->getError()),
|
|
number_format($call->getDuration()).' us',
|
|
phabricator_datetime($call->getDateCreated(), $user),
|
|
);
|
|
}
|
|
$table = new AphrontTableView($rows);
|
|
$table->setHeaders(
|
|
array(
|
|
'Connection',
|
|
'User',
|
|
'Method',
|
|
'Error',
|
|
'Duration',
|
|
'Date',
|
|
));
|
|
$table->setColumnClasses(
|
|
array(
|
|
'',
|
|
'',
|
|
'wide',
|
|
'',
|
|
'n',
|
|
'right',
|
|
));
|
|
return $table;
|
|
}
|
|
|
|
}
|