in web_ui/src/applications/bistro/controllers/BistroJobListViewController.php [15:135]
protected function processRequest() {
$request = $this->getRequest();
$this->prefs = new BistroJobListPrefs($request);
$this->fetcher = BistroDataFetcher::newFrom(
// This source must be constructed first, since it initializes the prefs
BistroHostPortSource::newFrom($this->prefs),
$this->prefs);
$pager = $this->makePager();
$this->loadJobIDs($pager); // Tell the fetcher what jobs to get.
// Must run before we render the error log.
self::detectDuplicateNodeNames($this->fetcher->loadNodeNames());
// Fetch and sort jobs.
$sorted_jobs = $this->getJobsInRenderOrder($this->fetcher->loadJobs());
$rendered_jobs = array();
foreach ($sorted_jobs as $job) {
$config_blob_id = celerity_generate_unique_node_id();
$iframe_div_id = celerity_generate_unique_node_id();
$was_modified = $job->modifiedTime->getConsensus() !==
$job->createdTime->getConsensus();
$job_info = array(
$this->renderJobHeader($job, $config_blob_id, $iframe_div_id),
$this->renderMeta('Depends on',
$job->dependencies->renderDep(array($this, 'renderDependencyID'))),
$this->renderMeta('Packages', $job->packageIDs->render()),
$this->renderMeta('Path', $job->path->render()),
$this->renderMeta('Owner', $job->owner->render()),
$this->renderMeta('Priority', $job->priority->render()),
// It's only useful to show this when it's inconsistent across
// Bistro instances:
$job->level->isInconsistent()
? $this->renderMeta('Level for tasks', $job->level->render()) : null,
// Save space: show only the created time for never-modified jobs.
$this->renderMeta(
'Created'.($was_modified ? ' / Modified' : ''),
array(
$job->createdTime->render(),
$was_modified ? array(' / ', $job->modifiedTime->render()) : null)),
phabricator_tag(
'div',
array(
'id' => $config_blob_id,
'style' => 'display: none', // Config blobs are shown by JS
),
$this->renderMeta('Config', $job->config->render())),
$this->renderIframeDiv($iframe_div_id),
$job->summary->render($this->prefs));
$rendered_jobs[] =
phabricator_tag('div', array('class' => 'job-col'), $job_info);
}
require_celerity_resource('bistro-jobs');
$panel = new AphrontPanelView();
$panel->addClass('bistro-jobs');
$panel->setHeader('Bistro Jobs');
$mini_form_prefs = array(
BistroJobListPrefs::PREF_JOB_ID_REGEX,
BistroJobListPrefs::PREF_SORT_BY);
$mini_form_controls = array(
// Since BistroPrefs don't support having a default value be a function
// of another pref value, we have to manually show the fallback here:
$this->prefs->renderPrefControl(BistroJobListPrefs::PREF_JOB_ID_REGEX,
$this->getJobIDRegex()),
$this->prefs->renderPrefControlCurrentValue(
BistroJobListPrefs::PREF_SORT_BY));
if ($this->prefs->get(BistroJobListPrefs::PREF_JOBS)) {
array_unshift($mini_form_prefs, BistroJobListPrefs::PREF_JOBS);
array_unshift($mini_form_controls,
$this->prefs->renderPrefControlCurrentValue(
BistroJobListPrefs::PREF_JOBS));
// Suppress PREF_DEPRECATED_JOB_IDS from the form, since it is
// merged into JOBS, which we just set explicitly.
// Future: delete this once PREF_DEPRECATED_JOB_IDS is gone.
array_unshift(
$mini_form_prefs, BistroJobListPrefs::PREF_DEPRECATED_JOB_IDS);
}
$panel->appendChild(phabricator_tag(
'div',
array('class' => 'job-filter'),
array(
// A green submit button to edit the current prefs via the query page.
phabricator_tag('div', array('class' => 'bistro-jobs-edit-query-on-right'),
$this->prefs->renderEditQueryButton($request, '/bistro')),
// A two-control pref form for quick access.
$this->prefs->renderUpdateForm(
$request,
// No hidden controls for these, since they have real controls below.
array_fill_keys($mini_form_prefs, null),
array(
phabricator_tag('table', array('width'=>'100%'),
phabricator_tag('tr', array(), array(
phabricator_tag('td', array(), $mini_form_controls),
phabricator_tag('td', array(),
phabricator_tag('button', array('type' => 'submit'), 'Update'))))))))));
$panel->appendChild(phabricator_tag(
'div',
array('class' => 'fetcher-summary'),
bistro_ucfirst($this->fetcher->getSummary())));
$panel->appendChild($this->fetcher->loadErrors()->render());
$panel->appendChild(bistro_id(new BistroJobSummaryView(
$this->prefs, $sorted_jobs, $this->fetcher))->render());
$panel->appendChild(bistro_monitor_log()->render());
$panel->appendChild($pager);
$panel->appendChild($rendered_jobs);
$panel->appendChild($pager);
// Forward to JS prefs that the logs endpoint should use for fetching logs
require_celerity_resource('bistro-render-node-group-details');
Javelin::initBehavior(
'set-log-fetching-config', $this->prefs->getExplicitCommonPrefs());
return $this->buildStandardPageResponse(
array($panel, $this->prefs->render()),
array('title' => 'Bistro Jobs'));
}