diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 5b959e6ed..86102a8a6 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -8,8 +8,12 @@ use Utopia\View; use Utopia\Config\Config; use Utopia\Domains\Domain; use Appwrite\Database\Database; +use Appwrite\Database\Validator\Authorization; use Appwrite\Database\Validator\UID; use Appwrite\Storage\Storage; +use Utopia\Validator\Numeric; +use Utopia\Validator\Range; +use Utopia\Validator\Text; $utopia->init(function () use ($layout, $utopia) { $layout @@ -79,6 +83,7 @@ $utopia->get('/console/account') ; $layout + ->setPath(__DIR__.'/../../views/layouts/strip.phtml') ->setParam('title', 'Account - '.APP_NAME) ->setParam('body', $page); }); @@ -178,7 +183,7 @@ $utopia->get('/console/database') }); $utopia->get('/console/database/collection') - ->desc('Platform console project settings') + ->desc('Platform console project database collection') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $projectDB) { @@ -190,7 +195,7 @@ $utopia->get('/console/database/collection') }); $utopia->get('/console/database/document') - ->desc('Platform console project settings') + ->desc('Platform console project database document') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $projectDB) { @@ -201,6 +206,38 @@ $utopia->get('/console/database/document') ->setParam('body', $page); }); +$utopia->get('/console/database/form') + ->desc('Platform console project database form') + ->label('permission', 'public') + ->label('scope', 'console') + ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') + ->param('namespace', 'project-document', function () { return new Text(256); }, 'Namespace for vars.', true) + ->param('key', 'data', function () { return new Text(256); }, 'Object main key.', true) + ->param('parent', 1, function () { return new Range(0, 1); }, 'Is parent?.', true) + ->action(function ($collectionId, $namespace, $key, $parent) use ($layout, $projectDB) { + + Authorization::disable(); + $collection = $projectDB->getDocument($collectionId, false); + Authorization::reset(); + + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + $page = new View(__DIR__.'/../../views/console/database/form.phtml'); + + $page + ->setParam('collection', $collection) + ->setParam('namespace', $namespace) + ->setParam('key', $key) + ->setParam('parent', $parent) + ; + + $layout + ->setParam('title', APP_NAME.' - Database Form') + ->setParam('body', $page); + }); + $utopia->get('/console/storage') ->desc('Platform console project settings') ->label('permission', 'public') diff --git a/app/init.php b/app/init.php index 7bf97d9d9..9d3fdbdd9 100644 --- a/app/init.php +++ b/app/init.php @@ -32,7 +32,7 @@ const APP_EMAIL_SECURITY = 'security@localhost.test'; // Default security email const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s'; const APP_MODE_ADMIN = 'admin'; const APP_PAGING_LIMIT = 15; -const APP_CACHE_BUSTER = 87; +const APP_CACHE_BUSTER = 88; const APP_VERSION_STABLE = '0.5.3'; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_CACHE = '/storage/cache'; diff --git a/app/views/console/database/document.phtml b/app/views/console/database/document.phtml index 1186bd0d5..65d209076 100644 --- a/app/views/console/database/document.phtml +++ b/app/views/console/database/document.phtml @@ -1,4 +1,3 @@ -
+ +
+ +
- - - '', - 'bind' => '{{project-document|documentLabel}}', - ], - [ - 'key' => '-array', - 'bind' => '{{node}}', - ], - [ - 'key' => '-child', - 'bind' => '{{project-document|documentLabel}}.{{rule.key}}{{childRule.key}}', - ], -]; -?> - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/app/views/console/database/form.phtml b/app/views/console/database/form.phtml new file mode 100644 index 000000000..85929127e --- /dev/null +++ b/app/views/console/database/form.phtml @@ -0,0 +1,75 @@ +getParam('collection', null); +$rules = $collection->getAttribute('rules', []); +$key = $this->getParam('key', 'data'); +$parent = $this->getParam('parent', true); +$namespace = $this->getParam('namespace', 'project-document'); +?> + + + + + + +
+ + + + + + +
\ No newline at end of file diff --git a/app/views/console/database/rules/array.phtml b/app/views/console/database/rules/array.phtml new file mode 100644 index 000000000..59ebc39fe --- /dev/null +++ b/app/views/console/database/rules/array.phtml @@ -0,0 +1,37 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$comp = $this->getParam('comp', ''); +$namespace = $this->getParam('namespace', ''); + +$comp->setParam('namespace', 'node.'); +?> + + required data-cast-to="array-empty"> + + \ No newline at end of file diff --git a/app/views/console/database/rules/boolean.phtml b/app/views/console/database/rules/boolean.phtml new file mode 100644 index 000000000..2e809d85a --- /dev/null +++ b/app/views/console/database/rules/boolean.phtml @@ -0,0 +1,7 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + + required class="margin-bottom-no" /> \ No newline at end of file diff --git a/app/views/console/database/rules/document.phtml b/app/views/console/database/rules/document.phtml new file mode 100644 index 000000000..8cdb076e9 --- /dev/null +++ b/app/views/console/database/rules/document.phtml @@ -0,0 +1,24 @@ +getParam('key', ''); +$array = $this->getParam('array', false); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + +
+ +
+ +
+
+
\ No newline at end of file diff --git a/app/views/console/database/rules/email.phtml b/app/views/console/database/rules/email.phtml new file mode 100644 index 000000000..94a8915f9 --- /dev/null +++ b/app/views/console/database/rules/email.phtml @@ -0,0 +1,6 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + required class="margin-bottom-no"> \ No newline at end of file diff --git a/app/views/console/database/rules/ip.phtml b/app/views/console/database/rules/ip.phtml new file mode 100644 index 000000000..eab629015 --- /dev/null +++ b/app/views/console/database/rules/ip.phtml @@ -0,0 +1,6 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + required class="margin-bottom-no"> \ No newline at end of file diff --git a/app/views/console/database/rules/numeric.phtml b/app/views/console/database/rules/numeric.phtml new file mode 100644 index 000000000..2f74331cf --- /dev/null +++ b/app/views/console/database/rules/numeric.phtml @@ -0,0 +1,7 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + + required class="margin-bottom-no" /> \ No newline at end of file diff --git a/app/views/console/database/rules/text.phtml b/app/views/console/database/rules/text.phtml new file mode 100644 index 000000000..e3723a812 --- /dev/null +++ b/app/views/console/database/rules/text.phtml @@ -0,0 +1,6 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + required /> \ No newline at end of file diff --git a/app/views/console/database/rules/url.phtml b/app/views/console/database/rules/url.phtml new file mode 100644 index 000000000..0696fb891 --- /dev/null +++ b/app/views/console/database/rules/url.phtml @@ -0,0 +1,6 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + required class="margin-bottom-no"> \ No newline at end of file diff --git a/app/views/console/database/rules/wildcard.phtml b/app/views/console/database/rules/wildcard.phtml new file mode 100644 index 000000000..ad38997db --- /dev/null +++ b/app/views/console/database/rules/wildcard.phtml @@ -0,0 +1,6 @@ +getParam('key', ''); +$required = $this->getParam('required', ''); +$namespace = $this->getParam('namespace', ''); +?> + \ No newline at end of file diff --git a/app/views/console/storage/index.phtml b/app/views/console/storage/index.phtml index 8ba7f544a..970d87f4d 100644 --- a/app/views/console/storage/index.phtml +++ b/app/views/console/storage/index.phtml @@ -111,7 +111,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0); -