Make project overview table update when build list does on dashboard, fixes #336
This commit is contained in:
parent
c50f7d07f2
commit
146470f39d
|
@ -41,20 +41,11 @@ class HomeController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$projects = $this->projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
|
$projects = $this->projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
|
||||||
|
|
||||||
$summaryBuilds = array();
|
|
||||||
foreach ($projects['items'] as $project) {
|
|
||||||
$summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
$summaryView = new b8\View('SummaryTable');
|
|
||||||
$summaryView->projects = $projects['items'];
|
|
||||||
$summaryView->builds = $summaryBuilds;
|
|
||||||
|
|
||||||
$this->view->builds = $this->getLatestBuildsHtml();
|
$this->view->builds = $this->getLatestBuildsHtml();
|
||||||
$this->view->projects = $projects['items'];
|
$this->view->projects = $projects['items'];
|
||||||
$this->view->summary = $summaryView->render();
|
$this->view->summary = $this->getSummaryHtml($projects);
|
||||||
|
|
||||||
$this->config->set('page_title', 'Dashboard');
|
$this->config->set('page_title', 'Dashboard');
|
||||||
|
|
||||||
|
@ -69,6 +60,26 @@ class HomeController extends \PHPCI\Controller
|
||||||
die($this->getLatestBuildsHtml());
|
die($this->getLatestBuildsHtml());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function summary()
|
||||||
|
{
|
||||||
|
$projects = $this->projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
|
||||||
|
die($this->getSummaryHtml($projects));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSummaryHtml($projects)
|
||||||
|
{
|
||||||
|
$summaryBuilds = array();
|
||||||
|
foreach ($projects['items'] as $project) {
|
||||||
|
$summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
$summaryView = new b8\View('SummaryTable');
|
||||||
|
$summaryView->projects = $projects['items'];
|
||||||
|
$summaryView->builds = $summaryBuilds;
|
||||||
|
|
||||||
|
return $summaryView->render();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get latest builds and render as a table.
|
* Get latest builds and render as a table.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -64,12 +64,16 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
refreshBuildsTable = function()
|
var refreshProjectData = function()
|
||||||
{
|
{
|
||||||
$('#latest-builds').load('<?php echo PHPCI_URL ?>home/latest', function () {
|
$('#latest-builds').load('<?php echo PHPCI_URL ?>home/latest', function () {
|
||||||
$('#latest-builds').trigger('latest-builds:reload');
|
$('#latest-builds').trigger('latest-builds:reload');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#project-overview').load('<?php echo PHPCI_URL ?>home/summary', function () {
|
||||||
|
$('#project-overview').trigger('project-overview:reload');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
setInterval(refreshBuildsTable, 10000);
|
setInterval(refreshProjectData, 10000);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue