From 13bc97bd7efe5ab727f5608a604ed8926011a757 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 11 May 2020 07:39:00 +0300 Subject: [PATCH] Updated SDKs --- app/config/collections.php | 4 +- app/controllers/api/functions.php | 14 +- app/controllers/web/console.php | 20 ++- .../docs/examples/functions/update-tag.md | 2 +- app/sdks/console-javascript/src/sdk.js | 64 ++++---- app/sdks/console-javascript/src/sdk.min.js | 10 +- app/sdks/console-javascript/types/index.d.ts | 22 +-- app/sdks/git/java | 1 - .../docs/examples/functions/update-tag.md | 2 +- app/sdks/server-go/functions.go | 24 +-- .../src/main/java/services/Functions.java | 34 ++--- .../docs/examples/functions/update-tag.md | 2 +- .../server-nodejs/lib/services/functions.js | 38 ++--- .../docs/examples/functions/update-tag.md | 2 +- app/sdks/server-php/docs/functions.md | 26 ++-- .../src/Appwrite/Services/Functions.php | 40 ++--- .../appwrite/services/functions.py | 24 +-- .../docs/examples/functions/update-tag.md | 2 +- .../lib/appwrite/services/functions.rb | 26 ++-- app/views/console/database/collection.phtml | 2 +- app/views/console/functions/function.phtml | 144 ++++++++++++++++++ app/views/console/functions/index.phtml | 115 +------------- app/views/console/users/index.phtml | 2 +- .../console/users/{view.phtml => user.phtml} | 6 +- gulpfile.js | 2 + public/dist/scripts/app-all.js | 6 +- public/dist/scripts/app.js | 6 +- public/scripts/app.js | 55 ------- public/scripts/routes.js | 18 ++- public/scripts/views/forms/headers.js | 59 +++++++ public/scripts/views/forms/key-value.js | 55 +++++++ .../Functions/FunctionsCustomServerTest.php | 14 +- 32 files changed, 483 insertions(+), 358 deletions(-) delete mode 160000 app/sdks/git/java create mode 100644 app/views/console/functions/function.phtml rename app/views/console/users/{view.phtml => user.phtml} (98%) create mode 100644 public/scripts/views/forms/headers.js create mode 100644 public/scripts/views/forms/key-value.js diff --git a/app/config/collections.php b/app/config/collections.php index d647271c57..e026b30951 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1223,8 +1223,8 @@ $collections = [ ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Active', - 'key' => 'active', + 'label' => 'Tag', + 'key' => 'tag', 'type' => Database::SYSTEM_VAR_TYPE_KEY, 'default' => '', 'required' => false, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 20d7cbaccb..9f7e33c6bb 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -38,7 +38,7 @@ $utopia->post('/v1/functions') 'dateCreated' => time(), 'dateUpdated' => time(), 'name' => $name, - 'active' => '', + 'tag' => '', 'vars' => '', //$vars, // TODO Should be encrypted 'trigger' => $trigger, 'events' => $events, @@ -146,17 +146,17 @@ $utopia->put('/v1/functions/:functionId') } ); -$utopia->patch('/v1/functions/:functionId/active') - ->desc('Update Function Active Tag') +$utopia->patch('/v1/functions/:functionId/tag') + ->desc('Update Function Tag') ->label('scope', 'functions.write') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'functions') ->label('sdk.method', 'updateTag') ->label('sdk.description', '/docs/references/functions/update-tag.md') ->param('functionId', '', function () { return new UID(); }, 'Function unique ID.') - ->param('active', '', function () { return new UID(); }, 'Active tag unique ID.') + ->param('tag', '', function () { return new UID(); }, 'Tag unique ID.') ->action( - function ($functionId, $active) use ($response, $projectDB) { + function ($functionId, $tag) use ($response, $projectDB) { $function = $projectDB->getDocument($functionId); if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { @@ -164,7 +164,7 @@ $utopia->patch('/v1/functions/:functionId/active') } $function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [ - 'active' => $active, + 'tag' => $tag, ])); if (false === $function) { @@ -381,7 +381,7 @@ $utopia->post('/v1/functions/:functionId/executions') throw new Exception('Failed saving execution to DB', 500); } - $tag = $projectDB->getDocument($function->getAttribute('active')); + $tag = $projectDB->getDocument($function->getAttribute('tag')); if($tag->getAttribute('functionId') !== $function->getId()) { throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index a96ff9aa8f..90655507fe 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -265,15 +265,15 @@ $utopia->get('/console/users') ->setParam('body', $page); }); -$utopia->get('/console/users/view') +$utopia->get('/console/users/user') ->desc('Platform console project user') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../../views/console/users/view.phtml'); + $page = new View(__DIR__.'/../../views/console/users/user.phtml'); $layout - ->setParam('title', APP_NAME.' - View User') + ->setParam('title', APP_NAME.' - User') ->setParam('body', $page); }); @@ -285,6 +285,18 @@ $utopia->get('/console/functions') $page = new View(__DIR__.'/../../views/console/functions/index.phtml'); $layout - ->setParam('title', APP_NAME.' - Users') + ->setParam('title', APP_NAME.' - Functions') + ->setParam('body', $page); + }); + +$utopia->get('/console/functions/function') + ->desc('Platform console project function') + ->label('permission', 'public') + ->label('scope', 'console') + ->action(function () use ($layout) { + $page = new View(__DIR__.'/../../views/console/functions/function.phtml'); + + $layout + ->setParam('title', APP_NAME.' - Function') ->setParam('body', $page); }); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/update-tag.md b/app/sdks/console-javascript/docs/examples/functions/update-tag.md index fdb2021f5a..9d1821ce91 100644 --- a/app/sdks/console-javascript/docs/examples/functions/update-tag.md +++ b/app/sdks/console-javascript/docs/examples/functions/update-tag.md @@ -5,7 +5,7 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = sdk.functions.updateTag('[FUNCTION_ID]', '[ACTIVE]'); +let promise = sdk.functions.updateTag('[FUNCTION_ID]', '[TAG]'); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/console-javascript/src/sdk.js b/app/sdks/console-javascript/src/sdk.js index a066a64aec..fdd2a84cd0 100644 --- a/app/sdks/console-javascript/src/sdk.js +++ b/app/sdks/console-javascript/src/sdk.js @@ -1801,38 +1801,6 @@ }, payload); }, - /** - * Update Function Active Tag - * - * - * @param {string} functionId - * @param {string} active - * @throws {Error} - * @return {Promise} - */ - updateTag: function(functionId, active) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(active === undefined) { - throw new Error('Missing required parameter: "active"'); - } - - let path = '/functions/{functionId}/active'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(active) { - payload['active'] = active; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - /** * List Executions * @@ -1932,6 +1900,38 @@ }, payload); }, + /** + * Update Function Tag + * + * + * @param {string} functionId + * @param {string} tag + * @throws {Error} + * @return {Promise} + */ + updateTag: function(functionId, tag) { + if(functionId === undefined) { + throw new Error('Missing required parameter: "functionId"'); + } + + if(tag === undefined) { + throw new Error('Missing required parameter: "tag"'); + } + + let path = '/functions/{functionId}/tag'.replace(new RegExp('{functionId}', 'g'), functionId); + + let payload = {}; + + if(tag) { + payload['tag'] = tag; + } + + return http + .patch(path, { + 'content-type': 'application/json', + }, payload); + }, + /** * List Tags * diff --git a/app/sdks/console-javascript/src/sdk.min.js b/app/sdks/console-javascript/src/sdk.min.js index da448a8f24..0d1539834c 100644 --- a/app/sdks/console-javascript/src/sdk.min.js +++ b/app/sdks/console-javascript/src/sdk.min.js @@ -154,10 +154,7 @@ if(events){payload.events=events} if(schedule){payload.schedule=schedule} if(timeout){payload.timeout=timeout} return http.put(path,{'content-type':'application/json',},payload)},delete:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateTag:function(functionId,active){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} -if(active===undefined){throw new Error('Missing required parameter: "active"')} -let path='/functions/{functionId}/active'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(active){payload.active=active} -return http.patch(path,{'content-type':'application/json',},payload)},listExecutions:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} +let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},listExecutions:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload.search=search} if(limit){payload.limit=limit} if(offset){payload.offset=offset} @@ -166,7 +163,10 @@ return http.get(path,{'content-type':'application/json',},payload)},createExecut let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(async){payload.async=async} return http.post(path,{'content-type':'application/json',},payload)},getExecution:function(functionId,executionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} if(executionId===undefined){throw new Error('Missing required parameter: "executionId"')} -let path='/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{executionId}','g'),executionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},listTags:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} +let path='/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{executionId}','g'),executionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateTag:function(functionId,tag){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} +if(tag===undefined){throw new Error('Missing required parameter: "tag"')} +let path='/functions/{functionId}/tag'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(tag){payload.tag=tag} +return http.patch(path,{'content-type':'application/json',},payload)},listTags:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')} let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload.search=search} if(limit){payload.limit=limit} if(offset){payload.offset=offset} diff --git a/app/sdks/console-javascript/types/index.d.ts b/app/sdks/console-javascript/types/index.d.ts index 3297b573c4..260272f34d 100644 --- a/app/sdks/console-javascript/types/index.d.ts +++ b/app/sdks/console-javascript/types/index.d.ts @@ -656,17 +656,6 @@ declare namespace Appwrite { */ delete(functionId: string): Promise; - /** - * Update Function Active Tag - * - * - * @param {string} functionId - * @param {string} active - * @throws {Error} - * @return {Promise} - */ - updateTag(functionId: string, active: string): Promise; - /** * List Executions * @@ -703,6 +692,17 @@ declare namespace Appwrite { */ getExecution(functionId: string, executionId: string): Promise; + /** + * Update Function Tag + * + * + * @param {string} functionId + * @param {string} tag + * @throws {Error} + * @return {Promise} + */ + updateTag(functionId: string, tag: string): Promise; + /** * List Tags * diff --git a/app/sdks/git/java b/app/sdks/git/java deleted file mode 160000 index d3fe8a096c..0000000000 --- a/app/sdks/git/java +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d3fe8a096c74cdfe90b44ad26cf70aebaa17a0b7 diff --git a/app/sdks/server-go/docs/examples/functions/update-tag.md b/app/sdks/server-go/docs/examples/functions/update-tag.md index 61aa8367e9..299b095736 100644 --- a/app/sdks/server-go/docs/examples/functions/update-tag.md +++ b/app/sdks/server-go/docs/examples/functions/update-tag.md @@ -15,7 +15,7 @@ func main() { client: &client } - var response, error := service.UpdateTag("[FUNCTION_ID]", "[ACTIVE]") + var response, error := service.UpdateTag("[FUNCTION_ID]", "[TAG]") if error != nil { panic(error) diff --git a/app/sdks/server-go/functions.go b/app/sdks/server-go/functions.go index 158a4ba35f..c79083fafb 100644 --- a/app/sdks/server-go/functions.go +++ b/app/sdks/server-go/functions.go @@ -86,18 +86,6 @@ func (srv *Functions) Delete(FunctionId string) (map[string]interface{}, error) return srv.client.Call("DELETE", path, nil, params) } -// UpdateTag -func (srv *Functions) UpdateTag(FunctionId string, Active string) (map[string]interface{}, error) { - r := strings.NewReplacer("{functionId}", FunctionId) - path := r.Replace("/functions/{functionId}/active") - - params := map[string]interface{}{ - "active": Active, - } - - return srv.client.Call("PATCH", path, nil, params) -} - // ListExecutions func (srv *Functions) ListExecutions(FunctionId string, Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { r := strings.NewReplacer("{functionId}", FunctionId) @@ -136,6 +124,18 @@ func (srv *Functions) GetExecution(FunctionId string, ExecutionId string) (map[s return srv.client.Call("GET", path, nil, params) } +// UpdateTag +func (srv *Functions) UpdateTag(FunctionId string, Tag string) (map[string]interface{}, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/tag") + + params := map[string]interface{}{ + "tag": Tag, + } + + return srv.client.Call("PATCH", path, nil, params) +} + // ListTags func (srv *Functions) ListTags(FunctionId string, Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { r := strings.NewReplacer("{functionId}", FunctionId) diff --git a/app/sdks/server-java/src/main/java/services/Functions.java b/app/sdks/server-java/src/main/java/services/Functions.java index c8575e2904..3f79965d50 100644 --- a/app/sdks/server-java/src/main/java/services/Functions.java +++ b/app/sdks/server-java/src/main/java/services/Functions.java @@ -114,23 +114,6 @@ public class Functions extends Service { return client.call("DELETE", path, headers, params); } - /// Update Function Active Tag - public Call updateTag(String functionId, String active) { - final String path = "/functions/{functionId}/active".replace("{functionId}", functionId); - - final Map params = Map.ofEntries( - entry("active", active) - ); - - - - final Map headers = Map.ofEntries( - entry("content-type", "application/json") - ); - - return client.call("PATCH", path, headers, params); - } - /// List Executions public Call listExecutions(String functionId, String search, int limit, int offset, OrderType orderType) { final String path = "/functions/{functionId}/executions".replace("{functionId}", functionId); @@ -184,6 +167,23 @@ public class Functions extends Service { return client.call("GET", path, headers, params); } + /// Update Function Tag + public Call updateTag(String functionId, String tag) { + final String path = "/functions/{functionId}/tag".replace("{functionId}", functionId); + + final Map params = Map.ofEntries( + entry("tag", tag) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PATCH", path, headers, params); + } + /// List Tags public Call listTags(String functionId, String search, int limit, int offset, OrderType orderType) { final String path = "/functions/{functionId}/tags".replace("{functionId}", functionId); diff --git a/app/sdks/server-nodejs/docs/examples/functions/update-tag.md b/app/sdks/server-nodejs/docs/examples/functions/update-tag.md index 8efebb9999..8b9baefaf0 100644 --- a/app/sdks/server-nodejs/docs/examples/functions/update-tag.md +++ b/app/sdks/server-nodejs/docs/examples/functions/update-tag.md @@ -10,7 +10,7 @@ client .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = functions.updateTag('[FUNCTION_ID]', '[ACTIVE]'); +let promise = functions.updateTag('[FUNCTION_ID]', '[TAG]'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/server-nodejs/lib/services/functions.js b/app/sdks/server-nodejs/lib/services/functions.js index abc2010d66..ab93f0f403 100644 --- a/app/sdks/server-nodejs/lib/services/functions.js +++ b/app/sdks/server-nodejs/lib/services/functions.js @@ -117,25 +117,6 @@ class Functions extends Service { }); } - /** - * Update Function Active Tag - * - * @param string functionId - * @param string active - * @throws Exception - * @return {} - */ - async updateTag(functionId, active) { - let path = '/functions/{functionId}/active'.replace(new RegExp('{functionId}', 'g'), functionId); - - return await this.client.call('patch', path, { - 'content-type': 'application/json', - }, - { - 'active': active - }); - } - /** * List Executions * @@ -198,6 +179,25 @@ class Functions extends Service { }); } + /** + * Update Function Tag + * + * @param string functionId + * @param string tag + * @throws Exception + * @return {} + */ + async updateTag(functionId, tag) { + let path = '/functions/{functionId}/tag'.replace(new RegExp('{functionId}', 'g'), functionId); + + return await this.client.call('patch', path, { + 'content-type': 'application/json', + }, + { + 'tag': tag + }); + } + /** * List Tags * diff --git a/app/sdks/server-php/docs/examples/functions/update-tag.md b/app/sdks/server-php/docs/examples/functions/update-tag.md index 4e7f6a8b56..68099d8fbb 100644 --- a/app/sdks/server-php/docs/examples/functions/update-tag.md +++ b/app/sdks/server-php/docs/examples/functions/update-tag.md @@ -12,4 +12,4 @@ $client $functions = new Functions($client); -$result = $functions->updateTag('[FUNCTION_ID]', '[ACTIVE]'); \ No newline at end of file +$result = $functions->updateTag('[FUNCTION_ID]', '[TAG]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/functions.md b/app/sdks/server-php/docs/functions.md index 1c832a3c43..91c86a40b2 100644 --- a/app/sdks/server-php/docs/functions.md +++ b/app/sdks/server-php/docs/functions.md @@ -74,19 +74,6 @@ DELETE https://appwrite.io/v1/functions/{functionId} | --- | --- | --- | --- | | functionId | string | **Required** Function unique ID. | | -## Update Function Active Tag - -```http request -PATCH https://appwrite.io/v1/functions/{functionId}/active -``` - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| functionId | string | **Required** Function unique ID. | | -| active | string | Active tag unique ID. | | - ## List Executions ```http request @@ -129,6 +116,19 @@ GET https://appwrite.io/v1/functions/{functionId}/executions/{executionId} | functionId | string | **Required** Function unique ID. | | | executionId | string | **Required** Execution unique ID. | | +## Update Function Tag + +```http request +PATCH https://appwrite.io/v1/functions/{functionId}/tag +``` + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| functionId | string | **Required** Function unique ID. | | +| tag | string | Tag unique ID. | | + ## List Tags ```http request diff --git a/app/sdks/server-php/src/Appwrite/Services/Functions.php b/app/sdks/server-php/src/Appwrite/Services/Functions.php index 0e5f2ab9f3..4403fac693 100644 --- a/app/sdks/server-php/src/Appwrite/Services/Functions.php +++ b/app/sdks/server-php/src/Appwrite/Services/Functions.php @@ -128,26 +128,6 @@ class Functions extends Service ], $params); } - /** - * Update Function Active Tag - * - * @param string $functionId - * @param string $active - * @throws Exception - * @return array - */ - public function updateTag(string $functionId, string $active):array - { - $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/active'); - $params = []; - - $params['active'] = $active; - - return $this->client->call(Client::METHOD_PATCH, $path, [ - 'content-type' => 'application/json', - ], $params); - } - /** * List Executions * @@ -213,6 +193,26 @@ class Functions extends Service ], $params); } + /** + * Update Function Tag + * + * @param string $functionId + * @param string $tag + * @throws Exception + * @return array + */ + public function updateTag(string $functionId, string $tag):array + { + $path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/tag'); + $params = []; + + $params['tag'] = $tag; + + return $this->client->call(Client::METHOD_PATCH, $path, [ + 'content-type' => 'application/json', + ], $params); + } + /** * List Tags * diff --git a/app/sdks/server-python/appwrite/services/functions.py b/app/sdks/server-python/appwrite/services/functions.py index c8f204d3ef..fb149e3546 100644 --- a/app/sdks/server-python/appwrite/services/functions.py +++ b/app/sdks/server-python/appwrite/services/functions.py @@ -75,18 +75,6 @@ class Functions(Service): 'content-type': 'application/json', }, params) - def update_tag(self, function_id, active): - """Update Function Active Tag""" - - params = {} - path = '/functions/{functionId}/active' - path = path.replace('{functionId}', function_id) - params['active'] = active - - return self.client.call('patch', path, { - 'content-type': 'application/json', - }, params) - def list_executions(self, function_id, search='', limit=25, offset=0, order_type='ASC'): """List Executions""" @@ -126,6 +114,18 @@ class Functions(Service): 'content-type': 'application/json', }, params) + def update_tag(self, function_id, tag): + """Update Function Tag""" + + params = {} + path = '/functions/{functionId}/tag' + path = path.replace('{functionId}', function_id) + params['tag'] = tag + + return self.client.call('patch', path, { + 'content-type': 'application/json', + }, params) + def list_tags(self, function_id, search='', limit=25, offset=0, order_type='ASC'): """List Tags""" diff --git a/app/sdks/server-python/docs/examples/functions/update-tag.md b/app/sdks/server-python/docs/examples/functions/update-tag.md index 856fd86040..4ab93d1b6a 100644 --- a/app/sdks/server-python/docs/examples/functions/update-tag.md +++ b/app/sdks/server-python/docs/examples/functions/update-tag.md @@ -10,4 +10,4 @@ client = Client() functions = Functions(client) -result = functions.update_tag('[FUNCTION_ID]', '[ACTIVE]') +result = functions.update_tag('[FUNCTION_ID]', '[TAG]') diff --git a/app/sdks/server-ruby/lib/appwrite/services/functions.rb b/app/sdks/server-ruby/lib/appwrite/services/functions.rb index a52b9b379b..7821d5a87c 100644 --- a/app/sdks/server-ruby/lib/appwrite/services/functions.rb +++ b/app/sdks/server-ruby/lib/appwrite/services/functions.rb @@ -75,19 +75,6 @@ module Appwrite }, params); end - def update_tag(function_id:, active:) - path = '/functions/{functionId}/active' - .gsub('{function_id}', function_id) - - params = { - 'active': active - } - - return @client.call('patch', path, { - 'content-type' => 'application/json', - }, params); - end - def list_executions(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC') path = '/functions/{functionId}/executions' .gsub('{function_id}', function_id) @@ -130,6 +117,19 @@ module Appwrite }, params); end + def update_tag(function_id:, tag:) + path = '/functions/{functionId}/tag' + .gsub('{function_id}', function_id) + + params = { + 'tag': tag + } + + return @client.call('patch', path, { + 'content-type' => 'application/json', + }, params); + end + def list_tags(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC') path = '/functions/{functionId}/tags' .gsub('{function_id}', function_id) diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index afd1b7326c..834e4f3b3b 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -385,7 +385,7 @@ $rules = $collection->getAttribute('rules', []); -
+
diff --git a/app/views/console/functions/function.phtml b/app/views/console/functions/function.phtml new file mode 100644 index 0000000000..82d50a37fb --- /dev/null +++ b/app/views/console/functions/function.phtml @@ -0,0 +1,144 @@ +
+ +
+

+ Functions +
+ +   +

+
+ + + +
+
    +
  • +

    Tags

    +
  • +
  • +

    Settings

    + +
    +
    +
    + + + +
    + + + + + +

    Variables

    + +
    +
    + + + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + +
    + +
    + +
      +
    • +
    • Last Updated:
    • +
    • Created:
    • +
    + +
    + + +
    +
    +
    +
  • +
+
+
\ No newline at end of file diff --git a/app/views/console/functions/index.phtml b/app/views/console/functions/index.phtml index 5e27057844..15804cde88 100644 --- a/app/views/console/functions/index.phtml +++ b/app/views/console/functions/index.phtml @@ -28,116 +28,17 @@
-
    +
    • - - -
      - - - - - -
      + Settings   ( events) +   (SSL/TLS Disabled) +
      @@ -155,18 +56,16 @@ data-analytics-event="submit" data-analytics-category="console" data-analytics-label="Create Project Function" - data-service="projects.create" - data-scope="console" + data-service="functions.create" + data-scope="sdk" data-event="submit" data-success="alert,trigger,reset" data-success-param-alert-text="Created function successfully" - data-success-param-trigger-events="projects.create" + data-success-param-trigger-events="functions.create" data-failure="alert" data-failure-param-alert-text="Failed to create function" data-failure-param-alert-classname="error"> - - diff --git a/app/views/console/users/index.phtml b/app/views/console/users/index.phtml index 62cf13a4b2..71920828c7 100644 --- a/app/views/console/users/index.phtml +++ b/app/views/console/users/index.phtml @@ -107,7 +107,7 @@ $providers = $this->getParam('providers', []); User Avatar - + ----- diff --git a/app/views/console/users/view.phtml b/app/views/console/users/user.phtml similarity index 98% rename from app/views/console/users/view.phtml rename to app/views/console/users/user.phtml index c7fdf20070..3efcf5e3fc 100644 --- a/app/views/console/users/view.phtml +++ b/app/views/console/users/user.phtml @@ -29,7 +29,7 @@
        -
      • +
      • General

    • -
    • +
    • Devices

    • -
    • +
    • Activity

      ","?",",",".","0","1","2","3","4","5","6","7","8","9"];var isRTL=function(value){for(var i=0;i=distance)&&(distance>=0)){if(minLink){minLink.classList.remove('selected');} +break;default:break;}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-forms-headers",controller:function(element){let key=document.createElement("input");let value=document.createElement("input");let wrap=document.createElement("div");let cell1=document.createElement("div");let cell2=document.createElement("div");key.type="text";key.className="margin-bottom-no";key.placeholder="Key";value.type="text";value.className="margin-bottom-no";value.placeholder="Value";wrap.className="row thin margin-bottom-small";cell1.className="col span-6";cell2.className="col span-6";element.parentNode.insertBefore(wrap,element);cell1.appendChild(key);cell2.appendChild(value);wrap.appendChild(cell1);wrap.appendChild(cell2);key.addEventListener("input",function(){syncA();});value.addEventListener("input",function(){syncA();});element.addEventListener("change",function(){syncB();});let syncA=function(){element.value=key.value.toLowerCase()+":"+value.value.toLowerCase();};let syncB=function(){let split=element.value.toLowerCase().split(":");key.value=split[0]||"";value.value=split[1]||"";key.value=key.value.trim();value.value=value.value.trim();};syncB();}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-forms-key-value",controller:function(element){let key=document.createElement("input");let value=document.createElement("input");let wrap=document.createElement("div");let cell1=document.createElement("div");let cell2=document.createElement("div");key.type="text";key.className="margin-bottom-no";key.placeholder="Key";value.type="text";value.className="margin-bottom-no";value.placeholder="Value";wrap.className="row thin margin-bottom-small";cell1.className="col span-6";cell2.className="col span-6";element.parentNode.insertBefore(wrap,element);cell1.appendChild(key);cell2.appendChild(value);wrap.appendChild(cell1);wrap.appendChild(cell2);key.addEventListener("input",function(){syncA();});value.addEventListener("input",function(){syncA();});element.addEventListener("change",function(){syncB();});let syncA=function(){element.name=key.value;element.value=value.value;};let syncB=function(){key.value=element.name||"";value.value=element.value||"";};syncB();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-move-down",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-move-down]")).map(function(obj){obj.addEventListener("click",function(){if(element.nextElementSibling){element.parentNode.insertBefore(element.nextElementSibling,element);element.scrollIntoView(true);}});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-move-up",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-move-up]")).map(function(obj){obj.addEventListener("click",function(){if(element.previousElementSibling){element.parentNode.insertBefore(element,element.previousElementSibling);element.scrollIntoView(true);}});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-nav",repeat:false,controller:function(element,view,container,document){let titles=document.querySelectorAll('[data-forms-nav-anchor]');let links=element.querySelectorAll('[data-forms-nav-link]');let minLink=null;let check=function(){let minDistance=null;let minElement=null;for(let i=0;i=distance)&&(distance>=0)){if(minLink){minLink.classList.remove('selected');} console.log('old',minLink);minDistance=distance;minElement=title;minLink=links[i];minLink.classList.add('selected');console.log('new',minLink);}}};window.addEventListener('scroll',check);check();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-password-meter",controller:function(element,window){var calc=function(password){var score=0;if(!password)return score;var letters=new window.Object();for(var i=0;i60)return(meter.className="password-meter strong");if(score>30)return(meter.className="password-meter medium");if(score>=0)return(meter.className="password-meter weak");};var meter=window.document.createElement("div");meter.className="password-meter";element.parentNode.insertBefore(meter,element.nextSibling);element.addEventListener("change",callback);element.addEventListener("keypress",callback);element.addEventListener("keyup",callback);element.addEventListener("keydown",callback);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-pell",controller:function(element,window,document,markdown,rtl){var div=document.createElement("div");element.className="pell hide";div.className="input pell";element.parentNode.insertBefore(div,element);element.tabIndex=-1;var turndownService=new TurndownService();turndownService.addRule("underline",{filter:["u"],replacement:function(content){return"__"+content+"__";}});var editor=window.pell.init({element:div,onChange:function onChange(html){alignText();element.value=turndownService.turndown(html);},defaultParagraphSeparator:"p",actions:[{name:"bold",icon:''},{name:"underline",icon:''},{name:"italic",icon:''},{name:"olist",icon:''},{name:"ulist",icon:''},{name:"link",icon:''}]});var clean=function(e){e.stopPropagation();e.preventDefault();var clipboardData=e.clipboardData||window.clipboardData;console.log(clipboardData.getData("Text"));window.pell.exec("insertText",clipboardData.getData("Text"));return true;};var alignText=function(){let paragraphs=editor.content.querySelectorAll('p,li');let last='';for(let paragraph of paragraphs){var content=paragraph.textContent;if(content.trim()===''){content=last.textContent;} diff --git a/public/dist/scripts/app.js b/public/dist/scripts/app.js index d95762f0d8..a94b493626 100644 --- a/public/dist/scripts/app.js +++ b/public/dist/scripts/app.js @@ -248,7 +248,7 @@ return slf.renderToken(tokens,idx,opts);} md.renderer.rules.strong_open=renderEm;md.renderer.rules.strong_close=renderEm;return md;},true);})(window);(function(window){"use strict";window.ls.container.set('rtl',function(){var rtlStock="^ا^ب^ت^ث^ج^ح^خ^د^ذ^ر^ز^س^ش^ص^ض^ط^ظ^ع^غ^ف^ق^ك^ل^م^ن^ه^و^ي^א^ב^ג^ד^ה^ו^ז^ח^ט^י^כ^ך^ל^מ^ם^נ^ן^ס^ע^פ^ף^צ^ץ^ק^ר^ש^ת^";var special=["\n"," "," ","״",'"',"_","'","!","@","#","$","^","&","%","*","(",")","+","=","-","[","]","\\","/","{","}","|",":","<",">","?",",",".","0","1","2","3","4","5","6","7","8","9"];var isRTL=function(value){for(var i=0;i=distance)&&(distance>=0)){if(minLink){minLink.classList.remove('selected');} +break;default:break;}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-forms-headers",controller:function(element){let key=document.createElement("input");let value=document.createElement("input");let wrap=document.createElement("div");let cell1=document.createElement("div");let cell2=document.createElement("div");key.type="text";key.className="margin-bottom-no";key.placeholder="Key";value.type="text";value.className="margin-bottom-no";value.placeholder="Value";wrap.className="row thin margin-bottom-small";cell1.className="col span-6";cell2.className="col span-6";element.parentNode.insertBefore(wrap,element);cell1.appendChild(key);cell2.appendChild(value);wrap.appendChild(cell1);wrap.appendChild(cell2);key.addEventListener("input",function(){syncA();});value.addEventListener("input",function(){syncA();});element.addEventListener("change",function(){syncB();});let syncA=function(){element.value=key.value.toLowerCase()+":"+value.value.toLowerCase();};let syncB=function(){let split=element.value.toLowerCase().split(":");key.value=split[0]||"";value.value=split[1]||"";key.value=key.value.trim();value.value=value.value.trim();};syncB();}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-forms-key-value",controller:function(element){let key=document.createElement("input");let value=document.createElement("input");let wrap=document.createElement("div");let cell1=document.createElement("div");let cell2=document.createElement("div");key.type="text";key.className="margin-bottom-no";key.placeholder="Key";value.type="text";value.className="margin-bottom-no";value.placeholder="Value";wrap.className="row thin margin-bottom-small";cell1.className="col span-6";cell2.className="col span-6";element.parentNode.insertBefore(wrap,element);cell1.appendChild(key);cell2.appendChild(value);wrap.appendChild(cell1);wrap.appendChild(cell2);key.addEventListener("input",function(){syncA();});value.addEventListener("input",function(){syncA();});element.addEventListener("change",function(){syncB();});let syncA=function(){element.name=key.value;element.value=value.value;};let syncB=function(){key.value=element.name||"";value.value=element.value||"";};syncB();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-move-down",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-move-down]")).map(function(obj){obj.addEventListener("click",function(){if(element.nextElementSibling){element.parentNode.insertBefore(element.nextElementSibling,element);element.scrollIntoView(true);}});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-move-up",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-move-up]")).map(function(obj){obj.addEventListener("click",function(){if(element.previousElementSibling){element.parentNode.insertBefore(element,element.previousElementSibling);element.scrollIntoView(true);}});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-nav",repeat:false,controller:function(element,view,container,document){let titles=document.querySelectorAll('[data-forms-nav-anchor]');let links=element.querySelectorAll('[data-forms-nav-link]');let minLink=null;let check=function(){let minDistance=null;let minElement=null;for(let i=0;i=distance)&&(distance>=0)){if(minLink){minLink.classList.remove('selected');} console.log('old',minLink);minDistance=distance;minElement=title;minLink=links[i];minLink.classList.add('selected');console.log('new',minLink);}}};window.addEventListener('scroll',check);check();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-password-meter",controller:function(element,window){var calc=function(password){var score=0;if(!password)return score;var letters=new window.Object();for(var i=0;i60)return(meter.className="password-meter strong");if(score>30)return(meter.className="password-meter medium");if(score>=0)return(meter.className="password-meter weak");};var meter=window.document.createElement("div");meter.className="password-meter";element.parentNode.insertBefore(meter,element.nextSibling);element.addEventListener("change",callback);element.addEventListener("keypress",callback);element.addEventListener("keyup",callback);element.addEventListener("keydown",callback);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-pell",controller:function(element,window,document,markdown,rtl){var div=document.createElement("div");element.className="pell hide";div.className="input pell";element.parentNode.insertBefore(div,element);element.tabIndex=-1;var turndownService=new TurndownService();turndownService.addRule("underline",{filter:["u"],replacement:function(content){return"__"+content+"__";}});var editor=window.pell.init({element:div,onChange:function onChange(html){alignText();element.value=turndownService.turndown(html);},defaultParagraphSeparator:"p",actions:[{name:"bold",icon:''},{name:"underline",icon:''},{name:"italic",icon:''},{name:"olist",icon:''},{name:"ulist",icon:''},{name:"link",icon:''}]});var clean=function(e){e.stopPropagation();e.preventDefault();var clipboardData=e.clipboardData||window.clipboardData;console.log(clipboardData.getData("Text"));window.pell.exec("insertText",clipboardData.getData("Text"));return true;};var alignText=function(){let paragraphs=editor.content.querySelectorAll('p,li');let last='';for(let paragraph of paragraphs){var content=paragraph.textContent;if(content.trim()===''){content=last.textContent;} diff --git a/public/scripts/app.js b/public/scripts/app.js index b9f9ce64b7..971e185760 100644 --- a/public/scripts/app.js +++ b/public/scripts/app.js @@ -27,61 +27,6 @@ window.ls.container } } }) - .add({ - selector: "data-forms-headers", - controller: function(element) { - let key = document.createElement("input"); - let value = document.createElement("input"); - let wrap = document.createElement("div"); - let cell1 = document.createElement("div"); - let cell2 = document.createElement("div"); - - key.type = "text"; - key.className = "margin-bottom-no"; - key.placeholder = "Key"; - value.type = "text"; - value.className = "margin-bottom-no"; - value.placeholder = "Value"; - - wrap.className = "row thin margin-bottom-small"; - cell1.className = "col span-6"; - cell2.className = "col span-6"; - - element.parentNode.insertBefore(wrap, element); - cell1.appendChild(key); - cell2.appendChild(value); - wrap.appendChild(cell1); - wrap.appendChild(cell2); - - key.addEventListener("input", function() { - syncA(); - }); - - value.addEventListener("input", function() { - syncA(); - }); - - element.addEventListener("change", function() { - syncB(); - }); - - let syncA = function() { - element.value = - key.value.toLowerCase() + ":" + value.value.toLowerCase(); - }; - - let syncB = function() { - let split = element.value.toLowerCase().split(":"); - key.value = split[0] || ""; - value.value = split[1] || ""; - - key.value = key.value.trim(); - value.value = value.value.trim(); - }; - - syncB(); - } - }) .add({ selector: "data-prism", controller: function(window, document, element, alerts) { diff --git a/public/scripts/routes.js b/public/scripts/routes.js index 1ca1293749..5c84d76a61 100644 --- a/public/scripts/routes.js +++ b/public/scripts/routes.js @@ -144,13 +144,13 @@ window.ls.router scope: "console", project: true }) - .add("/console/users/view", { - template: "/console/users/view?version=" + APP_ENV.VERSION, + .add("/console/users/user", { + template: "/console/users/user?version=" + APP_ENV.VERSION, scope: "console", project: true }) - .add("/console/users/view/:tab", { - template: "/console/users/view?version=" + APP_ENV.VERSION, + .add("/console/users/user/:tab", { + template: "/console/users/user?version=" + APP_ENV.VERSION, scope: "console", project: true }) @@ -164,6 +164,16 @@ window.ls.router scope: "console", project: true }) + .add("/console/functions/function", { + template: "/console/functions/function?version=" + APP_ENV.VERSION, + scope: "console", + project: true + }) + .add("/console/functions/function/:tab", { + template: "/console/functions/function?version=" + APP_ENV.VERSION, + scope: "console", + project: true + }) .add("/console/functions/:tab", { template: "/console/functions?version=" + APP_ENV.VERSION, scope: "console", diff --git a/public/scripts/views/forms/headers.js b/public/scripts/views/forms/headers.js new file mode 100644 index 0000000000..6818f97351 --- /dev/null +++ b/public/scripts/views/forms/headers.js @@ -0,0 +1,59 @@ +(function(window) { + //"use strict"; + + window.ls.container.get("view").add({ + selector: "data-forms-headers", + controller: function(element) { + let key = document.createElement("input"); + let value = document.createElement("input"); + let wrap = document.createElement("div"); + let cell1 = document.createElement("div"); + let cell2 = document.createElement("div"); + + key.type = "text"; + key.className = "margin-bottom-no"; + key.placeholder = "Key"; + value.type = "text"; + value.className = "margin-bottom-no"; + value.placeholder = "Value"; + + wrap.className = "row thin margin-bottom-small"; + cell1.className = "col span-6"; + cell2.className = "col span-6"; + + element.parentNode.insertBefore(wrap, element); + cell1.appendChild(key); + cell2.appendChild(value); + wrap.appendChild(cell1); + wrap.appendChild(cell2); + + key.addEventListener("input", function() { + syncA(); + }); + + value.addEventListener("input", function() { + syncA(); + }); + + element.addEventListener("change", function() { + syncB(); + }); + + let syncA = function() { + element.value = + key.value.toLowerCase() + ":" + value.value.toLowerCase(); + }; + + let syncB = function() { + let split = element.value.toLowerCase().split(":"); + key.value = split[0] || ""; + value.value = split[1] || ""; + + key.value = key.value.trim(); + value.value = value.value.trim(); + }; + + syncB(); + } + }); + })(window); \ No newline at end of file diff --git a/public/scripts/views/forms/key-value.js b/public/scripts/views/forms/key-value.js new file mode 100644 index 0000000000..6a118d483f --- /dev/null +++ b/public/scripts/views/forms/key-value.js @@ -0,0 +1,55 @@ +(function(window) { + //"use strict"; + + window.ls.container.get("view").add({ + selector: "data-forms-key-value", + controller: function(element) { + let key = document.createElement("input"); + let value = document.createElement("input"); + let wrap = document.createElement("div"); + let cell1 = document.createElement("div"); + let cell2 = document.createElement("div"); + + key.type = "text"; + key.className = "margin-bottom-no"; + key.placeholder = "Key"; + value.type = "text"; + value.className = "margin-bottom-no"; + value.placeholder = "Value"; + + wrap.className = "row thin margin-bottom-small"; + cell1.className = "col span-6"; + cell2.className = "col span-6"; + + element.parentNode.insertBefore(wrap, element); + cell1.appendChild(key); + cell2.appendChild(value); + wrap.appendChild(cell1); + wrap.appendChild(cell2); + + key.addEventListener("input", function() { + syncA(); + }); + + value.addEventListener("input", function() { + syncA(); + }); + + element.addEventListener("change", function() { + syncB(); + }); + + let syncA = function() { + element.name = key.value; + element.value = value.value; + }; + + let syncB = function() { + key.value = element.name || ""; + value.value = element.value || ""; + }; + + syncB(); + } + }); + })(window); \ No newline at end of file diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e0503e259a..2b1a0d0ac0 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -44,7 +44,7 @@ class FunctionsConsoleServerTest extends Scope $this->assertEquals('Test', $response1['body']['name']); $this->assertIsInt($response1['body']['dateCreated']); $this->assertIsInt($response1['body']['dateUpdated']); - $this->assertEquals('', $response1['body']['active']); + $this->assertEquals('', $response1['body']['tag']); // $this->assertEquals([ // 'key1' => 'value1', // 'key2' => 'value2', @@ -150,7 +150,7 @@ class FunctionsConsoleServerTest extends Scope $this->assertEquals('Test1', $response1['body']['name']); $this->assertIsInt($response1['body']['dateCreated']); $this->assertIsInt($response1['body']['dateUpdated']); - $this->assertEquals('', $response1['body']['active']); + $this->assertEquals('', $response1['body']['tag']); // $this->assertEquals([ // 'key4' => 'value4', // 'key5' => 'value5', @@ -207,23 +207,23 @@ class FunctionsConsoleServerTest extends Scope /** * @depends testCreateTag */ - public function testUpdateActive($data):array + public function testUpdateTag($data):array { /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_PATCH, '/functions/'.$data['functionId'].'/active', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/functions/'.$data['functionId'].'/tag', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'active' => $data['tagId'], + 'tag' => $data['tagId'], ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); $this->assertIsInt($response['body']['dateCreated']); $this->assertIsInt($response['body']['dateUpdated']); - $this->assertEquals($data['tagId'], $response['body']['active']); + $this->assertEquals($data['tagId'], $response['body']['tag']); /** * Test for FAILURE @@ -285,7 +285,7 @@ class FunctionsConsoleServerTest extends Scope /** - * @depends testUpdateActive + * @depends testUpdateTag */ public function testCreateExecution($data):array {