2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
2019-09-07 05:10:41 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
use Utopia\App;
|
2019-05-09 18:54:39 +12:00
|
|
|
use Utopia\View;
|
2020-03-29 01:42:16 +13:00
|
|
|
use Utopia\Config\Config;
|
2020-02-23 21:58:30 +13:00
|
|
|
use Utopia\Domains\Domain;
|
2020-03-25 06:56:32 +13:00
|
|
|
use Appwrite\Database\Database;
|
2020-04-21 06:47:26 +12:00
|
|
|
use Appwrite\Database\Validator\Authorization;
|
2020-03-25 06:56:32 +13:00
|
|
|
use Appwrite\Database\Validator\UID;
|
|
|
|
use Appwrite\Storage\Storage;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-30 09:43:34 +12:00
|
|
|
App::init(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
2020-06-13 23:13:53 +12:00
|
|
|
->setParam('description', 'Appwrite Console allows you to easily manage, monitor, and control your entire backend API and tools.')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('analytics', 'UA-26264668-5')
|
|
|
|
;
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout'], 'console');
|
|
|
|
|
|
|
|
App::shutdown(function ($response, $layout) {
|
2020-08-06 18:51:49 +12:00
|
|
|
/** @var Appwrite\Utopia\Response $response */
|
2020-06-30 09:43:34 +12:00
|
|
|
/** @var Utopia\View $layout */
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$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
|
|
|
|
2019-08-24 19:30:12 +12:00
|
|
|
$footer
|
2020-06-29 08:45:36 +12:00
|
|
|
->setParam('home', App::getEnv('_APP_HOME', ''))
|
2020-06-30 23:09:28 +12:00
|
|
|
->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN'))
|
2019-08-24 19:30:12 +12:00
|
|
|
;
|
2019-09-07 05:10:41 +12:00
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
|
|
|
->setParam('header', [$header])
|
|
|
|
->setParam('footer', [$footer])
|
|
|
|
;
|
|
|
|
|
2020-07-09 21:11:10 +12:00
|
|
|
$response->html($layout->render());
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['response', 'layout'], 'console');
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($code, $layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/error.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$page
|
|
|
|
->setParam('code', $code)
|
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2019-09-07 05:10:41 +12:00
|
|
|
->setParam('title', APP_NAME.' - Error')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13: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
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Console')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/account/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$cc = new View(__DIR__.'/../../views/console/forms/credit-card.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$page
|
|
|
|
->setParam('cc', $cc)
|
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2019-10-01 17:57:41 +13:00
|
|
|
->setParam('title', 'Account - '.APP_NAME)
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/v1/console/notifications/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Notifications')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/home/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Console')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2020-06-29 08:45:36 +12:00
|
|
|
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
|
2020-02-23 21:58:30 +13:00
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/settings/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-02-23 21:58:30 +13:00
|
|
|
$page
|
2020-02-25 01:55:42 +13:00
|
|
|
->setParam('customDomainsEnabled', ($target->isKnown() && !$target->isTest()))
|
|
|
|
->setParam('customDomainsTarget', $target->get())
|
2020-02-23 21:58:30 +13:00
|
|
|
;
|
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
$layout
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Settings')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/webhooks/index.phtml');
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2020-05-26 07:54:18 +12:00
|
|
|
$page
|
|
|
|
->setParam('events', Config::getParam('events', []))
|
|
|
|
;
|
|
|
|
|
2019-08-05 16:47:52 +12:00
|
|
|
$layout
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Webhooks')
|
2019-08-05 16:47:52 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
2019-08-05 16:47:52 +12:00
|
|
|
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2020-06-30 17:27:52 +12:00
|
|
|
$scopes = Config::getParam('scopes');
|
2019-12-17 08:35:33 +13: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
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - API Keys')
|
2019-08-05 16:47:52 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/tasks')
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/tasks/index.phtml');
|
2019-08-05 16:47:52 +12:00
|
|
|
|
|
|
|
$layout
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Tasks')
|
2019-08-05 16:47:52 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/database')
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/database/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Database')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/database/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-05-03 07:57:52 +12:00
|
|
|
->param('id', '', function () { return new UID(); }, 'Collection unique ID.')
|
2020-06-30 09:43:34 +12:00
|
|
|
->action(function ($id, $response, $layout, $projectDB) {
|
2020-08-06 18:51:49 +12:00
|
|
|
/** @var Appwrite\Utopia\Response $response */
|
2020-06-30 09:43:34 +12:00
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
/** @var Appwrite\Database\Database $projectDB */
|
|
|
|
|
2020-05-03 07:57:52 +12:00
|
|
|
Authorization::disable();
|
|
|
|
$collection = $projectDB->getDocument($id, false);
|
|
|
|
Authorization::reset();
|
|
|
|
|
|
|
|
if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
|
|
|
throw new Exception('Collection not found', 404);
|
|
|
|
}
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/database/collection.phtml');
|
2019-08-07 01:57:12 +12:00
|
|
|
|
2020-05-03 07:57:52 +12:00
|
|
|
$page
|
|
|
|
->setParam('collection', $collection)
|
|
|
|
;
|
2020-05-26 06:11:22 +12:00
|
|
|
|
2019-08-07 01:57:12 +12:00
|
|
|
$layout
|
2020-03-17 07:41:56 +13: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-06-30 09:43:34 +12:00
|
|
|
}, ['response', 'layout', 'projectDB']);
|
2020-03-17 07:41:56 +13:00
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
App::get('/console/database/document')
|
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')
|
2020-04-23 15:25:00 +12:00
|
|
|
->param('collection', '', function () { return new UID(); }, 'Collection unique ID.')
|
2020-06-30 09:43:34 +12:00
|
|
|
->action(function ($collection, $layout, $projectDB) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
/** @var Appwrite\Database\Database $projectDB */
|
|
|
|
|
2020-04-23 15:25:00 +12:00
|
|
|
Authorization::disable();
|
|
|
|
$collection = $projectDB->getDocument($collection, false);
|
|
|
|
Authorization::reset();
|
|
|
|
|
|
|
|
if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
|
|
|
throw new Exception('Collection not found', 404);
|
|
|
|
}
|
|
|
|
|
2020-03-17 07:41:56 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/database/document.phtml');
|
2020-05-03 07:57:52 +12:00
|
|
|
$searchFiles = new View(__DIR__.'/../../views/console/database/search/files.phtml');
|
|
|
|
$searchDocuments = new View(__DIR__.'/../../views/console/database/search/documents.phtml');
|
2020-03-17 07:41:56 +13:00
|
|
|
|
2020-04-21 06:47:26 +12:00
|
|
|
$page
|
2020-04-26 08:33:35 +12:00
|
|
|
->setParam('db', $projectDB)
|
2020-04-21 06:47:26 +12:00
|
|
|
->setParam('collection', $collection)
|
2020-05-03 07:57:52 +12:00
|
|
|
->setParam('searchFiles', $searchFiles)
|
|
|
|
->setParam('searchDocuments', $searchDocuments)
|
2020-04-21 06:47:26 +12:00
|
|
|
;
|
|
|
|
|
|
|
|
$layout
|
2020-04-26 08:33:35 +12:00
|
|
|
->setParam('title', APP_NAME.' - Database Document')
|
2020-04-21 06:47:26 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout', 'projectDB']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/storage/index.phtml');
|
2020-02-14 07:55:12 +13:00
|
|
|
|
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
|
2019-09-27 06:47:48 +12:00
|
|
|
->setParam('title', APP_NAME.' - Storage')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
2019-05-09 18:54:39 +12:00
|
|
|
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2019-12-17 08:35:33 +13:00
|
|
|
$page = new View(__DIR__.'/../../views/console/users/index.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-03-29 01:42:16 +13:00
|
|
|
$page->setParam('providers', Config::getParam('providers'));
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2019-09-29 08:47:01 +13:00
|
|
|
->setParam('title', APP_NAME.' - Users')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-06-30 09:43:34 +12:00
|
|
|
->action(function ($layout) {
|
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2020-06-07 16:18:02 +12:00
|
|
|
$page = new View(__DIR__.'/../../views/console/users/user.phtml');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$layout
|
2020-06-07 16:18:02 +12:00
|
|
|
->setParam('title', APP_NAME.' - User')
|
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-07-01 03:46:42 +12:00
|
|
|
->action(function ($layout) {
|
2020-06-30 09:43:34 +12:00
|
|
|
/** @var Utopia\View $layout */
|
|
|
|
|
2020-06-07 16:18:02 +12:00
|
|
|
$page = new View(__DIR__.'/../../views/console/users/team.phtml');
|
|
|
|
|
|
|
|
$layout
|
|
|
|
->setParam('title', APP_NAME.' - Team')
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('body', $page);
|
2020-06-30 09:43:34 +12:00
|
|
|
}, ['layout']);
|
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-07-13 08:43:03 +12:00
|
|
|
->action(function ($layout) {
|
2020-05-05 01:34:31 +12:00
|
|
|
$page = new View(__DIR__.'/../../views/console/functions/index.phtml');
|
|
|
|
|
2020-07-15 04:13:18 +12:00
|
|
|
$page
|
|
|
|
->setParam('environments', Config::getParam('environments'))
|
|
|
|
;
|
|
|
|
|
2020-05-05 01:34:31 +12:00
|
|
|
$layout
|
2020-05-11 16:39:00 +12:00
|
|
|
->setParam('title', APP_NAME.' - Functions')
|
|
|
|
->setParam('body', $page);
|
2020-07-13 08:43:03 +12:00
|
|
|
}, ['layout']);
|
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-07-13 08:43:03 +12:00
|
|
|
->action(function ($layout) {
|
2020-05-11 16:39:00 +12:00
|
|
|
$page = new View(__DIR__.'/../../views/console/functions/function.phtml');
|
|
|
|
|
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))
|
2020-05-11 18:48:26 +12:00
|
|
|
;
|
|
|
|
|
2020-05-11 16:39:00 +12:00
|
|
|
$layout
|
|
|
|
->setParam('title', APP_NAME.' - Function')
|
2020-05-05 01:34:31 +12:00
|
|
|
->setParam('body', $page);
|
2020-07-25 18:26:25 +12:00
|
|
|
}, ['layout']);
|
|
|
|
|
|
|
|
App::get('/console/version')
|
|
|
|
->groups(['web', 'console'])
|
|
|
|
->desc('Check for new version')
|
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'console')
|
|
|
|
->action(function ($response) {
|
|
|
|
try {
|
|
|
|
$version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost').'/v1/health/version'), true);
|
|
|
|
|
|
|
|
if($version && isset($version['version'])) {
|
|
|
|
return $response->json(['version' => $version['version']]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
throw new Exception('Failed to check for a newer version', 500);
|
|
|
|
}
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
throw new Exception('Failed to check for a newer version', 500);
|
|
|
|
}
|
|
|
|
}, ['response']);
|