1
0
Fork 0
mirror of synced 2024-06-09 22:34:46 +12:00

validate id exists or not for all services

This commit is contained in:
Damodar Lohani 2021-08-04 12:24:23 +05:45
parent e6b98bd022
commit 2bfdd787cc
13 changed files with 222 additions and 188 deletions

View file

@ -206,7 +206,8 @@
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.get"
required
maxlength="36"
class=""

View file

@ -29,7 +29,7 @@
<p class="margin-bottom-no">You haven't created any collections for your project yet.</p>
</div>
</div>
<div data-ls-if="0 != {{project-collections.sum}}">
<ul data-ls-loop="project-collections.collections" data-ls-as="collection" data-ls-append="" class="tiles cell-3 margin-bottom-small">
<li class="margin-bottom">
@ -98,18 +98,19 @@
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="database.getCollection"
required
maxlength="36"
name="collectionId" />
<label for="collection-name">Name</label>
<input type="text" class="full-width" id="collection-name" name="name" required autocomplete="off" maxlength="128" />
<input type="hidden" id="collection-read" name="read" required data-cast-to="json" value="<?php echo htmlentities(json_encode([])); ?>" />
<input type="hidden" id="collection-write" name="write" required data-cast-to="json" value="<?php echo htmlentities(json_encode([])); ?>" />
<input type="hidden" id="collection-rules" name="rules" required data-cast-to="json" value="{}" />
<hr />
<button type="submit">Create</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>

View file

@ -3,7 +3,7 @@ $fileLimit = $this->getParam('fileLimit', 0);
$fileLimitHuman = $this->getParam('fileLimitHuman', 0);
$events = array_keys($this->getParam('events', []));
$timeout = $this->getParam('timeout', 900);
$usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
$usageStatsEnabled = $this->getParam('usageStatsEnabled', true);
?>
<div
data-service="functions.get"
@ -23,8 +23,8 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</div>
<div data-ui-modal class="modal width-large box close" data-button-hide="on" data-open-event="open-json">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<h2>JSON View</h2>
<div class="margin-bottom">
@ -37,9 +37,9 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<div class="zone xl">
<ul class="phases clear" data-ui-phases data-selected="{{router.params.tab}}">
<li data-state="/console/functions/function?id={{router.params.id}}&project={{router.params.project}}">
<h2>Overview</h2>
<div class="row responsive margin-top-negative">
<div class="col span-8 margin-bottom">
<label>&nbsp;</label>
@ -98,7 +98,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input type="hidden" name="tag" data-ls-bind="{{tag.$id}}">
<button>Activate</button>
</form>
<b data-ls-bind="{{tag.$id}}"></b> &nbsp;
<span class="text-fade" data-ls-bind="{{tag.command}}"></span>
<div class="text-size-small margin-top-small clear">
@ -202,9 +202,9 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</div>
</div>
</li>
<?php if($usageStatsEnabled): ?>
<?php if ($usageStatsEnabled): ?>
<li data-state="/console/functions/function/monitors?id={{router.params.id}}&project={{router.params.project}}">
<form class="pull-end margin-start-small margin-top-small" data-ls-if="{{usage.range}} !== '90d'"
data-service="functions.getUsage"
data-event="submit"
@ -238,8 +238,8 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<button class="tick pull-end margin-start-small margin-top-small" data-ls-if="{{usage.range}} === '24h'" disabled>24h</button>
<h2>Monitors</h2>
<div
<div
data-service="functions.getUsage"
data-event="load"
data-name="usage"
@ -281,7 +281,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</ul>
</div>
</li>
<?php endif; ?>
<?php endif;?>
<li data-state="/console/functions/function/logs?id={{router.params.id}}&project={{router.params.project}}">
<div class="text-fade text-size-small pull-end margin-top" data-ls-bind="{{project-function-executions.sum}} executions found"></div>
@ -337,7 +337,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</td>
<td data-title="">
<div data-ls-if="{{execution.status}} === 'completed' || {{execution.status}} === 'failed'" data-title="">
<button class="desktops-only pull-end link margin-start text-danger" data-ls-ui-trigger="execution-stderr-{{execution.$id}}">Errors</button>
<button class="desktops-only pull-end link margin-start" data-ls-ui-trigger="execution-stdout-{{execution.$id}}">Output</button>
@ -463,18 +463,18 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<section class="margin-bottom" data-forms-select-all>
<label for="events" class="margin-bottom">Events <span class="tooltip small" data-tooltip="Choose which events should trigger this function."><i class="icon-info-circled"></i></span></label>
<div class="row responsive thin margin-top-small">
<?php foreach ($events as $i => $event) : ?>
<?php foreach ($events as $i => $event): ?>
<div class="col span-6 text-one-liner margin-bottom text-height-large text-size-small" title="<?php echo $event; ?>">
<input type="checkbox" name="events" data-ls-bind="{{project-function.events}}" id="<?php echo $event; ?>" value="<?php echo $event; ?>" />
&nbsp;
<label class="inline" for="<?php echo $event; ?>"><?php echo $event; ?></label>
</div>
<?php if (($i + 1) % 2 === 0) : ?>
<?php if (($i + 1) % 2 === 0): ?>
</div>
<div class="row responsive thin">
<?php endif; ?>
<?php endif;?>
<?php endforeach; ?>
<?php endforeach;?>
</div>
</section>
@ -631,14 +631,15 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
data-failure="alert"
data-failure-param-alert-text="Failed to create function tag"
data-failure-param-alert-classname="error">
<input type="hidden" name="functionId" data-ls-bind="{{router.params.id}}" />
<label for="tagId">Tag Id</label>
<input
type="hidden"
data-custom-id
id-type="custom"
data-id-type="custom"
data-validator="functions.getTag"
required
maxlength="36"
id="tagId"
@ -660,5 +661,5 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</ul>
</div>

View file

@ -35,7 +35,7 @@ $runtimes = $this->getParam('runtimes', []);
<div data-ls-if="0 != {{project-functions.functions.length}}">
<div class="margin-bottom-small margin-end-small text-align-end text-size-small margin-top-negative"><span data-ls-bind="{{project-functions.sum}}"></span> functions found</div>
<div class="box margin-bottom">
<ul data-ls-loop="project-functions.functions" data-ls-as="function" class="list">
<li class="clear">
@ -106,22 +106,23 @@ $runtimes = $this->getParam('runtimes', []);
data-failure-param-alert-text="Failed to create function"
data-failure-param-alert-classname="error">
<label for="functionId">Function ID</label>
<input
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="functions.get"
required
maxlength="36"
name="functionId" />
<label for="name">Name</label>
<input type="text" id="name" name="name" required autocomplete="off" class="margin-bottom" maxlength="128" />
<label for="runtime">Runtimes</label>
<select name="runtime" id="runtime" required class="margin-bottom-xl">
<?php foreach($runtimes as $key => $runtime): ?>
<?php foreach ($runtimes as $key => $runtime): ?>
<option value="<?php echo $this->escape($key); ?>"><?php echo $this->escape($runtime['name']); ?> <?php echo $this->escape($runtime['version']); ?></option>
<?php endforeach; ?>
<?php endforeach;?>
</select>
<input id="execute" name="execute" value="" hidden/>

View file

@ -1,6 +1,6 @@
<?php
$graph = $this->getParam('graph', false);
$usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
$usageStatsEnabled = $this->getParam('usageStatsEnabled', true);
?>
<div class="cover margin-bottom-small">
@ -73,7 +73,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<button class="tick margin-start-small" data-ls-if="{{usage.range}} === '90d'" disabled>90d</button>
</div>
<?php endif; ?>
<?php endif;?>
</div>
<div
data-service="projects.getUsage"
@ -105,7 +105,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</div>
</div>
</div>
<?php endif; ?>
<?php endif;?>
<div class="box dashboard">
<div class="row responsive">
@ -176,11 +176,11 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<div>
<div class="pull-start margin-end avatar-container">
<img src="" data-ls-attrs="src=/images/clients/{{platform.type}}.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="Platform Logo" class="avatar" loading="lazy" width="60" height="60" />
<div data-ls-if="{{platform.type}} === 'flutter-ios'" class="corner">
<img src="" data-ls-attrs="src=/images/clients/flutter.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="iOS Logo" class="avatar xs" loading="lazy" width="30" height="30" />
</div>
<div data-ls-if="{{platform.type}} === 'flutter-android'" class="corner">
<img src="" data-ls-attrs="src=/images/clients/flutter.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="Android Logo" class="avatar xs" loading="lazy" width="30" height="30" />
</div>
@ -275,7 +275,8 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
@ -286,7 +287,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<label for="hostname">Hostname <span class="tooltip large" data-tooltip="The hostname that your website will use to interact with the <?php echo APP_NAME; ?> APIs in production or development environments. No port number required."><i class="icon-question"></i></span></label>
<input name="hostname" type="text" class="margin-bottom" autocomplete="off" placeholder="localhost" required>
<div class="info margin-top margin-bottom">
<div class="text-bold margin-bottom-small">Next Steps</div>
@ -326,7 +327,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<label for="hostname">Hostname <span class="tooltip large" data-tooltip="The hostname that your website will use to interact with the <?php echo APP_NAME; ?> APIs in production or development environments. No port number required."><i class="icon-question"></i></span></label>
<input name="hostname" type="text" class="margin-bottom" autocomplete="off" placeholder="localhost" data-ls-bind="{{platform.hostname}}" required />
<hr />
<button type="submit">Update</button> &nbsp; <button data-ls-ui-trigger="modal-close" type="button" class="reverse">Back</button>
@ -360,7 +361,8 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<label for="platformId">Platform ID <span class="tooltip large" data-tooltip="Choose an ID that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
@ -405,17 +407,18 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="type" data-ls-bind="flutter-ios" />
<label for="platformId">Platform ID <span class="tooltip large" data-tooltip="Choose an ID that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
placeholder="my_flutter_ios_app" />
<label for="name">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" name="name" required autocomplete="off" placeholder="My iOS App" maxlength="128" />
@ -449,12 +452,13 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="type" data-ls-bind="flutter-android" />
<label for="platformId">Platform ID <span class="tooltip large" data-tooltip="Choose an ID that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
@ -497,12 +501,13 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
placeholder="my_flutter_linux_app" />
<label for="name">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" name="name" required autocomplete="off" placeholder="My Linux App" maxlength="128" />
@ -540,12 +545,13 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
placeholder="my_flutter_macos_app" />
<label for="name">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" name="name" required autocomplete="off" placeholder="My Mac OS App" maxlength="128" />
@ -583,12 +589,13 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getPlatform"
required
maxlength="36"
name="platformId"
placeholder="my_flutter_windows_app" />
<label for="name">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" name="name" required autocomplete="off" placeholder="My Windows App" maxlength="128" />
@ -628,7 +635,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<label data-ls-attrs="for=key-{{platform.$id}}">Bundle ID <span class="tooltip large" data-tooltip="You can find your Bundle Identifier in the General tab for your app's primary target in Xcode."><i class="icon-question"></i></span></label>
<input name="key" type="text" class="margin-bottom" autocomplete="off" placeholder="com.cpmpany.appname" data-ls-bind="{{platform.key}}" required />
<hr />
<button type="submit">Update</button> &nbsp; <button data-ls-ui-trigger="modal-close" type="button" class="reverse">Back</button>
@ -659,7 +666,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<label data-ls-attrs="for=key-{{platform.$id}}">Package Name <span class="tooltip large" data-tooltip="Your package name is generally the applicationId in your app-level build.gradle file."><i class="icon-question"></i></span></label>
<input name="key" type="text" class="margin-bottom" autocomplete="off" placeholder="com.cpmpany.appname" data-ls-bind="{{platform.key}}" required />
<hr />
<button type="submit">Update</button> &nbsp; <button data-ls-ui-trigger="modal-close" type="button" class="reverse">Back</button>
@ -691,7 +698,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<label data-ls-attrs="for=key-{{platform.$id}}">App Name <span class="tooltip large" data-tooltip="Your application name"><i class="icon-question"></i></span></label>
<input name="key" type="text" class="margin-bottom" autocomplete="off" placeholder="appname" data-ls-bind="{{platform.key}}" required />
<hr />
<button type="submit">Update</button> &nbsp; <button data-ls-ui-trigger="modal-close" type="button" class="reverse">Back</button>

