@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a rough "Chart" Dashboard Panel

Summary:
Depends on D20484. Ref T13279. Allows a chart to render as a panel.

Configuring these is currently quite low-level (you have to manually copy/paste a chart key in), but works well enough.

Test Plan: {F6412708}

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: yelirekim

Maniphest Tasks: T13279

Differential Revision: https://secure.phabricator.com/D20485

+114 -7
+4
src/__phutil_library_map__.php
··· 2937 2937 'PhabricatorDashboardApplication' => 'applications/dashboard/application/PhabricatorDashboardApplication.php', 2938 2938 'PhabricatorDashboardApplicationInstallWorkflow' => 'applications/dashboard/install/PhabricatorDashboardApplicationInstallWorkflow.php', 2939 2939 'PhabricatorDashboardArchiveController' => 'applications/dashboard/controller/dashboard/PhabricatorDashboardArchiveController.php', 2940 + 'PhabricatorDashboardChartPanelChartTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardChartPanelChartTransaction.php', 2941 + 'PhabricatorDashboardChartPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardChartPanelType.php', 2940 2942 'PhabricatorDashboardColumn' => 'applications/dashboard/layoutconfig/PhabricatorDashboardColumn.php', 2941 2943 'PhabricatorDashboardConsoleController' => 'applications/dashboard/controller/PhabricatorDashboardConsoleController.php', 2942 2944 'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php', ··· 8983 8985 'PhabricatorDashboardApplication' => 'PhabricatorApplication', 8984 8986 'PhabricatorDashboardApplicationInstallWorkflow' => 'PhabricatorDashboardInstallWorkflow', 8985 8987 'PhabricatorDashboardArchiveController' => 'PhabricatorDashboardController', 8988 + 'PhabricatorDashboardChartPanelChartTransaction' => 'PhabricatorDashboardPanelPropertyTransaction', 8989 + 'PhabricatorDashboardChartPanelType' => 'PhabricatorDashboardPanelType', 8986 8990 'PhabricatorDashboardColumn' => 'Phobject', 8987 8991 'PhabricatorDashboardConsoleController' => 'PhabricatorDashboardController', 8988 8992 'PhabricatorDashboardController' => 'PhabricatorController',
+76
src/applications/dashboard/paneltype/PhabricatorDashboardChartPanelType.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardChartPanelType 4 + extends PhabricatorDashboardPanelType { 5 + 6 + public function getPanelTypeKey() { 7 + return 'chart'; 8 + } 9 + 10 + public function getPanelTypeName() { 11 + return pht('Chart Panel'); 12 + } 13 + 14 + public function getIcon() { 15 + return 'fa-area-chart'; 16 + } 17 + 18 + public function getPanelTypeDescription() { 19 + return pht('Show a chart.'); 20 + } 21 + 22 + protected function newEditEngineFields(PhabricatorDashboardPanel $panel) { 23 + $chart_field = id(new PhabricatorTextEditField()) 24 + ->setKey('chartKey') 25 + ->setLabel(pht('Chart')) 26 + ->setTransactionType( 27 + PhabricatorDashboardChartPanelChartTransaction::TRANSACTIONTYPE) 28 + ->setValue($panel->getProperty('chartKey', '')); 29 + 30 + return array( 31 + $chart_field, 32 + ); 33 + } 34 + 35 + public function renderPanelContent( 36 + PhabricatorUser $viewer, 37 + PhabricatorDashboardPanel $panel, 38 + PhabricatorDashboardPanelRenderingEngine $engine) { 39 + 40 + $engine = id(new PhabricatorChartEngine()) 41 + ->setViewer($viewer); 42 + 43 + $chart = $engine->loadChart($panel->getProperty('chartKey')); 44 + if (!$chart) { 45 + return pht('no such chart!'); 46 + } 47 + 48 + return $engine->newChartView(); 49 + } 50 + 51 + public function adjustPanelHeader( 52 + PhabricatorUser $viewer, 53 + PhabricatorDashboardPanel $panel, 54 + PhabricatorDashboardPanelRenderingEngine $engine, 55 + PHUIHeaderView $header) { 56 + 57 + $key = $panel->getProperty('chartKey'); 58 + $uri = PhabricatorChartEngine::getChartURI($key); 59 + 60 + $icon = id(new PHUIIconView()) 61 + ->setIcon('fa-area-chart'); 62 + 63 + $button = id(new PHUIButtonView()) 64 + ->setTag('a') 65 + ->setText(pht('View Chart')) 66 + ->setIcon($icon) 67 + ->setHref($uri) 68 + ->setColor(PHUIButtonView::GREY); 69 + 70 + $header->addActionLink($button); 71 + 72 + return $header; 73 + } 74 + 75 + 76 + }
+12
src/applications/dashboard/xaction/panel/PhabricatorDashboardChartPanelChartTransaction.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardChartPanelChartTransaction 4 + extends PhabricatorDashboardPanelPropertyTransaction { 5 + 6 + const TRANSACTIONTYPE = 'chart.chartKey'; 7 + 8 + protected function getPropertyKey() { 9 + return 'chartKey'; 10 + } 11 + 12 + }
+4 -7
src/applications/fact/controller/PhabricatorFactChartController.php
··· 10 10 return $this->newDemoChart(); 11 11 } 12 12 13 - $chart = id(new PhabricatorFactChart())->loadOneWhere( 14 - 'chartKey = %s', 15 - $chart_key); 13 + $engine = id(new PhabricatorChartEngine()) 14 + ->setViewer($viewer); 15 + 16 + $chart = $engine->loadChart($chart_key); 16 17 if (!$chart) { 17 18 return new Aphront404Response(); 18 19 } 19 - 20 - $engine = id(new PhabricatorChartEngine()) 21 - ->setViewer($viewer) 22 - ->setChart($chart); 23 20 24 21 // When drawing a chart, we send down a placeholder piece of HTML first, 25 22 // then fetch the data via async request. Determine if we're drawing
+18
src/applications/fact/engine/PhabricatorChartEngine.php
··· 25 25 return $this->chart; 26 26 } 27 27 28 + public function loadChart($chart_key) { 29 + $chart = id(new PhabricatorFactChart())->loadOneWhere( 30 + 'chartKey = %s', 31 + $chart_key); 32 + 33 + if ($chart) { 34 + $this->setChart($chart); 35 + } 36 + 37 + return $chart; 38 + } 39 + 40 + public static function getChartURI($chart_key) { 41 + return id(new PhabricatorFactChart()) 42 + ->setChartKey($chart_key) 43 + ->getURI(); 44 + } 45 + 28 46 public function getStoredChart() { 29 47 if (!$this->storedChart) { 30 48 $chart = $this->getChart();