Make project overview table update when build list does on dashboard, fixes #336
This commit is contained in:
parent
15b880b2f0
commit
81eff5e41c
|
@ -41,20 +41,11 @@ class HomeController extends \PHPCI\Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$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;
|
||||
$projects = $this->projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
|
||||
|
||||
$this->view->builds = $this->getLatestBuildsHtml();
|
||||
$this->view->projects = $projects['items'];
|
||||
$this->view->summary = $summaryView->render();
|
||||
$this->view->summary = $this->getSummaryHtml($projects);
|
||||
|
||||
$this->config->set('page_title', 'Dashboard');
|
||||
|
||||
|
@ -69,6 +60,26 @@ class HomeController extends \PHPCI\Controller
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -64,12 +64,16 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
refreshBuildsTable = function()
|
||||
var refreshProjectData = function()
|
||||
{
|
||||
$('#latest-builds').load('<?php echo PHPCI_URL ?>home/latest', function () {
|
||||
$('#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>
|
||||
|
|
Loading…
Reference in a new issue