@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<?php
2
3final class PhabricatorDaemonTasksTableView extends AphrontView {
4
5 private $tasks;
6 private $noDataString;
7
8 public function setTasks(array $tasks) {
9 $this->tasks = $tasks;
10 return $this;
11 }
12
13 public function getTasks() {
14 return $this->tasks;
15 }
16
17 public function setNoDataString($no_data_string) {
18 $this->noDataString = $no_data_string;
19 return $this;
20 }
21
22 public function getNoDataString() {
23 return $this->noDataString;
24 }
25
26 public function render() {
27 $tasks = $this->getTasks();
28
29 $rows = array();
30 foreach ($tasks as $task) {
31 $rows[] = array(
32 $task->getID(),
33 $task->getTaskClass(),
34 $task->getLeaseOwner(),
35 $task->getLeaseExpires()
36 ? phutil_format_relative_time($task->getLeaseExpires() - time())
37 : '-',
38 $task->getPriority(),
39 $task->getFailureCount(),
40 phutil_tag(
41 'a',
42 array(
43 'href' => '/daemon/task/'.$task->getID().'/',
44 'class' => 'button small button-grey',
45 ),
46 pht('View Task')),
47 );
48 }
49
50 $table = new AphrontTableView($rows);
51 $table->setHeaders(
52 array(
53 pht('ID'),
54 pht('Class'),
55 pht('Owner'),
56 pht('Expires'),
57 pht('Priority'),
58 pht('Failures'),
59 '',
60 ));
61 $table->setColumnClasses(
62 array(
63 'n',
64 'wide',
65 '',
66 '',
67 'n',
68 'n',
69 'action',
70 ));
71
72 if (strlen($this->getNoDataString())) {
73 $table->setNoDataString($this->getNoDataString());
74 }
75
76 return $table;
77 }
78
79}