2019-08-05 16:47:52 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Utopia\Locale\Locale;
|
|
|
|
|
|
|
|
$scopes = [ // TODO sync with project list
|
|
|
|
'users.read',
|
|
|
|
'users.write',
|
|
|
|
'teams.read',
|
|
|
|
'teams.write',
|
|
|
|
'collections.read',
|
|
|
|
'collections.write',
|
|
|
|
'documents.read',
|
|
|
|
'documents.write',
|
|
|
|
'files.read',
|
|
|
|
'files.write',
|
|
|
|
];
|
|
|
|
?>
|
2019-08-05 17:51:02 +12:00
|
|
|
<div class="cover margin-bottom-large">
|
|
|
|
<h1 class="zone xl margin-bottom-large margin-top">
|
|
|
|
<?php echo Locale::getText('console.keys.title'); ?>
|
|
|
|
</h1>
|
|
|
|
</div>
|
2019-08-08 06:10:53 +12:00
|
|
|
<div class="zone xl"
|
|
|
|
data-service="projects.listKeys"
|
|
|
|
data-scope="console"
|
|
|
|
data-event="load,key-create,key-update,key-delete"
|
|
|
|
data-name="console-keys"
|
|
|
|
data-param-project-id="{{router.params.project}}"
|
|
|
|
data-success="trigger"
|
|
|
|
data-success-param-trigger-events="key-load">
|
2019-08-05 16:47:52 +12:00
|
|
|
|
|
|
|
<div data-ls-if="0 == {{console-keys.length}} || undefined == {{console-keys.length}}" class="box margin-top margin-bottom" style="display: none;">
|
2019-08-05 17:51:02 +12:00
|
|
|
<h3 class="margin-bottom-small">No API Keys Found</h3>
|
2019-08-05 16:47:52 +12:00
|
|
|
|
|
|
|
<p class="margin-bottom-no">You haven't created any API keys for your project yet.</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box margin-bottom" data-ls-if="0 != {{console-keys.length}}" style="display: none;">
|
|
|
|
<ul data-ls-loop="console-keys" data-ls-as="key" class="list">
|
|
|
|
<li class="clear">
|
2019-08-09 18:05:45 +12:00
|
|
|
<div data-ui-modal class="modal box close" data-button-text="Update" data-button-class="pull-end">
|
2019-08-05 16:47:52 +12:00
|
|
|
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
|
|
|
|
|
|
|
<h1>Update API Key</h1>
|
|
|
|
|
2019-08-08 06:10:53 +12:00
|
|
|
<form
|
|
|
|
data-service="projects.updateKey"
|
|
|
|
data-scope="console"
|
|
|
|
data-event="submit"
|
2019-08-08 08:35:20 +12:00
|
|
|
data-success="alert,trigger"
|
2019-08-08 06:10:53 +12:00
|
|
|
data-success-param-alert-text="Updated API key successfully"
|
|
|
|
data-success-triggers="key-update,modal-close"
|
2019-08-08 17:09:49 +12:00
|
|
|
data-failure="alert"
|
2019-08-09 01:43:24 +12:00
|
|
|
data-failure-param-alert-text="Failed to update API key"
|
|
|
|
data-failure-param-alert-classname="error">
|
2019-08-05 16:47:52 +12:00
|
|
|
|
|
|
|
<input type="hidden" name="projectId" data-ls-bind="{{console-project.$uid}}">
|
|
|
|
<input type="hidden" name="keyId" data-ls-bind="{{key.$uid}}">
|
|
|
|
|
|
|
|
<label data-ls-attrs="for=name-{{key.$uid}}">Name</label>
|
|
|
|
<input type="text" class="full-width" data-ls-attrs="id=name-{{key.$uid}}" name="name" required autocomplete="off" data-ls-bind="{{key.name}}" />
|
|
|
|
|
|
|
|
<label data-ls-attrs="for=scopes-{{key.$uid}}">Scopes (<a href="/docs/keys" target="_blank">Learn More</a>)</label>
|
|
|
|
<div class="row thin margin-bottom">
|
|
|
|
<?php foreach ($scopes as $i => $scope) : ?>
|
|
|
|
<div class="col span-6">
|
2019-08-06 16:19:16 +12:00
|
|
|
<input type="checkbox" name="scopes" data-ls-bind="{{key.scopes}}" value="<?php echo $scope; ?>" /> <?php echo $scope; ?>
|
2019-08-05 16:47:52 +12:00
|
|
|
</div>
|
|
|
|
<?php if (($i + 1) % 2 === 0) : ?>
|
|
|
|
</div>
|
|
|
|
<div class="row thin margin-bottom">
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
|
|
|
2019-08-06 16:19:16 +12:00
|
|
|
<hr />
|
|
|
|
|
|
|
|
<button type="submit">Save</button> <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
2019-08-05 16:47:52 +12:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
2019-08-08 06:10:53 +12:00
|
|
|
<form class="pull-end margin-end"
|
|
|
|
data-service="projects.deleteKey"
|
|
|
|
data-scope="console"
|
|
|
|
data-event="submit"
|
|
|
|
data-confirm="Are you sure you want to delete this API key?"
|
|
|
|
data-success="alert,trigger"
|
|
|
|
data-success-param-alert-text="Deleted API key successfully"
|
|
|
|
data-success-param-trigger-events="key-delete"
|
2019-08-08 17:09:49 +12:00
|
|
|
data-failure="alert"
|
2019-08-09 01:43:24 +12:00
|
|
|
data-failure-param-alert-text="Failed to delete API key"
|
|
|
|
data-failure-param-alert-classname="error">
|
2019-08-05 16:47:52 +12:00
|
|
|
|
|
|
|
<input type="hidden" name="projectId" data-ls-bind="{{console-project.$uid}}">
|
|
|
|
<input type="hidden" name="keyId" data-ls-bind="{{key.$uid}}">
|
|
|
|
|
|
|
|
<button class="reverse danger">Delete</button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div class="margin-bottom-tiny"><span data-ls-bind="{{key.name}}"></span> <span class="note">(<span data-ls-bind="{{key.scopes.length}}"></span> scopes granted)</span></div>
|
|
|
|
|
2019-08-06 16:19:16 +12:00
|
|
|
<div data-ui-modal class="modal close" data-button-text="Show Secret" data-button-class="link">
|
2019-08-05 16:47:52 +12:00
|
|
|
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
|
|
|
|
|
|
|
<h1>API Key Secret</h1>
|
|
|
|
|
|
|
|
<form>
|
|
|
|
<div class="input-copy">
|
|
|
|
<textarea disabled style="height: 130px; line-height: 26px" data-forms-copy data-ls-bind="{{key.secret}}"></textarea>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="clear">
|
2019-08-09 18:05:45 +12:00
|
|
|
<div data-ui-modal class="modal box close" data-button-text="Add API Key">
|
2019-08-05 16:47:52 +12:00
|
|
|
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
|
|
|
|
|
|
|
<h1>Add API Keys</h1>
|
|
|
|
|
2019-08-08 06:10:53 +12:00
|
|
|
<form
|
|
|
|
data-service="projects.createKey"
|
|
|
|
data-scope="console"
|
|
|
|
data-event="submit"
|
|
|
|
data-success="alert,trigger,reset"
|
|
|
|
data-success-param-alert-text="Created API key successfully"
|
|
|
|
data-success-param-trigger-events="key-create,modal-close"
|
2019-08-08 17:09:49 +12:00
|
|
|
data-failure="alert"
|
2019-08-09 01:43:24 +12:00
|
|
|
data-failure-param-alert-text="Failed to create API key"
|
|
|
|
data-failure-param-alert-classname="error">
|
2019-08-05 16:47:52 +12:00
|
|
|
|
|
|
|
<input type="hidden" name="projectId" data-ls-bind="{{console-project.$uid}}">
|
|
|
|
|
|
|
|
<label for="name">Name</label>
|
|
|
|
<input type="text" class="full-width" id="name" name="name" required autocomplete="off" />
|
|
|
|
|
|
|
|
<label for="scopes">Scopes (<a href="/docs/keys" target="_blank">Learn More</a>)</label>
|
|
|
|
<div class="row thin margin-bottom">
|
|
|
|
<?php foreach ($scopes as $i => $scope) : ?>
|
|
|
|
<div class="col span-6">
|
|
|
|
<input type="checkbox" name="scopes" value="<?php echo $scope; ?>" /> <?php echo $scope; ?>
|
|
|
|
</div>
|
|
|
|
<?php if (($i + 1) % 2 === 0) : ?>
|
|
|
|
</div>
|
|
|
|
<div class="row thin margin-bottom">
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
|
|
|
2019-08-06 16:19:16 +12:00
|
|
|
<hr />
|
2019-08-05 16:47:52 +12:00
|
|
|
|
2019-08-06 16:19:16 +12:00
|
|
|
<button type="submit">Create</button> <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
2019-08-05 16:47:52 +12:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|