View file

@ -57,18 +57,18 @@ $scopes = $this->getParam('scopes', []);
<section data-forms-select-all>
<label data-ls-attrs="for=scopes-{{key.$id}}">Scopes (<a data-ls-attrs="href={{env.HOME}}/docs/keys" target="_blank" rel="noopener">Learn more</a>)</label>
<div class="row responsive thin">
<?php foreach ($scopes as $i => $scope) : ?>
<?php foreach ($scopes as $i => $scope): ?>
<div class="col span-6 text-one-liner margin-bottom text-height-large text-size-small" title="<?php echo $scope; ?>">
<input data-ls-attrs="id=scope-<?php echo $scope; ?>" type="checkbox" name="scopes" data-ls-bind="{{key.scopes}}" value="<?php echo $scope; ?>" />
&nbsp;
<label class="inline" for="scope-<?php echo $scope; ?>"><?php echo $scope; ?></label>
</div>
<?php if (($i + 1) % 2 === 0) : ?>
<?php if (($i + 1) % 2 === 0): ?>
</div>
<div class="row responsive thin">
<?php endif; ?>
<?php endforeach; ?>
<?php endif;?>
<?php endforeach;?>
</div>
</section>
@ -114,7 +114,7 @@ $scopes = $this->getParam('scopes', []);
<div class="input-copy">
<textarea disabled style="height: 130px; line-height: 26px" data-forms-copy data-ls-bind="{{key.secret}}"></textarea>
</div>
<hr />
<div>
@ -153,34 +153,35 @@ $scopes = $this->getParam('scopes', []);
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<label for="keyId">Key ID <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different API keys."><i class="icon-question"></i></span></label>
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getKey"
required
maxlength="36"
name="keyId" />
<label for="name">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different API keys."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" id="name" name="name" required autocomplete="off" maxlength="128" />
<section data-forms-select-all>
<label for="scopes">Scopes (<a data-ls-attrs="href={{env.HOME}}/docs/keys" target="_blank" rel="noopener">Learn more</a>)</label>
<div class="row responsive thin">
<?php foreach ($scopes as $i => $scope) : ?>
<?php foreach ($scopes as $i => $scope): ?>
<div class="col span-6 text-one-liner margin-bottom text-height-large text-size-small" title="<?php echo $scope; ?>">
<input type="checkbox" name="scopes" id="<?php echo $scope; ?>" value="<?php echo $scope; ?>" />
&nbsp;
<input type="checkbox" name="scopes" id="<?php echo $scope; ?>" value="<?php echo $scope; ?>" />
&nbsp;
<label class="inline" for="<?php echo $scope; ?>"><?php echo $scope; ?></label>
</div>
<?php if (($i + 1) % 2 === 0) : ?>
<?php if (($i + 1) % 2 === 0): ?>
</div>
<div class="row responsive thin">
<?php endif; ?>
<?php endif;?>
<?php endforeach; ?>
<?php endforeach;?>
</div>
</section>

View file

@ -108,7 +108,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<label for="file-read">Read Access (<a data-ls-attrs="href={{env.HOME}}/docs/permissions" target="_blank" rel="noopener">Learn more</a>)</label>
<input type="hidden" data-ls-attrs="id=file-read-{{file.$id}}" name="read" data-forms-tags data-cast-to="json" data-ls-bind="{{file.$read}}" placeholder="User ID, Team ID or Role" />
<div class="text-fade text-size-xs margin-top-negative-small margin-bottom">Add * for wildcard access</div>
<label for="file-write">Write Access (<a data-ls-attrs="href={{env.HOME}}/docs/permissions" target="_blank" rel="noopener">Learn more</a>)</label>
<input type="hidden" data-ls-attrs="id=file-write-{{file.$id}}" name="write" data-forms-tags data-cast-to="json" data-ls-bind="{{file.$write}}" placeholder="User ID, Team ID or Role" />
<div class="text-fade text-size-xs margin-top-negative-small margin-bottom">Add * for wildcard access</div>
@ -136,7 +136,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
</div>
<div class="col span-4 text-size-small">
<div class="margin-bottom-small">File Preview</div>
<div class="margin-bottom-small">
<img src="" class="file-preview" data-ls-attrs="src={{env.ENDPOINT}}/v1/storage/files/{{file.$id}}/preview?width=350&height=250&project={{router.params.project}}&mode=admin" loading="lazy" width="225" height="160" />
</div>
@ -241,7 +241,8 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="storage.getFile"
required
maxlength="36"
name="fileId"
@ -255,7 +256,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<label for="file-read">Read Access (<a data-ls-attrs="href={{env.HOME}}/docs/permissions" target="_blank" rel="noopener">Learn more</a>)</label>
<input type="hidden" id="file-read" name="read" data-forms-tags data-cast-to="json" value="<?php echo htmlentities(json_encode(['role:all'])); ?>" placeholder="User ID, Team ID or Role" />
<div class="text-fade text-size-xs margin-top-negative-small margin-bottom">Add * for wildcard access</div>
<label for="file-write">Write Access (<a data-ls-attrs="href={{env.HOME}}/docs/permissions" target="_blank" rel="noopener">Learn more</a>)</label>
<input type="hidden" id="file-write" name="write" data-forms-tags data-cast-to="json" value="" placeholder="User ID, Team ID or Role" />
<div class="text-fade text-size-xs margin-top-negative-small margin-bottom">Add * for wildcard access</div>

View file

