ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\UI\examples\Progress\Bar Namespace Reference

Functions

 client ()
 

description: > This example shows how a Progress Bar can be rendered and used on the client. More...

 
 server ()
 

description: > This example shows how a Progress Bar can be rendered and updated by the server. More...

 
 callArtificialTaskEndpoint (GlobalHttpState $http, UI\Factory $factory, UI\Renderer $renderer)
 
 initialiseArtificialTaskOnce ()
 
 incrementTaskProgress ()
 
 getTaskProgress ()
 
 resetTask ()
 

Function Documentation

◆ callArtificialTaskEndpoint()

ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint ( GlobalHttpState  $http,
UI\Factory  $factory,
UI\Renderer  $renderer 
)

Definition at line 77 of file server.php.

References ILIAS\HTTP\GlobalHttpState\close(), ILIAS\UI\examples\Progress\Bar\getTaskProgress(), ILIAS\UI\examples\Progress\Bar\incrementTaskProgress(), ILIAS\UI\examples\Progress\Bar\initialiseArtificialTaskOnce(), ILIAS\UI\examples\Progress\Bar\resetTask(), ILIAS\HTTP\GlobalHttpState\response(), ILIAS\HTTP\GlobalHttpState\saveResponse(), and ILIAS\HTTP\GlobalHttpState\sendResponse().

Referenced by ILIAS\UI\examples\Progress\Bar\server().

77  : void
78 {
80 
81  $task_progress = getTaskProgress();
82 
83  $state = match ($task_progress) {
84  1 => $state = $factory->progress()->state()->bar()->determinate(10, 'Start processing...'),
85  2 => $state = $factory->progress()->state()->bar()->determinate(20),
86  3 => $state = $factory->progress()->state()->bar()->determinate(30),
87  4 => $state = $factory->progress()->state()->bar()->determinate(40),
88  5 => $state = $factory->progress()->state()->bar()->determinate(50, 'Still processing...'),
89  6 => $state = $factory->progress()->state()->bar()->determinate(60),
90  7 => $state = $factory->progress()->state()->bar()->determinate(70),
91  8 => $state = $factory->progress()->state()->bar()->determinate(80),
92  9 => $state = $factory->progress()->state()->bar()->determinate(90),
93  10 => $state = $factory->progress()->state()->bar()->success("All done!"),
94  default => $state = $factory->progress()->state()->bar()->failure("An error ocurred."),
95  };
96 
97  if (10 > $task_progress) {
99  } else {
100  resetTask();
101  }
102 
103  $html = $renderer->renderAsync($state);
104 
105  $http->saveResponse(
106  $http->response()
107  ->withHeader('Content-Type', 'text/html; charset=utf-8')
108  ->withBody(Streams::ofString($html))
109  );
110  $http->sendResponse();
111  $http->close();
112 }
$renderer
$http
Definition: deliver.php:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client()

ILIAS\UI\examples\Progress\Bar\client ( )


description: > This example shows how a Progress Bar can be rendered and used on the client.

The trigger button is supplied with the according JavaScript code, which uses the clientside facility of a Progress Bar.

expected output: > ILIAS shows the rendered Progress Bar and Standard Button. The Progress Bar is initially empty (no progress), and cannot be operated in any way. When the Standard Button is clicked, the Progress Bar value us increased by 10% each time.

After the 10th click, the Progress Bar is finished showing a successful state.

Definition at line 37 of file client.php.

References $DIC, $id, and $renderer.

Referenced by XapiProxy\XapiProxyPolyFill\__construct(), ilCmiXapiStatementsDeleteRequest\__construct(), ilCmiXapiStatementsDeleteRequest\_lookUpDataCount(), ilSoapClient\call(), ilCmiXapiStatementsDeleteRequest\deleteData(), ilAuthProviderCAS\doAuthentication(), ilAuthProviderSoap\handleSoapAuth(), ilSoapClient\init(), ilAuthProviderSoap\initClient(), ilCmiXapiStatementsDeleteRequest\queryBatch(), ilWACToken\setClient(), and ilWACPath\setClient().

