38 protected \ILIAS\DI\Container
$dic;
52 $ui_factory = $this->dic->ui()->factory();
54 $title = $ui_factory->link()->standard($this->
txt(
'background_tasks'),
'#');
55 $icon = $ui_factory->symbol()->icon()->standard(
'bgtk', $this->
txt(
'background_tasks'));
57 return $this->dic->ui()->factory()
59 ->notification($title, $icon)
60 ->withDescription(
"$nr_buckets {$this->txt('background_tasks')}")
70 $persistence = $this->dic->backgroundTasks()->persistence();
72 $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(),
'id',
'DESC');
73 foreach ($persistence->loadBuckets($observer_ids) as $observer) {
83 $redirect_uri =
"//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
85 $f = $this->dic->ui()->factory();
90 $icon =
$f->symbol()->icon()->standard(
"bgtk", $this->
txt(
"bg_task"));
91 $title = $observer->
getTitle() . ($state === State::SCHEDULED ?
" ({$this->txt('scheduled')})" :
"");
93 if ($state === State::USER_INTERACTION) {
94 $actions = $this->getUserInteractionContent($observer,
$redirect_uri);
95 $primary_action = array_pop($actions);
96 if ($primary_action instanceof
Button) {
97 $title = $primary_action->withLabel($title);
99 $item =
$f->item()->notification($title, $icon);
107 $item = $item->withActions(
$f->dropdown()->standard($actions));
108 $input = $current_task->getInput();
109 $message = $current_task->getMessage($input);
111 if (!empty($message) && $message != null) {
112 $item = $item->withDescription($message);
114 $item = $item->withAdditionalContent($this->
getProgressbar($observer));
117 return $item->withCloseAction(
122 $item =
$f->item()->notification($title, $icon);
124 if ($state === State::RUNNING) {
127 $item = $item->withAdditionalOnLoadCode(fn (
$id) =>
"var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id')); 128 il.BGTask.refreshItem(notification_item,'$url');");
132 if ($possibly_failed) {
133 $item = $item->withDescription($this->
txt(
'task_might_be_failed'));
134 $item = $item->withCloseAction(
155 $factory = $this->dic->ui()->factory();
156 $language = $this->dic->language();
157 $persistence = $this->dic->backgroundTasks()->persistence();
158 $ctrl = $this->dic->ctrl();
161 return [$factory->legacy(
'')];
165 $options = $userInteraction->getOptions($userInteraction->getInput());
169 $ctrl->setParameterByClass(
170 ilBTControllerGUI::class,
174 $ctrl->setParameterByClass(
175 ilBTControllerGUI::class,
179 $ctrl->setParameterByClass(
180 ilBTControllerGUI::class,
182 $persistence->getBucketContainerId($observer)
186 return $factory->button()
188 $language->txt($option->getLangVar()),
202 case ($percentage === 100):
204 $content = $this->dic->language()->txt(
"completed");
206 case ($observer->
getState() === State::USER_INTERACTION):
208 $content = $this->dic->language()->txt(
"waiting");
212 $content =
"{$percentage}%";
216 return $this->dic->ui()->factory()->legacy(
" <div class='progress'> 217 <div class='progress-bar progress-bar-striped {$running}' role='progressbar' aria-valuenow='{$percentage}' 218 aria-valuemin='0' aria-valuemax='100' style='width:{$percentage}%'> 227 $ctrl = $this->dic->ctrl();
228 $persistence = $this->dic->backgroundTasks()->persistence();
233 switch ($option->getValue()) {
234 case AbstractTask::MAIN_ABORT:
237 case AbstractTask::MAIN_REMOVE:
252 $ctrl = $this->dic->ctrl();
253 $persistence = $this->dic->backgroundTasks()->persistence();
268 return $this->dic->language()->txt($id);
__construct(\ILIAS\DI\Container $dic)
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getItemForObserver(Bucket $observer)
getDefaultCardContent(Bucket $observer)
const CMD_GET_REPLACEMENT_ITEM
getLastHeartbeat()
When was the last time that something happened on this bucket?
getProgressbar(Bucket $observer)
getCloseButtonAction(UserInteraction\Option $option, string $redirect_uri, Bucket $observer)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRefreshUrl(Bucket $observer)
getExpectedTimeOfTaskInSeconds()
addFromUrlToNextRequest(string $redirect_uri)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
const CMD_USER_INTERACTION
getNotificationItem(int $nr_buckets)
Get the Notification Items.