@ -158,7 +158,8 @@ $auth = $this->getParam('auth', []);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="users.get"
required
maxlength="36"
id="userId"
@ -304,7 +305,8 @@ $auth = $this->getParam('auth', []);
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="teams.get"
required
maxlength="36"
id="teamId"
@ -312,7 +314,7 @@ $auth = $this->getParam('auth', []);
<label for="team-name">Name</label>
<input type="text" class="full-width" id="team-name" name="name" required autocomplete="off" maxlength="128" />
<hr />
<button type="submit">Create</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
@ -320,11 +322,11 @@ $auth = $this->getParam('auth', []);
</div>
</div>
</li>
<li data-state="/console/users/providers?project={{router.params.project}}">
<p data-ls-if="{{console-project.usersAuthLimit}} == 0" class="text-fade text-size-small margin-bottom pull-end">Unlimited Users <span class="link" data-ls-ui-trigger="project-update-auth-users-limit">Set Limit</a></p>
<p data-ls-if="{{console-project.usersAuthLimit}} != 0" class="text-fade text-size-small margin-bottom pull-end"><span data-ls-bind="{{console-project.usersAuthLimit|statsTotal}}"></span> Users allowed <span class="link" data-ls-ui-trigger="project-update-auth-users-limit">Change Limit</a></p>
<h2>Settings</h2>
<div data-ui-modal class="modal close" data-button-alias="none" data-open-event="project-update-auth-users-limit">
@ -365,50 +367,50 @@ $auth = $this->getParam('auth', []);
<p class="text-fade margin-bottom">Choose auth methods you wish to use.</p>
<ul class="tiles cell-3 margin-bottom-small">
<?php foreach($auth as $index => $method):
$key = $method['key'] ?? '';
$name = $method['name'] ?? '';
$icon = $method['icon'] ?? '';
$docs = $method['docs'] ?? '';
$enabled = $method['enabled'] ?? false;
?>
<li class="">
<div class="box padding-small margin-bottom clear">
<?php if($enabled): ?>
<form
data-analytics
data-analytics-activity
data-analytics-event="submit"
data-analytics-category="console"
data-analytics-label="Update Project Auth Status (<?php echo $this->escape($name); ?>)"
data-service="projects.updateAuthStatus"
data-scope="console"
data-event="change"
data-param-project-id="{{router.params.project}}"
data-success="alert,trigger"
data-success-param-alert-text="Updated project auth status successfully"
data-success-param-trigger-events="projects.update"
data-failure="alert"
data-failure-param-alert-text="Failed to update project auth status settings"
data-failure-param-alert-classname="error">
<input name="method" id="<?php echo $this->escape($key); ?>" type="hidden" autocomplete="off" value="<?php echo $this->escape($index); ?>">
<?php foreach ($auth as $index => $method):
$key = $method['key'] ?? '';
$name = $method['name'] ?? '';
$icon = $method['icon'] ?? '';
$docs = $method['docs'] ?? '';
$enabled = $method['enabled'] ?? false;
?>
<li class="">
<div class="box padding-small margin-bottom clear">
<?php if ($enabled): ?>
<form
data-analytics
data-analytics-activity
data-analytics-event="submit"
data-analytics-category="console"
data-analytics-label="Update Project Auth Status (<?php echo $this->escape($name); ?>)"
data-service="projects.updateAuthStatus"
data-scope="console"
data-event="change"
data-param-project-id="{{router.params.project}}"
data-success="alert,trigger"
data-success-param-alert-text="Updated project auth status successfully"
data-success-param-trigger-events="projects.update"
data-failure="alert"
data-failure-param-alert-text="Failed to update project auth status settings"
data-failure-param-alert-classname="error">
<input name="method" id="<?php echo $this->escape($key); ?>" type="hidden" autocomplete="off" value="<?php echo $this->escape($index); ?>">
<input name="status" type="hidden" data-forms-switch data-ls-bind="{{console-project.<?php echo $this->escape($key); ?>}}" data-cast-to="boolean" class="pull-end" />
</form>
<?php endif; ?>
<input name="status" type="hidden" data-forms-switch data-ls-bind="{{console-project.<?php echo $this->escape($key); ?>}}" data-cast-to="boolean" class="pull-end" />
</form>
<?php endif;?>
<img src="<?php echo $this->escape($icon); ?>?buster=<?php echo APP_CACHE_BUSTER; ?>" alt="<?php echo $this->escape($name); ?> Logo" class="pull-start provider margin-end" />
<span class="text-size-small"><?php echo $this->escape($name); ?><?php if(!$enabled): ?> <span class="text-fade text-size-xs">soon</span><?php endif; ?></span>
<?php if($docs): ?>
<span class="text-size-small"><?php echo $this->escape($name); ?><?php if (!$enabled): ?> <span class="text-fade text-size-xs">soon</span><?php endif;?></span>
<?php if ($docs): ?>
<p class="margin-bottom-no text-one-liner text-size-small">
<a href="<?php echo $this->escape($docs); ?>" target="_blank" rel="noopener">Docs<i class="icon-link-ext"></i></a>
</p>
<?php endif; ?>
<?php endif;?>
</div>
</li>
<?php endforeach; ?>
<?php endforeach;?>
</ul>
<h3>OAuth2 Providers</h3>
@ -421,18 +423,18 @@ $auth = $this->getParam('auth', []);
data-scope="console">
<ul class="tiles cell-3 margin-bottom-small">
<?php foreach ($providers as $provider => $data):
if (isset($data['enabled']) && !$data['enabled']) { continue; }
if (isset($data['mock']) && $data['mock']) { continue; }
$sandbox = $data['sandbox'] ?? false;
$form = $data['form'] ?? false;
$name = $data['name'] ?? 'Unknown';
$beta = $data['beta'] ?? false;
?>
<li class="<?php echo (isset($data['enabled']) && !$data['enabled']) ? 'dev-feature' : ''; ?>">
<div data-ui-modal class="modal close" data-button-alias="none" data-open-event="provider-update-<?php echo $provider; ?>">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
if (isset($data['enabled']) && !$data['enabled']) {continue;}
if (isset($data['mock']) && $data['mock']) {continue;}
$sandbox = $data['sandbox'] ?? false;
$form = $data['form'] ?? false;
$name = $data['name'] ?? 'Unknown';
$beta = $data['beta'] ?? false;
?>
<li class="<?php echo (isset($data['enabled']) && !$data['enabled']) ? 'dev-feature' : ''; ?>">
<div data-ui-modal class="modal close" data-button-alias="none" data-open-event="provider-update-<?php echo $provider; ?>">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<h1><?php echo $this->escape($name); ?> <?php if($sandbox): ?>Sandbox<?php endif; ?> OAuth2 Settings</h1>
<h1><?php echo $this->escape($name); ?> <?php if ($sandbox): ?>Sandbox<?php endif;?> OAuth2 Settings</h1>
<form
autocomplete="off"
@ -451,16 +453,16 @@ $auth = $this->getParam('auth', []);
data-failure="alert"
data-failure-param-alert-text="Failed to update project OAuth2 settings"
data-failure-param-alert-classname="error">
<input style="display: none" type="text" /> <?php /** Disabling Chrone Autofill @see https://stackoverflow.com/a/15917221/2299554 */ ?>
<input style="display: none" type="password" /> <?php /** Disabling Chrone Autofill @see https://stackoverflow.com/a/15917221/2299554 */ ?>
<input style="display: none" type="text" /> <?php /** Disabling Chrone Autofill @see https://stackoverflow.com/a/15917221/2299554 */?>
<input style="display: none" type="password" /> <?php /** Disabling Chrone Autofill @see https://stackoverflow.com/a/15917221/2299554 */?>
<input name="provider" id="provider<?php echo $this->escape(ucfirst($provider)); ?>" type="hidden" autocomplete="off" value="<?php echo $this->escape($provider); ?>">
<?php if(!$form): ?>
<?php if (!$form): ?>
<label for="oauth2<?php echo $this->escape(ucfirst($provider)); ?>Appid">App ID</label>
<input name="appId" id="oauth2<?php echo $this->escape(ucfirst($provider)); ?>Appid" type="text" autocomplete="off" data-ls-bind="{{console-project.usersOauth2<?php echo $this->escape(ucfirst($provider)); ?>Appid}}">
<label for="oauth2<?php echo $this->escape(ucfirst($provider)); ?>Secret">App Secret</label>
<input name="secret" data-forms-show-secret id="oauth2<?php echo $this->escape(ucfirst($provider)); ?>Secret" type="password" autocomplete="off" data-ls-bind="{{console-project.usersOauth2<?php echo $this->escape(ucfirst($provider)); ?>Secret}}">
<?php else: ?>
@ -468,7 +470,7 @@ $auth = $this->getParam('auth', []);
<input name="appId" id="oauth2<?php echo $this->escape(ucfirst($provider)); ?>Appid" type="text" autocomplete="off" data-ls-bind="{{console-project.usersOauth2<?php echo $this->escape(ucfirst($provider)); ?>Appid}}" placeholder="com.company.appname" />
<input name="secret" data-forms-oauth-apple id="oauth2<?php echo $this->escape(ucfirst($provider)); ?>Secret" type="hidden" autocomplete="off" data-ls-bind="{{console-project.usersOauth2<?php echo $this->escape(ucfirst($provider)); ?>Secret}}" />
<?php endif; ?>
<?php endif;?>
<div class="info row thin margin-bottom margin-top">
<div class="col span-1">
@ -501,9 +503,9 @@ $auth = $this->getParam('auth', []);
</span>
<img src="/images/users/<?php echo $this->escape(strtolower($provider)); ?>.png?buster=<?php echo APP_CACHE_BUSTER; ?>" alt="<?php echo $this->escape(ucfirst($provider)); ?> Logo" class="pull-start provider margin-end" />
<span class="text-size-small">
<?php echo $this->escape($name); ?> <?php if($sandbox): ?><span class="text-size-xs text-fade">sandbox</span><?php endif; ?> <?php if($beta): ?><span class="text-size-xs text-fade">beta</span><?php endif; ?>
<?php echo $this->escape($name); ?> <?php if ($sandbox): ?><span class="text-size-xs text-fade">sandbox</span><?php endif;?> <?php if ($beta): ?><span class="text-size-xs text-fade">beta</span><?php endif;?>
</span>
<p class="margin-bottom-no text-one-liner text-size-small">
@ -511,7 +513,7 @@ $auth = $this->getParam('auth', []);
</p>
</div>
</li>
<?php endforeach; ?>
<?php endforeach;?>
</ul>
</div>
</li>

View file

@ -17,8 +17,8 @@
</div>
<div data-ui-modal class="modal width-large box close" data-button-hide="on" data-open-event="open-json">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<h2>JSON View</h2>
<div class="margin-bottom">
@ -32,7 +32,7 @@
<ul class="phases clear" data-ui-phases data-selected="{{router.params.tab}}">
<li data-state="/console/users/teams/team?id={{router.params.id}}&project={{router.params.project}}">
<h2>Overview</h2>
<div class="row responsive margin-top-negative">
<div class="col span-8 margin-bottom-large">
<label>&nbsp;</label>
@ -146,20 +146,21 @@
<input name="teamId" id="team-teamId" type="hidden" data-ls-bind="{{team.$id}}">
<input name="url" type="hidden" data-ls-bind="{{env.ENDPOINT}}" />
<label for="membershipId">Membership ID</label>
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="teams.getMembership"
required
maxlength="36"
name="membershipId"
id="membershipId" />
<label for="email">Email</label>
<input name="email" id="email" type="email" autocomplete="email" required>
<label for="team-name">Name <small>(optional)</small></label>
<input name="name" id="team-name" type="text" autocomplete="name" maxlength="128" />
@ -242,7 +243,7 @@
</div>
</div>
</li>
</ul>
</div>
</div>

View file

@ -61,18 +61,18 @@ $events = array_keys($this->getParam('events', []));
<section data-forms-select-all>
<label data-ls-attrs="for=events-{{webhook.$id}}">Events</label>
<div class="row responsive thin">
<?php foreach ($events as $i => $event) : ?>
<?php foreach ($events as $i => $event): ?>
<div class="col span-6 text-one-liner margin-bottom text-height-large text-size-small" title="<?php echo $event; ?>">
<input type="checkbox" name="events" data-ls-bind="{{webhook.events}}" id="update-<?php echo $event; ?>" value="<?php echo $event; ?>" />
&nbsp;
<label class="inline" for="update-<?php echo $event; ?>"><?php echo $event; ?></label>
</div>
<?php if (($i + 1) % 2 === 0) : ?>
<?php if (($i + 1) % 2 === 0): ?>
</div>
<div class="row responsive thin">
<?php endif; ?>
<?php endforeach; ?>
<?php endif;?>
<?php endforeach;?>
</div>
</section>
@ -82,7 +82,7 @@ $events = array_keys($this->getParam('events', []));
<div class="margin-bottom toggle" data-ls-ui-open data-button-aria="Advanced Options">
<i class="icon-plus pull-end margin-top-tiny"></i>
<i class="icon-minus pull-end margin-top-tiny"></i>
<h2 class="margin-bottom">
Advanced Options
<small class="text-size-small">(optional)</small>
@ -90,7 +90,7 @@ $events = array_keys($this->getParam('events', []));
<label data-ls-attrs="for=security-{{task.$id}}" class="margin-bottom-small">
<div class="margin-bottom-small text-bold">SSL / TLS (Certificate verification)</div>
<input name="security" type="radio" required data-ls-attrs="id=secure-yes-{{webhook.$id}}" data-ls-bind="{{webhook.security}}" value="true" data-cast-to="boolean" /> &nbsp; <span>Enabled</span> &nbsp;
<input name="security" type="radio" required data-ls-attrs="id=secure-no-{{webhook.$id}}" data-ls-bind="{{webhook.security}}" value="false" data-cast-to="boolean" /> &nbsp; <span>Disabled</span> &nbsp;
</label>
@ -180,30 +180,31 @@ $events = array_keys($this->getParam('events', []));
<input
type="hidden"
data-custom-id
id-type="auto"
data-id-type="auto"
data-validator="projects.getWebhook"
required
maxlength="36"
id="webhookId"
name="webhookId" />
<label for="name">Name</label>
<input type="text" class="full-width" id="name" name="name" required autocomplete="off" maxlength="128" />
<section data-forms-select-all>
<label for="events">Events</label>
<div class="row responsive thin">
<?php foreach ($events as $i => $event) : ?>
<?php foreach ($events as $i => $event): ?>
<div class="col span-6 text-one-liner margin-bottom text-height-large text-size-small" title="<?php echo $event; ?>">
<input type="checkbox" name="events" id="add-<?php echo $event; ?>" value="<?php echo $event; ?>" />
&nbsp;
<label class="inline" for="add-<?php echo $event; ?>"><?php echo $event; ?></label>
</div>
<?php if (($i + 1) % 2 === 0) : ?>
<?php if (($i + 1) % 2 === 0): ?>
</div>
<div class="row responsive thin">
<?php endif; ?>
<?php endif;?>
<?php endforeach; ?>
<?php endforeach;?>
</div>
</section>
@ -213,7 +214,7 @@ $events = array_keys($this->getParam('events', []));
<div class="margin-bottom toggle" data-ls-ui-open data-button-aria="Advanced Options">
<i class="icon-plus pull-end margin-top-tiny"></i>
<i class="icon-minus pull-end margin-top-tiny"></i>
<h2 class="margin-bottom">
Advanced Options
<small class="text-size-small">(optional)</small>
@ -221,7 +222,7 @@ $events = array_keys($this->getParam('events', []));
<label data-ls-attrs="for=security-{{task.$id}}" class="margin-bottom-small">
<div class="margin-bottom-small text-bold">SSL / TLS (Certificate verification)</div>
<input name="security" type="radio" required data-ls-attrs="id=secure-yes" checked="checked" value="1" /> &nbsp; <span>Enabled</span> &nbsp;
<input name="security" type="radio" required data-ls-attrs="id=secure-no" value="0" /> &nbsp; <span>Disabled</span> &nbsp;
</label>

