ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI Class Reference
+ Collaboration diagram for ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI:

Public Member Functions

 __construct (protected Container $dic)
 
 getNotificationItem (int $nr_buckets)
 Get the Notification Items. More...
 
 getItemForObserver (Bucket $observer)
 

Protected Member Functions

 getAggregateItems ()
 

Private Member Functions

 getDefaultCardContent (Bucket $observer)
 
 getProgressbar (Bucket $observer)
 
 getCloseButtonAction (Option $option, string $redirect_uri, Bucket $observer)
 
 getRefreshUrl (Bucket $observer)
 
 addFromUrlToNextRequest (string $redirect_uri)
 
 txt (string $id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::__construct ( protected Container  $dic)

Definition at line 42 of file PopOverGUI.php.

43 {
44 }

Member Function Documentation

◆ addFromUrlToNextRequest()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::addFromUrlToNextRequest ( string  $redirect_uri)
private

Definition at line 260 of file PopOverGUI.php.

260 : void
261 {
262 $this->dic->ctrl()->setParameterByClass(ControllerGUI::class, ControllerGUI::FROM_URL, ControllerGUI::hash($redirect_uri));
263 }

References ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\FROM_URL, and ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\hash().

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getCloseButtonAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAggregateItems()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getAggregateItems ( )
protected
Returns
Notification[]

Definition at line 68 of file PopOverGUI.php.

68 : array
69 {
70 $persistence = $this->dic->backgroundTasks()->persistence();
71 $items = [];
72 $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(), 'id', 'DESC');
73 foreach ($persistence->loadBuckets($observer_ids) as $observer) {
74 $items[] = $this->getItemForObserver($observer);
75 }
76
77 return $items;
78 }

References ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getItemForObserver().

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getNotificationItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCloseButtonAction()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getCloseButtonAction ( Option  $option,
string  $redirect_uri,
Bucket  $observer 
)
private

Definition at line 225 of file PopOverGUI.php.

225 : string
226 {
227 $ctrl = $this->dic->ctrl();
228 $persistence = $this->dic->backgroundTasks()->persistence();
229 $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
230 $this->addFromUrlToNextRequest($redirect_uri);
231 $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::IS_ASYNC, "true");
232
233 switch ($option->getValue()) {
235 $action = $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_ABORT);
236 break;
238 $action = $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_REMOVE);
239 break;
240 default:
241 $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::SELECTED_OPTION, $option->getValue());
242 $action = $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_USER_INTERACTION);
243 break;
244 }
245
246 return $action;
247 }

References ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\addFromUrlToNextRequest(), ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\CMD_ABORT, ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\CMD_REMOVE, ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\CMD_USER_INTERACTION, ILIAS\BackgroundTasks\Task\UserInteraction\Option\getValue(), ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\IS_ASYNC, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\MAIN_ABORT, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\MAIN_REMOVE, ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\OBSERVER_ID, and ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\SELECTED_OPTION.

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getItemForObserver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultCardContent()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getDefaultCardContent ( Bucket  $observer)
private

Definition at line 144 of file PopOverGUI.php.

144 : Content
145 {
146 return $this->getProgressbar($observer);
147 }

References ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getProgressbar().

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getItemForObserver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemForObserver()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getItemForObserver ( Bucket  $observer)

Definition at line 81 of file PopOverGUI.php.

