2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
2019-09-07 05:10:41 +12:00
|
|
|
|
2022-02-07 10:27:16 +13:00
|
|
|
use Appwrite\Extend\Exception;
|
2022-05-27 01:23:49 +12:00
|
|
|
use Appwrite\Utopia\Response;
|
2021-12-14 22:11:34 +13:00
|
|
|
use Appwrite\Utopia\View;
|
2020-06-29 05:31:21 +12:00
|
|
|
use Utopia\App;
|
2020-03-29 01:42:16 +13:00
|
|
|
use Utopia\Config\Config;
|
2022-08-13 18:34:47 +12:00
|
|
|
use Utopia\Database\Database;
|
2020-02-23 21:58:30 +13:00
|
|
|
use Utopia\Domains\Domain;
|
2021-08-08 00:45:44 +12:00
|
|
|
use Utopia\Database\Validator\UID;
|
2021-01-22 21:28:33 +13:00
|
|
|
use Utopia\Storage\Storage;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-07-22 18:00:42 +12:00
|
|
|
App::init()
|
|
|
|
->groups(['console'])
|
2022-08-02 13:10:48 +12:00
|
|
|
->inject('layout')
|
2022-07-22 18:00:42 +12:00
|
|
|
->action(function (View $layout) {
|
|
|
|
$layout
|
|
|
|
->setParam('description', 'Appwrite Console allows you to easily manage, monitor, and control your entire backend API and tools.')
|
|
|
|
->setParam('analytics', 'UA-26264668-5')
|
|
|
|
;
|
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-07-22 18:00:42 +12:00
|
|
|
App::shutdown()
|
2022-08-02 13:10:48 +12:00
|
|
|
->groups(['console'])
|
2022-07-22 18:00:42 +12:00
|
|
|
->inject('response')
|
|
|
|
->inject('layout')
|
|
|
|
->action(function (Response $response, View $layout) {
|
|
|
|
$header = new View(__DIR__ . '/../../views/console/comps/header.phtml');
|
|
|
|
$footer = new View(__DIR__ . '/../../views/console/comps/footer.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-09-08 17:24:46 +12:00
|
|
|
$header
|
2022-09-08 18:24:58 +12:00
|
|
|
->setParam('regions', explode(',', App::getEnv('_APP_REGIONS', '')))
|
|
|
|
->setParam('disabledRegions', explode(',', App::getEnv('_APP_REGIONS_DISABLED', '')))
|
2022-09-08 17:24:46 +12:00
|
|
|
->setParam('defaultRegion', App::getEnv('_APP_REGION_DEFAULT', 'default'))
|
|
|
|
;
|
|
|
|
|
2022-07-22 18:00:42 +12:00
|
|
|
$footer
|
|
|
|
->setParam('home', App::getEnv('_APP_HOME', ''))
|
|
|
|
->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN'))
|
|
|
|
;
|
2019-09-07 05:10:41 +12:00
|
|
|
|
2022-07-22 18:00:42 +12:00
|
|
|
$layout
|
|
|
|
->setParam('header', [$header])
|
|
|
|
->setParam('footer', [$footer])
|
|
|
|
;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-07-22 18:00:42 +12:00
|
|
|
$response->html($layout->render());
|
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/error/:code')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'home')
|
|
|
|
->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false)
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (int $code, View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/error.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$page
|
|
|
|
->setParam('code', $code)
|
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Error')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2019-08-24 19:30:12 +12:00
|
|
|
$page
|
2020-06-29 08:45:36 +12:00
|
|
|
->setParam('home', App::getEnv('_APP_HOME', ''))
|
2019-08-24 19:30:12 +12:00
|
|
|
;
|
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Console')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/account')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/account/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$cc = new View(__DIR__ . '/../../views/console/forms/credit-card.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$page
|
|
|
|
->setParam('cc', $cc)
|
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', 'Account - ' . APP_NAME)
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/notifications')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/v1/console/notifications/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Notifications')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/home')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/home/index.phtml');
|
2021-01-13 19:25:43 +13:00
|
|
|
$page
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('usageStatsEnabled', App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled');
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Console')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/settings')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2020-06-29 08:45:36 +12:00
|
|
|
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
|
2020-02-23 21:58:30 +13:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/settings/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-05-24 04:42:27 +12:00
|
|
|
$page->setParam('services', array_filter(Config::getParam('services'), fn($element) => $element['optional']))
|
2020-02-25 01:55:42 +13:00
|
|
|
->setParam('customDomainsEnabled', ($target->isKnown() && !$target->isTest()))
|
|
|
|
->setParam('customDomainsTarget', $target->get())
|
2021-02-23 04:50:14 +13:00
|
|
|
->setParam('smtpEnabled', (!empty(App::getEnv('_APP_SMTP_HOST'))))
|
2020-02-23 21:58:30 +13:00
|
|
|
;
|
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Settings')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-05-06 20:49:37 +12:00
|
|
|
App::get('/console/webhooks')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-08-05 16:47:52 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/webhooks/index.phtml');
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2022-04-28 23:40:59 +12:00
|
|
|
$page->setParam('events', Config::getParam('events', []));
|
2022-04-19 04:21:45 +12:00
|
|
|
|
2019-08-05 16:47:52 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Webhooks')
|
2019-08-05 16:47:52 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2022-05-06 20:49:37 +12:00
|
|
|
App::get('/console/webhooks/webhook')
|
2022-05-04 23:29:50 +12:00
|
|
|
->groups(['web', 'console'])
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2022-05-06 20:49:37 +12:00
|
|
|
->param('id', '', new UID(), 'Webhook unique ID.')
|
2022-05-04 23:29:50 +12:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (string $id, View $layout) {
|
2022-05-04 23:29:50 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/webhooks/webhook.phtml');
|
2022-05-04 23:29:50 +12:00
|
|
|
|
2022-05-06 20:49:37 +12:00
|
|
|
$page
|
|
|
|
->setParam('events', Config::getParam('events', []))
|
|
|
|
->setParam('new', false)
|
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Webhooks')
|
2022-05-06 20:49:37 +12:00
|
|
|
->setParam('body', $page);
|
|
|
|
});
|
|
|
|
|
|
|
|
App::get('/console/webhooks/webhook/new')
|
|
|
|
->groups(['web', 'console'])
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2022-05-06 20:49:37 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/webhooks/webhook.phtml');
|
2022-05-06 20:49:37 +12:00
|
|
|
|
|
|
|
$page
|
|
|
|
->setParam('events', Config::getParam('events', []))
|
|
|
|
->setParam('new', true)
|
|
|
|
;
|
2022-05-04 23:29:50 +12:00
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Webhooks')
|
2022-05-04 23:29:50 +12:00
|
|
|
->setParam('body', $page);
|
|
|
|
});
|
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/keys')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-08-05 16:47:52 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2021-01-01 19:42:50 +13:00
|
|
|
$scopes = array_keys(Config::getParam('scopes'));
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/keys/index.phtml');
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2019-12-16 18:11:41 +13:00
|
|
|
$page->setParam('scopes', $scopes);
|
|
|
|
|
2019-08-05 16:47:52 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - API Keys')
|
2019-08-05 16:47:52 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
App::get('/console/databases')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/databases/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Database')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
App::get('/console/databases/database')
|
|
|
|
->groups(['web', 'console'])
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
|
|
|
->param('id', '', new UID(), 'Database unique ID.')
|
|
|
|
->inject('response')
|
|
|
|
->inject('layout')
|
|
|
|
->action(function (string $id, Response $response, View $layout) {
|
|
|
|
|
|
|
|
$logs = new View(__DIR__ . '/../../views/console/comps/logs.phtml');
|
|
|
|
|
|
|
|
$logs
|
|
|
|
->setParam('interval', App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 0))
|
|
|
|
->setParam('method', 'database.listLogs')
|
|
|
|
->setParam('params', [
|
|
|
|
'database-id' => '{{router.params.id}}',
|
|
|
|
])
|
|
|
|
;
|
|
|
|
|
|
|
|
$page = new View(__DIR__ . '/../../views/console/databases/database.phtml');
|
|
|
|
|
|
|
|
$page->setParam('logs', $logs);
|
|
|
|
|
|
|
|
$layout
|
|
|
|
->setParam('title', APP_NAME . ' - Database')
|
|
|
|
->setParam('body', $page)
|
|
|
|
;
|
|
|
|
|
|
|
|
$response
|
|
|
|
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
|
|
|
->addHeader('Expires', 0)
|
|
|
|
->addHeader('Pragma', 'no-cache')
|
|
|
|
;
|
|
|
|
});
|
|
|
|
|
|
|
|
App::get('/console/databases/collection')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-08-07 01:57:12 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-09-11 02:40:14 +12:00
|
|
|
->param('id', '', new UID(), 'Collection unique ID.')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('response')
|
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (string $id, Response $response, View $layout) {
|
2020-05-03 07:57:52 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$logs = new View(__DIR__ . '/../../views/console/comps/logs.phtml');
|
2021-08-16 09:09:40 +12:00
|
|
|
|
|
|
|
$logs
|
|
|
|
->setParam('interval', App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 0))
|
2022-06-22 22:51:49 +12:00
|
|
|
->setParam('method', 'databases.listCollectionLogs')
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('params', [
|
|
|
|
'collection-id' => '{{router.params.id}}',
|
2022-06-22 22:51:49 +12:00
|
|
|
'database-id' => '{{router.params.databaseId}}'
|
2021-08-29 19:43:09 +12:00
|
|
|
])
|
2021-08-16 09:09:40 +12:00
|
|
|
;
|
|
|
|
|
2022-08-13 18:33:11 +12:00
|
|
|
$permissions = new View(__DIR__ . '/../../views/console/comps/permissions-matrix.phtml');
|
|
|
|
$permissions
|
|
|
|
->setParam('method', 'databases.getCollection')
|
2022-08-26 15:34:26 +12:00
|
|
|
->setParam('events', 'load,databases.updateCollection')
|
2022-08-29 22:24:04 +12:00
|
|
|
->setParam('form', 'collectionPermissions')
|
2022-08-13 18:33:11 +12:00
|
|
|
->setParam('data', 'project-collection')
|
|
|
|
->setParam('params', [
|
|
|
|
'collection-id' => '{{router.params.id}}',
|
|
|
|
'database-id' => '{{router.params.databaseId}}'
|
|
|
|
]);
|
2022-08-13 21:01:33 +12:00
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/databases/collection.phtml');
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2022-08-13 18:33:11 +12:00
|
|
|
$page
|
|
|
|
->setParam('permissions', $permissions)
|
|
|
|
->setParam('logs', $logs)
|
|
|
|
;
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2019-08-07 01:57:12 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Database Collection')
|
2020-05-26 06:11:22 +12:00
|
|
|
->setParam('body', $page)
|
|
|
|
;
|
|
|
|
|
|
|
|
$response
|
|
|
|
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
|
|
|
->addHeader('Expires', 0)
|
|
|
|
->addHeader('Pragma', 'no-cache')
|
|
|
|
;
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2020-03-17 07:41:56 +13:00
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
App::get('/console/databases/document')
|
2021-08-29 19:43:09 +12:00
|
|
|
->groups(['web', 'console'])
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2022-06-22 22:51:49 +12:00
|
|
|
->param('databaseId', '', new UID(), 'Database unique ID.')
|
2021-08-29 19:43:09 +12:00
|
|
|
->param('collection', '', new UID(), 'Collection unique ID.')
|
|
|
|
->inject('layout')
|
2022-06-22 22:51:49 +12:00
|
|
|
->action(function (string $databaseId, string $collection, View $layout) {
|
2021-08-29 19:43:09 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$logs = new View(__DIR__ . '/../../views/console/comps/logs.phtml');
|
2021-08-29 19:43:09 +12:00
|
|
|
$logs
|
|
|
|
->setParam('interval', App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 0))
|
2022-06-22 22:51:49 +12:00
|
|
|
->setParam('method', 'databases.listDocumentLogs')
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('params', [
|
2022-06-22 22:51:49 +12:00
|
|
|
'database-id' => '{{router.params.databaseId}}',
|
2021-08-29 19:43:09 +12:00
|
|
|
'collection-id' => '{{router.params.collection}}',
|
|
|
|
'document-id' => '{{router.params.id}}',
|
|
|
|
])
|
|
|
|
;
|
|
|
|
|
2022-08-13 18:34:47 +12:00
|
|
|
$permissions = new View(__DIR__ . '/../../views/console/comps/permissions-matrix.phtml');
|
|
|
|
$permissions
|
|
|
|
->setParam('method', 'databases.getDocument')
|
2022-08-26 15:34:26 +12:00
|
|
|
->setParam('events', 'load,databases.updateDocument')
|
2022-08-29 22:24:04 +12:00
|
|
|
->setParam('form', 'documentPermissions')
|
2022-08-13 18:34:47 +12:00
|
|
|
->setParam('data', 'project-document')
|
2022-08-29 22:25:00 +12:00
|
|
|
->setParam('permissions', [
|
|
|
|
Database::PERMISSION_READ,
|
|
|
|
Database::PERMISSION_UPDATE,
|
|
|
|
Database::PERMISSION_DELETE,
|
|
|
|
])
|
2022-08-13 18:34:47 +12:00
|
|
|
->setParam('params', [
|
|
|
|
'collection-id' => '{{router.params.collection}}',
|
|
|
|
'database-id' => '{{router.params.databaseId}}',
|
|
|
|
'document-id' => '{{router.params.id}}',
|
|
|
|
]);
|
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/databases/document.phtml');
|
2021-08-29 19:43:09 +12:00
|
|
|
|
|
|
|
$page
|
|
|
|
->setParam('new', false)
|
2022-06-22 22:51:49 +12:00
|
|
|
->setParam('database', $databaseId)
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('collection', $collection)
|
2022-08-13 18:34:47 +12:00
|
|
|
->setParam('permissions', $permissions)
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('logs', $logs)
|
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Database Document')
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('body', $page);
|
|
|
|
});
|
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
App::get('/console/databases/document/new')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2020-03-17 07:41:56 +13:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2022-06-22 22:51:49 +12:00
|
|
|
->param('databaseId', '', new UID(), 'Database unique ID.')
|
2020-09-11 02:40:14 +12:00
|
|
|
->param('collection', '', new UID(), 'Collection unique ID.')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-06-22 22:51:49 +12:00
|
|
|
->action(function (string $databaseId, string $collection, View $layout) {
|
2022-08-13 21:01:33 +12:00
|
|
|
|
2022-08-13 18:34:47 +12:00
|
|
|
$permissions = new View(__DIR__ . '/../../views/console/comps/permissions-matrix.phtml');
|
2020-04-23 15:25:00 +12:00
|
|
|
|
2022-08-13 18:34:47 +12:00
|
|
|
$permissions
|
|
|
|
->setParam('data', 'project-document')
|
2022-08-30 00:03:18 +12:00
|
|
|
->setParam('form', 'documentPermissions')
|
|
|
|
->setParam('permissions', [
|
|
|
|
Database::PERMISSION_READ,
|
|
|
|
Database::PERMISSION_UPDATE,
|
|
|
|
Database::PERMISSION_DELETE,
|
|
|
|
])
|
2022-08-13 18:34:47 +12:00
|
|
|
->setParam('params', [
|
|
|
|
'collection-id' => '{{router.params.collection}}',
|
|
|
|
'database-id' => '{{router.params.databaseId}}',
|
|
|
|
'document-id' => '{{router.params.id}}',
|
|
|
|
]);
|
2022-08-13 21:01:33 +12:00
|
|
|
|
2022-06-22 22:51:49 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/databases/document.phtml');
|
2020-03-17 07:41:56 +13:00
|
|
|
|
2020-04-21 06:47:26 +12:00
|
|
|
$page
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('new', true)
|
2022-06-22 22:51:49 +12:00
|
|
|
->setParam('database', $databaseId)
|
2020-04-21 06:47:26 +12:00
|
|
|
->setParam('collection', $collection)
|
2022-08-13 18:34:47 +12:00
|
|
|
->setParam('permissions', $permissions)
|
2021-08-29 19:43:09 +12:00
|
|
|
->setParam('logs', new View())
|
2020-04-21 06:47:26 +12:00
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Database Document')
|
2020-04-21 06:47:26 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2020-04-21 06:47:26 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/storage')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2022-05-31 23:35:59 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/storage/index.phtml');
|
|
|
|
|
2019-10-13 10:53:03 +13:00
|
|
|
$page
|
2020-06-29 08:45:36 +12:00
|
|
|
->setParam('home', App::getEnv('_APP_HOME', 0))
|
|
|
|
->setParam('fileLimit', App::getEnv('_APP_STORAGE_LIMIT', 0))
|
|
|
|
->setParam('fileLimitHuman', Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0)))
|
2019-10-13 10:53:03 +13:00
|
|
|
;
|
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Storage')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2021-11-08 21:26:06 +13:00
|
|
|
App::get('/console/storage/bucket')
|
|
|
|
->groups(['web', 'console'])
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
|
|
|
->param('id', '', new UID(), 'Bucket unique ID.')
|
|
|
|
->inject('response')
|
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (string $id, Response $response, View $layout) {
|
2021-11-08 21:26:06 +13:00
|
|
|
|
2022-08-13 21:02:32 +12:00
|
|
|
$bucketPermissions = new View(__DIR__ . '/../../views/console/comps/permissions-matrix.phtml');
|
|
|
|
$bucketPermissions
|
|
|
|
->setParam('method', 'databases.getBucket')
|
|
|
|
->setParam('events', 'load,databases.updateBucket')
|
|
|
|
->setParam('data', 'project-bucket')
|
|
|
|
->setParam('form', 'bucketPermissions')
|
|
|
|
->setParam('params', [
|
|
|
|
'bucket-id' => '{{router.params.id}}',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$fileCreatePermissions = new View(__DIR__ . '/../../views/console/comps/permissions-matrix.phtml');
|
|
|
|
$fileCreatePermissions
|
|
|
|
->setParam('form', 'fileCreatePermissions')
|
2022-08-29 22:25:00 +12:00
|
|
|
->setParam('permissions', [
|
|
|
|
Database::PERMISSION_READ,
|
|
|
|
Database::PERMISSION_UPDATE,
|
|
|
|
Database::PERMISSION_DELETE,
|
|
|
|
]);
|
2022-08-13 21:02:32 +12:00
|
|
|
|
|
|
|
$fileUpdatePermissions = new View(__DIR__ . '/../../views/console/comps/permissions-matrix.phtml');
|
|
|
|
$fileUpdatePermissions
|
|
|
|
->setParam('method', 'storage.getFile')
|
2022-08-26 15:34:26 +12:00
|
|
|
->setParam('data', 'file')
|
2022-08-13 21:02:32 +12:00
|
|
|
->setParam('form', 'fileUpdatePermissions')
|
2022-08-29 22:25:00 +12:00
|
|
|
->setParam('permissions', [
|
|
|
|
Database::PERMISSION_READ,
|
|
|
|
Database::PERMISSION_UPDATE,
|
|
|
|
Database::PERMISSION_DELETE,
|
|
|
|
])
|
2022-08-13 21:02:32 +12:00
|
|
|
->setParam('params', [
|
|
|
|
'bucket-id' => '{{router.params.id}}',
|
|
|
|
]);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/storage/bucket.phtml');
|
2021-11-08 21:26:06 +13:00
|
|
|
$page
|
|
|
|
->setParam('home', App::getEnv('_APP_HOME', 0))
|
|
|
|
->setParam('fileLimit', App::getEnv('_APP_STORAGE_LIMIT', 0))
|
|
|
|
->setParam('fileLimitHuman', Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0)))
|
2022-08-13 21:02:32 +12:00
|
|
|
->setParam('bucketPermissions', $bucketPermissions)
|
|
|
|
->setParam('fileCreatePermissions', $fileCreatePermissions)
|
|
|
|
->setParam('fileUpdatePermissions', $fileUpdatePermissions)
|
2021-11-08 21:26:06 +13:00
|
|
|
;
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-11-08 21:26:06 +13:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Storage Buckets')
|
2021-11-08 21:26:06 +13:00
|
|
|
->setParam('body', $page)
|
|
|
|
;
|
|
|
|
|
|
|
|
$response
|
|
|
|
->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
|
|
|
->addHeader('Expires', 0)
|
|
|
|
->addHeader('Pragma', 'no-cache')
|
|
|
|
;
|
|
|
|
});
|
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/users')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/users/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2021-03-01 00:41:18 +13:00
|
|
|
$page
|
|
|
|
->setParam('auth', Config::getParam('auth'))
|
|
|
|
->setParam('providers', Config::getParam('providers'))
|
2021-08-31 21:45:51 +12:00
|
|
|
->setParam('smtpEnabled', (!empty(App::getEnv('_APP_SMTP_HOST'))))
|
2021-03-01 00:41:18 +13:00
|
|
|
;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Users')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/users/user')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/users/user.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - User')
|
2020-06-07 16:18:02 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2020-06-07 16:18:02 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/users/teams/team')
|
2020-06-26 06:32:12 +12:00
|
|
|
->groups(['web', 'console'])
|
2020-06-07 16:18:02 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/users/team.phtml');
|
2020-06-07 16:18:02 +12:00
|
|
|
|
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Team')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2020-06-14 03:18:26 +12:00
|
|
|
|
2020-07-13 08:43:03 +12:00
|
|
|
App::get('/console/functions')
|
2020-07-13 09:18:52 +12:00
|
|
|
->groups(['web', 'console'])
|
2020-05-05 01:34:31 +12:00
|
|
|
->desc('Platform console project functions')
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2022-05-31 23:35:59 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/functions/index.phtml');
|
2020-05-05 01:34:31 +12:00
|
|
|
|
2020-07-15 04:13:18 +12:00
|
|
|
$page
|
2021-04-21 23:02:54 +12:00
|
|
|
->setParam('runtimes', Config::getParam('runtimes'))
|
2020-07-15 04:13:18 +12:00
|
|
|
;
|
|
|
|
|
2020-05-05 01:34:31 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Functions')
|
2020-05-11 16:39:00 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2020-05-11 16:39:00 +12:00
|
|
|
|
2020-07-13 08:43:03 +12:00
|
|
|
App::get('/console/functions/function')
|
2020-07-13 09:18:52 +12:00
|
|
|
->groups(['web', 'console'])
|
2020-05-11 16:39:00 +12:00
|
|
|
->desc('Platform console project function')
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('layout')
|
2022-05-27 01:23:49 +12:00
|
|
|
->action(function (View $layout) {
|
2022-05-31 23:35:59 +12:00
|
|
|
$page = new View(__DIR__ . '/../../views/console/functions/function.phtml');
|
2020-05-11 16:39:00 +12:00
|
|
|
|
2020-05-11 18:48:26 +12:00
|
|
|
$page
|
|
|
|
->setParam('events', Config::getParam('events', []))
|
2020-07-15 15:38:57 +12:00
|
|
|
->setParam('fileLimit', App::getEnv('_APP_STORAGE_LIMIT', 0))
|
|
|
|
->setParam('fileLimitHuman', Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0)))
|
2020-07-20 02:42:46 +12:00
|
|
|
->setParam('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900))
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('usageStatsEnabled', App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled');
|
2020-05-11 18:48:26 +12:00
|
|
|
;
|
|
|
|
|
2020-05-11 16:39:00 +12:00
|
|
|
$layout
|
2022-05-24 02:54:50 +12:00
|
|
|
->setParam('title', APP_NAME . ' - Function')
|
2020-05-05 01:34:31 +12:00
|
|
|
->setParam('body', $page);
|
2020-12-27 05:59:59 +13:00
|
|
|
});
|
2020-07-25 18:26:25 +12:00
|
|
|
|
|
|
|
App::get('/console/version')
|
|
|
|
->groups(['web', 'console'])
|
|
|
|
->desc('Check for new version')
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
2020-12-27 05:59:59 +13:00
|
|
|
->inject('response')
|
2020-07-25 18:26:25 +12:00
|
|
|
->action(function ($response) {
|
|
|
|
try {
|
2022-05-24 02:54:50 +12:00
|
|
|
$version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost') . '/v1/health/version'), true);
|
|
|
|
|
2020-10-28 08:46:15 +13:00
|
|
|
if ($version && isset($version['version'])) {
|
2020-07-25 18:26:25 +12:00
|
|
|
return $response->json(['version' => $version['version']]);
|
2020-10-28 08:46:15 +13:00
|
|
|
} else {
|
2022-07-27 02:24:32 +12:00
|
|
|
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to check for a newer version');
|
2020-07-25 18:26:25 +12:00
|
|
|
}
|
|
|
|
} catch (\Throwable $th) {
|
2022-07-27 02:24:32 +12:00
|
|
|
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to check for a newer version');
|
2020-07-25 18:26:25 +12:00
|
|
|
}
|
2022-05-24 02:54:50 +12:00
|
|
|
});
|