View file

@ -2336,10 +2336,10 @@ code.innerHTML=value;Prism.highlightElement(code);div.scrollTop=0;};element.addE
function syncA(){element.value=picker.value;update();}
function syncB(){picker.value=element.value;}
element.parentNode.insertBefore(preview,element);update();syncB();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-copy",controller:function(element,alerts,document,window){var button=window.document.createElement("i");button.type="button";button.className="icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);var copy=function(event){let disabled=element.disabled;element.disabled=false;element.focus();element.select();document.execCommand("Copy");if(document.selection){document.selection.empty();}else if(window.getSelection){window.getSelection().removeAllRanges();}
element.disabled=disabled;element.blur();alerts.add({text:"Copied to clipboard",class:""},3000);};button.addEventListener("click",copy);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-custom-id",controller:function(element,sdk,console){var prevData="";let idType=element.getAttribute('id-type');var div=window.document.createElement("div");div.className="input-copy";var button=window.document.createElement("i");button.type="button";button.style.cursor="pointer";var writer=document.createElement("input");writer.type="text";writer.className="";writer.setAttribute("maxlength",element.getAttribute("maxlength"));var placeholder=element.getAttribute("placeholder");if(placeholder){writer.setAttribute("placeholder",placeholder);}
element.disabled=disabled;element.blur();alerts.add({text:"Copied to clipboard",class:""},3000);};button.addEventListener("click",copy);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-custom-id",controller:function(element,sdk,console){var prevData="";let idType=element.dataset["id-type"];var div=window.document.createElement("div");div.className="input-copy";var button=window.document.createElement("i");button.type="button";button.style.cursor="pointer";var writer=document.createElement("input");writer.type="text";writer.className="";writer.setAttribute("maxlength",element.getAttribute("maxlength"));var placeholder=element.getAttribute("placeholder");if(placeholder){writer.setAttribute("placeholder",placeholder);}
var info=window.document.createElement("div");info.className="text-fade text-size-xs margin-top-negative-small margin-bottom";div.appendChild(writer);div.appendChild(button);element.parentNode.insertBefore(div,element);element.parentNode.insertBefore(info,div.nextSibling);var switchType=function(event){if(idType=="custom"){idType="auto";setIdType(idType);}else{idType="custom";setIdType(idType);}}
var validate=function async(event){const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{console.projects.get(value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}}
var setIdType=function(idType){if(idType=="custom"){info.innerHTML="(Allowed Characters A-Z, a-z, 0-9, and non-leading _)";element.setAttribute('id-type',idType);writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="(Automatically generated)";element.setAttribute('id-type',idType);prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';}
var validate=function(event){var service=element.dataset["validator"];service=service.split('.');const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{if(service[0]=='projects'){if(service[1]=='getPlatform'){var projectId=element.form.elements.namedItem("projectId").value;console[service[0]][service[1]](projectId,value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}else{console[service[0]][service[1]](value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}}else{sdk[service[0]][service[1]](value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}}}
var setIdType=function(idType){if(idType=="custom"){info.innerHTML="Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";element.setAttribute('data-id-type',idType);writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="Appwrite will generate a unique ID";element.setAttribute('data-id-type',idType);prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';}
button.className=idType=="custom"?"icon-cog copy":"icon-edit copy";}
var sync=function(event){if(element.value!=='unique()'){writer.value=element.value;}}
var syncE=function(event){element.value=writer.value;}

View file

@ -356,10 +356,10 @@ code.innerHTML=value;Prism.highlightElement(code);div.scrollTop=0;};element.addE
function syncA(){element.value=picker.value;update();}
function syncB(){picker.value=element.value;}
element.parentNode.insertBefore(preview,element);update();syncB();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-copy",controller:function(element,alerts,document,window){var button=window.document.createElement("i");button.type="button";button.className="icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);var copy=function(event){let disabled=element.disabled;element.disabled=false;element.focus();element.select();document.execCommand("Copy");if(document.selection){document.selection.empty();}else if(window.getSelection){window.getSelection().removeAllRanges();}
element.disabled=disabled;element.blur();alerts.add({text:"Copied to clipboard",class:""},3000);};button.addEventListener("click",copy);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-custom-id",controller:function(element,sdk,console){var prevData="";let idType=element.getAttribute('id-type');var div=window.document.createElement("div");div.className="input-copy";var button=window.document.createElement("i");button.type="button";button.style.cursor="pointer";var writer=document.createElement("input");writer.type="text";writer.className="";writer.setAttribute("maxlength",element.getAttribute("maxlength"));var placeholder=element.getAttribute("placeholder");if(placeholder){writer.setAttribute("placeholder",placeholder);}
element.disabled=disabled;element.blur();alerts.add({text:"Copied to clipboard",class:""},3000);};button.addEventListener("click",copy);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-custom-id",controller:function(element,sdk,console){var prevData="";let idType=element.dataset["id-type"];var div=window.document.createElement("div");div.className="input-copy";var button=window.document.createElement("i");button.type="button";button.style.cursor="pointer";var writer=document.createElement("input");writer.type="text";writer.className="";writer.setAttribute("maxlength",element.getAttribute("maxlength"));var placeholder=element.getAttribute("placeholder");if(placeholder){writer.setAttribute("placeholder",placeholder);}
var info=window.document.createElement("div");info.className="text-fade text-size-xs margin-top-negative-small margin-bottom";div.appendChild(writer);div.appendChild(button);element.parentNode.insertBefore(div,element);element.parentNode.insertBefore(info,div.nextSibling);var switchType=function(event){if(idType=="custom"){idType="auto";setIdType(idType);}else{idType="custom";setIdType(idType);}}
var validate=function async(event){const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{console.projects.get(value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}}
var setIdType=function(idType){if(idType=="custom"){info.innerHTML="(Allowed Characters A-Z, a-z, 0-9, and non-leading _)";element.setAttribute('id-type',idType);writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="(Automatically generated)";element.setAttribute('id-type',idType);prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';}
var validate=function(event){var service=element.dataset["validator"];service=service.split('.');const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{if(service[0]=='projects'){if(service[1]=='getPlatform'){var projectId=element.form.elements.namedItem("projectId").value;console[service[0]][service[1]](projectId,value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}else{console[service[0]][service[1]](value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}}else{sdk[service[0]][service[1]](value).then(function(res){if(res.$id==value){event.target.setCustomValidity("ID already exists");}else{event.target.setCustomValidity("");}},function(e){event.target.setCustomValidity("");});}}}
var setIdType=function(idType){if(idType=="custom"){info.innerHTML="Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";element.setAttribute('data-id-type',idType);writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="Appwrite will generate a unique ID";element.setAttribute('data-id-type',idType);prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';}
button.className=idType=="custom"?"icon-cog copy":"icon-edit copy";}
var sync=function(event){if(element.value!=='unique()'){writer.value=element.value;}}
var syncE=function(event){element.value=writer.value;}

View file

@ -6,23 +6,13 @@
window.ls.container.get("view").add({
selector: "data-custom-id",
controller: function (element, sdk, console) {
//sdk should be console sdk for this project
var prevData = "";
let idType = element.getAttribute('id-type');
let idType = element.dataset["id-type"];
var div = window.document.createElement("div");
div.className = "input-copy";
//verify the ID doesn't already exist using a Get endpoint
//on the right side of the help info show id exists or not
//validator in javascript
//extend HTML validators?
//if not possible disable create button if not valid id
//provide information about length
var button = window.document.createElement("i");
button.type = "button";
@ -55,35 +45,62 @@
}
}
var validate = function async(event) {
var validate = function (event) {
var service = element.dataset["validator"];
service = service.split('.');
const value = event.target.value;
if (value.length < 1) {
event.target.setCustomValidity("ID is required");
} else {
console.projects.get(value).then(function(res){
if (res.$id == value) {
event.target.setCustomValidity("ID already exists");
if (service[0] == 'projects') {
if (service[1] == 'getPlatform') {
var projectId = element.form.elements.namedItem("projectId").value;
console[service[0]][service[1]](projectId, value).then(function (res) {
if (res.$id == value) {
event.target.setCustomValidity("ID already exists");
} else {
event.target.setCustomValidity("");
}
}, function (e) {
event.target.setCustomValidity("");
});
} else {
event.target.setCustomValidity("");
console[service[0]][service[1]](value).then(function (res) {
if (res.$id == value) {
event.target.setCustomValidity("ID already exists");
} else {
event.target.setCustomValidity("");
}
}, function (e) {
event.target.setCustomValidity("");
});
}
}, function(e){
event.target.setCustomValidity("");
});
} else {
sdk[service[0]][service[1]](value).then(function (res) {
if (res.$id == value) {
event.target.setCustomValidity("ID already exists");
} else {
event.target.setCustomValidity("");
}
}, function (e) {
event.target.setCustomValidity("");
});
}
}
}
var setIdType = function (idType) {
if (idType == "custom") {
info.innerHTML = "(Allowed Characters A-Z, a-z, 0-9, and non-leading _)";
element.setAttribute('id-type', idType);
info.innerHTML = "Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";
element.setAttribute('data-id-type', idType);
writer.value = prevData;
writer.disabled = false;
element.value = prevData;
writer.focus();
writer.addEventListener('blur', validate);
} else {
info.innerHTML = "(Automatically generated)";
element.setAttribute('id-type', idType);
info.innerHTML = "Appwrite will generate a unique ID";
element.setAttribute('data-id-type', idType);
prevData = writer.value;
writer.disabled = true;
writer.value = 'auto-generated';