81 : Notification
82 {
83 $redirect_uri = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
84
85 $f = $this->dic->ui()->factory();
86
87 $state = $observer->getState();
88 $current_task = $observer->getCurrentTask();
89
90 $icon = $f->symbol()->icon()->standard("bgtk", $this->txt("bg_task"));
91 $title = $observer->getTitle() . ($state === State::SCHEDULED ? " ({$this->txt('scheduled')})" : "");
92
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);
98 }
99 $item = $f->item()->notification($title, $icon);
100
101 // $item = $item->withProperties([
102 // $this->dic->language()->txt('nc_mail_prop_time') => \ilDatePresentation::formatDate(
103 // new \ilDateTime(time(), IL_CAL_UNIX)
104 // )
105 // ]);
106
107 $item = $item->withActions($f->dropdown()->standard($actions));
108 $input = $current_task->getInput();
109 $message = $current_task->getMessage($input);
110
111 if (!empty($message) && $message != null) {
112 $item = $item->withDescription($message);
113 } else {
114 $item = $item->withAdditionalContent($this->getProgressbar($observer));
115 }
116
117 return $item->withCloseAction(
118 $this->getCloseButtonAction($current_task->getRemoveOption(), $redirect_uri, $observer)
119 );
120 }
121
122 $item = $f->item()->notification($title, $icon);
123
124 if ($state === State::RUNNING) {
125 $url = $this->getRefreshUrl($observer);
126 //Running Items probably need to refresh themselves, right?
127 $item = $item->withAdditionalOnLoadCode(fn($id): string => "var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id'));
128 il.BGTask.refreshItem(notification_item,'$url');");
129
130 $expected = $current_task instanceof Job ? $current_task->getExpectedTimeOfTaskInSeconds() : 0;
131 $possibly_failed = ($observer->getLastHeartbeat() < (time() - $expected));
132 if ($possibly_failed) {
133 $item = $item->withDescription($this->txt('task_might_be_failed'));
134 $item = $item->withCloseAction(
135 $this->getCloseButtonAction($current_task->getAbortOption(), $redirect_uri, $observer)
136 );
137 }
138 }
139
140 return $item->withAdditionalContent($this->getDefaultCardContent($observer));
141 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getCloseButtonAction(Option $option, string $redirect_uri, Bucket $observer)
Definition: PopOverGUI.php:225
getLastHeartbeat()
When was the last time that something happened on this bucket?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References Vendor\Package\$f, $id, $message, ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getCloseButtonAction(), ILIAS\BackgroundTasks\Bucket\getCurrentTask(), ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getDefaultCardContent(), ILIAS\BackgroundTasks\Task\Job\getExpectedTimeOfTaskInSeconds(), ILIAS\BackgroundTasks\Bucket\getLastHeartbeat(), ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getProgressbar(), ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getRefreshUrl(), ILIAS\BackgroundTasks\Bucket\getState(), ILIAS\BackgroundTasks\Bucket\getTitle(), ILIAS\BackgroundTasks\Implementation\Bucket\State\RUNNING, ILIAS\BackgroundTasks\Implementation\Bucket\State\SCHEDULED, ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\txt(), and ILIAS\BackgroundTasks\Implementation\Bucket\State\USER_INTERACTION.

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getAggregateItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNotificationItem()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getNotificationItem ( int  $nr_buckets)

Get the Notification Items.

DOES NOT DO ANY PERMISSION CHECKS.

Definition at line 50 of file PopOverGUI.php.

50 : Notification
51 {
52 $ui_factory = $this->dic->ui()->factory();
53
54 $title = $ui_factory->link()->standard($this->txt('background_tasks'), '#');
55 $icon = $ui_factory->symbol()->icon()->standard('bgtk', $this->txt('background_tasks'));
56
57 return $this->dic->ui()->factory()
58 ->item()
59 ->notification($title, $icon)
60 ->withDescription("$nr_buckets {$this->txt('background_tasks')}")
61 ->withAggregateNotifications($this->getAggregateItems());
62 }

References ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getAggregateItems(), ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\txt(), and ILIAS\UI\Component\Item\Item\withDescription().

+ Here is the call graph for this function:

◆ getProgressbar()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getProgressbar ( Bucket  $observer)
private

Definition at line 197 of file PopOverGUI.php.

197 : Content
198 {
199 $percentage = $observer->getOverallPercentage();
200
201 switch (true) {
202 case ($percentage === 100):
203 $running = "";
204 $content = $this->dic->language()->txt("completed");
205 break;
206 case ($observer->getState() === State::USER_INTERACTION):
207 $running = "";
208 $content = $this->dic->language()->txt("waiting");
209 break;
210 default:
211 $running = "active";
212 $content = "{$percentage}%";
213 break;
214 }
215
216 return $this->dic->ui()->factory()->legacy()->content(" <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}%'>
219 {$content}
220 </div>
221 </div> ");
222 }

References ILIAS\BackgroundTasks\Bucket\getOverallPercentage(), ILIAS\BackgroundTasks\Bucket\getState(), and ILIAS\BackgroundTasks\Implementation\Bucket\State\USER_INTERACTION.

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getDefaultCardContent(), and ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getItemForObserver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefreshUrl()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::getRefreshUrl ( Bucket  $observer)
private

Definition at line 250 of file PopOverGUI.php.

250 : string
251 {
252 $ctrl = $this->dic->ctrl();
253 $persistence = $this->dic->backgroundTasks()->persistence();
254 $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
255
256 return $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_GET_REPLACEMENT_ITEM);
257 }

References ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\CMD_GET_REPLACEMENT_ITEM, and ILIAS\BackgroundTasks\Implementation\UI\ControllerGUI\OBSERVER_ID.

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getItemForObserver().

+ Here is the caller graph for this function:

◆ txt()

ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI::txt ( string  $id)
private

Definition at line 266 of file PopOverGUI.php.

266 : string
267 {
268 return $this->dic->language()->txt($id);
269 }

References $id.

Referenced by ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getItemForObserver(), and ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI\getNotificationItem().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: