-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Notifications and Client-side GlobalScreen (Draft)
- Loading branch information
Showing
42 changed files
with
1,859 additions
and
5 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
Services/BackgroundTasks/classes/Provider/BTClientSideNotificationProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php namespace ILIAS\BackgroundTasks\Provider; | ||
|
||
use ILIAS\GlobalScreen\Scope\Notification\Factory\isItem; | ||
use ILIAS\GlobalScreen\Scope\Notification\Provider\AbstractClientSideNotificationProvider; | ||
use ILIAS\GlobalScreen\Scope\Notification\Provider\ClientSideNotificationProvider; | ||
|
||
/** | ||
* Class BTClientSideNotificationProvider | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class BTClientSideNotificationProvider extends AbstractClientSideNotificationProvider implements ClientSideNotificationProvider | ||
{ | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getClientSideProviderName() : string | ||
{ | ||
return "BTClientSideNotificationProvider"; | ||
} | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function enrichItem(isItem $notification) : isItem | ||
{ | ||
// here you can "fill" your notification server side | ||
|
||
return $notification; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Services/BackgroundTasks/classes/Provider/BTNotificationProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php namespace ILIAS\BackgroundTasks\Provider; | ||
|
||
use ILIAS\GlobalScreen\Identification\IdentificationInterface; | ||
use ILIAS\GlobalScreen\Scope\Notification\Provider\AbstractNotificationProvider; | ||
use ILIAS\GlobalScreen\Scope\Notification\Provider\NotificationProvider; | ||
|
||
/** | ||
* Class BTNotificationProvider | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class BTNotificationProvider extends AbstractNotificationProvider implements NotificationProvider | ||
{ | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getNotifications() : array | ||
{ | ||
$id = function (string $id) : IdentificationInterface { | ||
return $this->if->identifier($id); | ||
}; | ||
|
||
$factory = $this->globalScreen()->notifications()->factory(); | ||
|
||
$group = $factory->standardGroup($id('bg_bucket_group'))->withTitle("Some Notifications"); | ||
|
||
for ($x = 1; $x < 10; $x++) { | ||
$n = $factory->standard($id('bg_bucket_id_' . $x)) | ||
->withTitle("A Notification " . $x) | ||
->withSummary("with a super summary " . $x) | ||
->withAction("#"); | ||
|
||
$group->addNotification($n); | ||
} | ||
|
||
return [ | ||
$group, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php namespace ILIAS\GlobalScreen\Client; | ||
|
||
use ILIAS\GlobalScreen\Provider\Provider; | ||
|
||
/** | ||
* Class ClientSideProvider | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
interface ClientSideProvider extends Provider | ||
{ | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getClientSideProviderName() : string; | ||
} |
50 changes: 50 additions & 0 deletions
50
src/GlobalScreen/Client/Provider/ClientSideProviderRegistrar.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php namespace ILIAS\GlobalScreen\Client; | ||
|
||
use ILIAS\GlobalScreen\Scope\Layout\MetaContent\MetaContent; | ||
|
||
/** | ||
* Class ClientSideProviderRegistrar | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class ClientSideProviderRegistrar | ||
{ | ||
|
||
/** | ||
* @var MetaContent | ||
*/ | ||
private $meta_content; | ||
|
||
|
||
/** | ||
* ClientSideProviderRegistrar constructor. | ||
* | ||
* @param MetaContent $meta_content | ||
*/ | ||
public function __construct(MetaContent $meta_content) | ||
{ | ||
$this->meta_content = $meta_content; | ||
$this->meta_content->addJs('./src/GlobalScreen/Client/dist/GS.js', 1, 1); | ||
$this->meta_content->addJs('./src/GlobalScreen/Client/dist/test.js', 1, 2); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function registerProviderClientSideCode(ClientSideProvider $provider) | ||
{ | ||
|
||
$provider_name = $provider->getClientSideProviderName(); | ||
|
||
$deo = <<<EOT | ||
$( document ).ready(function() { | ||
var $provider_name; | ||
$provider_name = il.GS.Services.provider().getByProviderName('$provider_name'); | ||
console.log($provider_name); | ||
}); | ||
EOT; | ||
|
||
$this->meta_content->addOnloadCode($deo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Client Side GlobalScreen | ||
======================== | ||
|
||
There are different scenarios in which besides the `Items` provided by the GlobalScreen providers on the server side, `Items` on the client side can also arise. | ||
|
||
Such a case are the `Notifications`: Beside all the notifications, which are offered on the server side by the NotificationProvider, the chat client side must have the possibility to communicate own notifications to the `MainNotificationCollector` as well. | ||
|
||
For the moment, this requirement is solved as described below. | ||
|
||
> At the moment some projects are taking place around ILIAS to find more central ways for such problems. As soon as an ILIAS-wide approach exists, the GlobalScreen service will adhere to it. | ||
## ClientSideProvider | ||
A `ClientSideProvider` allows you to generate your own items of a scope in a similar way as on the server side and communicate them to a collector. At the moment there is only the possibility to create `ClientSideNotificationProvider` within a POC. More about this under the description of the `Notifications`: Documentation](../Scope/Notification/README.md) | ||
|
||
All `ClientSideProviders` are collected on the server side by a collector and registered on the client side using the `ClientSideProviderRegistrar`. | ||
|
||
On the client side, similar services are available as on the server side: | ||
|
||
```typescript | ||
export class Services { | ||
|
||
... | ||
|
||
public static provider(): ProviderFactory { | ||
... | ||
} | ||
|
||
public static identification(provider: isProvider, internal_identifier: string) { | ||
... | ||
} | ||
|
||
public static collector(): CollectorFactory { | ||
... | ||
} | ||
|
||
public static factory(): DTOFactory { | ||
... | ||
} | ||
} | ||
``` | ||
|
||
With the help of these services you can now compile NotificationDTOs on the client side and log on to the collector: | ||
|
||
```javascript | ||
// Get My Provider | ||
var provider = il.GS.Services.provider().getByProviderName('BTClientSideNotificationProvider'); | ||
|
||
// Create a new Identification | ||
var identification = il.GS.Services.identification(provider, 'my_first_notification'); | ||
|
||
// Create a new NotificationDTO and fill it with some stuff | ||
var one_notification = il.GS.Services.factory().notifications().onScreen(identification); | ||
|
||
one_notification.title = "My Title"; | ||
one_notification.summary = "My Summary"; | ||
|
||
// get the Notifications Collector and push my notification | ||
var collector = il.GS.Services.collector().notifications(); | ||
|
||
collector.push(one_notification); | ||
|
||
``` | ||
|
||
> From here on, a conceptual description of how the client side can communicate with the server side follows. This in connection with notifications. None of this is implemented yet. | ||
|
||
In the case of the Notification Center, all NotificationDTS could now be sent with the asynchronous retrieval of the HTML content of the Notification Center. NotificationDTS can be serialized and converted to effective notifications, e.g. `StandardNotification`, during server-side readout. Since these do not have all the information that a `StandardNotification` should have, they can be supplemented by the corresponding `ClientSideNotificationProvider` with `public function enrichItem(isItem $notification) : isItem;` to full server-side notifications. These, together with all other server-side notifications, can then be rendered and displayed in the NotificationCenter. |
Oops, something went wrong.