public function processRequest(AphrontRequest $request) { $user = $this->getUser(); $viewer = $request->getUser(); $keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->execute(); $table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys.")); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $upload_icon = id(new PHUIIconView())->setIconFont('fa-upload'); $upload_button = id(new PHUIButtonView())->setText(pht('Upload Public Key'))->setHref('/auth/sshkey/upload/?objectPHID=' . $user->getPHID())->setWorkflow(true)->setTag('a')->setIcon($upload_icon); try { PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); $can_generate = true; } catch (Exception $ex) { $can_generate = false; } $generate_icon = id(new PHUIIconView())->setIconFont('fa-lock'); $generate_button = id(new PHUIButtonView())->setText(pht('Generate Keypair'))->setHref('/auth/sshkey/generate/?objectPHID=' . $user->getPHID())->setTag('a')->setWorkflow(true)->setDisabled(!$can_generate)->setIcon($generate_icon); $header->setHeader(pht('SSH Public Keys')); $header->addActionLink($generate_button); $header->addActionLink($upload_button); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $db_values = id(new PhabricatorConfigEntry())->loadAllWhere('namespace = %s', 'default'); $db_values = mpull($db_values, null, 'getConfigKey'); $rows = array(); $options = PhabricatorApplicationConfigOptions::loadAllOptions(); ksort($options); foreach ($options as $option) { $key = $option->getKey(); if ($option->getHidden()) { $value = phutil_tag('em', array(), pht('Hidden')); } else { $value = PhabricatorEnv::getEnvConfig($key); $value = PhabricatorConfigJSON::prettyPrintJSON($value); } $db_value = idx($db_values, $key); $rows[] = array(phutil_tag('a', array('href' => $this->getApplicationURI('edit/' . $key . '/')), $key), $value, $db_value && !$db_value->getIsDeleted() ? pht('Customized') : ''); } $table = id(new AphrontTableView($rows))->setColumnClasses(array('', 'wide'))->setHeaders(array(pht('Key'), pht('Value'), pht('Customized'))); $title = pht('Current Settings'); $crumbs = $this->buildApplicationCrumbs()->addTextCrumb($title); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Current Settings')); $panel->setTable($table); $nav = $this->buildSideNavView(); $nav->selectFilter('all/'); $view = id(new PHUITwoColumnView())->setNavigation($nav)->setMainColumn(array($panel)); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view); }
public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $package = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->needPaths(true)->executeOne(); if (!$package) { return new Aphront404Response(); } $paths = $package->getPaths(); $repository_phids = array(); foreach ($paths as $path) { $repository_phids[$path->getRepositoryPHID()] = true; } if ($repository_phids) { $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs(array_keys($repository_phids))->execute(); $repositories = mpull($repositories, null, 'getPHID'); } else { $repositories = array(); } $actions = $this->buildPackageActionView($package); $properties = $this->buildPackagePropertyView($package); $properties->setActionList($actions); $header = id(new PHUIHeaderView())->setUser($viewer)->setHeader($package->getName())->setPolicyObject($package); $panel = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $commit_views = array(); $commit_uri = id(new PhutilURI('/audit/'))->setQueryParams(array('auditorPHIDs' => $package->getPHID())); $attention_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->setLimit(10)->execute(); if ($attention_commits) { $view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($attention_commits); $commit_views[] = array('view' => $view, 'header' => pht('Commits in this Package that Need Attention'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri->alter('status', 'open'))->setText(pht('View All Problem Commits'))); } $all_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->needCommitData(true)->setLimit(100)->execute(); $view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($all_commits)->setNoDataString(pht('No commits in this package.')); $commit_views[] = array('view' => $view, 'header' => pht('Recent Commits in Package'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri)->setText(pht('View All Package Commits'))); $phids = array(); foreach ($commit_views as $commit_view) { $phids[] = $commit_view['view']->getRequiredHandlePHIDs(); } $phids = array_mergev($phids); $handles = $this->loadViewerHandles($phids); $commit_panels = array(); foreach ($commit_views as $commit_view) { $commit_panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader($commit_view['header']); if (isset($commit_view['button'])) { $header->addActionLink($commit_view['button']); } $commit_view['view']->setHandles($handles); $commit_panel->setHeader($header); $commit_panel->appendChild($commit_view['view']); $commit_panels[] = $commit_panel; } $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($package->getName()); $timeline = $this->buildTransactionTimeline($package, new PhabricatorOwnersPackageTransactionQuery()); $timeline->setShouldTerminate(true); return $this->buildApplicationPage(array($crumbs, $panel, $this->renderPathsTable($paths, $repositories), $commit_panels, $timeline), array('title' => $package->getName())); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $log = id(new PhabricatorDaemonLogQuery())->setViewer($viewer)->withIDs(array($id))->setAllowStatusWrites(true)->executeOne(); if (!$log) { return new Aphront404Response(); } $events = id(new PhabricatorDaemonLogEvent())->loadAllWhere('logID = %d ORDER BY id DESC LIMIT 1000', $log->getID()); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Daemon %s', $log->getID())); $header = id(new PHUIHeaderView())->setHeader($log->getDaemon()); $tag = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE); $status = $log->getStatus(); switch ($status) { case PhabricatorDaemonLog::STATUS_UNKNOWN: $tag->setBackgroundColor(PHUITagView::COLOR_ORANGE); $tag->setName(pht('Unknown')); break; case PhabricatorDaemonLog::STATUS_RUNNING: $tag->setBackgroundColor(PHUITagView::COLOR_GREEN); $tag->setName(pht('Running')); break; case PhabricatorDaemonLog::STATUS_DEAD: $tag->setBackgroundColor(PHUITagView::COLOR_RED); $tag->setName(pht('Dead')); break; case PhabricatorDaemonLog::STATUS_WAIT: $tag->setBackgroundColor(PHUITagView::COLOR_BLUE); $tag->setName(pht('Waiting')); break; case PhabricatorDaemonLog::STATUS_EXITING: $tag->setBackgroundColor(PHUITagView::COLOR_YELLOW); $tag->setName(pht('Exiting')); break; case PhabricatorDaemonLog::STATUS_EXITED: $tag->setBackgroundColor(PHUITagView::COLOR_GREY); $tag->setName(pht('Exited')); break; } $header->addTag($tag); $env_hash = PhabricatorEnv::calculateEnvironmentHash(); if ($log->getEnvHash() != $env_hash) { $tag = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_YELLOW)->setName(pht('Stale Config')); $header->addTag($tag); } $properties = $this->buildPropertyListView($log); $event_view = id(new PhabricatorDaemonLogEventsView())->setUser($viewer)->setEvents($events); $event_panel = new PHUIObjectBoxView(); $event_panel->setHeaderText(pht('Events')); $event_panel->appendChild($event_view); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); return $this->buildApplicationPage(array($crumbs, $object_box, $event_panel), array('title' => pht('Daemon Log'))); }
private function buildPropertyLists(PHUIObjectBoxView $box, HarbormasterBuildable $buildable, PhabricatorActionListView $actions) { $request = $this->getRequest(); $viewer = $request->getUser(); $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($buildable)->setActionList($actions); $box->addPropertyList($properties); if ($buildable->getContainerHandle() !== null) { $properties->addProperty(pht('Container'), $buildable->getContainerHandle()->renderLink()); } $properties->addProperty(pht('Buildable'), $buildable->getBuildableHandle()->renderLink()); $properties->addProperty(pht('Origin'), $buildable->getIsManualBuildable() ? pht('Manual Buildable') : pht('Automatic Buildable')); }
public function processRequest(AphrontRequest $request) { if ($request->getExists('new')) { return $this->processNew($request); } if ($request->getExists('edit')) { return $this->processEdit($request); } if ($request->getExists('delete')) { return $this->processDelete($request); } $user = $this->getUser(); $viewer = $request->getUser(); $factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere('userPHID = %s', $user->getPHID()); $rows = array(); $rowc = array(); $highlight_id = $request->getInt('id'); foreach ($factors as $factor) { $impl = $factor->getImplementation(); if ($impl) { $type = $impl->getFactorName(); } else { $type = $factor->getFactorKey(); } if ($factor->getID() == $highlight_id) { $rowc[] = 'highlighted'; } else { $rowc[] = null; } $rows[] = array(javelin_tag('a', array('href' => $this->getPanelURI('?edit=' . $factor->getID()), 'sigil' => 'workflow'), $factor->getFactorName()), $type, phabricator_datetime($factor->getDateCreated(), $viewer), javelin_tag('a', array('href' => $this->getPanelURI('?delete=' . $factor->getID()), 'sigil' => 'workflow', 'class' => 'small grey button'), pht('Remove'))); } $table = new AphrontTableView($rows); $table->setNoDataString(pht("You haven't added any authentication factors to your account yet.")); $table->setHeaders(array(pht('Name'), pht('Type'), pht('Created'), '')); $table->setColumnClasses(array('wide pri', '', 'right', 'action')); $table->setRowClasses($rowc); $table->setDeviceVisibility(array(true, false, false, true)); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $help_uri = PhabricatorEnv::getDoclink('User Guide: Multi-Factor Authentication'); $help_icon = id(new PHUIIconView())->setIconFont('fa-info-circle'); $help_button = id(new PHUIButtonView())->setText(pht('Help'))->setHref($help_uri)->setTag('a')->setIcon($help_icon); $create_icon = id(new PHUIIconView())->setIconFont('fa-plus'); $create_button = id(new PHUIButtonView())->setText(pht('Add Authentication Factor'))->setHref($this->getPanelURI('?new=true'))->setTag('a')->setWorkflow(true)->setIcon($create_icon); $header->setHeader(pht('Authentication Factors')); $header->addActionLink($help_button); $header->addActionLink($create_button); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $db_values = id(new PhabricatorConfigEntry())->loadAllWhere('namespace = %s', 'default'); $db_values = mpull($db_values, null, 'getConfigKey'); $rows = array(); $options = PhabricatorApplicationConfigOptions::loadAllOptions(); ksort($options); foreach ($options as $option) { $key = $option->getKey(); if ($option->getMasked()) { $value = phutil_tag('em', array(), pht('Masked')); } else { if ($option->getHidden()) { $value = phutil_tag('em', array(), pht('Hidden')); } else { $value = PhabricatorEnv::getEnvConfig($key); $value = PhabricatorConfigJSON::prettyPrintJSON($value); } } $db_value = idx($db_values, $key); $rows[] = array(phutil_tag('a', array('href' => $this->getApplicationURI('edit/' . $key . '/')), $key), $value, $db_value && !$db_value->getIsDeleted() ? pht('Customized') : ''); } $table = id(new AphrontTableView($rows))->setColumnClasses(array('', 'wide'))->setHeaders(array(pht('Key'), pht('Value'), pht('Customized'))); $title = pht('Current Settings'); $crumbs = $this->buildApplicationCrumbs()->addTextCrumb($title); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Current Settings')); $panel->appendChild($table); $versions = $this->loadVersions(); $version_property_list = id(new PHUIPropertyListView()); foreach ($versions as $version) { list($name, $hash) = $version; $version_property_list->addProperty($name, $hash); } $object_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Current Version'))->addPropertyList($version_property_list); $phabricator_root = dirname(phutil_get_library_root('phabricator')); $version_path = $phabricator_root . '/conf/local/VERSION'; if (Filesystem::pathExists($version_path)) { $version_from_file = Filesystem::readFile($version_path); $version_property_list->addProperty(pht('Local Version'), $version_from_file); } $nav = $this->buildSideNavView(); $nav->selectFilter('all/'); $nav->setCrumbs($crumbs); $nav->appendChild($object_box); $nav->appendChild($panel); return $this->buildApplicationPage($nav, array('title' => $title)); }
protected function processDiffusionRequest(AphrontRequest $request) { $drequest = $this->diffusionRequest; $results = $this->getBrowseQueryResults(); $reason = $results->getReasonForEmptyResultSet(); $content = array(); $actions = $this->buildActionView($drequest); $properties = $this->buildPropertyView($drequest, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties); $content[] = $object_box; $content[] = $this->renderSearchForm($collapsed = true); if (!$results->isValidResults()) { $empty_result = new DiffusionEmptyResultView(); $empty_result->setDiffusionRequest($drequest); $empty_result->setDiffusionBrowseResultSet($results); $empty_result->setView($request->getStr('view')); $content[] = $empty_result; } else { $phids = array(); foreach ($results->getPaths() as $result) { $data = $result->getLastCommitData(); if ($data) { if ($data->getCommitDetail('authorPHID')) { $phids[$data->getCommitDetail('authorPHID')] = true; } } } $phids = array_keys($phids); $handles = $this->loadViewerHandles($phids); $browse_table = new DiffusionBrowseTableView(); $browse_table->setDiffusionRequest($drequest); $browse_table->setHandles($handles); $browse_table->setPaths($results->getPaths()); $browse_table->setUser($request->getUser()); $browse_panel = new PHUIObjectBoxView(); $browse_panel->setHeaderText($drequest->getPath(), '/'); $browse_panel->setTable($browse_table); $content[] = $browse_panel; } $content[] = $this->buildOpenRevisions(); $readme_path = $results->getReadmePath(); if ($readme_path) { $readme_content = $this->callConduitWithDiffusionRequest('diffusion.filecontentquery', array('path' => $readme_path, 'commit' => $drequest->getStableCommit())); if ($readme_content) { $content[] = id(new DiffusionReadmeView())->setUser($this->getViewer())->setPath($readme_path)->setContent($readme_content['corpus']); } } $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse')); return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(nonempty(basename($drequest->getPath()), '/'), pht('%s Repository', $drequest->getRepository()->getCallsign())))); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $table = new PhabricatorFactRaw(); $conn_r = $table->establishConnection('r'); $table_name = $table->getTableName(); $series = $request->getStr('y1'); $specs = PhabricatorFactSpec::newSpecsForFactTypes(PhabricatorFactEngine::loadAllEngines(), array($series)); $spec = idx($specs, $series); $data = queryfx_all($conn_r, 'SELECT valueX, epoch FROM %T WHERE factType = %s ORDER BY epoch ASC', $table_name, $series); $points = array(); $sum = 0; foreach ($data as $key => $row) { $sum += (int) $row['valueX']; $points[(int) $row['epoch']] = $sum; } if (!$points) { // NOTE: Raphael crashes Safari if you hand it series with no points. throw new Exception(pht('No data to show!')); } // Limit amount of data passed to browser. $count = count($points); $limit = 2000; if ($count > $limit) { $i = 0; $every = ceil($count / $limit); foreach ($points as $epoch => $sum) { $i++; if ($i % $every && $i != $count) { unset($points[$epoch]); } } } $x = array_keys($points); $y = array_values($points); $id = celerity_generate_unique_node_id(); $chart = phutil_tag('div', array('id' => $id, 'style' => 'border: 1px solid #6f6f6f; ' . 'margin: 1em 2em; ' . 'background: #ffffff; ' . 'height: 400px; '), ''); require_celerity_resource('raphael-core'); require_celerity_resource('raphael-g'); require_celerity_resource('raphael-g-line'); Javelin::initBehavior('line-chart', array('hardpoint' => $id, 'x' => array($x), 'y' => array($y), 'xformat' => 'epoch', 'colors' => array('#0000ff'))); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Count of %s', $spec->getName())); $panel->appendChild($chart); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Chart')); return $this->buildApplicationPage(array($crumbs, $panel), array('title' => pht('Chart'))); }
public function processRequest(AphrontRequest $request) { $user = $this->getUser(); $viewer = $request->getUser(); $keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->withIsActive(true)->execute(); $table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys.")); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $ssh_actions = PhabricatorAuthSSHKeyTableView::newKeyActionsMenu($viewer, $user); $header->setHeader(pht('SSH Public Keys')); $header->addActionLink($ssh_actions); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function processRequest() { $request = $this->getRequest(); $event = id(new PhabricatorDaemonLogEvent())->load($this->id); if (!$event) { return new Aphront404Response(); } $event_view = id(new PhabricatorDaemonLogEventsView())->setEvents(array($event))->setUser($request->getUser())->setCombinedLog(true)->setShowFullMessage(true); $log_panel = new PHUIObjectBoxView(); $log_panel->setHeaderText(pht('Combined Log')); $log_panel->appendChild($event_view); $daemon_id = $event->getLogID(); $crumbs = $this->buildApplicationCrumbs()->addTextCrumb(pht('Daemon %s', $daemon_id), $this->getApplicationURI("log/{$daemon_id}/"))->addTextCrumb(pht('Event %s', $event->getID())); return $this->buildApplicationPage(array($crumbs, $log_panel), array('title' => pht('Combined Daemon Log'))); }
public function render() { DarkConsoleXHProfPluginAPI::includeXHProfLib(); $data = $this->profileData; $GLOBALS['display_calls'] = true; $totals = array(); $flat = xhprof_compute_flat_info($data, $totals); unset($GLOBALS['display_calls']); $symbol = $this->symbol; $children = array(); $parents = array(); foreach ($this->profileData as $key => $counters) { if (strpos($key, '==>') !== false) { list($parent, $child) = explode('==>', $key, 2); } else { continue; } if ($parent == $symbol) { $children[$key] = $child; } else { if ($child == $symbol) { $parents[$key] = $parent; } } } $rows = array(); $rows[] = array(pht('Metrics for this Call'), '', '', ''); $rows[] = $this->formatRow(array($symbol, $flat[$symbol]['ct'], $flat[$symbol]['wt'], 1.0)); $rows[] = array(pht('Parent Calls'), '', '', ''); foreach ($parents as $key => $name) { $rows[] = $this->formatRow(array($name, $data[$key]['ct'], $data[$key]['wt'], '')); } $rows[] = array(pht('Child Calls'), '', '', ''); $child_rows = array(); foreach ($children as $key => $name) { $child_rows[] = array($name, $data[$key]['ct'], $data[$key]['wt'], $data[$key]['wt'] / $flat[$symbol]['wt']); } $child_rows = isort($child_rows, 2); $child_rows = array_reverse($child_rows); $rows = array_merge($rows, array_map(array($this, 'formatRow'), $child_rows)); $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Symbol'), pht('Count'), pht('Wall Time'), '%')); $table->setColumnClasses(array('wide pri', 'n', 'n', 'n')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('XHProf Profile')); $panel->appendChild($table); return $panel->render(); }
public function render() { $project_phid = $this->request->getStr('project'); $project_handle = null; if ($project_phid) { $phids = array($project_phid); $project_handle = $this->getProjectHandle($phids, $project_phid, $this->request); $tasks = $this->getOpenTasksforProject($this->user, $phids); } else { $tasks = $this->getOpenTasks($this->user); } $recently_closed = $this->loadRecentlyClosedTasks(); $date = phabricator_date(time(), $this->user); $viewer_task_view = new UserOpenTasksView(); $project_task_view = new ProjectOpenTasksView(); if ($this->view == 'user') { list($leftover, $leftover_closed, $base_link, $leftover_name, $col_header, $header, $result_closed, $result) = $viewer_task_view->execute($tasks, $recently_closed, $date); } else { if ($this->view == 'project') { list($leftover, $base_link, $leftover_name, $col_header, $header, $result_closed, $leftover_closed, $result) = $project_task_view->execute($tasks, $recently_closed, $date); } else { $result = array(); $result_closed = array(); $base_link = null; $leftover = array(); $leftover_closed = array(); $leftover_name = null; $col_header = ''; $header = ''; } } $order = $this->request->getStr('order', 'name'); list($order, $reverse) = AphrontTableView::parseSort($order); require_celerity_resource('aphront-tooltip-css'); Javelin::initBehavior('phabricator-tooltips', array()); $rows = $this->buildRowsfromResult($project_handle, $result, $result_closed, $base_link, $leftover, $leftover_name, $leftover_closed, $order, $reverse); list($cname, $cclass) = $this->buildTableColumns($col_header); $table = $this->buildOpenTasksTable($rows, $cname, $cclass, $order, $reverse); $panel = new PHUIObjectBoxView(); $panel->setHeaderText($header); $panel->setTable($table); $tokens = array(); if ($project_handle) { $tokens = array($project_handle); } $filter = $this->renderReportFilters($tokens, $has_window = false, $this->request, $this->user); return array($filter, $panel); }
public function renderExample() { $rows = array(); $examples = array(array(pht('Reactive button only generates a stream of events'), 'ReactorButtonExample', 'phabricator-uiexample-reactor-button', array()), array(pht('Reactive checkbox generates a boolean dynamic value'), 'ReactorCheckboxExample', 'phabricator-uiexample-reactor-checkbox', array('checked' => true)), array(pht('Reactive focus detector generates a boolean dynamic value'), 'ReactorFocusExample', 'phabricator-uiexample-reactor-focus', array()), array(pht('Reactive input box, with normal and calmed output'), 'ReactorInputExample', 'phabricator-uiexample-reactor-input', array('init' => 'Initial value')), array(pht('Reactive mouseover detector generates a boolean dynamic value'), 'ReactorMouseoverExample', 'phabricator-uiexample-reactor-mouseover', array()), array(pht('Reactive radio buttons generate a string dynamic value'), 'ReactorRadioExample', 'phabricator-uiexample-reactor-radio', array()), array(pht('Reactive select box generates a string dynamic value'), 'ReactorSelectExample', 'phabricator-uiexample-reactor-select', array()), array(pht('%s makes the class of an element a string dynamic value', 'sendclass'), 'ReactorSendClassExample', 'phabricator-uiexample-reactor-sendclass', array()), array(pht('%s makes some properties of an object into dynamic values', 'sendproperties'), 'ReactorSendPropertiesExample', 'phabricator-uiexample-reactor-sendproperties', array())); foreach ($examples as $example) { list($desc, $name, $resource, $params) = $example; $template = new AphrontJavelinView(); $template->setName($name)->setParameters($params)->setCelerityResource($resource); $rows[] = array($desc, $template->render()); } $table = new AphrontTableView($rows); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Example')); $panel->appendChild($table); return $panel; }
public function render() { DarkConsoleXHProfPluginAPI::includeXHProfLib(); $GLOBALS['display_calls'] = true; $totals = array(); $flat = xhprof_compute_flat_info($this->profileData, $totals); unset($GLOBALS['display_calls']); $aggregated = array(); foreach ($flat as $call => $counters) { $parts = explode('@', $call, 2); $agg_call = reset($parts); if (empty($aggregated[$agg_call])) { $aggregated[$agg_call] = $counters; } else { foreach ($aggregated[$agg_call] as $key => $val) { if ($key != 'wt') { $aggregated[$agg_call][$key] += $counters[$key]; } } } } $flat = $aggregated; $flat = isort($flat, 'wt'); $flat = array_reverse($flat); $rows = array(); $rows[] = array(pht('Total'), number_format($totals['ct']), number_format($totals['wt']) . ' us', '100.0%', number_format($totals['wt']) . ' us', '100.0%'); if ($this->limit) { $flat = array_slice($flat, 0, $this->limit); } foreach ($flat as $call => $counters) { $rows[] = array($this->renderSymbolLink($call), number_format($counters['ct']), number_format($counters['wt']) . ' us', sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']), number_format($counters['excl_wt']) . ' us', sprintf('%.1f%%', 100 * $counters['excl_wt'] / $totals['wt'])); } Javelin::initBehavior('phabricator-tooltips'); $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Symbol'), pht('Count'), javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Total wall time spent in this function and all of ' . 'its children (children are other functions it called ' . 'while executing).'), 'size' => 200)), pht('Wall Time (Inclusive)')), '%', javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Wall time spent in this function, excluding time ' . 'spent in children (children are other functions it ' . 'called while executing).'), 'size' => 200)), pht('Wall Time (Exclusive)')), '%')); $table->setColumnClasses(array('wide pri', 'n', 'n', 'n', 'n', 'n')); $panel = new PHUIObjectBoxView(); $header = id(new PHUIHeaderView())->setHeader(pht('XHProf Profile')); if ($this->file) { $button = id(new PHUIButtonView())->setHref($this->file->getBestURI())->setText(pht('Download %s Profile', '.xhprof'))->setTag('a'); $header->addActionLink($button); } $panel->setHeader($header); $panel->appendChild($table); return $panel->render(); }
private function buildPropertyViews(PHUIObjectBoxView $box, PhabricatorFile $file, PhabricatorActionListView $actions) { $request = $this->getRequest(); $user = $request->getUser(); $properties = id(new PHUIPropertyListView()); $properties->setActionList($actions); $box->addPropertyList($properties, pht('Details')); if ($file->getAuthorPHID()) { $properties->addProperty(pht('Author'), $this->getHandle($file->getAuthorPHID())->renderLink()); } $properties->addProperty(pht('Created'), phabricator_datetime($file->getDateCreated(), $user)); $finfo = id(new PHUIPropertyListView()); $box->addPropertyList($finfo, pht('File Info')); $finfo->addProperty(pht('Size'), phutil_format_bytes($file->getByteSize())); $finfo->addProperty(pht('Mime Type'), $file->getMimeType()); $width = $file->getImageWidth(); if ($width) { $finfo->addProperty(pht('Width'), pht('%s px', new PhutilNumber($width))); } $height = $file->getImageHeight(); if ($height) { $finfo->addProperty(pht('Height'), pht('%s px', new PhutilNumber($height))); } $is_image = $file->isViewableImage(); if ($is_image) { $image_string = pht('Yes'); $cache_string = $file->getCanCDN() ? pht('Yes') : pht('No'); } else { $image_string = pht('No'); $cache_string = pht('Not Applicable'); } $finfo->addProperty(pht('Viewable Image'), $image_string); $finfo->addProperty(pht('Cacheable'), $cache_string); $storage_properties = new PHUIPropertyListView(); $box->addPropertyList($storage_properties, pht('Storage')); $storage_properties->addProperty(pht('Engine'), $file->getStorageEngine()); $storage_properties->addProperty(pht('Format'), $file->getStorageFormat()); $storage_properties->addProperty(pht('Handle'), $file->getStorageHandle()); $phids = $file->getObjectPHIDs(); if ($phids) { $attached = new PHUIPropertyListView(); $box->addPropertyList($attached, pht('Attached')); $attached->addProperty(pht('Attached To'), $this->renderHandlesForPHIDs($phids)); } if ($file->isViewableImage()) { $image = phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phui-property-list-image')); $linked_image = phutil_tag('a', array('href' => $file->getViewURI()), $image); $media = id(new PHUIPropertyListView())->addImageContent($linked_image); $box->addPropertyList($media); } else { if ($file->isAudio()) { $audio = phutil_tag('audio', array('controls' => 'controls', 'class' => 'phui-property-list-audio'), phutil_tag('source', array('src' => $file->getViewURI(), 'type' => $file->getMimeType()))); $media = id(new PHUIPropertyListView())->addImageContent($audio); $box->addPropertyList($media); } } }
protected function processDiffusionRequest(AphrontRequest $request) { $drequest = $this->diffusionRequest; $viewer = $request->getUser(); $repository = $drequest->getRepository(); $page_size = $request->getInt('pagesize', 100); $offset = $request->getInt('offset', 0); $params = array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => $offset, 'limit' => $page_size + 1); if (!$request->getBool('copies')) { $params['needDirectChanges'] = true; $params['needChildChanges'] = true; } $history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', $params); $history = DiffusionPathChange::newFromConduit($history_results['pathChanges']); $pager = new AphrontPagerView(); $pager->setPageSize($page_size); $pager->setOffset($offset); $history = $pager->sliceResults($history); $pager->setURI($request->getRequestURI(), 'offset'); $show_graph = !strlen($drequest->getPath()); $content = array(); $history_table = new DiffusionHistoryTableView(); $history_table->setUser($request->getUser()); $history_table->setDiffusionRequest($drequest); $history_table->setHistory($history); $history_table->loadRevisions(); $phids = $history_table->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $history_table->setHandles($handles); if ($show_graph) { $history_table->setParents($history_results['parents']); $history_table->setIsHead($offset == 0); } $history_panel = new PHUIObjectBoxView(); $history_panel->setHeaderText(pht('History')); $history_panel->appendChild($history_table); $content[] = $history_panel; $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($repository)->setHeader($this->renderPathLinks($drequest, $mode = 'history')); $actions = $this->buildActionView($drequest); $properties = $this->buildPropertyView($drequest, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history')); return $this->buildApplicationPage(array($crumbs, $object_box, $content, $pager), array('title' => array(pht('History'), pht('%s Repository', $drequest->getRepository()->getCallsign())))); }
public function renderExample() { $request = $this->getRequest(); $init = $request->getStr('init'); $parent_server_template = new JavelinViewExampleServerView(); $parent_client_template = new AphrontJavelinView(); $parent_client_template->setName('JavelinViewExample')->setCelerityResource('phabricator-uiexample-javelin-view'); $child_server_template = new JavelinViewExampleServerView(); $child_client_template = new AphrontJavelinView(); $child_client_template->setName('JavelinViewExample')->setCelerityResource('phabricator-uiexample-javelin-view'); $parent_server_template->appendChild($parent_client_template); $parent_client_template->appendChild($child_server_template); $child_server_template->appendChild($child_client_template); $child_client_template->appendChild(pht('Hey, it worked.')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Example')); $panel->appendChild(phutil_tag_div('ml', $parent_server_template)); return $panel; }
public function handleRequest(AphrontRequest $request) { $response = $this->loadDiffusionContext(); if ($response) { return $response; } $viewer = $this->getViewer(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $pager = id(new PHUIPagerView())->readFromRequest($request); $params = array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => $pager->getOffset(), 'limit' => $pager->getPageSize() + 1); if (!$request->getBool('copies')) { $params['needDirectChanges'] = true; $params['needChildChanges'] = true; } $history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', $params); $history = DiffusionPathChange::newFromConduit($history_results['pathChanges']); $history = $pager->sliceResults($history); $show_graph = !strlen($drequest->getPath()); $content = array(); $history_table = id(new DiffusionHistoryTableView())->setUser($request->getUser())->setDiffusionRequest($drequest)->setHistory($history); $history_table->loadRevisions(); if ($show_graph) { $history_table->setParents($history_results['parents']); $history_table->setIsHead(!$pager->getOffset()); $history_table->setIsTail(!$pager->getHasMorePages()); } $history_panel = new PHUIObjectBoxView(); $history_panel->setHeaderText(pht('History')); $history_panel->setTable($history_table); $content[] = $history_panel; $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($repository)->setHeader($this->renderPathLinks($drequest, $mode = 'history')); $actions = $this->buildActionView($drequest); $properties = $this->buildPropertyView($drequest, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history')); $pager_box = $this->renderTablePagerBox($pager); return $this->newPage()->setTitle(array(pht('History'), $repository->getDisplayName()))->setCrumbs($crumbs)->appendChild(array($object_box, $content, $pager_box)); }
public function renderExample() { $request = $this->getRequest(); $offset = (int) $request->getInt('offset'); $page_size = 20; $item_count = 173; $rows = array(); for ($ii = $offset; $ii < min($item_count, $offset + $page_size); $ii++) { $rows[] = array(pht('Item #%d', $ii + 1)); } $table = new AphrontTableView($rows); $table->setHeaders(array('Item')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Example')); $panel->appendChild($table); $panel->appendChild(hsprintf('<p class="phabricator-ui-example-note">%s</p>', pht('Use %s to render a pager element.', phutil_tag('tt', array(), 'PHUIPagerView')))); $pager = new PHUIPagerView(); $pager->setPageSize($page_size); $pager->setOffset($offset); $pager->setCount($item_count); $pager->setURI($request->getRequestURI(), 'offset'); $panel->appendChild($pager); $panel->appendChild(hsprintf('<p class="phabricator-ui-example-note">%s</p>', pht('You can show more or fewer pages of surrounding context.'))); $many_pages_pager = new PHUIPagerView(); $many_pages_pager->setPageSize($page_size); $many_pages_pager->setOffset($offset); $many_pages_pager->setCount($item_count); $many_pages_pager->setURI($request->getRequestURI(), 'offset'); $many_pages_pager->setSurroundingPages(7); $panel->appendChild($many_pages_pager); $panel->appendChild(hsprintf('<p class="phabricator-ui-example-note">%s</p>', pht('When it is prohibitively expensive or complex to attain a complete ' . 'count of the items, you can select one extra item and set ' . '%s if it exists, creating an inexact pager.', phutil_tag('tt', array(), 'hasMorePages(true)')))); $inexact_pager = new PHUIPagerView(); $inexact_pager->setPageSize($page_size); $inexact_pager->setOffset($offset); $inexact_pager->setHasMorePages($offset < $item_count - $page_size); $inexact_pager->setURI($request->getRequestURI(), 'offset'); $panel->appendChild($inexact_pager); return $panel; }
public function renderExample() { $rows = array(array('make' => 'Honda', 'model' => 'Civic', 'year' => 2004, 'price' => 3199, 'color' => pht('Blue')), array('make' => 'Ford', 'model' => 'Focus', 'year' => 2001, 'price' => 2549, 'color' => pht('Red')), array('make' => 'Toyota', 'model' => 'Camry', 'year' => 2009, 'price' => 4299, 'color' => pht('Black')), array('make' => 'NASA', 'model' => 'Shuttle', 'year' => 1998, 'price' => 1000000000, 'color' => pht('White'))); $request = $this->getRequest(); $orders = array('make', 'model', 'year', 'price'); $sort = $request->getStr('sort'); list($sort, $reverse) = AphrontTableView::parseSort($sort); if (!in_array($sort, $orders)) { $sort = 'make'; } $rows = isort($rows, $sort); if ($reverse) { $rows = array_reverse($rows); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Make'), pht('Model'), pht('Year'), pht('Price'), pht('Color'))); $table->setColumnClasses(array('', 'wide', 'n', 'n', '')); $table->makeSortable($request->getRequestURI(), 'sort', $sort, $reverse, $orders); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Sortable Table of Vehicles')); $panel->appendChild($table); return $panel; }
private function buildChartForm() { $request = $this->getRequest(); $viewer = $request->getUser(); $table = new PhabricatorFactRaw(); $conn_r = $table->establishConnection('r'); $table_name = $table->getTableName(); $facts = queryfx_all($conn_r, 'SELECT DISTINCT factType from %T', $table_name); $specs = PhabricatorFactSpec::newSpecsForFactTypes(PhabricatorFactEngine::loadAllEngines(), ipull($facts, 'factType')); $options = array(); foreach ($specs as $spec) { if ($spec->getUnit() == PhabricatorFactSpec::UNIT_COUNT) { $options[$spec->getType()] = $spec->getName(); } } if (!$options) { return id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NODATA)->setTitle(pht('No Chartable Facts'))->appendChild(phutil_tag('p', array(), pht('There are no facts that can be plotted yet.'))); } $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Y-Axis'))->setName('y1')->setOptions($options))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Plot Chart'))); $panel = new PHUIObjectBoxView(); $panel->setForm($form); $panel->setHeaderText(pht('Plot Chart')); return $panel; }
private function newItem(AphrontRequest $request, $title, $done, $content) { $viewer = $request->getUser(); $box = new PHUIObjectBoxView(); $header = new PHUIActionHeaderView(); $header->setHeaderTitle($title); if ($done === true) { $box->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTGREEN); $header->addAction(id(new PHUIIconView())->setIconFont('fa-check')); } else { if ($done === false) { $box->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTVIOLET); $header->addAction(id(new PHUIIconView())->setIconFont('fa-exclamation')); } } $content = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($content), 'default', $viewer); $content = phutil_tag('div', array('class' => 'config-welcome-box-content'), $content); $box->setHeader($header); $box->appendChild($content); return $box; }
protected function processDiffusionRequest(AphrontRequest $request) { $user = $request->getUser(); $this->name = $request->getURIData('name'); $query = id(new DiffusionSymbolQuery())->setViewer($user)->setName($this->name); if ($request->getStr('context')) { $query->setContext($request->getStr('context')); } if ($request->getStr('type')) { $query->setType($request->getStr('type')); } if ($request->getStr('lang')) { $query->setLanguage($request->getStr('lang')); } if ($request->getStr('repositories')) { $phids = $request->getStr('repositories'); $phids = explode(',', $phids); $phids = array_filter($phids); if ($phids) { $repos = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs($phids)->execute(); $repos = mpull($repos, 'getPHID'); if ($repos) { $query->withRepositoryPHIDs($repos); } } } $query->needPaths(true); $query->needRepositories(true); $symbols = $query->execute(); $external_query = id(new DiffusionExternalSymbolQuery())->withNames(array($this->name)); if ($request->getStr('context')) { $external_query->withContexts(array($request->getStr('context'))); } if ($request->getStr('type')) { $external_query->withTypes(array($request->getStr('type'))); } if ($request->getStr('lang')) { $external_query->withLanguages(array($request->getStr('lang'))); } $external_sources = id(new PhutilClassMapQuery())->setAncestorClass('DiffusionExternalSymbolsSource')->execute(); $results = array($symbols); foreach ($external_sources as $source) { $results[] = $source->executeQuery($external_query); } $symbols = array_mergev($results); if ($request->getBool('jump') && count($symbols) == 1) { // If this is a clickthrough from Differential, just jump them // straight to the target if we got a single hit. $symbol = head($symbols); return id(new AphrontRedirectResponse())->setIsExternal($symbol->isExternal())->setURI($symbol->getURI()); } $rows = array(); foreach ($symbols as $symbol) { $href = $symbol->getURI(); if ($symbol->isExternal()) { $source = $symbol->getSource(); $location = $symbol->getLocation(); } else { $repo = $symbol->getRepository(); $file = $symbol->getPath(); $line = $symbol->getLineNumber(); $source = $repo->getMonogram(); $location = $file . ':' . $line; } $location = phutil_tag('a', array('href' => $href), $location); $rows[] = array($symbol->getSymbolType(), $symbol->getSymbolContext(), $symbol->getSymbolName(), $symbol->getSymbolLanguage(), $source, $location); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Type'), pht('Context'), pht('Name'), pht('Language'), pht('Source'), pht('Location'))); $table->setColumnClasses(array('', '', 'pri', '', '', '')); $table->setNoDataString(pht('No matching symbol could be found in any indexed repository.')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Similar Symbols')); $panel->setTable($table); return $this->buildApplicationPage($panel, array('title' => pht('Find Symbol'))); }
private function buildMergesTable(PhabricatorRepositoryCommit $commit) { $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $vcs = $repository->getVersionControlSystem(); switch ($vcs) { case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: // These aren't supported under SVN. return null; } $limit = 50; $merges = $this->callConduitWithDiffusionRequest('diffusion.mergedcommitsquery', array('commit' => $drequest->getCommit(), 'limit' => $limit + 1)); if (!$merges) { return null; } $merges = DiffusionPathChange::newFromConduit($merges); $caption = null; if (count($merges) > $limit) { $merges = array_slice($merges, 0, $limit); $caption = new PHUIInfoView(); $caption->setSeverity(PHUIInfoView::SEVERITY_NOTICE); $caption->appendChild(pht('This commit merges a very large number of changes. ' . 'Only the first %s are shown.', new PhutilNumber($limit))); } $history_table = new DiffusionHistoryTableView(); $history_table->setUser($this->getRequest()->getUser()); $history_table->setDiffusionRequest($drequest); $history_table->setHistory($merges); $history_table->loadRevisions(); $phids = $history_table->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $history_table->setHandles($handles); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Merged Changes')); $panel->setTable($history_table); if ($caption) { $panel->setInfoView($caption); } return $panel; }
private function buildBrowseTable($browse_results, $browse_paths, $browse_exception, array $handles) { require_celerity_resource('diffusion-icons-css'); $request = $this->getRequest(); $viewer = $request->getUser(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); if ($browse_exception) { if ($repository->isImporting()) { // The history table renders a useful message. return null; } else { return $this->renderStatusMessage(pht('Unable to Retrieve Paths'), $browse_exception->getMessage()); } } $browse_table = id(new DiffusionBrowseTableView())->setUser($viewer)->setDiffusionRequest($drequest)->setHandles($handles); if ($browse_paths) { $browse_table->setPaths($browse_paths); } else { $browse_table->setPaths(array()); } $browse_uri = $drequest->generateURI(array('action' => 'browse')); $browse_panel = new PHUIObjectBoxView(); $header = id(new PHUIHeaderView())->setHeader(pht('Repository')); $icon = id(new PHUIIconView())->setIconFont('fa-folder-open'); $button = new PHUIButtonView(); $button->setText(pht('Browse Repository')); $button->setTag('a'); $button->setIcon($icon); $button->setHref($browse_uri); $header->addActionLink($button); $browse_panel->setHeader($header); $locate_panel = null; if ($repository->canUsePathTree()) { Javelin::initBehavior('diffusion-locate-file', array('controlID' => 'locate-control', 'inputID' => 'locate-input', 'browseBaseURI' => (string) $drequest->generateURI(array('action' => 'browse')), 'uri' => (string) $drequest->generateURI(array('action' => 'pathtree')))); $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormTypeaheadControl())->setHardpointID('locate-control')->setID('locate-input')->setLabel(pht('Locate File'))); $form_box = id(new PHUIBoxView())->appendChild($form->buildLayoutView()); $locate_panel = id(new PHUIObjectBoxView())->setHeaderText('Locate File')->appendChild($form_box); } $browse_panel->setTable($browse_table); return array($locate_panel, $browse_panel); }
public function renderOpenTasks() { $request = $this->getRequest(); $viewer = $request->getUser(); $query = id(new ManiphestTaskQuery())->setViewer($viewer)->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); switch ($this->view) { case 'project': $query->needProjectPHIDs(true); break; } $project_phid = $request->getStr('project'); $project_handle = null; if ($project_phid) { $phids = array($project_phid); $handles = $this->loadViewerHandles($phids); $project_handle = $handles[$project_phid]; $query->withEdgeLogicPHIDs(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, PhabricatorQueryConstraint::OPERATOR_OR, $phids); } $tasks = $query->execute(); $recently_closed = $this->loadRecentlyClosedTasks(); $date = phabricator_date(time(), $viewer); switch ($this->view) { case 'user': $result = mgroup($tasks, 'getOwnerPHID'); $leftover = idx($result, '', array()); unset($result['']); $result_closed = mgroup($recently_closed, 'getOwnerPHID'); $leftover_closed = idx($result_closed, '', array()); unset($result_closed['']); $base_link = '/maniphest/?assigned='; $leftover_name = phutil_tag('em', array(), pht('(Up For Grabs)')); $col_header = pht('User'); $header = pht('Open Tasks by User and Priority (%s)', $date); break; case 'project': $result = array(); $leftover = array(); foreach ($tasks as $task) { $phids = $task->getProjectPHIDs(); if ($phids) { foreach ($phids as $project_phid) { $result[$project_phid][] = $task; } } else { $leftover[] = $task; } } $result_closed = array(); $leftover_closed = array(); foreach ($recently_closed as $task) { $phids = $task->getProjectPHIDs(); if ($phids) { foreach ($phids as $project_phid) { $result_closed[$project_phid][] = $task; } } else { $leftover_closed[] = $task; } } $base_link = '/maniphest/?projects='; $leftover_name = phutil_tag('em', array(), pht('(No Project)')); $col_header = pht('Project'); $header = pht('Open Tasks by Project and Priority (%s)', $date); break; } $phids = array_keys($result); $handles = $this->loadViewerHandles($phids); $handles = msort($handles, 'getName'); $order = $request->getStr('order', 'name'); list($order, $reverse) = AphrontTableView::parseSort($order); require_celerity_resource('aphront-tooltip-css'); Javelin::initBehavior('phabricator-tooltips', array()); $rows = array(); $pri_total = array(); foreach (array_merge($handles, array(null)) as $handle) { if ($handle) { if ($project_handle && $project_handle->getPHID() == $handle->getPHID()) { // If filtering by, e.g., "bugs", don't show a "bugs" group. continue; } $tasks = idx($result, $handle->getPHID(), array()); $name = phutil_tag('a', array('href' => $base_link . $handle->getPHID()), $handle->getName()); $closed = idx($result_closed, $handle->getPHID(), array()); } else { $tasks = $leftover; $name = $leftover_name; $closed = $leftover_closed; } $taskv = $tasks; $tasks = mgroup($tasks, 'getPriority'); $row = array(); $row[] = $name; $total = 0; foreach (ManiphestTaskPriority::getTaskPriorityMap() as $pri => $label) { $n = count(idx($tasks, $pri, array())); if ($n == 0) { $row[] = '-'; } else { $row[] = number_format($n); } $total += $n; } $row[] = number_format($total); list($link, $oldest_all) = $this->renderOldest($taskv); $row[] = $link; $normal_or_better = array(); foreach ($taskv as $id => $task) { // TODO: This is sort of a hard-code for the default "normal" status. // When reports are more powerful, this should be made more general. if ($task->getPriority() < 50) { continue; } $normal_or_better[$id] = $task; } list($link, $oldest_pri) = $this->renderOldest($normal_or_better); $row[] = $link; if ($closed) { $task_ids = implode(',', mpull($closed, 'getID')); $row[] = phutil_tag('a', array('href' => '/maniphest/?ids=' . $task_ids, 'target' => '_blank'), number_format(count($closed))); } else { $row[] = '-'; } switch ($order) { case 'total': $row['sort'] = $total; break; case 'oldest-all': $row['sort'] = $oldest_all; break; case 'oldest-pri': $row['sort'] = $oldest_pri; break; case 'closed': $row['sort'] = count($closed); break; case 'name': default: $row['sort'] = $handle ? $handle->getName() : '~'; break; } $rows[] = $row; } $rows = isort($rows, 'sort'); foreach ($rows as $k => $row) { unset($rows[$k]['sort']); } if ($reverse) { $rows = array_reverse($rows); } $cname = array($col_header); $cclass = array('pri right wide'); $pri_map = ManiphestTaskPriority::getShortNameMap(); foreach ($pri_map as $pri => $label) { $cname[] = $label; $cclass[] = 'n'; } $cname[] = pht('Total'); $cclass[] = 'n'; $cname[] = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Oldest open task.'), 'size' => 200)), pht('Oldest (All)')); $cclass[] = 'n'; $cname[] = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Oldest open task, excluding those with Low or Wishlist priority.'), 'size' => 200)), pht('Oldest (Pri)')); $cclass[] = 'n'; list($ignored, $window_epoch) = $this->getWindow(); $edate = phabricator_datetime($window_epoch, $viewer); $cname[] = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Closed after %s', $edate), 'size' => 260)), pht('Recently Closed')); $cclass[] = 'n'; $table = new AphrontTableView($rows); $table->setHeaders($cname); $table->setColumnClasses($cclass); $table->makeSortable($request->getRequestURI(), 'order', $order, $reverse, array('name', null, null, null, null, null, null, 'total', 'oldest-all', 'oldest-pri', 'closed')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText($header); $panel->setTable($table); $tokens = array(); if ($project_handle) { $tokens = array($project_handle); } $filter = $this->renderReportFilters($tokens, $has_window = true); return array($filter, $panel); }
private function buildHumanReadableResponse($method, ConduitAPIRequest $request = null, $result = null, ConduitAPIMethod $method_implementation = null) { $param_rows = array(); $param_rows[] = array('Method', $this->renderAPIValue($method)); if ($request) { foreach ($request->getAllParameters() as $key => $value) { $param_rows[] = array($key, $this->renderAPIValue($value)); } } $param_table = new AphrontTableView($param_rows); $param_table->setColumnClasses(array('header', 'wide')); $result_rows = array(); foreach ($result as $key => $value) { $result_rows[] = array($key, $this->renderAPIValue($value)); } $result_table = new AphrontTableView($result_rows); $result_table->setColumnClasses(array('header', 'wide')); $param_panel = new PHUIObjectBoxView(); $param_panel->setHeaderText(pht('Method Parameters')); $param_panel->setTable($param_table); $result_panel = new PHUIObjectBoxView(); $result_panel->setHeaderText(pht('Method Result')); $result_panel->setTable($result_table); $method_uri = $this->getApplicationURI('method/' . $method . '/'); $crumbs = $this->buildApplicationCrumbs()->addTextCrumb($method, $method_uri)->addTextCrumb(pht('Call')); $example_panel = null; if ($request && $method_implementation) { $params = $request->getAllParameters(); $example_panel = $this->renderExampleBox($method_implementation, $params); } return $this->buildApplicationPage(array($crumbs, $param_panel, $result_panel, $example_panel), array('title' => pht('Method Call Result'))); }
public function buildCommitPanel() { $request = $this->getRequest(); $user = $request->getUser(); $phids = array($user->getPHID()); $query = id(new DiffusionCommitQuery())->setViewer($user)->withAuthorPHIDs($phids)->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->needAuditRequests(true)->setLimit(10); $commits = $query->execute(); if (!$commits) { return $this->renderMinipanel(pht('No Problem Commits'), pht('No one has raised concerns with your commits.')); } $view = id(new PhabricatorAuditListView())->setCommits($commits)->setUser($user); $phids = $view->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $view->setHandles($handles); $title = pht('Problem Commits'); $href = '/audit/'; $panel = new PHUIObjectBoxView(); $panel->setHeader($this->renderSectionHeader($title, $href)); $panel->setObjectList($view); return $panel; }
private function buildPropertyViews(PHUIObjectBoxView $box, PhabricatorFile $file) { $request = $this->getRequest(); $viewer = $request->getUser(); $tab_group = id(new PHUITabGroupView()); $box->addTabGroup($tab_group); $properties = id(new PHUIPropertyListView()); $tab_group->addTab(id(new PHUITabView())->setName(pht('Details'))->setKey('details')->appendChild($properties)); if ($file->getAuthorPHID()) { $properties->addProperty(pht('Author'), $viewer->renderHandle($file->getAuthorPHID())); } $properties->addProperty(pht('Created'), phabricator_datetime($file->getDateCreated(), $viewer)); $finfo = id(new PHUIPropertyListView()); $tab_group->addTab(id(new PHUITabView())->setName(pht('File Info'))->setKey('info')->appendChild($finfo)); $finfo->addProperty(pht('Size'), phutil_format_bytes($file->getByteSize())); $finfo->addProperty(pht('Mime Type'), $file->getMimeType()); $width = $file->getImageWidth(); if ($width) { $finfo->addProperty(pht('Width'), pht('%s px', new PhutilNumber($width))); } $height = $file->getImageHeight(); if ($height) { $finfo->addProperty(pht('Height'), pht('%s px', new PhutilNumber($height))); } $is_image = $file->isViewableImage(); if ($is_image) { $image_string = pht('Yes'); $cache_string = $file->getCanCDN() ? pht('Yes') : pht('No'); } else { $image_string = pht('No'); $cache_string = pht('Not Applicable'); } $types = array(); if ($file->isViewableImage()) { $types[] = pht('Image'); } if ($file->isVideo()) { $types[] = pht('Video'); } if ($file->isAudio()) { $types[] = pht('Audio'); } if ($file->getCanCDN()) { $types[] = pht('Can CDN'); } $builtin = $file->getBuiltinName(); if ($builtin !== null) { $types[] = pht('Builtin ("%s")', $builtin); } if ($file->getIsProfileImage()) { $types[] = pht('Profile'); } if ($types) { $types = implode(', ', $types); $finfo->addProperty(pht('Attributes'), $types); } $storage_properties = new PHUIPropertyListView(); $tab_group->addTab(id(new PHUITabView())->setName(pht('Storage'))->setKey('storage')->appendChild($storage_properties)); $storage_properties->addProperty(pht('Engine'), $file->getStorageEngine()); $engine = $this->loadStorageEngine($file); if ($engine && $engine->isChunkEngine()) { $format_name = pht('Chunks'); } else { $format_key = $file->getStorageFormat(); $format = PhabricatorFileStorageFormat::getFormat($format_key); if ($format) { $format_name = $format->getStorageFormatName(); } else { $format_name = pht('Unknown ("%s")', $format_key); } } $storage_properties->addProperty(pht('Format'), $format_name); $storage_properties->addProperty(pht('Handle'), $file->getStorageHandle()); $phids = $file->getObjectPHIDs(); if ($phids) { $attached = new PHUIPropertyListView(); $tab_group->addTab(id(new PHUITabView())->setName(pht('Attached'))->setKey('attached')->appendChild($attached)); $attached->addProperty(pht('Attached To'), $viewer->renderHandleList($phids)); } if ($file->isViewableImage()) { $image = phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phui-property-list-image')); $linked_image = phutil_tag('a', array('href' => $file->getViewURI()), $image); $media = id(new PHUIPropertyListView())->addImageContent($linked_image); $box->addPropertyList($media); } else { if ($file->isVideo()) { $video = phutil_tag('video', array('controls' => 'controls', 'class' => 'phui-property-list-video'), phutil_tag('source', array('src' => $file->getViewURI(), 'type' => $file->getMimeType()))); $media = id(new PHUIPropertyListView())->addImageContent($video); $box->addPropertyList($media); } else { if ($file->isAudio()) { $audio = phutil_tag('audio', array('controls' => 'controls', 'class' => 'phui-property-list-audio'), phutil_tag('source', array('src' => $file->getViewURI(), 'type' => $file->getMimeType()))); $media = id(new PHUIPropertyListView())->addImageContent($audio); $box->addPropertyList($media); } } } $engine = $this->loadStorageEngine($file); if ($engine) { if ($engine->isChunkEngine()) { $chunkinfo = new PHUIPropertyListView(); $tab_group->addTab(id(new PHUITabView())->setName(pht('Chunks'))->setKey('chunks')->appendChild($chunkinfo)); $chunks = id(new PhabricatorFileChunkQuery())->setViewer($viewer)->withChunkHandles(array($file->getStorageHandle()))->execute(); $chunks = msort($chunks, 'getByteStart'); $rows = array(); $completed = array(); foreach ($chunks as $chunk) { $is_complete = $chunk->getDataFilePHID(); $rows[] = array($chunk->getByteStart(), $chunk->getByteEnd(), $is_complete ? pht('Yes') : pht('No')); if ($is_complete) { $completed[] = $chunk; } } $table = id(new AphrontTableView($rows))->setHeaders(array(pht('Offset'), pht('End'), pht('Complete')))->setColumnClasses(array('', '', 'wide')); $chunkinfo->addProperty(pht('Total Chunks'), count($chunks)); $chunkinfo->addProperty(pht('Completed Chunks'), count($completed)); $chunkinfo->addRawContent($table); } } }