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