13 use Symfony\Component\HttpFoundation\Request;
14 use Symfony\Component\HttpFoundation\Response;
15 use Symfony\Component\HttpFoundation\JsonResponse;
27 const NAME =
"ajax_all_job_status";
37 function __construct()
39 parent::__construct(self::NAME,
42 self::REQUIRES_LOGIN =>
false
46 $this->showJobDao = $this->
getObject(
'dao.show_jobs');
53 public function handle(Request $request)
55 $results = $this->showJobDao->getJobsForAll();
56 $uniqueTypes = array_unique(array_column($results,
'job'));
59 foreach ($uniqueTypes as $type) {
61 $data[$type][
'running'] = 0;
62 $data[$type][
'pending'] = 0;
63 $data[$type][
'eta'] = 0;
64 foreach ($results as $row) {
65 if ($row[
'job'] != $type || empty($row[
'status'])) {
68 $data[$type][$row[
'status']] ++;
69 $newEta = $this->showJobDao->getEstimatedTime($row[
'jq_job_fk'],
70 $row[
'job'], 0, $row[
'upload_fk'], 1);
71 if (! empty($newEta)) {
72 $data[$type][
'eta'] = ($newEta > $data[$type][
'eta']) ? $newEta:$data[$type][
'eta'];
77 $returnData = array();
78 foreach ($data as $agent => $row) {
81 "running" => $row[
"running"],
82 "pending" => $row[
"pending"]
84 if ($row[
'eta'] == 0) {
85 $dataRow[
'eta'] =
"N/A";
87 $dataRow[
'eta'] = intval($row[
"eta"] / 3600) .
88 gmdate(
":i:s", $row[
"eta"]);
90 $returnData[] = $dataRow;
94 $schedStatus =
"Running";
97 && strstr($error_msg,
"Connection refused") !==
false) {
98 $schedStatus =
"Stopped";
100 return new JsonResponse([
"data" => $returnData,
"scheduler" => $schedStatus,
"systemLoad" => $systemLoad]);
104 register_plugin(
new AjaxAllJobStatus());
Contains the constants and helpers for authentication of user.
fo_communicate_with_scheduler($input, &$output, &$error_msg)
Communicate with scheduler, send commands to the scheduler, then get the output.
get_system_load_average()
Get system load average.
fo_dbManager * dbManager
fo_dbManager object