1
0
Fork 0
mirror of synced 2024-06-28 19:20:25 +12:00

Added public events config file

This commit is contained in:
Eldad Fux 2020-05-11 09:47:53 +03:00
parent 13bc97bd7e
commit c679a327f9
4 changed files with 106 additions and 29 deletions

58
app/config/events.php Normal file
View file

@ -0,0 +1,58 @@
<?php
/**
* List of publicly accessiable system events
*/
return [
'account.create' => [
'description' => 'Triggers any time a new user register an account.',
],
'account.update.email' => [
'description' => 'Triggers any time a a user updates his or her acoount email address.',
],
'account.update.name' => [
'description' => 'Triggers any time a a user updates his or her acoount name.',
],
'account.update.password' => [
'description' => 'Triggers any time a a user updates his or her acoount password.',
],
'account.update.prefs' => [
'description' => 'Triggers any time a a user updates his or her acoount preferences.',
],
'account.delete' => [
'description' => 'Triggers any time a new user is deleting its account.',
],
'account.sessions.create' => [
'description' => 'Triggers any time a user session is being created.',
],
'account.sessions.delete' => [
'description' => 'Triggers any time a user session is being deleted.',
],
'database.collections.create' => [
'description' => 'Triggers any time a new database collection is being created.',
],
'database.collections.update' => [
'description' => 'Triggers any time a new database collection is being updated.',
],
'database.collections.delete' => [
'description' => 'Triggers any time a database collection is being deleted.',
],
'database.documents.create' => [
'description' => 'Triggers any time a new database document is being created.',
],
'database.documents.patch' => [
'description' => 'Triggers any time a new database document is being updated.',
],
'database.documents.delete' => [
'description' => 'Triggers any time a database document is being deleted.',
],
'storage.files.create' => [
'description' => 'Triggers any time a storage file has been created.',
],
'storage.files.update' => [
'description' => 'Triggers any time a storage file has been updated.',
],
'storage.files.delete' => [
'description' => 'Triggers any time a file has been deleted.',
],
];

View file

@ -53,6 +53,7 @@ $response = new Response();
/*
* ENV vars
*/
Config::load('events', __DIR__.'/../app/config/events.php');
Config::load('providers', __DIR__.'/../app/config/providers.php');
Config::load('platforms', __DIR__.'/../app/config/platforms.php');
Config::load('locales', __DIR__.'/../app/config/locales.php');

View file

@ -1,3 +1,9 @@
<?php
$events = array_keys($this->getParam('events', []));
?>
<div
data-service="functions.get"
data-name="project-function"
@ -11,7 +17,7 @@
<a data-ls-attrs="href=/console/functions?project={{router.params.project}}" class="back text-size-small"><i class="icon-left-open"></i> Functions</a>
<br />
<span data-ls-bind="{{project-function.name}}">&nbsp;</span>
<span data-ls-bind="{{project-function.name}}&nbsp;">&nbsp;</span>
</h1>
</div>
@ -55,23 +61,33 @@
<label>&nbsp;</label>
<div class="box">
<label for="function-name">Name</label>
<label for="name">Name</label>
<input name="name" id="function-name" type="text" autocomplete="off" data-ls-bind="{{project-function.name}}" data-forms-text-direction required placeholder="Function Name" />
<label for="timeout">Timeout</label>
<select name="timeout" data-ls-bind="{{project-function.timeout}}" required>
<option value="5">5 seconds</option>
<option value="15">15 seconds</option>
<option value="30">30 seconds</option>
<option value="60">1 minute</option>
<!-- <option value="300" disabled>5 minutes</option> -->
<!-- <option value="900" disabled>15 minutes</option> -->
</select>
<label for="function-trigger">Trigger</label>
<select name="type" required>
<select name="trigger" data-ls-bind="{{project-function.trigger}}" required>
<option value="event">On Event</option>
<option value="schedule">On Schedule</option>
</select>
<div data-ls-template="template-trigger-{{project-function.trigger}}" data-type="script" class="margin-bottom"></div>
<h3 class="margin-bottom-small">Variables</h3>
<div data-ls-if="(!{{project-function.vars.length}})">
<hr class="margin-bottom margin-top-no" />
<!-- <div class="margin-bottom-xl margin-top-xl margin-end margin-start text-align-center">
<h4 class="text-fade text-size-small">No variables added yet.</h4>
</div> -->
<fieldset name="vars" data-cast-to="object">
<div data-ls-loop="project-function.vars" data-ls-as="var" style="overflow: hidden">
<div class="margin-bottom-small">
@ -141,4 +157,26 @@
</li>
</ul>
</div>
</div>
</div>
<script type="text/html" id="template-trigger-event">
<label for="events">Events</label>
<div class="row responsive thin">
<?php foreach ($events as $i => $event) : ?>
<div class="col span-6 text-one-liner margin-bottom text-height-large">
<input type="checkbox" name="events" data-ls-bind="{{project-function.events}}" value="<?php echo $event; ?>" /> <?php echo $event; ?>
</div>
<?php if (($i + 1) % 2 === 0) : ?>
</div>
<div class="row responsive thin">
<?php endif; ?>
<?php endforeach; ?>
</div>
</script>
<script type="text/html" id="template-trigger-schedule">
<label for="schedule">Schedule (CRON Syntax)</label>
<input type="text" class="full-width" name="schedule" required autocomplete="off" data-ls-bind="{{project-function.schedule}}" placeholder="* * * * *" />
</script>

View file

@ -1,26 +1,6 @@
<?php
$events = [
'database.collections.create',
'database.collections.update',
'database.collections.delete',
'database.documents.create',
'database.documents.update',
'database.documents.delete',
'storage.files.create',
'storage.files.update',
'storage.files.delete',
// 'auth.register',
// 'auth.confirm',
// 'auth.login',
// 'auth.logout',
'account.create',
'account.update.email',
'account.update.name',
'account.update.password',
'account.update.prefs',
'account.delete',
];
$events = array_keys($this->getParam('events', []));
?>
<div class="cover margin-bottom-large">