37  : string
38 {
39  global $DIC;
40  $factory = $DIC->ui()->factory();
41  $renderer = $DIC->ui()->renderer();
42 
43  $progress_bar = $factory->progress()->bar('clicking the button 10 times');
44 
45  $make_progress = $factory->button()->standard('make some progress', '#');
46  $make_progress = $make_progress->withAdditionalOnLoadCode(
47  static fn(string $id) => "
48  let progress = 0;
49  document.getElementById('$id')?.addEventListener('click', (event) => {
50  if (90 === progress) {
51  event.target.disabled = true;
52  il.UI.Progress.Bar.success('{$progress_bar->getUpdateSignal()}', 'all done!');
53  return;
54  }
55 
56  progress += 10;
57  il.UI.Progress.Bar.determinate('{$progress_bar->getUpdateSignal()}', progress);
58  });
59  ",
60  );
61 
62  return $renderer->render([$progress_bar, $make_progress]);
63 }
$renderer
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getTaskProgress()

ILIAS\UI\examples\Progress\Bar\getTaskProgress ( )

Definition at line 127 of file server.php.

References ILIAS\GlobalScreen\get().

Referenced by ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint().

127  : int
128 {
129  return \ilSession::get(__NAMESPACE__ . '_example_task_progress') ?? 1;
130 }
get(string $class_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ incrementTaskProgress()

ILIAS\UI\examples\Progress\Bar\incrementTaskProgress ( )

Definition at line 121 of file server.php.

References ilSession\get(), and ilSession\set().

Referenced by ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint().

121  : void
122 {
123  $previous_value = \ilSession::get(__NAMESPACE__ . '_example_task_progress');
124  \ilSession::set(__NAMESPACE__ . '_example_task_progress', (int) $previous_value + 1);
125 }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialiseArtificialTaskOnce()

ILIAS\UI\examples\Progress\Bar\initialiseArtificialTaskOnce ( )

Definition at line 114 of file server.php.

References ilSession\has(), and ilSession\set().

Referenced by ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint().

114  : void
115 {
116  if (!\ilSession::has(__NAMESPACE__ . '_example_task_progress')) {
117  \ilSession::set(__NAMESPACE__ . '_example_task_progress', 1);
118  }
119 }
static has($a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetTask()

ILIAS\UI\examples\Progress\Bar\resetTask ( )

Definition at line 132 of file server.php.

References ilSession\clear().

Referenced by ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint().

132  : void
133 {
134  \ilSession::clear(__NAMESPACE__ . '_example_task_progress');
135 }
static clear(string $a_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ server()

ILIAS\UI\examples\Progress\Bar\server ( )


description: > This example shows how a Progress Bar can be rendered and updated by the server.

The artificial endpoint uses Progres Bar Instructions to order the clientside Progress Bar to perform a desired update. A Standard Button can be used to start this process.

expected output: > ILIAS shows the rendered Progress Bar and Standard Button. The Progress Bar is initially empty (no progress), and cannot be operated in any way. When the Standard Button is clicked, the Progress Bar value us increased by 10% ~every second. After the ~10 seconds, the Progress Bar will be finished showing a

successful state.

Definition at line 43 of file server.php.

References $DIC, $http, $id, $renderer, and ILIAS\UI\examples\Progress\Bar\callArtificialTaskEndpoint().

Referenced by ilSoapUserAdministrationAdapter\__construct(), ilECSCmsTreeCommandQueueHandler\__construct(), ilECSCommunityTableGUI\__construct(), ilECSCmsCourseCommandQueueHandler\__construct(), ilECSEnrolmentStatusCommandQueueHandler\__construct(), ilECSCmsCourseMemberCommandQueueHandler\__construct(), ilECSCourseCreationHandler\__construct(), ilECSCmsTreeSynchronizer\__construct(), ilNusoapUserAdministrationAdapter\__construct(), ilECSMappingSettingsGUI\__construct(), ilSoapDummyAuthServer\__construct(), ilLDAPSettingsGUI\activateServer(), ilLDAPSettingsGUI\addRoleMapping(), ilECSCmsTreeSynchronizer\checkTreeUpdates(), ilLDAPSettingsGUI\createRoleMapping(), ilLDAPSettingsGUI\deactivateServer(), ILIAS\Cache\Adaptor\Memcached\delete(), ilNusoapUserAdministrationAdapter\enableWSDL(), ilSoapDummyAuthServer\enableWSDL(), ILIAS\Cache\Adaptor\Memcached\flush(), ILIAS\Cache\Adaptor\Memcached\flushContainer(), ILIAS\Cache\Adaptor\Memcached\get(), ilLDAPSettingsGUI\getRoleAssignmentTable(), ilNusoapUserAdministrationAdapter\handleSoapPlugins(), ilECSCmsTreeSynchronizer\handleTreeUpdate(), ILIAS\Cache\Adaptor\Memcached\has(), ILIAS\Cache\Adaptor\Memcached\initServer(), ilAuthProviderLDAP\initServer(), ilLDAPUserSynchronisation\initServer(), ilLDAPSettingsGUI\initServer(), ILIAS\Cache\Adaptor\Memcached\isAvailable(), ilCASSettings\read(), ilSoapUserAdministrationAdapter\registerMethods(), ilSoapDummyAuthServer\registerMethods(), ilLDAPSettingsGUI\roleAssignments(), ilLDAPSettingsGUI\roleMapping(), ilLDAPSettingsGUI\save(), ilLDAPSettingsGUI\saveSyncronizationSettings(), ilLDAPSettingsGUI\serverList(), ILIAS\Cache\Adaptor\Memcached\set(), ilCASSettings\setServer(), ilECSCourseMemberAssignment\setServer(), ilECSSetting\setServer(), ilLDAPSettingsGUI\setServerFormValues(), ilSoapUserAdministrationAdapter\start(), ilNusoapUserAdministrationAdapter\start(), ilSoapDummyAuthServer\start(), ilECSCmsTreeSynchronizer\sync(), ilECSCmsTreeSynchronizer\syncCategory(), ilECSCmsTreeSynchronizer\syncNode(), and ilLDAPSettingsGUI\updateRoleMapping().

43  : string
44 {
45  global $DIC;
46  $http = $DIC->http();
47  $uri = $http->request()->getUri();
48  $request = $http->wrapper()->query();
49  $factory = $DIC->ui()->factory();
50  $renderer = $DIC->ui()->renderer();
51  $data_factory = new \ILIAS\Data\Factory();
52 
53  $endpoint_flag = 'progress_bar_example_endpoint';
54  $endpoint_url = $uri . "&$endpoint_flag=1";
55  $endpoint_url = $data_factory->uri($endpoint_url);
56 
57  $progress_bar = $factory->progress()->bar('waiting about 10 seconds', $endpoint_url);
58 
59  $trigger = $factory->button()->standard('start making progress', '#');
60  $trigger = $trigger->withAdditionalOnLoadCode(
61  static fn(string $id) => "
62  document.getElementById('$id')?.addEventListener('click', (event) => {
63  // always 'kick off' async progress bars with an indeterminate state.
64  il.UI.Progress.Bar.indeterminate('{$progress_bar->getUpdateSignal()}', 'Estimating...');
65  event.target.disabled = true;
66  });
67  "
68  );
69 
70  if ($request->has($endpoint_flag)) {
72  }
73 
74  return $renderer->render([$progress_bar, $trigger]);
75 }
$renderer
callArtificialTaskEndpoint(GlobalHttpState $http, UI\Factory $factory, UI\Renderer $renderer)
Definition: server.php:77
$http
Definition: deliver.php:30
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function: