1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00
phorge-phorge/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php

156 lines
4.5 KiB
PHP
Raw Normal View History

2011-03-27 07:55:18 +02:00
<?php
/*
* Copyright 2012 Facebook, Inc.
2011-03-27 07:55:18 +02:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorWorkerTaskDetailController
2011-03-27 07:55:18 +02:00
extends PhabricatorDaemonController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$task = id(new PhabricatorWorkerTask())->load($this->id);
if (!$task) {
$error_view = new AphrontErrorView();
$error_view->setTitle('No Such Task');
$error_view->appendChild(
'<p>This task may have recently completed.</p>');
$error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
return $this->buildStandardPageResponse(
$error_view,
array(
'title' => 'Task Does Not Exist',
));
}
$data = id(new PhabricatorWorkerTaskData())->loadOneWhere(
'id = %d',
$task->getDataID());
$extra = null;
switch ($task->getTaskClass()) {
case 'PhabricatorRepositorySvnCommitChangeParserWorker':
case 'PhabricatorRepositoryGitCommitChangeParserWorker':
$commit_id = idx($data->getData(), 'commitID');
if ($commit_id) {
$commit = id(new PhabricatorRepositoryCommit())->load($commit_id);
if ($commit) {
$repository = id(new PhabricatorRepository())->load(
$commit->getRepositoryID());
if ($repository) {
$extra =
"<strong>NOTE:</strong> ".
"You can manually retry this task by running this script:".
"<pre>".
"phabricator/\$ ./scripts/repository/reparse.php ".
"r".
phutil_escape_html($repository->getCallsign()).
phutil_escape_html($commit->getCommitIdentifier()).
" ".
"--change".
"</pre>";
}
}
}
break;
default:
break;
}
2011-03-27 07:55:18 +02:00
if ($data) {
$data = json_encode($data->getData());
}
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('ID')
->setValue($task->getID()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Type')
->setValue($task->getTaskClass()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Lease Owner')
->setValue($task->getLeaseOwner()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Lease Expires')
->setValue($task->getLeaseExpires() - time()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Failure Count')
->setValue($task->getFailureCount()))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Data')
->setValue($data));
if ($extra) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel('More')
->setValue($extra));
}
$form
2011-03-27 07:55:18 +02:00
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/daemon/', 'Back'));
2011-03-27 07:55:18 +02:00
$panel = new AphrontPanelView();
$panel->setHeader('Task Detail');
$panel->setWidth(AphrontPanelView::WIDTH_WIDE);
2011-03-27 07:55:18 +02:00
$panel->appendChild($form);
$panel->addButton(
javelin_render_tag(
'a',
array(
'href' => '/daemon/task/'.$task->getID().'/delete/',
'class' => 'button grey',
'sigil' => 'workflow',
),
'Delete Task'));
$panel->addButton(
javelin_render_tag(
'a',
array(
'href' => '/daemon/task/'.$task->getID().'/release/',
'class' => 'button grey',
'sigil' => 'workflow',
),
'Free Lease'));
2011-03-27 07:55:18 +02:00
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Task',
));
}
}