From 034d6db8c32d6e26e9118cec8683a655de7da953 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 9 Aug 2021 10:08:49 +0300 Subject: [PATCH] UI - work in progress --- app/controllers/api/database.php | 20 +-- app/views/console/database/collection.phtml | 165 +++++++++++++------ public/dist/scripts/app-all.js | 14 +- public/dist/scripts/app.js | 14 +- public/scripts/views/forms/clone.js | 12 +- public/scripts/views/forms/duplications.js | 24 ++- src/Appwrite/Auth/Auth.php | 9 + src/Appwrite/Utopia/Response/Model/Index.php | 14 -- 8 files changed, 178 insertions(+), 94 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 1ebb857da..afab4065f 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -6,7 +6,6 @@ use Utopia\Exception; use Utopia\Validator\Boolean; use Utopia\Validator\FloatValidator; use Utopia\Validator\Integer; -use Utopia\Validator\Numeric; use Utopia\Validator\Range; use Utopia\Validator\WhiteList; use Utopia\Validator\Text; @@ -717,21 +716,22 @@ App::delete('/v1/database/collections/:collectionId/attributes/:attributeId') throw new Exception('Collection not found', 404); } - $attributes = $collection->getAttributes(); + // $attributes = $collection->getAttributes(); // Search for attribute - $attributeIndex = array_search($attributeId, array_column($attributes, '$id')); + // $attributeIndex = array_search($attributeId, array_column($attributes, '$id')); + $attribute = $collection->find('$id', $attributeId, 'attributes'); - if ($attributeIndex === false) { + if (empty($attribute) || !$attribute instanceof Document) { throw new Exception('Attribute not found', 404); } - $attribute = new Document([\array_merge($attributes[$attributeIndex], [ - 'collectionId' => $collectionId, - ])]); + // $attribute = new Document([\array_merge($attributes[$attributeIndex], [ + // 'collectionId' => $collectionId, + // ])]); - $type = $attribute->getAttribute('type', ''); - $format = $attribute->getAttribute('format', ''); + // $type = $attribute->getAttribute('type', ''); + // $format = $attribute->getAttribute('format', ''); $database ->setParam('type', DELETE_TYPE_ATTRIBUTE) @@ -764,7 +764,7 @@ App::post('/v1/database/collections/:collectionId/indexes') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_INDEX) ->param('collectionId', '', new UID(), 'Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection).') - ->param('id', null, new Key(), 'Index ID.') + ->param('indexId', null, new Key(), 'Index ID.') ->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE, Database::INDEX_SPATIAL, Database::INDEX_ARRAY]), 'Index type.') ->param('attributes', null, new ArrayList(new Key()), 'Array of attributes to index.') ->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING)), 'Array of index orders.', true) diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index d3848a881..3b37e1a79 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -33,28 +33,6 @@

Documents

- -

No Documents Found

-

Create your first document to get started

+

Add your first document to get started

@@ -132,16 +110,16 @@

Attributes

-
+

No Attributes Found

-

Create your first attribute to get started

+

Add your first attribute to get started

- +
- + @@ -152,11 +130,11 @@
Attribute ID Type Default
- Ready  + Available  - + @@ -207,12 +185,12 @@ -
- Creating  + + Creating  - + @@ -233,7 +211,7 @@
-
+
  • @@ -254,19 +232,19 @@

    Indexes

    -
    +

    No Indexes Found

    -

    Create your first index to get started

    +

    Add your first index to get started

    - +
    - + - + @@ -274,7 +252,7 @@ -
    Index ID TypeDefaultAttributes
    - Ready  + Available  @@ -286,9 +264,8 @@ [] - - n/a + + @@ -329,13 +306,36 @@ - + + + + + + + + + + +
    + Creating  + + + + + [] + + + + Required * + + +
    - +
  • Settings

    @@ -426,7 +426,7 @@ + +