diff --git a/.env b/.env index a6bea88b0..92b13e20c 100644 --- a/.env +++ b/.env @@ -45,6 +45,7 @@ _APP_SMTP_SECURE= _APP_SMTP_USERNAME= _APP_SMTP_PASSWORD= _APP_STORAGE_LIMIT=30000000 +_APP_STORAGE_PREVIEW_LIMIT=20000000 _APP_FUNCTIONS_SIZE_LIMIT=30000000 _APP_FUNCTIONS_TIMEOUT=900 _APP_FUNCTIONS_BUILD_TIMEOUT=900 @@ -53,7 +54,7 @@ _APP_FUNCTIONS_CPUS=0 _APP_FUNCTIONS_MEMORY=0 _APP_FUNCTIONS_MEMORY_SWAP=0 _APP_FUNCTIONS_INACTIVE_THRESHOLD=60 -_APP_EXECUTOR_RUNTIME_NETWORK=appwrite_runtimes +OPEN_RUNTIMES_NETWORK=appwrite_runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 diff --git a/app/config/variables.php b/app/config/variables.php index c741cb548..606762245 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -599,7 +599,7 @@ return [ ], [ 'name' => '_APP_EXECUTOR_RUNTIME_NETWORK', - 'description' => 'The docker network used for communication between the executor and runtimes. Change this if you have altered the default network names.', + 'description' => 'Deprecated with 0.14.0, use \'OPEN_RUNTIMES_NETWORK\' instead!', 'introduction' => '0.13.0', 'default' => 'appwrite_runtimes', 'required' => false, @@ -651,48 +651,57 @@ return [ 'question' => '', 'filter' => '' ], - ], - [ - 'category' => 'Maintenance', - 'description' => '', - 'variables' => [ - [ - 'name' => '_APP_MAINTENANCE_INTERVAL', - 'description' => 'Interval value containing the number of seconds that the Appwrite maintenance process should wait before executing system cleanups and optimizations. The default value is 86400 seconds (1 day).', - 'introduction' => '0.7.0', - 'default' => '86400', - 'required' => false, - 'question' => '', - 'filter' => '' - ], - [ - 'name' => '_APP_MAINTENANCE_RETENTION_EXECUTION', - 'description' => 'The maximum duration (in seconds) upto which to retain execution logs. The default value is 1209600 seconds (14 days).', - 'introduction' => '0.7.0', - 'default' => '1209600', - 'required' => false, - 'question' => '', - 'filter' => '' - ], - [ - 'name' => '_APP_MAINTENANCE_RETENTION_AUDIT', - 'description' => 'IThe maximum duration (in seconds) upto which to retain audit logs. The default value is 1209600 seconds (14 days).', - 'introduction' => '0.7.0', - 'default' => '1209600', - 'required' => false, - 'question' => '', - 'filter' => '' - ], - [ - 'name' => '_APP_MAINTENANCE_RETENTION_ABUSE', - 'description' => 'The maximum duration (in seconds) upto which to retain abuse logs. The default value is 86400 seconds (1 day).', - 'introduction' => '0.7.0', - 'default' => '86400', - 'required' => false, - 'question' => '', - 'filter' => '' - ] + [ + 'name' => 'OPEN_RUNTIMES_NETWORK', + 'description' => 'The docker network used for communication between the executor and runtimes. Change this if you have altered the default network names.', + 'introduction' => '0.13.0', + 'default' => 'appwrite_runtimes', + 'required' => false, + 'question' => '', + 'filter' => '' ], ], ], + [ + 'category' => 'Maintenance', + 'description' => '', + 'variables' => [ + [ + 'name' => '_APP_MAINTENANCE_INTERVAL', + 'description' => 'Interval value containing the number of seconds that the Appwrite maintenance process should wait before executing system cleanups and optimizations. The default value is 86400 seconds (1 day).', + 'introduction' => '0.7.0', + 'default' => '86400', + 'required' => false, + 'question' => '', + 'filter' => '' + ], + [ + 'name' => '_APP_MAINTENANCE_RETENTION_EXECUTION', + 'description' => 'The maximum duration (in seconds) upto which to retain execution logs. The default value is 1209600 seconds (14 days).', + 'introduction' => '0.7.0', + 'default' => '1209600', + 'required' => false, + 'question' => '', + 'filter' => '' + ], + [ + 'name' => '_APP_MAINTENANCE_RETENTION_AUDIT', + 'description' => 'IThe maximum duration (in seconds) upto which to retain audit logs. The default value is 1209600 seconds (14 days).', + 'introduction' => '0.7.0', + 'default' => '1209600', + 'required' => false, + 'question' => '', + 'filter' => '' + ], + [ + 'name' => '_APP_MAINTENANCE_RETENTION_ABUSE', + 'description' => 'The maximum duration (in seconds) upto which to retain abuse logs. The default value is 86400 seconds (1 day).', + 'introduction' => '0.7.0', + 'default' => '86400', + 'required' => false, + 'question' => '', + 'filter' => '' + ] + ], + ], ]; diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index eefabe43a..04f1dbc86 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -131,6 +131,8 @@ App::post('/v1/projects') 'signed' => $attribute['signed'], 'array' => $attribute['array'], 'filters' => $attribute['filters'], + 'default' => $attribute['default'] ?? null, + 'format' => $attribute['format'] ?? '' ]); } diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 97e82b553..856e89811 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -86,6 +86,8 @@ App::post('/v1/storage/buckets') 'signed' => $attribute['signed'], 'array' => $attribute['array'], 'filters' => $attribute['filters'], + 'default' => $attribute['default'] ?? null, + 'format' => $attribute['format'] ?? '' ]); } diff --git a/app/executor.php b/app/executor.php index 566f17747..e9f4c2139 100644 --- a/app/executor.php +++ b/app/executor.php @@ -141,7 +141,6 @@ App::post('/v1/runtimes') ->param('vars', [], new Assoc(), 'Environment Variables required for the build') ->param('commands', [], new ArrayList(new Text(0)), 'Commands required to build the container') ->param('runtime', '', new Text(128), 'Runtime for the cloud function') - ->param('network', '', new Text(128), 'Network to attach the container to') ->param('baseImage', '', new Text(128), 'Base image name of the runtime') ->param('entrypoint', '', new Text(256), 'Entrypoint of the code file', true) ->param('remove', false, new Boolean(), 'Remove a runtime after execution') @@ -149,8 +148,7 @@ App::post('/v1/runtimes') ->inject('orchestrationPool') ->inject('activeRuntimes') ->inject('response') - ->action(function (string $runtimeId, string $source, string $destination, array $vars, array $commands, string $runtime, string $network, string $baseImage, string $entrypoint, bool $remove, string $workdir, $orchestrationPool, $activeRuntimes, Response $response) { - + ->action(function (string $runtimeId, string $source, string $destination, array $vars, array $commands, string $runtime, string $baseImage, string $entrypoint, bool $remove, string $workdir, $orchestrationPool, $activeRuntimes, Response $response) { if ($activeRuntimes->exists($runtimeId)) { throw new Exception('Runtime already exists.', 409); } @@ -235,9 +233,7 @@ App::post('/v1/runtimes') throw new Exception('Failed to create build container', 500); } - if (!empty($network)) { - $orchestration->networkConnect($runtimeId, $network); - } + $orchestration->networkConnect($runtimeId, App::getEnv('OPEN_RUNTIMES_NETWORK', 'appwrite_runtimes')); /** * Execute any commands if they were provided diff --git a/app/http.php b/app/http.php index ab6679e7e..d36c59b29 100644 --- a/app/http.php +++ b/app/http.php @@ -132,6 +132,8 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { 'signed' => $attribute['signed'], 'array' => $attribute['array'], 'filters' => $attribute['filters'], + 'default' => $attribute['default'] ?? null, + 'format' => $attribute['format'] ?? '' ]); } @@ -187,6 +189,8 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { 'signed' => $attribute['signed'], 'array' => $attribute['array'], 'filters' => $attribute['filters'], + 'default' => $attribute['default'] ?? null, + 'format' => $attribute['format'] ?? '' ]); } diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index bb3fa8d8f..c1c28d2e2 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -1,3 +1,10 @@ +x-logging: &x-logging + logging: + driver: 'json-file' + options: + max-file: 5 + max-size: 10m + getParam('httpPort', ''); @@ -36,6 +43,7 @@ services: appwrite: image: /: container_name: appwrite + <<: *x-logging restart: unless-stopped networks: - appwrite @@ -98,6 +106,7 @@ services: - _APP_INFLUXDB_HOST - _APP_INFLUXDB_PORT - _APP_STORAGE_LIMIT + - _APP_STORAGE_PREVIEW_LIMIT - _APP_STORAGE_ANTIVIRUS - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT @@ -132,6 +141,7 @@ services: image: /: entrypoint: realtime container_name: appwrite-realtime + <<: *x-logging restart: unless-stopped labels: - "traefik.enable=true" @@ -172,6 +182,7 @@ services: appwrite-worker-audits: image: /: entrypoint: worker-audits + <<: *x-logging container_name: appwrite-worker-audits restart: unless-stopped networks: @@ -197,6 +208,7 @@ services: appwrite-worker-webhooks: image: /: entrypoint: worker-webhooks + <<: *x-logging container_name: appwrite-worker-webhooks restart: unless-stopped networks: @@ -218,6 +230,7 @@ services: appwrite-worker-deletes: image: /: entrypoint: worker-deletes + <<: *x-logging container_name: appwrite-worker-deletes restart: unless-stopped networks: @@ -259,6 +272,7 @@ services: appwrite-worker-database: image: /: entrypoint: worker-database + <<: *x-logging container_name: appwrite-worker-database restart: unless-stopped networks: @@ -284,6 +298,7 @@ services: appwrite-worker-builds: image: /: entrypoint: worker-builds + <<: *x-logging container_name: appwrite-worker-builds restart: unless-stopped networks: @@ -310,6 +325,7 @@ services: appwrite-worker-certificates: image: /: entrypoint: worker-certificates + <<: *x-logging container_name: appwrite-worker-certificates restart: unless-stopped networks: @@ -340,6 +356,7 @@ services: appwrite-worker-functions: image: /: entrypoint: worker-functions + <<: *x-logging container_name: appwrite-worker-functions restart: unless-stopped networks: @@ -369,6 +386,7 @@ services: appwrite-executor: image: /: entrypoint: executor + <<: *x-logging container_name: appwrite-executor restart: unless-stopped stop_signal: SIGINT @@ -396,7 +414,7 @@ services: - _APP_FUNCTIONS_MEMORY_SWAP - _APP_FUNCTIONS_INACTIVE_THRESHOLD - _APP_EXECUTOR_SECRET - - _APP_EXECUTOR_RUNTIME_NETWORK + - OPEN_RUNTIMES_NETWORK - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_STORAGE_DEVICE @@ -414,6 +432,7 @@ services: appwrite-worker-mails: image: /: entrypoint: worker-mails + <<: *x-logging container_name: appwrite-worker-mails restart: unless-stopped networks: @@ -440,6 +459,7 @@ services: appwrite-maintenance: image: /: entrypoint: maintenance + <<: *x-logging container_name: appwrite-maintenance restart: unless-stopped networks: @@ -465,6 +485,7 @@ services: image: /: entrypoint: usage container_name: appwrite-usage + <<: *x-logging restart: unless-stopped networks: - appwrite @@ -491,6 +512,7 @@ services: image: /: entrypoint: schedule container_name: appwrite-schedule + <<: *x-logging restart: unless-stopped networks: - appwrite @@ -506,6 +528,7 @@ services: mariadb: image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p container_name: appwrite-mariadb + <<: *x-logging restart: unless-stopped networks: - appwrite @@ -521,6 +544,7 @@ services: redis: image: redis:6.2-alpine container_name: appwrite-redis + <<: *x-logging restart: unless-stopped networks: - appwrite @@ -539,6 +563,7 @@ services: influxdb: image: appwrite/influxdb:1.5.0 container_name: appwrite-influxdb + <<: *x-logging restart: unless-stopped networks: - appwrite @@ -548,6 +573,7 @@ services: telegraf: image: appwrite/telegraf:1.4.0 container_name: appwrite-telegraf + <<: *x-logging restart: unless-stopped networks: - appwrite diff --git a/composer.json b/composer.json index b49224ba0..59d4a70fd 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "utopia-php/abuse": "0.7.*", "utopia-php/analytics": "0.2.*", "utopia-php/audit": "0.8.*", - "utopia-php/cache": "0.4.*", + "utopia-php/cache": "0.6.*", "utopia-php/cli": "0.12.*", "utopia-php/config": "0.2.*", "utopia-php/database": "0.15.*", diff --git a/composer.lock b/composer.lock index 00ea8b880..be60c6c07 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3ef20ad6919a1844f207e06719ad8929", + "content-hash": "c23ee95a9a573b123ec587734023132e", "packages": [ { "name": "adhocore/jwt", @@ -300,16 +300,16 @@ }, { "name": "colinmollenhour/credis", - "version": "v1.13.0", + "version": "v1.12.2", "source": { "type": "git", "url": "https://github.com/colinmollenhour/credis.git", - "reference": "afec8e58ec93d2291c127fa19709a048f28641e5" + "reference": "77e6ede2e01c4cfaade114fe1e07d2f9756949f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/afec8e58ec93d2291c127fa19709a048f28641e5", - "reference": "afec8e58ec93d2291c127fa19709a048f28641e5", + "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/77e6ede2e01c4cfaade114fe1e07d2f9756949f1", + "reference": "77e6ede2e01c4cfaade114fe1e07d2f9756949f1", "shasum": "" }, "require": { @@ -341,9 +341,9 @@ "homepage": "https://github.com/colinmollenhour/credis", "support": { "issues": "https://github.com/colinmollenhour/credis/issues", - "source": "https://github.com/colinmollenhour/credis/tree/v1.13.0" + "source": "https://github.com/colinmollenhour/credis/tree/v1.12.2" }, - "time": "2022-04-07T14:57:22+00:00" + "time": "2022-03-08T18:12:43+00:00" }, { "name": "composer/package-versions-deprecated", @@ -1976,22 +1976,22 @@ }, { "name": "utopia-php/cache", - "version": "0.4.2", + "version": "0.6.0", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "7334c5b182c6ccf66b21ca61808d7c6c899e2bcb" + "reference": "8ea1353a4bbab617e23c865a7c97b60d8074aee3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/7334c5b182c6ccf66b21ca61808d7c6c899e2bcb", - "reference": "7334c5b182c6ccf66b21ca61808d7c6c899e2bcb", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/8ea1353a4bbab617e23c865a7c97b60d8074aee3", + "reference": "8ea1353a4bbab617e23c865a7c97b60d8074aee3", "shasum": "" }, "require": { "ext-json": "*", "ext-redis": "*", - "php": ">=7.4" + "php": ">=8.0" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -2023,9 +2023,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.4.2" + "source": "https://github.com/utopia-php/cache/tree/0.6.0" }, - "time": "2021-11-25T16:41:35+00:00" + "time": "2022-04-04T12:30:05+00:00" }, { "name": "utopia-php/cli", @@ -2133,16 +2133,16 @@ }, { "name": "utopia-php/database", - "version": "0.15.4", + "version": "0.15.5", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "166365d9c39c4d70b1267af4562f4327e8930f79" + "reference": "6507b58ef3e22703b9df68d3dbd5e822d5bb023f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/166365d9c39c4d70b1267af4562f4327e8930f79", - "reference": "166365d9c39c4d70b1267af4562f4327e8930f79", + "url": "https://api.github.com/repos/utopia-php/database/zipball/6507b58ef3e22703b9df68d3dbd5e822d5bb023f", + "reference": "6507b58ef3e22703b9df68d3dbd5e822d5bb023f", "shasum": "" }, "require": { @@ -2151,7 +2151,7 @@ "ext-redis": "*", "mongodb/mongodb": "1.8.0", "php": ">=8.0", - "utopia-php/cache": "0.4.*", + "utopia-php/cache": "0.6.*", "utopia-php/framework": "0.*.*" }, "require-dev": { @@ -2190,9 +2190,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.15.4" + "source": "https://github.com/utopia-php/database/tree/0.15.5" }, - "time": "2022-03-15T17:20:14+00:00" + "time": "2022-04-04T13:42:00+00:00" }, { "name": "utopia-php/domains", @@ -6327,16 +6327,16 @@ }, { "name": "twig/twig", - "version": "v3.3.10", + "version": "v3.3.9", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "8442df056c51b706793adf80a9fd363406dd3674" + "reference": "6ff9b0e440fa66f97f207e181c41340ddfa5683d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/8442df056c51b706793adf80a9fd363406dd3674", - "reference": "8442df056c51b706793adf80a9fd363406dd3674", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/6ff9b0e440fa66f97f207e181c41340ddfa5683d", + "reference": "6ff9b0e440fa66f97f207e181c41340ddfa5683d", "shasum": "" }, "require": { @@ -6387,7 +6387,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.3.10" + "source": "https://github.com/twigphp/Twig/tree/v3.3.9" }, "funding": [ { @@ -6399,7 +6399,7 @@ "type": "tidelift" } ], - "time": "2022-04-06T06:47:41+00:00" + "time": "2022-03-25T09:37:52+00:00" }, { "name": "vimeo/psalm", diff --git a/docker-compose.yml b/docker-compose.yml index ac990eef8..bb6244c46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,11 +3,19 @@ # Avoid using this file in your production environment. # We're exposing here sensitive ports and mounting code volumes for rapid development and debugging of the server stack. +x-logging: &x-logging + logging: + driver: 'json-file' + options: + max-file: 5 + max-size: 10m + version: '3' services: traefik: image: traefik:2.5 + <<: *x-logging container_name: appwrite-traefik command: - --log.level=DEBUG @@ -37,6 +45,7 @@ services: appwrite: container_name: appwrite + <<: *x-logging build: context: . args: @@ -152,6 +161,7 @@ services: appwrite-realtime: entrypoint: realtime + <<: *x-logging container_name: appwrite-realtime build: context: . @@ -200,6 +210,7 @@ services: appwrite-worker-audits: entrypoint: worker-audits + <<: *x-logging container_name: appwrite-worker-audits build: context: . @@ -228,6 +239,7 @@ services: appwrite-worker-webhooks: entrypoint: worker-webhooks + <<: *x-logging container_name: appwrite-worker-webhooks build: context: . @@ -253,6 +265,7 @@ services: appwrite-worker-deletes: entrypoint: worker-deletes + <<: *x-logging container_name: appwrite-worker-deletes build: context: . @@ -296,6 +309,7 @@ services: appwrite-worker-database: entrypoint: worker-database + <<: *x-logging container_name: appwrite-worker-database build: context: . @@ -325,6 +339,7 @@ services: appwrite-worker-builds: entrypoint: worker-builds + <<: *x-logging container_name: appwrite-worker-builds build: context: . @@ -354,6 +369,7 @@ services: appwrite-worker-certificates: entrypoint: worker-certificates + <<: *x-logging container_name: appwrite-worker-certificates build: context: . @@ -387,6 +403,7 @@ services: appwrite-worker-functions: entrypoint: worker-functions + <<: *x-logging container_name: appwrite-worker-functions build: context: . @@ -419,6 +436,7 @@ services: appwrite-executor: container_name: appwrite-executor + <<: *x-logging entrypoint: executor stop_signal: SIGINT build: @@ -455,7 +473,7 @@ services: - _APP_FUNCTIONS_MEMORY_SWAP - _APP_FUNCTIONS_INACTIVE_THRESHOLD - _APP_EXECUTOR_SECRET - - _APP_EXECUTOR_RUNTIME_NETWORK + - OPEN_RUNTIMES_NETWORK - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_STORAGE_DEVICE @@ -472,6 +490,7 @@ services: appwrite-worker-mails: entrypoint: worker-mails + <<: *x-logging container_name: appwrite-worker-mails build: context: . @@ -503,6 +522,7 @@ services: appwrite-maintenance: entrypoint: maintenance + <<: *x-logging container_name: appwrite-maintenance build: context: . @@ -532,6 +552,7 @@ services: appwrite-usage: entrypoint: usage + <<: *x-logging container_name: appwrite-usage build: context: . @@ -564,6 +585,7 @@ services: appwrite-schedule: entrypoint: schedule + <<: *x-logging container_name: appwrite-schedule build: context: . @@ -584,6 +606,7 @@ services: mariadb: image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p container_name: appwrite-mariadb + <<: *x-logging networks: - appwrite volumes: @@ -612,6 +635,7 @@ services: redis: image: redis:6.2-alpine + <<: *x-logging container_name: appwrite-redis ports: - "6379:6379" @@ -631,6 +655,7 @@ services: influxdb: image: appwrite/influxdb:1.5.0 container_name: appwrite-influxdb + <<: *x-logging networks: - appwrite volumes: @@ -639,6 +664,7 @@ services: telegraf: image: appwrite/telegraf:1.4.0 container_name: appwrite-telegraf + <<: *x-logging networks: - appwrite environment: @@ -661,6 +687,7 @@ services: maildev: # used mainly for dev tests image: appwrite/mailcatcher:1.0.0 container_name: appwrite-mailcatcher + <<: *x-logging ports: - '9503:1080' networks: @@ -669,6 +696,7 @@ services: request-catcher: # used mainly for dev tests image: appwrite/requestcatcher:1.0.0 container_name: appwrite-requestcatcher + <<: *x-logging ports: - '9504:5000' networks: @@ -677,6 +705,7 @@ services: adminer: image: adminer container_name: appwrite-adminer + <<: *x-logging restart: always ports: - 9506:8080 diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index da8522953..03b14b185 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -3859,13 +3859,14 @@ tag.className="tag";tag.textContent=value;tag.addEventListener("click",function( if(element.required&&array.length===0){add.setCustomValidity("Please add permissions");}else{add.setCustomValidity("");}};tags.className="tags";preview.className="tags-list";add.type="text";add.className="add";add.placeholder=element.placeholder;tags.addEventListener("click",function(){add.focus();});add.addEventListener("keydown",listen);add.addEventListener("blur",function(event){if(add.value!==''){array.push(add.value);add.value="";element.value=JSON.stringify(array);check();}});tags.appendChild(preview);tags.appendChild(add);element.parentNode.insertBefore(tags,element);element.addEventListener("change",check);check();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-text-count",controller:function(element){var counter=document.createElement("div");counter.className="counter";element.parentNode.insertBefore(counter,element.nextSibling);var count=function(){if(0<=element.maxLength){counter.innerText=(element.maxLength-element.value.length).toString()+" / "+ element.maxLength;}else{var words=element.value!==""?element.value.trim().split(" ").length:0;counter.innerText=words+" words and "+element.value.length.toString()+" chars";}};element.addEventListener("keyup",count);element.addEventListener("change",count);element.addEventListener("cut",count);element.addEventListener("paste",count);element.addEventListener("drop",count);count();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-text-direction",controller:function(element,rtl){var setDirection=function(){var value=element.value[0]?element.value:"";var direction="ltr";var align="left";if(rtl.isRTL(value)){direction="rtl";align="right";} element.style.direction=direction;element.style.textAlign=align;};element.addEventListener("keyup",setDirection);element.addEventListener("change",setDirection);element.addEventListener("cut",setDirection);element.addEventListener("paste",setDirection);element.addEventListener("drop",setDirection);setDirection();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-text-resize",controller:function(element,window){function resize(){var scrollLeft=window.pageXOffset||(window.document.documentElement||window.document.body.parentNode||window.document.body).scrollLeft;var scrollTop=window.pageYOffset||(window.document.documentElement||window.document.body.parentNode||window.document.body).scrollTop;var offset=element.offsetHeight-element.clientHeight;element.style.height="auto";element.style.height=element.scrollHeight+offset+"px";window.scrollTo(scrollLeft,scrollTop);} -element.addEventListener("keyup",resize);element.addEventListener("change",resize);element.addEventListener("cut",resize);element.addEventListener("paste",resize);element.addEventListener("drop",resize);window.addEventListener("resize",resize);resize();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-upload",controller:function(element,container,alerts,expression,env,search){var scope=element.dataset["scope"];var project=expression.parse(element.dataset["project"]||"console");var labelButton=element.dataset["labelButton"]||"Upload";var labelLoading=element.dataset["labelLoading"]||"Uploading...";var previewWidth=element.dataset["previewWidth"]||200;var previewHeight=element.dataset["previewHeight"]||200;var previewAlt=element.dataset["previewAlt"]||200;var accept=element.dataset["accept"]||"";var searchButton=(element.dataset["search"]||0);var required=element.dataset["required"]||false;var className=element.dataset["class"]||"upload";var max=parseInt(element.dataset["max"]||4);var sdk=scope==="sdk"?container.get("sdk"):container.get("console");var output=element.value||null;var wrapper=document.createElement("div");var input=document.createElement("input");var upload=document.createElement("div");var preview=document.createElement("ul");var progress=document.createElement("div");var count=document.createElement("div");wrapper.className=className;input.type="file";input.accept=accept;input.required=required;input.tabIndex=-1;count.className="count";upload.className="button reverse margin-bottom-small";upload.innerHTML=' '+labelButton;upload.tabIndex=0;preview.className="preview";progress.className="progress";progress.style.width="0%";progress.style.display="none";var onComplete=function(message){alerts.remove(message);input.disabled=false;upload.classList.remove("disabled");progress.style.width="0%";progress.style.display="none";};var render=function(result){preview.innerHTML="";count.innerHTML="0 / "+max;if(!result){return;} +element.addEventListener("keyup",resize);element.addEventListener("change",resize);element.addEventListener("cut",resize);element.addEventListener("paste",resize);element.addEventListener("drop",resize);window.addEventListener("resize",resize);resize();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-upload",controller:function(element,container,alerts,expression,env,search){var scope=element.dataset["scope"];var project=expression.parse(element.dataset["project"]||"console");var labelButton=element.dataset["labelButton"]||"Upload";var labelLoading=element.dataset["labelLoading"]||"Uploading...";var previewWidth=element.dataset["previewWidth"]||200;var previewHeight=element.dataset["previewHeight"]||200;var previewAlt=element.dataset["previewAlt"]||200;var accept=element.dataset["accept"]||"";var searchButton=(element.dataset["search"]||0);var required=element.dataset["required"]||false;var className=element.dataset["class"]||"upload";var max=parseInt(element.dataset["max"]||4);var sdk=scope==="sdk"?container.get("sdk"):container.get("console");var output=element.value||null;console.log(element);var wrapper=document.createElement("div");var input=document.createElement("input");var upload=document.createElement("div");var preview=document.createElement("ul");var progress=document.createElement("div");var count=document.createElement("div");wrapper.className=className;input.type="file";input.accept=accept;input.required=required;input.tabIndex=-1;count.className="count";upload.className="button reverse margin-bottom-small";upload.innerHTML=' '+labelButton;upload.tabIndex=0;preview.className="preview";progress.className="progress";progress.style.width="0%";progress.style.display="none";var onComplete=function(message){alerts.remove(message);input.disabled=false;upload.classList.remove("disabled");progress.style.width="0%";progress.style.display="none";};var render=function(result){try{result=JSON.parse(result);}catch(err){} +preview.innerHTML="";count.innerHTML="0 / "+max;if(!result){return;} var file=document.createElement("li");var image=document.createElement("img");image.src=image.src=env.API+"/storage/buckets/"+ result.bucketId+"/files/"+ result.fileId+"/preview?width="+ previewWidth+"&height="+ -previewHeight+"&project="+project+"&mode=admin";image.alt=previewAlt;file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$id);element.value='';};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=result;};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile('default','unique()',files[0],read,write).then(function(response){onComplete(message);render({bucketId:response.bucketId,fileId:response.$id});},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){if(!element.value){return;} -render(element.value);wrapper.scrollIntoView();});upload.addEventListener("keypress",function(){input.click();});element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(preview);wrapper.appendChild(progress);wrapper.appendChild(upload);upload.appendChild(input);render(output);if(searchButton){let searchOpen=document.createElement("button");searchOpen.type='button';searchOpen.innerHTML=' Search';searchOpen.classList.add('reverse');let path=container.scope(searchButton);searchOpen.addEventListener('click',function(){search.selected=element.value;search.path=path;document.dispatchEvent(new CustomEvent("open-file-search",{bubbles:false,cancelable:true}));});wrapper.appendChild(searchOpen);}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-cookies",controller:function(element,alerts,cookie,env){if(!cookie.get("cookie-alert")){let text=element.dataset["cookies"]||"";alerts.add({text:text,class:"cookie-alert",link:env.HOME+"/policy/cookies",label:'Learn More',callback:function(){cookie.set("cookie-alert","true",365*10);}},0);}}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-copy',repeat:false,controller:function(document,element,alerts){let button=document.createElement("i");button.type="button";button.title="Copy to Clipboard";button.className=element.getAttribute("data-class")||"icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);let copy=function(event){window.getSelection().removeAllRanges();let range=document.createRange();range.selectNode(element);window.getSelection().addRange(range);try{document.execCommand("copy");alerts.add({text:"Copied to clipboard",class:""},3000);}catch(err){alerts.add({text:"Failed to copy text ",class:"error"},3000);} +previewHeight+"&project="+project+"&mode=admin";image.alt=previewAlt;file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$id);element.value='';};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=JSON.stringify(result);};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile('default','unique()',files[0],read,write).then(function(response){onComplete(message);render({bucketId:response.bucketId,fileId:response.$id});},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){if(!element.value){return;} +render(element.value);wrapper.scrollIntoView();});upload.addEventListener("keypress",function(){input.click();});element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(preview);wrapper.appendChild(progress);wrapper.appendChild(upload);upload.appendChild(input);console.log(output);render(output);if(searchButton){let searchOpen=document.createElement("button");searchOpen.type='button';searchOpen.innerHTML=' Search';searchOpen.classList.add('reverse');let path=container.scope(searchButton);searchOpen.addEventListener('click',function(){search.selected=element.value;search.path=path;document.dispatchEvent(new CustomEvent("open-file-search",{bubbles:false,cancelable:true}));});wrapper.appendChild(searchOpen);}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-cookies",controller:function(element,alerts,cookie,env){if(!cookie.get("cookie-alert")){let text=element.dataset["cookies"]||"";alerts.add({text:text,class:"cookie-alert",link:env.HOME+"/policy/cookies",label:'Learn More',callback:function(){cookie.set("cookie-alert","true",365*10);}},0);}}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-copy',repeat:false,controller:function(document,element,alerts){let button=document.createElement("i");button.type="button";button.title="Copy to Clipboard";button.className=element.getAttribute("data-class")||"icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);let copy=function(event){window.getSelection().removeAllRanges();let range=document.createRange();range.selectNode(element);window.getSelection().addRange(range);try{document.execCommand("copy");alerts.add({text:"Copied to clipboard",class:""},3000);}catch(err){alerts.add({text:"Failed to copy text ",class:"error"},3000);} window.getSelection().removeAllRanges();};button.addEventListener("click",copy);}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-page-title",repeat:true,controller:function(element,document,expression){document.title=expression.parse(element.getAttribute("data-page-title"))||document.title;}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-to',repeat:false,controller:function(element,window){let button=window.document.createElement('button');button.className='scroll-to icon-up-dir';button.alt='Back To Top';button.title='Back To Top';button.addEventListener('click',function(){element.scrollIntoView(true,{behavior:'smooth'});button.blur();},false);element.appendChild(button);}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-direction',repeat:false,controller:function(element,window){let position=0;let check=function(){let direction=window.document.documentElement.scrollTop;if(direction>position){element.classList.remove('scroll-to-top') element.classList.add('scroll-to-bottom')} else{element.classList.remove('scroll-to-bottom') diff --git a/public/dist/scripts/app.js b/public/dist/scripts/app.js index 0accf79a6..9ae4d12e6 100644 --- a/public/dist/scripts/app.js +++ b/public/dist/scripts/app.js @@ -809,13 +809,14 @@ tag.className="tag";tag.textContent=value;tag.addEventListener("click",function( if(element.required&&array.length===0){add.setCustomValidity("Please add permissions");}else{add.setCustomValidity("");}};tags.className="tags";preview.className="tags-list";add.type="text";add.className="add";add.placeholder=element.placeholder;tags.addEventListener("click",function(){add.focus();});add.addEventListener("keydown",listen);add.addEventListener("blur",function(event){if(add.value!==''){array.push(add.value);add.value="";element.value=JSON.stringify(array);check();}});tags.appendChild(preview);tags.appendChild(add);element.parentNode.insertBefore(tags,element);element.addEventListener("change",check);check();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-text-count",controller:function(element){var counter=document.createElement("div");counter.className="counter";element.parentNode.insertBefore(counter,element.nextSibling);var count=function(){if(0<=element.maxLength){counter.innerText=(element.maxLength-element.value.length).toString()+" / "+ element.maxLength;}else{var words=element.value!==""?element.value.trim().split(" ").length:0;counter.innerText=words+" words and "+element.value.length.toString()+" chars";}};element.addEventListener("keyup",count);element.addEventListener("change",count);element.addEventListener("cut",count);element.addEventListener("paste",count);element.addEventListener("drop",count);count();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-text-direction",controller:function(element,rtl){var setDirection=function(){var value=element.value[0]?element.value:"";var direction="ltr";var align="left";if(rtl.isRTL(value)){direction="rtl";align="right";} element.style.direction=direction;element.style.textAlign=align;};element.addEventListener("keyup",setDirection);element.addEventListener("change",setDirection);element.addEventListener("cut",setDirection);element.addEventListener("paste",setDirection);element.addEventListener("drop",setDirection);setDirection();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-text-resize",controller:function(element,window){function resize(){var scrollLeft=window.pageXOffset||(window.document.documentElement||window.document.body.parentNode||window.document.body).scrollLeft;var scrollTop=window.pageYOffset||(window.document.documentElement||window.document.body.parentNode||window.document.body).scrollTop;var offset=element.offsetHeight-element.clientHeight;element.style.height="auto";element.style.height=element.scrollHeight+offset+"px";window.scrollTo(scrollLeft,scrollTop);} -element.addEventListener("keyup",resize);element.addEventListener("change",resize);element.addEventListener("cut",resize);element.addEventListener("paste",resize);element.addEventListener("drop",resize);window.addEventListener("resize",resize);resize();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-upload",controller:function(element,container,alerts,expression,env,search){var scope=element.dataset["scope"];var project=expression.parse(element.dataset["project"]||"console");var labelButton=element.dataset["labelButton"]||"Upload";var labelLoading=element.dataset["labelLoading"]||"Uploading...";var previewWidth=element.dataset["previewWidth"]||200;var previewHeight=element.dataset["previewHeight"]||200;var previewAlt=element.dataset["previewAlt"]||200;var accept=element.dataset["accept"]||"";var searchButton=(element.dataset["search"]||0);var required=element.dataset["required"]||false;var className=element.dataset["class"]||"upload";var max=parseInt(element.dataset["max"]||4);var sdk=scope==="sdk"?container.get("sdk"):container.get("console");var output=element.value||null;var wrapper=document.createElement("div");var input=document.createElement("input");var upload=document.createElement("div");var preview=document.createElement("ul");var progress=document.createElement("div");var count=document.createElement("div");wrapper.className=className;input.type="file";input.accept=accept;input.required=required;input.tabIndex=-1;count.className="count";upload.className="button reverse margin-bottom-small";upload.innerHTML=' '+labelButton;upload.tabIndex=0;preview.className="preview";progress.className="progress";progress.style.width="0%";progress.style.display="none";var onComplete=function(message){alerts.remove(message);input.disabled=false;upload.classList.remove("disabled");progress.style.width="0%";progress.style.display="none";};var render=function(result){preview.innerHTML="";count.innerHTML="0 / "+max;if(!result){return;} +element.addEventListener("keyup",resize);element.addEventListener("change",resize);element.addEventListener("cut",resize);element.addEventListener("paste",resize);element.addEventListener("drop",resize);window.addEventListener("resize",resize);resize();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-upload",controller:function(element,container,alerts,expression,env,search){var scope=element.dataset["scope"];var project=expression.parse(element.dataset["project"]||"console");var labelButton=element.dataset["labelButton"]||"Upload";var labelLoading=element.dataset["labelLoading"]||"Uploading...";var previewWidth=element.dataset["previewWidth"]||200;var previewHeight=element.dataset["previewHeight"]||200;var previewAlt=element.dataset["previewAlt"]||200;var accept=element.dataset["accept"]||"";var searchButton=(element.dataset["search"]||0);var required=element.dataset["required"]||false;var className=element.dataset["class"]||"upload";var max=parseInt(element.dataset["max"]||4);var sdk=scope==="sdk"?container.get("sdk"):container.get("console");var output=element.value||null;console.log(element);var wrapper=document.createElement("div");var input=document.createElement("input");var upload=document.createElement("div");var preview=document.createElement("ul");var progress=document.createElement("div");var count=document.createElement("div");wrapper.className=className;input.type="file";input.accept=accept;input.required=required;input.tabIndex=-1;count.className="count";upload.className="button reverse margin-bottom-small";upload.innerHTML=' '+labelButton;upload.tabIndex=0;preview.className="preview";progress.className="progress";progress.style.width="0%";progress.style.display="none";var onComplete=function(message){alerts.remove(message);input.disabled=false;upload.classList.remove("disabled");progress.style.width="0%";progress.style.display="none";};var render=function(result){try{result=JSON.parse(result);}catch(err){} +preview.innerHTML="";count.innerHTML="0 / "+max;if(!result){return;} var file=document.createElement("li");var image=document.createElement("img");image.src=image.src=env.API+"/storage/buckets/"+ result.bucketId+"/files/"+ result.fileId+"/preview?width="+ previewWidth+"&height="+ -previewHeight+"&project="+project+"&mode=admin";image.alt=previewAlt;file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$id);element.value='';};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=result;};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile('default','unique()',files[0],read,write).then(function(response){onComplete(message);render({bucketId:response.bucketId,fileId:response.$id});},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){if(!element.value){return;} -render(element.value);wrapper.scrollIntoView();});upload.addEventListener("keypress",function(){input.click();});element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(preview);wrapper.appendChild(progress);wrapper.appendChild(upload);upload.appendChild(input);render(output);if(searchButton){let searchOpen=document.createElement("button");searchOpen.type='button';searchOpen.innerHTML=' Search';searchOpen.classList.add('reverse');let path=container.scope(searchButton);searchOpen.addEventListener('click',function(){search.selected=element.value;search.path=path;document.dispatchEvent(new CustomEvent("open-file-search",{bubbles:false,cancelable:true}));});wrapper.appendChild(searchOpen);}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-cookies",controller:function(element,alerts,cookie,env){if(!cookie.get("cookie-alert")){let text=element.dataset["cookies"]||"";alerts.add({text:text,class:"cookie-alert",link:env.HOME+"/policy/cookies",label:'Learn More',callback:function(){cookie.set("cookie-alert","true",365*10);}},0);}}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-copy',repeat:false,controller:function(document,element,alerts){let button=document.createElement("i");button.type="button";button.title="Copy to Clipboard";button.className=element.getAttribute("data-class")||"icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);let copy=function(event){window.getSelection().removeAllRanges();let range=document.createRange();range.selectNode(element);window.getSelection().addRange(range);try{document.execCommand("copy");alerts.add({text:"Copied to clipboard",class:""},3000);}catch(err){alerts.add({text:"Failed to copy text ",class:"error"},3000);} +previewHeight+"&project="+project+"&mode=admin";image.alt=previewAlt;file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$id);element.value='';};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=JSON.stringify(result);};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile('default','unique()',files[0],read,write).then(function(response){onComplete(message);render({bucketId:response.bucketId,fileId:response.$id});},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){if(!element.value){return;} +render(element.value);wrapper.scrollIntoView();});upload.addEventListener("keypress",function(){input.click();});element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(preview);wrapper.appendChild(progress);wrapper.appendChild(upload);upload.appendChild(input);console.log(output);render(output);if(searchButton){let searchOpen=document.createElement("button");searchOpen.type='button';searchOpen.innerHTML=' Search';searchOpen.classList.add('reverse');let path=container.scope(searchButton);searchOpen.addEventListener('click',function(){search.selected=element.value;search.path=path;document.dispatchEvent(new CustomEvent("open-file-search",{bubbles:false,cancelable:true}));});wrapper.appendChild(searchOpen);}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-cookies",controller:function(element,alerts,cookie,env){if(!cookie.get("cookie-alert")){let text=element.dataset["cookies"]||"";alerts.add({text:text,class:"cookie-alert",link:env.HOME+"/policy/cookies",label:'Learn More',callback:function(){cookie.set("cookie-alert","true",365*10);}},0);}}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-copy',repeat:false,controller:function(document,element,alerts){let button=document.createElement("i");button.type="button";button.title="Copy to Clipboard";button.className=element.getAttribute("data-class")||"icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);let copy=function(event){window.getSelection().removeAllRanges();let range=document.createRange();range.selectNode(element);window.getSelection().addRange(range);try{document.execCommand("copy");alerts.add({text:"Copied to clipboard",class:""},3000);}catch(err){alerts.add({text:"Failed to copy text ",class:"error"},3000);} window.getSelection().removeAllRanges();};button.addEventListener("click",copy);}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-page-title",repeat:true,controller:function(element,document,expression){document.title=expression.parse(element.getAttribute("data-page-title"))||document.title;}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-to',repeat:false,controller:function(element,window){let button=window.document.createElement('button');button.className='scroll-to icon-up-dir';button.alt='Back To Top';button.title='Back To Top';button.addEventListener('click',function(){element.scrollIntoView(true,{behavior:'smooth'});button.blur();},false);element.appendChild(button);}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-direction',repeat:false,controller:function(element,window){let position=0;let check=function(){let direction=window.document.documentElement.scrollTop;if(direction>position){element.classList.remove('scroll-to-top') element.classList.add('scroll-to-bottom')} else{element.classList.remove('scroll-to-bottom') diff --git a/public/scripts/views/forms/oauth-custom.js b/public/scripts/views/forms/oauth-custom.js index 323c87441..fd8bd855d 100644 --- a/public/scripts/views/forms/oauth-custom.js +++ b/public/scripts/views/forms/oauth-custom.js @@ -10,11 +10,11 @@ let providers = { "Microsoft": { "clientSecret": "oauth2MicrosoftClientSecret", - "tenantId": "oauth2MicrosoftTenantId" + "tenantID": "oauth2MicrosoftTenantId" }, "Apple": { - "keyId": "oauth2AppleKeyId", - "teamId": "oauth2AppleTeamId", + "keyID": "oauth2AppleKeyId", + "teamID": "oauth2AppleTeamId", "p8": "oauth2AppleP8" } } diff --git a/public/scripts/views/forms/upload.js b/public/scripts/views/forms/upload.js index e99d16fd2..3d25831b1 100644 --- a/public/scripts/views/forms/upload.js +++ b/public/scripts/views/forms/upload.js @@ -55,6 +55,12 @@ }; var render = function(result) { + try { + result = JSON.parse(result); + } catch(err) { + // Not JSON = empty string. No image + + } preview.innerHTML = ""; count.innerHTML = "0 / " + max; @@ -97,7 +103,7 @@ file.addEventListener("click", remove); file.addEventListener("keypress", remove); - element.value = result; + element.value = JSON.stringify(result); }; input.addEventListener("change", function() { diff --git a/src/Appwrite/Auth/OAuth2/Microsoft.php b/src/Appwrite/Auth/OAuth2/Microsoft.php index 417c2ef3d..ebfd2e4e8 100644 --- a/src/Appwrite/Auth/OAuth2/Microsoft.php +++ b/src/Appwrite/Auth/OAuth2/Microsoft.php @@ -41,7 +41,7 @@ class Microsoft extends OAuth2 */ public function getLoginURL(): string { - return 'https://login.microsoftonline.com/'.$this->getTenantId().'/oauth2/v2.0/authorize?'.\http_build_query([ + return 'https://login.microsoftonline.com/'.$this->getTenantID().'/oauth2/v2.0/authorize?'.\http_build_query([ 'client_id' => $this->appID, 'redirect_uri' => $this->callback, 'state'=> \json_encode($this->state), @@ -62,7 +62,7 @@ class Microsoft extends OAuth2 $headers = ['Content-Type: application/x-www-form-urlencoded']; $this->tokens = \json_decode($this->request( 'POST', - 'https://login.microsoftonline.com/' . $this->getTenantId() . '/oauth2/v2.0/token', + 'https://login.microsoftonline.com/' . $this->getTenantID() . '/oauth2/v2.0/token', $headers, \http_build_query([ 'code' => $code, @@ -88,7 +88,7 @@ class Microsoft extends OAuth2 $headers = ['Content-Type: application/x-www-form-urlencoded']; $this->tokens = \json_decode($this->request( 'POST', - 'https://login.microsoftonline.com/' . $this->getTenantId() . '/oauth2/v2.0/token', + 'https://login.microsoftonline.com/' . $this->getTenantID() . '/oauth2/v2.0/token', $headers, \http_build_query([ 'refresh_token' => $refreshToken, @@ -169,38 +169,40 @@ class Microsoft extends OAuth2 return $this->user; } - /** - * Extracts the Client Secret from the JSON stored in appSecret - * @return string - */ - protected function getClientSecret(): string - { - $secret = $this->decodeJson(); - - return (isset($secret['clientSecret'])) ? $secret['clientSecret'] : ''; - } - /** * Decode the JSON stored in appSecret + * * @return array */ - protected function decodeJson(): array + protected function getAppSecret(): array { try { - $secret = \json_decode($this->appSecret, true); + $secret = \json_decode($this->appSecret, true, 512, JSON_THROW_ON_ERROR); } catch (\Throwable $th) { - throw new Exception('Invalid secret'); + throw new \Exception('Invalid secret'); } return $secret; } /** - * Extracts the Tenant Id from the JSON stored in appSecret. Defaults to 'common' as a fallback + * Extracts the Client Secret from the JSON stored in appSecret + * * @return string */ - protected function getTenantId(): string + protected function getClientSecret(): string { - $secret = $this->decodeJson(); - return (isset($secret['tenantId'])) ? $secret['tenantId'] : 'common'; + $secret = $this->getAppSecret(); + return (isset($secret['clientSecret'])) ? $secret['clientSecret'] : ''; + } + + /** + * Extracts the Tenant Id from the JSON stored in appSecret. Defaults to 'common' as a fallback + * + * @return string + */ + protected function getTenantID(): string + { + $secret = $this->getAppSecret(); + return (isset($secret['tenantID'])) ? $secret['tenantID'] : 'common'; } } diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 1a96b3561..fff322161 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -59,7 +59,6 @@ class Executor string $entrypoint = '', string $workdir = '', string $destination = '', - string $network = '', array $vars = [], array $commands = [] ) { @@ -76,7 +75,6 @@ class Executor 'baseImage' => $baseImage, 'entrypoint' => $entrypoint, 'workdir' => $workdir, - 'network' => empty($network) ? App::getEnv('_APP_EXECUTOR_RUNTIME_NETWORK', 'appwrite_runtimes') : $network, 'vars' => $vars, 'remove' => $remove, 'commands' => $commands