period links fix

This commit is contained in:
shimon committed 2023-02-14 16:21:56 +02:00
commit 5f985d8a68
201 files changed
+3024 -1463

No files matched your search

+9 -1
View File
@@ -4,7 +4,15 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
overrides: [
{
files: ['*.svelte'],
processor: 'svelte3/svelte3',
rules: {
'no-redeclare': 'off'
}
}
],
settings: {
'svelte3/typescript': () => require('typescript')
},
+1 -1
View File
@@ -19,7 +19,7 @@ jobs:
with:
node-version: 16
- name: Audit dependencies
run: npm audit --audit-level high
run: npm audit --audit-level low
- name: Install dependencies
run: npm ci
- name: Build Console
+28 -28
View File
@@ -1,10 +1,10 @@
# Contributing
We would ❤️ for you to contribute to Appwrite and help make it better! We want contributing to Appwrite to be fun, enjoyable, and educational for anyone and everyone. All contributions are welcome, including issues, new docs as well as updates and tweaks, blog posts, workshops, and more.
We would ❤️ for you to contribute to Appwrite and help make it better! We want your experience while contributing to Appwrite to be fun, enjoyable, and educational for anyone and everyone. All contributions are welcome, including issues, and new docs, as well as updates and tweaks, blog posts, workshops, and more.
## How to Start?
If you are worried or don’t know where to start, check out our next section explaining what kind of help is needed and where you can get involved. You can reach out with questions on our [Discord](https://appwrite.io/discord) server. You can also submit an issue and a maintainer can guide you!
If you are worried about or don’t know where to start, check out the next section that explains what kind of help is needed and how you can get involved. You can reach out with any questions on our [Discord](https://appwrite.io/discord) server. You can also submit an issue and a maintainer can guide you!
## Repo Structure
@@ -62,7 +62,7 @@ This will run tests in the `tests/` directory.
### Format
Code should like everywhere the same, for this reason a code-formatter is mandatory.
Code should be consistently formatted everywhere. Before committing code, run the code-formatter.
```bash
npm run format
@@ -76,7 +76,7 @@ npm run lint
### Diagnostics
Diagnostic tool that checks for following:
Diagnostic tool that checks for the following:
- Unused CSS
- Svelte A11y hints
@@ -88,7 +88,7 @@ npm run check
## Submit a Pull Request 🚀
Branch naming convention is as follows
The branch naming convention is as follows
`TYPE-ISSUE_ID-DESCRIPTION`
@@ -106,11 +106,11 @@ When `TYPE` can be:
- **fix** - a bug fix
- **refactor** - code change that neither fixes a bug nor adds a feature
**All PRs must include a commit message with the description of the changes made!**
**All PRs must include a commit message with a description of the changes made!**
Start by forking the project and use the `git clone` command to download the repository to your computer. A standard procedure for working on an issue would be to:
1. Before creating a new branch, pull the changes from upstream to make sure your default branch is be up to date.
1. Before creating a new branch, pull the changes from upstream to make sure your default branch is up to date.
```
$ git pull
@@ -143,7 +143,7 @@ $ git push origin [name_of_your_new_branch]
### Consistency
Before commiting always make sure to run all available tools to improve the codebase:
Before committing always make sure to run all available tools to improve the codebase:
- Formatter
- `npm run format`
@@ -158,21 +158,21 @@ Page load times are a key consideration for users of all browsers and device typ
There are some general things we can do in front-end development:
- Minimise HTTP requests
- Minimise blocking – content should be readable before client side processing
- Lazy load 'supplementary' content (especially images)
- Minimize HTTP requests
- Minimize blocking – content should be readable before client-side processing
- Lazy load "supplementary" content, especially images
### Don't Repeat Yourself (DRY)
If you repeat anything that has already been defined in code, refactor it so that it only ever has one representation in the codebase.
If you stick to this principle, you will ensure that you will only ever need to change one implementation of a feature without worrying about needing to change any other part of the code.
If you stick to this principle, you will ensure that you will only ever need to change one implementation of a feature without worrying about the need to change any other part of the code.
### Separation of concerns
Separate _structure_ from _presentation_ from _behaviour_ to aid maintainability and understanding.
Separate _structure_ from _presentation_ from _behavior_ to aid maintainability and understanding.
- Keep CSS (presentation), JS (behaviour) and HTML (structure) in the same respective Svelte component
- Keep CSS (presentation), JS (behavior) and HTML (structure) in the same respective Svelte component
- Avoid writing inline CSS or Javascript in HTML
- Avoid writing CSS or HTML in Javascript
- Don't choose HTML elements to imply style
@@ -181,29 +181,29 @@ Separate _structure_ from _presentation_ from _behaviour_ to aid maintainability
### Write code to be read
Follow the principles of ['Keep It Simple, Stupid'](http://en.wikipedia.org/wiki/KISS_principle) (KISS); hard to read or obfuscated code is difficult to maintain and debug. Don't be too clever; write code to be read.
Follow the principles of ['Keep It Simple, Stupid'](http://en.wikipedia.org/wiki/KISS_principle) (KISS); hard-to-read or obfuscated code is difficult to maintain and debug. Don't be too clever; write code to be read.
### Identify technical debt
Use code comment annotations (`@todo`) to mark parts of your code that require further work. This will allow the measurement and management of technical debt.
Don't use `@fixme` (which defines things that are broken) - you shouldn't be committing broken code to the repo.
Don't use `@fixme`, which defines things that are broken. Don't commit broken code in to the repo.
### Dependencies
Please avoid introducing new dependencies to Appwrite without consulting the team. New dependencies can be very helpful but also introduce new security and privacy issues, complexity, and impact total docker image size.
Please avoid introducing new dependencies to Appwrite without consulting the team. New dependencies can be very helpful, but they also introduce new security and privacy issues, complexity, and impact total docker image size.
Adding a new dependency should have vital value on the product with minimum possible risk.
Adding a new dependency should contribute vital value to the product with minimum possible risk.
## Introducing New Features
We would 💖 you to contribute to Appwrite, but we would also like to make sure Appwrite is as great as possible and loyal to its vision and mission statement 🙏.
We would 💖 you to contribute to Appwrite, but we also want to ensure Appwrite is loyal to its vision and mission statement 🙏.
For us to find the right balance, please open an issue explaining your ideas before introducing a new pull request.
This will allow the Appwrite community to have sufficient discussion about the new feature value and how it fits in the product roadmap and vision.
This will allow the Appwrite community to sufficiently discuss the new feature value and how it fits within the product roadmap and vision.
This is also important for Appwrite maintainers to discuss the feature's design and architecture to help the contribution fit in organically in the Appwrite codebase. Some bigger features might need to go through our [RFC process](https://github.com/appwrite/rfc).
This is also important for the Appwrite lead developers to be able to provide technical input and potentially a different emphasis regarding the feature design and architecture. Some bigger features might need to go through our [RFC process](https://github.com/appwrite/rfc).
## Other Ways to Help
@@ -211,27 +211,27 @@ Pull requests are great, but there are many other areas where you can help Appwr
### Blogging & Speaking
Blogging, speaking about, or creating tutorials about one of Appwrite’s many features. Mention [@appwrite](https://twitter.com/appwrite) on Twitter and/or email [team@appwrite.io](mailto:team@appwrite.io) so we can give pointers and tips and help you spread the word by promoting your content on the different Appwrite communication channels. Please add your blog posts and videos of talks to our [Awesome Appwrite](https://github.com/appwrite/awesome-appwrite) repo on GitHub.
When blogging, speaking about, or creating tutorials about one of Appwrite's many features, mention [@appwrite](https://twitter.com/appwrite) on Twitter and/or email [team@appwrite.io](mailto:team@appwrite.io) so we can give pointers and tips and help you spread the word by promoting your content on the different Appwrite communication channels. Please add your blog posts and videos of talks to our [Awesome Appwrite](https://github.com/appwrite/awesome-appwrite) repo on GitHub.
### Presenting at Meetups
Presenting at meetups and conferences about your Appwrite projects. Your unique challenges and successes in building things with Appwrite can provide great speaking material. We’d love to review your talk abstract/CFP, so get in touch with us if you’d like some help!
Presenting at meetups and conferences about your Appwrite projects is another excellent way to get the word out about Appwrite. Your unique challenges and successes in building things with Appwrite can provide great speaking material. We’d love to review your talk abstract/CFP, so get in touch with us if you’d like some help!
### Sending Feedbacks & Reporting Bugs
### Sending Feedback & Reporting Bugs
Sending feedback is a great way for us to understand your different use cases of Appwrite better. If you had any issues, bugs, or want to share about your experience, feel free to do so on our GitHub issues page or at our [Discord channel](https://discord.gg/GSeTUeA).
Sending feedback is an excellent way for us to understand different use cases for Appwrite. If you have any issues or want to share your experience, feel free to do so on our GitHub issues page or our [Discord channel](https://discord.gg/GSeTUeA).
### Submitting New Ideas
If you think Appwrite could use a new feature, please open an issue on our GitHub repository, stating as much information as you can think about your new idea and it's implications. We would also use this issue to gather more information, get more feedback from the community, and have a proper discussion about the new feature.
If you think Appwrite could use a new feature, please open an issue on our GitHub repository, stating as much information as you can think about your new idea and its implications. We would also use this issue to gather more information, get more feedback from the community, and have a proper discussion about the new feature.
### Improving Documentation
Submitting documentation updates, enhancements, designs, or bug fixes. Spelling or grammar fixes will be very much appreciated.
Submitting documentation updates, enhancements, designs, or bug fixes help us to improve our documentation. Spelling or grammar fixes are also very much appreciated.
### Helping Someone
Searching for Appwrite on Discord, GitHub, or StackOverflow and helping someone else who needs help. You can also help by teaching others how to contribute to Appwrite's repo!
You can also help by teaching others how to contribute to Appwrite's repo! Please consider searching for Appwrite on Discord, GitHub, or StackOverflow and helping someone else who needs help.
## Code of Conduct
+2 -2
View File
@@ -35,7 +35,7 @@ The new console is more maintainable and welcoming to community contributions. C
## Contributing
All code contributions - including those of people having commit access - must go through a pull request and be approved by a core developer before being merged. This is to ensure a proper review of all the code.
All code contributions, including those of people with commit access, must go through a pull request and be approved by a core developer before being merged. This is to ensure a proper review of all the code.
We truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the [contribution guide](CONTRIBUTING.md).
@@ -45,7 +45,7 @@ For security issues, kindly email us at [security@appwrite.io](mailto:security@a
## Follow Us
Join our growing community around the world! See our official [Blog](https://medium.com/appwrite-io). Follow us on [Twitter](https://twitter.com/appwrite), [Facebook Page](https://www.facebook.com/appwrite.io), [Facebook Group](https://www.facebook.com/groups/appwrite.developers/), [Dev Community](https://dev.to/appwrite) or join our live [Discord server](https://appwrite.io/discord) for more help, ideas, and discussions.
Join our growing community around the world! See our official [Blog](https://medium.com/appwrite-io). Follow us on [Twitter](https://twitter.com/appwrite), [Facebook Page](https://www.facebook.com/appwrite.io), [Facebook Group](https://www.facebook.com/groups/appwrite.developers/), and [Dev Community](https://dev.to/appwrite) or join our live [Discord server](https://appwrite.io/discord) for more help, ideas, and discussions.
## License
+147 -7
View File
@@ -4,7 +4,10 @@ import { get } from 'svelte/store';
import { page } from '$app/stores';
import { user } from '$lib/stores/user';
import { growthEndpoint, Mode } from '$lib/constants';
import { AppwriteException } from '@aw-labs/appwrite-console';
const isDevelopment =
import.meta.env.DEV || import.meta.env?.VITE_VERCEL_ENV?.toString() === 'preview';
const analytics = Analytics({
app: 'appwrite',
plugins: [
@@ -18,9 +21,32 @@ export function trackEvent(name: string, data: object = null): void {
if (!isTrackingAllowed()) {
return;
}
const path = get(page).route.id;
analytics.track(name, { ...data, path });
sendEventToGrowth(name, path, data);
const currentPage = get(page);
const path = currentPage.route.id;
if (currentPage.params?.project) {
data = {
...data,
project: currentPage.params.project
};
}
if (isDevelopment) {
console.debug(`[Analytics] Event ${name} ${path}`, data);
} else {
analytics.track(name, { ...data, path });
sendEventToGrowth(name, path, data);
}
}
export function trackError(exception: Error, event: Submit): void {
if (exception instanceof AppwriteException && exception.type) {
trackEvent(Submit.Error, {
type: exception.type,
form: event
});
}
}
export function trackPageView(path: string) {
@@ -28,14 +54,19 @@ export function trackPageView(path: string) {
return;
}
analytics.page({
path
});
if (isDevelopment) {
console.debug(`[Analytics] Pageview ${path}`);
} else {
analytics.page({
path
});
}
}
function sendEventToGrowth(event: string, path: string, data: object = null): void {
let email: string, name: string;
if (!growthEndpoint) return;
const userStore = get(user);
let email: string, name: string;
if (userStore) {
email = userStore.email;
name = userStore.name;
@@ -60,6 +91,9 @@ function sendEventToGrowth(event: string, path: string, data: object = null): vo
}
function isTrackingAllowed() {
if (import.meta.env?.VITEST) {
return;
}
if (window.navigator?.doNotTrack) {
if (navigator.doNotTrack === '1' || navigator.doNotTrack === 'yes') {
return false;
@@ -70,3 +104,109 @@ function isTrackingAllowed() {
return true;
}
}
export enum Submit {
Error = 'submit_error',
AccountCreate = 'submit_account_create',
AccountLogin = 'submit_account_login',
AccountLogout = 'submit_account_logout',
AccountRecover = 'submit_account_recover',
AccountUpdateName = 'submit_account_update_name',
AccountUpdateEmail = 'submit_account_update_email',
AccountUpdatePassword = 'submit_account_update_password',
AccountDelete = 'submit_account_delete',
AccountDeleteSession = 'submit_account_delete_session',
AccountDeleteAllSessions = 'submit_account_delete_all_sessions',
UserCreate = 'submit_user_create',
UserDelete = 'submit_user_delete',
UserUpdateEmail = 'submit_user_update_email',
UserUpdateName = 'submit_user_update_name',
UserUpdatePassword = 'submit_user_update_password',
UserUpdatePhone = 'submit_user_update_phone',
UserUpdatePreferences = 'submit_user_update_preferences',
UserUpdateStatus = 'submit_user_update_status',
UserUpdateVerificationEmail = 'submit_user_update_verification_email',
UserUpdateVerificationPhone = 'submit_user_update_verification_phone',
OrganizationCreate = 'submit_organization_create',
OrganizationDelete = 'submit_organization_delete',
OrganizationUpdateName = 'submit_organization_update_name',
ProjectCreate = 'submit_project_create',
ProjectDelete = 'submit_project_delete',
ProjectUpdateName = 'submit_project_update_name',
ProjectService = 'submit_project_service',
MemberCreate = 'submit_member_create',
MemberDelete = 'submit_member_delete',
MembershipUpdateStatus = 'submit_membership_update_status',
ProviderUpdate = 'submit_provider_update',
TeamCreate = 'submit_team_create',
TeamDelete = 'submit_team_delete',
TeamUpdateName = 'submit_team_update_name',
AuthLimitUpdate = 'submit_auth_limit_update',
AuthStatusUpdate = 'submit_auth_status_update',
SessionsLengthUpdate = 'submit_sessions_length_update',
SessionsLimitUpdate = 'submit_sessions_limit_update',
SessionDelete = 'submit_session_delete',
SessionDeleteAll = 'submit_session_delete_all',
DatabaseCreate = 'submit_database_create',
DatabaseDelete = 'submit_database_delete',
DatabaseUpdateName = 'submit_database_update_name',
AttributeCreate = 'submit_attribute_create',
AttributeDelete = 'submit_attribute_delete',
DocumentCreate = 'submit_document_create',
DocumentDelete = 'submit_document_delete',
DocumentUpdate = 'submit_document_update',
DocumentUpdatePermissions = 'submit_document_update_permissions',
IndexCreate = 'submit_index_create',
IndexDelete = 'submit_index_delete',
CollectionCreate = 'submit_collection_create',
CollectionDelete = 'submit_collection_delete',
CollectionUpdateName = 'submit_collection_update_name',
CollectionUpdatePermissions = 'submit_collection_update_permissions',
CollectionUpdateSecurity = 'submit_collection_update_security',
CollectionUpdateEnabled = 'submit_collection_update_enabled',
FunctionCreate = 'submit_function_create',
FunctionDelete = 'submit_function_delete',
FunctionUpdateName = 'submit_function_update_name',
FunctionUpdatePermissions = 'submit_function_update_permissions',
FunctionUpdateSchedule = 'submit_function_update_schedule',
FunctionUpdateTimeout = 'submit_function_update_timeout',
FunctionUpdateEvents = 'submit_function_update_events',
DeploymentCreate = 'submit_deployment_create',
DeploymentDelete = 'submit_deployment_delete',
DeploymentUpdate = 'submit_deployment_update',
ExecutionCreate = 'submit_execution_create',
VariableCreate = 'submit_variable_create',
VariableDelete = 'submit_variable_delete',
VariableUpdate = 'submit_variable_update',
KeyCreate = 'submit_key_create',
KeyDelete = 'submit_key_delete',
KeyUpdateName = 'submit_key_update_name',
KeyUpdateScopes = 'submit_key_update_scopes',
KeyUpdateExpire = 'submit_key_update_expire',
PlatformCreate = 'submit_platform_create',
PlatformDelete = 'submit_platform_delete',
PlatformUpdate = 'submit_platform_update',
DomainCreate = 'submit_domain_create',
DomainDelete = 'submit_domain_delete',
DomainUpdateVerification = 'submit_domain_update_verification',
WebhookCreate = 'submit_webhook_create',
WebhookDelete = 'submit_webhook_delete',
WebhookUpdateSignature = 'submit_webhook_update_signature',
WebhookUpdateUrl = 'submit_webhook_update_url',
WebhookUpdateEvents = 'submit_webhook_update_events',
WebhookUpdateName = 'submit_webhook_update_name',
WebhookUpdateSecurity = 'submit_webhook_update_security',
BucketCreate = 'submit_bucket_create',
BucketDelete = 'submit_bucket_delete',
BucketUpdateEnabled = 'submit_bucket_update_enabled',
BucketUpdateName = 'submit_bucket_update_name',
BucketUpdatePermissions = 'submit_bucket_update_permissions',
BucketUpdateSecurity = 'submit_bucket_update_security',
BucketUpdateFileSecurity = 'submit_bucket_update_file_security',
BucketUpdateSize = 'submit_bucket_update_size',
BucketUpdateCompression = 'submit_bucket_update_compression',
BucketUpdateExtensions = 'submit_bucket_update_extensions',
FileCreate = 'submit_file_create',
FileDelete = 'submit_file_delete',
FileUpdatePermissions = 'submit_file_update_permissions'
}
+28
View File
@@ -0,0 +1,28 @@
import type { Action } from 'svelte/action';
type Props = {
onChange: (selectionStart: number) => void;
};
export const selectionStart: Action<HTMLInputElement, Props> = (node, { onChange }) => {
const handler = () => {
onChange(node.selectionStart);
};
node.addEventListener('click', handler);
node.addEventListener('keydown', handler);
node.addEventListener('keyup', handler);
return {
update({ onChange }) {
const handler = () => {
onChange(node.selectionStart);
};
node.addEventListener('click', handler);
node.addEventListener('keydown', handler);
node.addEventListener('keyup', handler);
},
destroy() {
onChange(-1);
}
};
};
+40
View File
@@ -0,0 +1,40 @@
import { calculateTime } from '$lib/helpers/timeConversion';
import type { Action } from 'svelte/action';
type Props = {
start?: string;
enabled?: boolean;
};
const defaultProps: Props = {
enabled: true
};
export const timer: Action<HTMLElement, Props> = (node, props) => {
let startDate: Date;
let frame: number;
function init(props: Props) {
const { start, enabled } = { ...defaultProps, ...props };
startDate = start ? new Date(start) : new Date();
frame = enabled ? window.requestAnimationFrame(step) : null;
}
function step() {
const diffInSeconds = Math.floor((new Date().getTime() - startDate.getTime()) / 1000);
node.textContent = calculateTime(diffInSeconds);
frame = window.requestAnimationFrame(step);
}
init(props);
return {
update(props) {
window.cancelAnimationFrame(frame);
init(props);
},
destroy() {
window.cancelAnimationFrame(frame);
}
};
};
+9 -2
View File
@@ -1,17 +1,24 @@
import type { Action } from 'svelte/action';
import type { Props } from 'tippy.js';
import type { Props as TippyProps } from 'tippy.js';
import tippy from 'tippy.js';
type Props = TippyProps & {
disabled?: boolean;
};
export const tooltip: Action<HTMLElement, Partial<Props>> = (node, config) => {
const instance = tippy(node, config);
if (config.disabled) instance.disable();
return {
update({ content }) {
update({ content, disabled }) {
if (content !== instance.props.content) {
instance.setProps({
content
});
}
disabled ? instance.disable() : instance.enable();
},
destroy() {
instance.destroy();
+6 -1
View File
@@ -9,6 +9,7 @@
import type { ECharts } from 'echarts/core';
import type { BarSeriesOption, LineSeriesOption } from 'echarts/charts';
import type { EChartsOption } from 'echarts';
import { wizard } from '$lib/stores/wizard';
registerTheme('light', { ...base, ...light });
registerTheme('dark', { ...base, ...dark });
@@ -70,7 +71,7 @@
let timeoutId: unknown;
const onResize = () => {
if (timeoutId == undefined) {
if (timeoutId == undefined && !$wizard.show) {
timeoutId = setTimeout(() => {
if (chart && !chart.isDisposed()) {
chart.resize();
@@ -79,6 +80,10 @@
}, 250);
}
};
$: if (!$wizard.show) {
onResize();
}
</script>
<svelte:window on:resize={onResize} />
+5
View File
@@ -119,6 +119,11 @@
"crossStyle": {
"color": "#444444"
}
},
"backgroundColor": "#373B4D",
"borderColor": "#373B4D",
"textStyle": {
"color": "#F2F2F8"
}
},
"timeline": {
+5 -2
View File
@@ -7,6 +7,8 @@
export let value: string;
export let event: string = null;
export let eventContext = 'click_id_tag';
export let appendTo: Parameters<typeof tooltip>['1']['appendTo'] = undefined;
let content = 'Click to copy';
@@ -23,7 +25,7 @@
}
if (event) {
trackEvent('click_id_tag', {
trackEvent(eventContext, {
name: event
});
}
@@ -36,7 +38,8 @@
on:mouseenter={() => setTimeout(() => (content = 'Click to copy'))}
use:tooltip={{
content,
hideOnClick: false
hideOnClick: false,
appendTo
}}>
<slot />
</span>
+2 -17
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { InnerModal } from '$lib/components';
import { InputText } from '$lib/elements/forms';
import { InputId } from '$lib/elements/forms';
export let show = false;
export let name: string;
@@ -27,22 +27,7 @@
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading underscore, period
</span>
</div>
<InputId bind:value={id} />
</div>
</svelte:fragment>
</InnerModal>
-3
View File
@@ -1,3 +0,0 @@
<ul class="drop-tabs">
<slot />
</ul>
-9
View File
@@ -1,9 +0,0 @@
<script lang="ts">
export let disabled = false;
</script>
<li class="drop-tabs-item">
<button class="drop-tabs-button" {disabled} on:click>
<span class="text"><slot /></span>
</button>
</li>
-16
View File
@@ -1,16 +0,0 @@
<script lang="ts">
export let href: string;
export let disabled = false;
</script>
<li class="drop-tabs-item">
{#if disabled}
<button class="drop-tabs-button" disabled>
<span class="text"><slot /></span>
</button>
{:else}
<a class="drop-tabs-button" {href}>
<span class="text"><slot /></span>
</a>
{/if}
</li>
+302 -248
View File
@@ -1,323 +1,376 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { Modal, Copy } from '$lib/components';
import { Modal } from '$lib/components';
import { Pill } from '$lib/elements';
import { createEventDispatcher } from 'svelte';
import { at, empty } from '$lib/helpers/array';
import Copy from './copy.svelte';
import { selectionStart } from '$lib/actions/selectionStart';
import { singular } from '$lib/helpers/string';
import {
eventServices as services,
type EventAction,
type EventResource,
type EventService
} from '$lib/constants';
import { tooltip } from '$lib/actions/tooltip';
import { trackEvent } from '$lib/actions/analytics';
// Props
export let show = false;
export let initialValue = '';
type Service = {
name: string;
resources: Resource[];
actions?: Action[];
};
// Constants
const serviceNames = services.map((s) => s.name);
const resourceNames = services.flatMap((s) => s.resources.map((r) => r.name));
const actionNames = [
...services.flatMap((s) => s.actions.map((a) => a.name)),
...services.flatMap((s) => s.resources.flatMap((r) => r.actions.map((a) => a.name)))
];
const attributeNames = [
...services.flatMap((s) => s.actions.flatMap((a) => a.attributes ?? [])),
...services.flatMap((s) =>
s.resources.flatMap((r) => r.actions.flatMap((a) => a.attributes ?? []))
)
];
type Resource = {
name: string;
actions?: Action[];
attributes?: string[];
};
type Action = {
name: string;
attributes?: string[];
};
let selectedService: Service = null;
let selectedResource: Resource = null;
let selectedAction: Action = null;
let selectedAttribute: string = null;
let helper: string = null;
let inputData: string = null;
let showInput = false;
// Helpers
const isService = (s: string) => serviceNames.includes(s);
const isResource = (s: string) => resourceNames.includes(s);
const isAction = (s: string) => actionNames.includes(s);
const isAttribute = (s: string) => attributeNames.includes(s);
const dispatch = createEventDispatcher();
function create() {
show = false;
dispatch('created', copyValue);
trackEvent('events_add', {
value: inputValue
});
dispatch('created', inputValue);
}
const actions = [{ name: 'create' }, { name: 'update' }, { name: 'delete' }];
const services = [
{
name: 'buckets',
resources: [{ name: 'files', actions }],
actions
},
{
name: 'databases',
resources: [
{ name: 'collections', actions },
{ name: 'documents', actions }
],
actions
},
{
name: 'functions',
resources: [
{ name: 'deployments', actions },
{ name: 'executions', actions }
],
actions
},
{
name: 'teams',
resources: [{ name: 'memberships', actions }],
actions: [
{ name: 'create' },
{ name: 'update', attributes: ['status'] },
{ name: 'delete' }
]
},
{
name: 'users',
resources: [
{ name: 'recovery', actions: [{ name: 'create' }, { name: 'delete' }] },
{ name: 'sessions', actions: [{ name: 'create' }, { name: 'delete' }] },
{ name: 'verifications', actions: [{ name: 'create' }, { name: 'delete' }] }
],
actions: [
{ name: 'create' },
{ name: 'update', attributes: ['email', 'name', 'password', 'status', 'prefs'] },
{ name: 'delete' }
]
}
];
function createEventString(
service: Service,
resource: Resource,
action: Action,
attribute: string
) {
const data = new Map();
if (service) {
data.set('service', { value: service.name, description: 'service' });
data.set('serviceId', {
value: '*',
description: `ID of ${service?.name.slice(0, -1)}`
});
function select(field: 'service', value: EventService): void;
function select(field: 'resource', value: EventResource): void;
function select(field: 'action', value: EventAction): void;
function select(field: 'attribute', value: string): void;
function select(
field: string,
value: string | EventService | EventResource | EventAction
): void {
if (typeof value === 'string') {
selected[field as 'attribute'] = selected[field] === value ? null : value;
} else {
selected[field] = selected[field]?.name === value.name ? null : value;
}
if (resource) {
if (resource.name === 'documents') {
data.set('resource', {
value: 'collections',
description: 'resource'
});
data.set('resourceId', {
value: '*',
description: `ID of collection`
});
data.set('secondaryResource', {
value: 'documents',
description: 'secondary resource'
});
data.set('secondaryResourceId', {
value: '*',
description: `ID of document`
});
} else {
data.set('resource', {
value: resource.name,
description: `resource`
});
data.set('resourceId', {
value: '*',
description: `ID of ${resource?.name.slice(0, -1)}`
});
customInput = null;
switch (field) {
case 'service': {
selected.resource = null;
selected.action = null;
selected.attribute = null;
break;
}
case 'resource': {
const availableActions = selected.resource
? selected.resource?.actions
: selected.service?.actions;
// We need to check if the selected action name is still
// on the available list, and if so, change tje action to the
// appropriate one, as it may contain different attributes
const availableAction = availableActions.find(
(a) => a.name === selected.action?.name
);
if (!availableAction) {
selected.action = null;
selected.attribute = null;
} else {
selected.action = availableAction;
if (!selected?.action?.attributes?.includes(selected.attribute)) {
selected.attribute = null;
}
}
break;
}
case 'action': {
selected.attribute = null;
break;
}
}
}
function resetSelected() {
Object.keys(selected).forEach((key) => (selected[key] = null));
}
function inferSelectedFromCustomInput() {
resetSelected();
for (const field of customInput.split('.')) {
if (isService(field)) {
selected.service = services.find((s) => s.name === field);
} else if (isResource(field)) {
const resource = selected.service?.resources.find((r) => r.name === field);
selected.resource = resource;
} else if (isAction(field)) {
const action =
selected.resource?.actions.find((a) => a.name === field) ||
selected.service?.actions.find((a) => a.name === field);
selected.action = action;
} else if (isAttribute(field)) {
const attribute = selected.action?.attributes?.find((a) => a === field);
selected.attribute = attribute;
}
}
}
function toggleShowInput(e: Event) {
e.preventDefault();
showInput = !showInput;
if (showInput) return;
helper = null;
inferSelectedFromCustomInput();
}
function getHelperStr(fields: string[], index: number) {
const currField = at(fields, index);
const prevField = at(fields, index - 1);
const secondToLastField = at(fields, index - 2);
if (index === 0 || isService(currField)) return 'service';
if (isAttribute(currField) || isAction(prevField)) return 'attribute';
if (isAction(currField)) return 'action';
if (isResource(currField)) return 'resource';
if (isService(prevField) || isResource(prevField) || index === 1) {
return `ID of ${singular(prevField)}`;
}
// TODO: Find better name for 'resource or action'
if (isService(secondToLastField) || index === 2) return 'resource or action';
if (isResource(secondToLastField)) return 'action';
return '';
}
function getCustomInputHelperStr(input: string, selectionStart?: number): string {
const fields = input.split('.');
let fieldIndex = -1;
if (selectionStart > -1) {
let currentIndex = 0;
let arrayIndex = 0;
for (const item of fields) {
currentIndex += item.length + 1;
if (currentIndex > selectionStart) {
fieldIndex = arrayIndex;
break;
}
arrayIndex++;
}
}
if (action) {
data.set('action', { value: action.name, description: 'action' });
return getHelperStr(fields, fieldIndex);
}
// State & Reactive Declarations
let selected = {
service: null as EventService | null,
resource: null as EventResource | null,
action: null as EventAction | null,
attribute: null as string | null
};
let helper: string = null;
let customInput: string = null;
let customInputCursor = -1;
let showInput = false;
let copyParent: HTMLElement;
$: if (show && initialValue) {
customInput = initialValue;
inferSelectedFromCustomInput();
}
$: available = {
services: services,
resources: selected.service?.resources || [],
actions: (selected.resource ? selected.resource?.actions : selected.service?.actions) || [],
attributes: selected.action?.attributes || []
};
$: eventString = (function createEventString(): Array<{ value: string; description: string }> {
let fields: string[] = [];
// Avoid calculating the event string if the user is typing, as it is not shown
if (showInput) return [];
if (customInput) {
fields = customInput.split('.');
} else {
if (selected.service) {
fields.push(selected.service.name, '*');
}
if (selected.resource?.name === 'documents') {
fields.push('collections', '*');
}
if (selected.resource) {
fields.push(selected.resource.name, '*');
}
if (selected.action) {
fields.push(selected.action.name);
}
if (selected.attribute) {
fields.push(selected.attribute);
}
}
if (attribute && !resource) {
data.set('attribute', { value: attribute, description: 'attribute' });
} else if (action?.attributes && !resource) {
data.set('attribute', { value: '*', description: `attribute` });
}
return data;
}
return fields.map((value, i, arr) => ({ value, description: getHelperStr(arr, i) }));
})();
$: eventString = createEventString(
selectedService,
selectedResource,
selectedAction,
selectedAttribute
);
$: copyValue =
inputData ??
Array.from(eventString.values())
.map((d) => d.value)
.join('.');
$: if (selectedService) {
selectedResource = null;
selectedAction = null;
selectedAttribute = null;
helper = null;
}
$: if (!selectedAction?.attributes) {
selectedAttribute = null;
}
$: if (!showInput) {
helper = null;
}
$: inputValue = eventString.map((d) => d.value).join('.');
$: if (!show) {
selectedService = null;
selectedResource = null;
selectedAction = null;
selectedAttribute = null;
resetSelected();
helper = null;
inputData = null;
customInput = null;
showInput = false;
}
//allows to add the href attribute without throwing an error
const attributes = { type: 'text', readonly: 'readonly' } as Record<string, string>;
$: if (showInput) {
helper = getCustomInputHelperStr(customInput, customInputCursor);
}
</script>
<Modal bind:show on:submit={create} size="big">
<svelte:fragment slot="header">Create Event</svelte:fragment>
<slot />
<div>
<p class="u-text">Choose a service</p>
<div class="u-flex u-gap-8 u-margin-block-start-8">
{#each services as service}
{#each available.services as service}
<Pill
disabled={showInput}
selected={service.name === selectedService?.name}
selected={selected.service?.name === service.name}
button
on:click={() => {
selectedService = service;
inputData = null;
}}>{service.name}</Pill>
on:click={() => select('service', service)}>
{service.name}
</Pill>
{/each}
</div>
</div>
{#if selectedService}
{#if !empty(available.resources)}
<div>
<p class="u-text">Choose a resource (optional)</p>
<div class="u-flex u-gap-8 u-margin-block-start-8">
{#each selectedService.resources as resource}
{#each available.resources as resource}
<Pill
disabled={showInput}
selected={resource.name === selectedResource?.name}
selected={selected.resource?.name === resource.name}
button
on:click={() => {
selectedResource === resource
? (selectedResource = null)
: (selectedResource = resource);
inputData = null;
}}>{resource.name}</Pill>
on:click={() => select('resource', resource)}>
{resource.name}
</Pill>
{/each}
</div>
</div>
{/if}
{#if !empty(available.actions)}
<div>
<p class="u-text">Choose an action (optional)</p>
<div class="u-flex u-gap-8 u-margin-block-start-8">
{#each selectedResource?.actions ?? selectedService?.actions as action}
{#each available.actions as action}
<Pill
disabled={showInput}
selected={selectedAction === action}
selected={selected.action?.name === action.name}
button
on:click={() => {
selectedAction === action
? (selectedAction = null)
: (selectedAction = action);
inputData = null;
}}>{action.name}</Pill>
on:click={() => select('action', action)}>
{action.name}
</Pill>
{/each}
</div>
</div>
{#if selectedAction?.attributes}
<div>
<p class="u-text">Choose an attribute (optional)</p>
<div class="u-flex u-gap-8 u-margin-block-start-8">
{#each selectedAction.attributes as attribute}
<Pill
disabled={showInput}
selected={selectedAttribute === attribute}
button
on:click={() => {
selectedAttribute === attribute
? (selectedAttribute = null)
: (selectedAttribute = attribute);
inputData = null;
}}>{attribute}</Pill>
{/each}
</div>
</div>
{/if}
{/if}
{#if !empty(available.attributes)}
<div>
<p class="u-text">Choose an attribute (optional)</p>
<div class="u-flex u-gap-8 u-margin-block-start-8">
{#each available.attributes as attribute}
<Pill
disabled={showInput}
selected={selected.attribute === attribute}
button
on:click={() => select('attribute', attribute)}>
{attribute}
</Pill>
{/each}
</div>
</div>
{/if}
{#if showInput}
<div class="input-text-wrapper" style="--amount-of-buttons:2">
<input type="text" placeholder="Enter custom event" bind:value={inputData} />
<input
type="text"
placeholder="Enter custom event"
bind:value={customInput}
use:selectionStart={{ onChange: (newValue) => (customInputCursor = newValue) }} />
<div class="options-list">
<button
on:click|preventDefault={() => {
showInput = false;
}}
class="options-list-button"
aria-label="confirm">
<button on:click={toggleShowInput} class="options-list-button" aria-label="confirm">
<span class="icon-check" aria-hidden="true" />
</button>
<button
on:click|preventDefault={() => {
inputData = null;
showInput = false;
}}
class="options-list-button"
aria-label="cancel">
<button on:click={toggleShowInput} class="options-list-button" aria-label="cancel">
<span class="icon-x" aria-hidden="true" />
</button>
</div>
<p style="height: 2rem;">{helper ?? ''}</p>
</div>
{:else}
<div class="input-text-wrapper" style="--amount-of-buttons:2">
<div {...attributes} style="min-height: 2.5rem;">
{#if inputData}
<span>{inputData}</span>
{:else}
{#each Array.from(eventString.values()) as route, i}
<button
class:u-opacity-50={helper !== route.description}
on:mouseenter={() => {
helper = route.description;
}}
on:mouseleave={() => {
helper = null;
}}>
{route.value}
</button>
<span class="u-opacity-50">
{i + 1 < eventString?.size ? '.' : ''}
</span>
{/each}
{/if}
<div class="input-text-wrapper" style="--amount-of-buttons:2" bind:this={copyParent}>
<!--
This object syntax avoids TS erroring because 'type' isn't a valid HTMLDivElement attribute
(we need to set it to 'text' to add styling)
-->
<div {...{ type: 'text' }} style="min-height: 2.5rem;">
{#each eventString as route, i}
<span
class:u-opacity-0-5={helper !== route.description}
on:mouseenter={() => (helper = route.description)}
on:mouseleave={() => (helper = null)}>
{route.value}
</span>
<span class="u-opacity-0-5">
{i + 1 < eventString?.length ? '.' : ''}
</span>
{/each}
</div>
<div class="options-list">
<button
on:click|preventDefault={() => {
inputData = copyValue;
showInput = true;
}}
class="options-list-button"
aria-label="edit event">
<span class="icon-pencil" aria-hidden="true" />
</button>
<button disabled={!copyValue} class="options-list-button" aria-label="copy text">
<Copy value={copyValue}>
<span class="icon-duplicate" aria-hidden="true" />
</Copy>
</button>
{#key copyParent}
<button
on:click={(e) => {
customInput = inputValue;
toggleShowInput(e);
}}
use:tooltip={{ content: 'Edit event', appendTo: copyParent }}
class="options-list-button"
aria-label="edit event">
<span class="icon-pencil" aria-hidden="true" />
</button>
<button
disabled={!inputValue}
class="options-list-button"
aria-label="copy text">
<Copy value={inputValue} appendTo={copyParent}>
<span class="icon-duplicate" aria-hidden="true" />
</Copy>
</button>
{/key}
</div>
<p style="height: 2rem;">{helper ?? ''}</p>
</div>
@@ -325,6 +378,7 @@
<svelte:fragment slot="footer">
<Button secondary on:click={() => (show = false)}>Cancel</Button>
<Button disabled={showInput || !copyValue} submit>Create</Button>
<Button disabled={showInput || !inputValue} submit
>{initialValue ? 'Update' : 'Create'}</Button>
</svelte:fragment>
</Modal>
+7 -2
View File
@@ -18,13 +18,18 @@
async function handleSubmit() {
try {
await feedback.submitFeedback('feedback-general', message, name, email);
show = false;
addNotification({
type: 'success',
message: 'Feedback submitted successfully'
});
} catch (error) {
show = false;
addNotification({
type: 'error',
message: error.message
});
} finally {
show = false;
}
}
</script>
+2 -3
View File
@@ -20,9 +20,8 @@ export { default as DropListItem } from './dropListItem.svelte';
export { default as DropListLink } from './dropListLink.svelte';
export { default as Collapsible } from './collapsible.svelte';
export { default as CollapsibleItem } from './collapsibleItem.svelte';
export { default as DropTabs } from './dropTabs.svelte';
export { default as DropTabsItem } from './dropTabsItem.svelte';
export { default as DropTabsLink } from './dropTabsLink.svelte';
export { default as SecondaryTabs } from './secondaryTabs.svelte';
export { default as SecondaryTabsItem } from './secondaryTabsItem.svelte';
export { default as Avatar } from './avatar.svelte';
export { default as AvatarInitials } from './avatarInitials.svelte';
export { default as AvatarGroup } from './avatarGroup.svelte';
@@ -154,7 +154,7 @@
<TableCellHead width={40} />
</TableHeader>
<TableBody>
{#each [...$groups].sort(sortRoles) as [role, permission]}
{#each [...$groups].sort(sortRoles) as [role, permission] (role)}
<TableRow>
<TableCell title="Role">
<Row {role} />
+10 -10
View File
@@ -65,7 +65,7 @@
{#if data}
{@const isUser = role.startsWith('user')}
{@const isTeam = role.startsWith('team')}
{@const isAnonymous = !data.email && !data.phone}
{@const isAnonymous = !data.email && !data.phone && isUser}
<div class="user-profile">
{#if isAnonymous}
<div class="avatar is-size-small ">
@@ -80,13 +80,7 @@
{/if}
<span class="user-profile-info is-only-desktop">
<span class="name">
{data.name
? data.name
: data?.email
? data?.email
: data?.phone
? data?.phone
: '-'}
{data.name ?? data?.email ?? data?.phone ?? '-'}
</span>
<Output value={data.$id}>{role}</Output>
</span>
@@ -96,8 +90,14 @@
<span class="user-profile-empty-column" />
<span class="user-profile-info is-only-desktop">
{#if isUser}
<p class="text u-x-small">{data?.email}</p>
<p class="text u-x-small">{data?.phone}</p>
<div class="u-grid u-gap-4">
{#if data?.email}
<p class="text u-x-small">Email: {data?.email}</p>
{/if}
{#if data?.phone}
<p class="text u-x-small">Phone: {data?.phone}</p>
{/if}
</div>
{:else if isTeam}
<p class="text u-x-small">Members: {data?.total}</p>
{/if}
+4 -3
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { onMount } from 'svelte';
import { onDestroy } from 'svelte';
@@ -30,7 +31,7 @@
$: valueChange(search);
const valueChange = (value: string) => {
function valueChange(value: string) {
clearTimeout(timer);
timer = setTimeout(async () => {
const url = new URL($page.url);
@@ -45,10 +46,10 @@
}
url.search = value;
trackEvent('search');
goto(url, { keepFocus: true });
}, debounce);
};
}
</script>
<div class="u-flex u-gap-12 common-section u-main-space-between">
+3
View File
@@ -0,0 +1,3 @@
<ul class="secondary-tabs">
<slot />
</ul>
@@ -0,0 +1,22 @@
<script lang="ts">
export let href: string;
export let disabled = false;
</script>
<li class="secondary-tabs-item">
{#if href}
{#if disabled}
<button class="secondary-tabs-button" disabled>
<span class="text"><slot /></span>
</button>
{:else}
<a class="secondary-tabs-button" {href}>
<span class="text"><slot /></span>
</a>
{/if}
{:else}
<button class="secondary-tabs-button" {disabled} on:click>
<span class="text"><slot /></span>
</button>
{/if}
</li>
+9 -2
View File
@@ -1,8 +1,11 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { tooltip } from '$lib/actions/tooltip';
import { Copy } from '.';
export let show = false;
export let value: string;
export let copyEvent: string = null;
</script>
<div class="interactive-text-output" class:is-textarea={show}>
@@ -16,10 +19,14 @@
class="interactive-text-output-button"
aria-label="show hidden text"
type="button"
on:click={() => (show = !show)}>
on:click={() => {
show = !show;
trackEvent(`click_secret_${show ? 'show' : 'hide'}`);
}}
use:tooltip={{ content: show ? 'Hide secret' : 'Show secret', hideOnClick: false }}>
<span class:icon-eye-off={show} class:icon-eye={!show} aria-hidden="true" />
</button>
<Copy {value}>
<Copy {value} event={copyEvent} eventContext="click_secret_copy">
<button class="interactive-text-output-button" aria-label="copy text" type="button">
<span class="icon-duplicate" aria-hidden="true" />
</button>
+84
View File
@@ -176,3 +176,87 @@ export const scopes: {
category: 'Other'
}
];
export type EventService = {
name: string;
resources: EventResource[];
actions?: EventAction[];
};
export type EventResource = {
name: string;
actions?: EventAction[];
};
export type EventAction = {
name: string;
attributes?: string[];
};
export const eventServices: Array<EventService> = [
{
name: 'buckets',
resources: [
{
name: 'files',
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
}
],
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
},
{
name: 'databases',
resources: [
{
name: 'collections',
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
},
{
name: 'documents',
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
}
],
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
},
{
name: 'functions',
resources: [
{
name: 'deployments',
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
},
{
name: 'executions',
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
}
],
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
},
{
name: 'teams',
resources: [
{
name: 'memberships',
actions: [
{ name: 'create' },
{ name: 'update', attributes: ['status'] },
{ name: 'delete' }
]
}
],
actions: [{ name: 'create' }, { name: 'update' }, { name: 'delete' }]
},
{
name: 'users',
resources: [
{ name: 'recovery', actions: [{ name: 'create' }, { name: 'delete' }] },
{ name: 'sessions', actions: [{ name: 'create' }, { name: 'delete' }] },
{ name: 'verification', actions: [{ name: 'create' }, { name: 'delete' }] }
],
actions: [
{ name: 'create' },
{ name: 'update', attributes: ['email', 'name', 'password', 'status', 'prefs'] },
{ name: 'delete' }
]
}
];
+1 -1
View File
@@ -3,7 +3,7 @@
</script>
<p
class="helper u-margin-block-start-12"
class="helper u-margin-block-start-8"
class:u-color-text-info={type === 'info'}
class:u-color-text-danger={type === 'error'}
class:u-color-text-success={type === 'success'}
+1
View File
@@ -20,5 +20,6 @@ export { default as InputChoice } from './inputChoice.svelte';
export { default as InputPhone } from './inputPhone.svelte';
export { default as InputCron } from './inputCron.svelte';
export { default as InputURL } from './inputURL.svelte';
export { default as InputId } from './inputId.svelte';
export { default as InputSecret } from './inputSecret.svelte';
export { default as Helper } from './helper.svelte';
+8 -1
View File
@@ -2,6 +2,7 @@
import { FormItem, Helper } from '.';
export let label: string;
export let optionalText: string | undefined = undefined;
export let showLabel = true;
export let id: string;
export let value = false;
@@ -26,7 +27,13 @@
</script>
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<label class:u-hide={!showLabel} class="label" for={id}>
{label}
{#if optionalText}
<span class="optional">{optionalText}</span>
{/if}
</label>
<div class="input-text-wrapper">
<input
{id}
+1 -1
View File
@@ -18,7 +18,7 @@
let element: HTMLInputElement;
let error: string;
const pattern = String.raw`^[^]+\s+[^]+\s+[^]+\s+[^]+\s+[^]`;
const pattern = String.raw`^[^]+\s+[^]+\s+[^]+\s+[^]+\s+[^]+`;
onMount(() => {
if (element && autofocus) {
+9 -2
View File
@@ -4,6 +4,7 @@
export let label: string;
export let showLabel = true;
export let optionalText: string | undefined = undefined;
export let id: string;
export let value = '';
export let required = false;
@@ -38,8 +39,14 @@
</script>
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<div class="input-text-wrapper">
<label class:u-hide={!showLabel} class="label" for={id}>
{label}
<span class:u-hide={!showLabel || !optionalText} class="optional">
{optionalText}
</span>
</label>
<div class="input-text-wrapper" style="--amount-of-buttons:1; --button-size: 1rem">
<input
{id}
{disabled}
+87 -28
View File
@@ -1,21 +1,24 @@
<script lang="ts">
import { Trim } from '$lib/components';
import { Button } from '.';
import { humanFileSize } from '$lib/helpers/sizeConvertion';
import { Helper } from '.';
export let label: string = null;
export let files: FileList;
export let list = new DataTransfer();
export let allowedFileExtensions: string[] = [];
export let maxSize: number = null;
export let required = false;
export let error: string = null;
let input: HTMLInputElement;
let hovering = false;
function dropHandler(ev: DragEvent) {
ev.dataTransfer.dropEffect = 'move';
hovering = false;
if (ev.dataTransfer.items) {
// Use DataTransferItemList interface to access the file(s)
for (let i = 0; i < ev.dataTransfer.items.length; i++) {
// If dropped items aren't files, reject them
if (ev.dataTransfer.items[i].kind === 'file') {
list.items.clear();
list.items.add(ev.dataTransfer.items[i].getAsFile());
@@ -28,6 +31,22 @@
function dragOverHandler() {
hovering = true;
}
const handleInvalid = (event: Event) => {
event.preventDefault();
if (input.validity.valueMissing) {
error = 'This field is required';
return;
}
error = input.validationMessage;
};
$: if (files) {
error = null;
}
$: fileArray = files?.length ? Array.from(files) : [];
</script>
<input
@@ -35,49 +54,89 @@
bind:this={input}
accept={allowedFileExtensions.map((n) => `.${n}`).join(',')}
type="file"
style="display: none" />
style="display: none"
{required}
on:invalid={handleInvalid} />
<div>
{#if label}
<p class="text">{label}</p>
{/if}
<div
class="card is-border-dashed is-no-shadow"
class="box is-no-shadow u-padding-24"
style="--box-border-radius:var(--border-radius-xsmall); z-index: 1"
class:is-border-dashed={!hovering}
class:is-hover-with-file={hovering}
on:drop|preventDefault={dropHandler}
on:dragover|preventDefault={dragOverHandler}
on:dragenter|preventDefault
on:dragleave|preventDefault={() => (hovering = false)}>
<div class="u-flex u-main-center u-cross-center u-gap-32">
<div class="avatar is-size-large u-min-width-0">
<span class="icon-folder" aria-hidden="true" />
<div class="upload-file-box">
<div class="upload-file-box-image">
<span class="icon-upload" aria-hidden="true" />
</div>
<div class="u-min-width-0 u-text-center">
<h5 class="upload-file-box-title heading-level-7 u-inline">
<span class="is-only-desktop">Drag and drop files here to upload</span>
<span class="is-not-desktop">Upload a File</span>
</h5>
{#if allowedFileExtensions?.length}
<button
class="tooltip u-inline u-margin-inline-start-4"
aria-label="variables info">
<span class="icon-info" aria-hidden="true" />
<span class="tooltip-popup" role="tooltip"
>Only {allowedFileExtensions.join(', ')} accepted.</span>
</button>
{/if}
</div>
<div class="u-flex u-main-center u-cross-center u-gap-16 u-flex-vertical-mobile">
{#if maxSize}
{@const readableMaxSize = humanFileSize(maxSize)}
<p class="upload-file-box-info body-text-2 u-normal">
Max file size: {readableMaxSize.value + readableMaxSize.unit}
</p>
{/if}
<button
class="button is-secondary is-full-width-mobile"
type="button"
on:click={() => input.click()}>
<span class="text">Choose a file</span>
</button>
</div>
<div class="u-grid u-gap-16 u-min-width-0">
<p>Drag and drop files here</p>
<div class="u-flex u-gap-8 u-min-width-0">
<Button secondary on:click={() => input.click()}>
<span class="icon-upload" aria-hidden="true" />
<span class="text">Choose File</span>
</Button>
{#if files?.length}
{@const fileName = files.item(0).name.split('.')}
<div class="u-flex u-cross-center u-min-width-0">
<Trim>{fileName[0]}</Trim>
<span class="u-min-width-0 u-flex-shrink-0 u-margin-inline-end-16"
>.{fileName[1]}</span>
{#if files?.length}
<ul class="upload-file-box-list u-min-width-0">
{#each fileArray as file}
{@const fileName = file.name.split('.')}
{@const fileSize = humanFileSize(file.size)}
<li class="u-flex u-cross-center u-min-width-0">
<span class="icon-document" aria-hidden="true" />
<span class="upload-file-box-name u-trim u-min-width-0">
<Trim>{fileName[0]}</Trim>
</span>
<span class="upload-file-box-name u-min-width-0 u-flex-shrink-0">
.{fileName[1]}
</span>
<span
class="upload-file-box-size u-margin-inline-start-4 u-margin-inline-end-16">
{fileSize.value + fileSize.unit}
</span>
<button
on:click={() => (files = null)}
type="button"
class="button is-text is-only-icon"
style="--button-size:1.5rem;"
class="button is-text is-only-icon u-margin-inline-start-auto"
aria-label="remove file"
title="Remove file">
style="--button-size:1.5rem;">
<span class="icon-x" aria-hidden="true" />
</button>
</div>
{/if}
</div>
</div>
</li>
{/each}
</ul>
{/if}
</div>
</div>
{#if error}
<Helper type="warning">{error}</Helper>
{/if}
</div>
+63
View File
@@ -0,0 +1,63 @@
<script lang="ts">
import { onMount } from 'svelte';
import { FormItem } from '.';
export let value = '';
let element: HTMLInputElement;
let icon = 'info';
const pattern = String.raw`^[a-zA-Z0-9][a-zA-Z0-9._-]*$`;
const autofocus = true;
onMount(() => {
if (element && autofocus) {
element.focus();
}
});
const handleInvalid = (event: Event) => {
event.preventDefault();
if (element.validity.patternMismatch) {
icon = 'exclamation';
return;
}
};
$: if (value) {
icon = 'info';
}
</script>
<FormItem>
<div class="input-text-wrapper">
<input
id="id"
placeholder="Enter ID"
maxlength={36}
{pattern}
autocomplete="off"
type="text"
class="input-text"
bind:value
bind:this={element}
on:invalid={handleInvalid} />
<span class="text-counter">
<span class="text-counter-count">{value?.length ?? 0}</span>
<span class="text-counter-separator" />
<span class="text-counter-max">36</span>
</span>
</div>
</FormItem>
<div
class="u-flex u-gap-4 u-margin-block-start-8 u-small"
class:u-color-text-warning={icon === 'exclamation'}>
<span
class:icon-info={icon === 'info'}
class:icon-exclamation={icon === 'exclamation'}
class="u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, non-leading hyphen, underscore, period
</span>
</div>
+8 -1
View File
@@ -3,6 +3,7 @@
import { FormItem, Helper } from '.';
export let label: string;
export let optionalText: string | undefined = undefined;
export let showLabel = true;
export let id: string;
export let value: number = null;
@@ -51,7 +52,13 @@
</script>
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<label class:u-hide={!showLabel} class="label" for={id}>
{label}
{#if optionalText}
<span class="optional">{optionalText}</span>
{/if}
</label>
<div class="input-text-wrapper">
<input
{id}
+11 -13
View File
@@ -12,7 +12,7 @@
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<div class="input-text-wrapper" style="--amount-of-buttons:1">
<div class="input-text-wrapper" style=" --amount-of-buttons: 1;">
{#if showInPlainText}
<div
contenteditable="true"
@@ -31,17 +31,15 @@
autocomplete="off"
bind:value />
{/if}
<div class="options-list">
<button
type="button"
on:click={() => (showInPlainText = !showInPlainText)}
class="options-list-button"
aria-label="show / hide password">
<span
class:icon-eye={!showInPlainText}
class:icon-eye-off={showInPlainText}
aria-hidden="true" />
</button>
</div>
<button
type="button"
on:click={() => (showInPlainText = !showInPlainText)}
class="show-password-button"
aria-label="show / hide password">
<span
class:icon-eye={!showInPlainText}
class:icon-eye-off={showInPlainText}
aria-hidden="true" />
</button>
</div>
</FormItem>
+18 -1
View File
@@ -3,6 +3,7 @@
export let id: string;
export let label: string;
export let optionalText: string | undefined = undefined;
export let showLabel = true;
export let value: string | number | boolean;
export let placeholder = '';
@@ -26,13 +27,27 @@
error = element.validationMessage;
};
$: if (element && required && !value) {
element.setCustomValidity('This field is required');
}
$: if (element && required && value) {
element.setCustomValidity('');
}
$: if (value) {
error = null;
}
</script>
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<label class:u-hide={!showLabel} class="label" for={id}>
{label}
{#if optionalText}
<span class="optional">{optionalText}</span>
{/if}
</label>
<div class="select">
<select
{id}
@@ -54,5 +69,7 @@
</div>
{#if error}
<Helper type="warning">{error}</Helper>
{:else}
<slot name="helper" />
{/if}
</FormItem>
+3 -1
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { last } from '$lib/helpers/array';
import { onMount } from 'svelte';
import { FormItem, Helper } from '.';
@@ -36,7 +37,7 @@
}
if (['Backspace', 'Delete'].includes(e.key)) {
if (value.length === 0) {
removeValue(tags[tags.length - 1]);
removeValue(last(tags));
}
}
};
@@ -50,6 +51,7 @@
};
const removeValue = (value: string) => {
if (readonly) return;
tags = tags.filter((tag) => tag !== value);
};
+7 -2
View File
@@ -4,6 +4,7 @@
import { FormItem, Helper } from '.';
export let label: string;
export let optionalText: string | undefined = undefined;
export let showLabel = true;
export let id: string;
export let value = '';
@@ -42,8 +43,8 @@
</script>
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}
>{label}
<label class:u-hide={!showLabel} class="label" for={id}>
{label}
{#if tooltip}
<span
class="icon-info"
@@ -52,7 +53,11 @@
content: tooltip
}} />
{/if}
{#if optionalText}
<span class="optional">{optionalText}</span>
{/if}
</label>
<div class="input-text-wrapper">
<input
{id}
+46
View File
@@ -27,3 +27,49 @@ export function remove<T>(arr: T[], index: number): T[] {
// Remove the element at the given index, return a new array
return [...arr.slice(0, index), ...arr.slice(index + 1)];
}
/**
* Returns true if the array is empty, false otherwise.
*
* @export
* @param {unknown[]} arr
* @returns {boolean}
*/
export function empty(arr: unknown[]): boolean {
if (!arr) return true;
return arr.length === 0;
}
/**
* Get nth item of Array. Negative for backward
*
* @export
* @template T
* @param {(readonly T[] | [])} array
* @param {number} index
* @returns {(T | undefined)}
*/
export function at(array: readonly [], index: number): undefined;
export function at<T>(array: readonly T[], index: number): T;
export function at<T>(array: readonly T[] | [], index: number): T | undefined {
const len = array.length;
if (!len) return undefined;
if (index < 0) index += len;
return array[index];
}
/**
* Get last item
*
* @export
* @template T
* @param {readonly T[]} array
* @returns {(T | undefined)}
*/
export function last(array: readonly []): undefined;
export function last<T>(array: readonly T[]): T;
export function last<T>(array: readonly T[]): T | undefined {
return at(array, -1);
}
+17
View File
@@ -22,3 +22,20 @@ export const toLocaleDateTime = (datetime: string | number) => {
return date.toLocaleDateString('en', options);
};
export const isSameDay = (date1: Date, date2: Date) => {
return (
date1.getFullYear() === date2.getFullYear() &&
date1.getMonth() === date2.getMonth() &&
date1.getDate() === date2.getDate()
);
};
export const isValidDate = (date: string) => {
return !isNaN(new Date(date).getTime());
};
export const diffDays = (date1: Date, date2: Date) => {
const diffTime = Math.abs(date2.getTime() - date1.getTime());
return Math.floor(diffTime / (1000 * 60 * 60 * 24));
};
+9
View File
@@ -0,0 +1,9 @@
/**
* Strict typed `Object.entries`
* Extracted from https://github.com/antfu/utils
*
* @category Object
*/
export function objectEntries<T extends object>(obj: T) {
return Object.entries(obj) as Array<[keyof T, T[keyof T]]>;
}
+22
View File
@@ -0,0 +1,22 @@
/**
* Capitalizes the first letter of a string
*
* @export
* @param {string} str
* @returns {string}
*/
export function capitalize(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1);
}
/**
* Given a string, returns the singular version of it,
* by removing the trailing 's'.
*
* @export
* @param {string} str
* @returns {string}
*/
export function singular(str: string): string {
return str.replace(/s$/, '');
}
+33 -3
View File
@@ -1,3 +1,10 @@
/**
* Formats the time in a human readable format.
*
* @export
* @param {number} time - The time in seconds.
* @returns {string} The formatted time string.
*/
export function calculateTime(time: number) {
const milliseconds = Math.floor(time * 1000);
const seconds = Math.floor(time);
@@ -20,11 +27,13 @@ export function calculateTime(time: number) {
} else if (months < 12) {
return `${months}M`;
} else {
return `${years} y`;
return `${years}y`;
}
}
export function timeToSeconds(time: number, unit: string) {
type Unit = 'ms' | 's' | 'm' | 'h' | 'd' | 'M' | 'y';
export function timeToSeconds(time: number, unit: Unit) {
switch (unit) {
case 'ms':
return time / 1000;
@@ -44,7 +53,7 @@ export function timeToSeconds(time: number, unit: string) {
return time;
}
}
export function timeToMinutes(time: number, unit: string) {
export function timeToMinutes(time: number, unit: Unit) {
switch (unit) {
case 'ms':
return time / 1000 / 60;
@@ -64,3 +73,24 @@ export function timeToMinutes(time: number, unit: string) {
return time;
}
}
export function secsToUnit(time: number, unit: Unit) {
switch (unit) {
case 'ms':
return time * 1000;
case 's':
return time;
case 'm':
return time / 60;
case 'h':
return time / 60 / 60;
case 'd':
return time / 60 / 60 / 24;
case 'M':
return time / 60 / 60 / 24 / 30;
case 'y':
return time / 60 / 60 / 24 / 30 / 12;
default:
return time;
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ function sendToAnalytics(metric: Metric, options: Options) {
};
if (options.debug) {
console.log('[Analytics]', metric.name, JSON.stringify(body, null, 2));
console.debug('[Analytics]', metric.name, JSON.stringify(body, null, 2));
}
const blob = new Blob([new URLSearchParams(body).toString()], {
+9 -9
View File
@@ -19,7 +19,7 @@
let showFeedback = false;
import { slide } from 'svelte/transition';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent } from '$lib/actions/analytics';
import { sdkForConsole } from '$lib/stores/sdk';
import { goto } from '$app/navigation';
@@ -36,7 +36,7 @@
async function logout() {
await sdkForConsole.account.deleteSession('current');
trackEvent('submit_account_logout');
trackEvent(Submit.AccountLogout);
await goto(`${base}/login`);
}
@@ -93,7 +93,7 @@
<span class="text">Support</span>
</a>
</nav>
<nav class="u-flex u-height-100-percents u-sep-inline-start">
<nav class="u-flex u-height-100-percent u-sep-inline-start">
{#if $user}
<div class="drop-wrapper" class:is-open={showDropdown} bind:this={droplistElement}>
<button class="user-profile-button" on:click={() => (showDropdown = !showDropdown)}>
@@ -114,9 +114,9 @@
<div
class="drop is-no-arrow is-block-end is-inline-end"
transition:slide={{ duration: 100 }}>
<section class="drop-section u-overflow-y-auto u-max-height-200">
<ul class="drop-list">
{#if $organizationList?.total}
{#if $organizationList?.total}
<section class="drop-section u-overflow-y-auto u-max-height-200">
<ul class="drop-list">
{#each $organizationList.teams as org}
<DropListLink
href={`${base}/console/organization-${org.$id}`}
@@ -124,9 +124,9 @@
showDropdown = false;
}}>{org.name}</DropListLink>
{/each}
{/if}
</ul>
</section>
</ul>
</section>
{/if}
<section class="drop-section">
<ul class="drop-list">
<DropListItem
+3 -4
View File
@@ -83,11 +83,10 @@
<div>Size: {size.value} {size.unit}</div>
</div>
<div class="status u-margin-inline-start-auto">
<div class="u-flex u-flex-vertical u-cross-end">
<div class="status u-margin-inline-start-auto">
<Status status={$log.data.status}>{$log.data.status}</Status>
<p class="text">
{calculateTime($log.data.buildTime)}
</p>
<time>{calculateTime($log.data.buildTime)}</time>
</div>
</div>
</div>
+1 -1
View File
@@ -70,7 +70,7 @@
<div class="u-margin-block-start-40" />
</section>
<section class="grid-1-1-col-2 u-flex u-main-center u-cross-center">
<div class="container u-flex u-flex-vertical u-cross-center u-height-100-percents">
<div class="container u-flex u-flex-vertical u-cross-center u-height-100-percent">
<div class="u-margin-block-start-auto" />
<div class="u-max-width-500 u-width-full-line">
+9 -9
View File
@@ -14,7 +14,7 @@
<script lang="ts">
import { Container } from '$lib/layout';
import { BarChart, LineChart } from '$lib/charts';
import { Card, DropTabs, DropTabsLink, Heading, Tiles } from '$lib/components';
import { Card, SecondaryTabs, SecondaryTabsItem, Heading, Tiles } from '$lib/components';
import { Colors } from '$lib/charts/config';
import type { Models } from '@aw-labs/appwrite-console';
import { page } from '$app/stores';
@@ -33,19 +33,19 @@
<Container>
<div class="u-flex u-main-space-between common-section">
<Heading tag="h2" size="5">{title}</Heading>
<DropTabs>
<DropTabsLink href={`${path}/24h`} disabled={$page.params.period === '24h'}>
<SecondaryTabs>
<SecondaryTabsItem href={`${path}/24h`} disabled={$page.params.period === '24h'}>
24h
</DropTabsLink>
<DropTabsLink
</SecondaryTabsItem>
<SecondaryTabsItem
href={`${path}/30d`}
disabled={!$page.params.period || $page.params.period === '30d'}>
30d
</DropTabsLink>
<DropTabsLink href={`${path}/90d`} disabled={$page.params.period === '90d'}>
</SecondaryTabsItem>
<SecondaryTabsItem href={`${path}/90d`} disabled={$page.params.period === '90d'}>
90d
</DropTabsLink>
</DropTabs>
</SecondaryTabsItem>
</SecondaryTabs>
</div>
<Card>
{#if count}
+26 -3
View File
@@ -10,6 +10,8 @@
</script>
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Steps } from '$lib/components';
import { Button, Form } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -31,6 +33,9 @@
const openDialog = document.querySelectorAll('dialog[open]');
if (event.key === 'Escape' && !showExitModal && !openDialog?.length) {
event.preventDefault();
trackEvent('wizard_exit', {
from: 'escape'
});
dispatch('exit');
wizard.hide();
}
@@ -40,6 +45,9 @@
if (confirmExit) {
showExitModal = true;
} else {
trackEvent('wizard_exit', {
from: 'button'
});
dispatch('exit');
wizard.hide();
}
@@ -67,8 +75,10 @@
wizard.setInterceptor(null);
if (isLastStep) {
trackEvent('wizard_finish');
dispatch('finish');
} else {
trackEvent('wizard_next');
currentStep++;
}
}
@@ -129,10 +139,16 @@
<Button secondary on:click={handleExit}>Cancel</Button>
<Button submit>Next</Button>
{:else if isLastStep}
<Button secondary on:click={() => currentStep--}>Back</Button>
<Button
secondary
on:click={() => currentStep--}
on:click={() => trackEvent('wizard_back')}>Back</Button>
<Button submit>{finalAction}</Button>
{:else}
<Button secondary on:click={() => currentStep--}>Back</Button>
<Button
secondary
on:click={() => currentStep--}
on:click={() => trackEvent('wizard_back')}>Back</Button>
<Button submit>Next</Button>
{/if}
</div>
@@ -142,7 +158,14 @@
</section>
{#if showExitModal}
<WizardExitModal bind:show={showExitModal} on:exit={() => wizard.hide()}>
<WizardExitModal
bind:show={showExitModal}
on:exit={() => {
trackEvent('wizard_exit', {
from: 'prompt'
});
wizard.hide();
}}>
<slot name="exit">this process</slot>
</WizardExitModal>
{/if}
+1
View File
@@ -64,6 +64,7 @@ function createFeedbackStore() {
email?: string,
value?: number
) => {
if (!growthEndpoint) return;
const response = await fetch(`${growthEndpoint}/feedback`, {
method: 'POST',
headers: {
+1 -1
View File
@@ -15,7 +15,7 @@ import {
import { Project } from './project';
const endpoint =
import.meta.env.VITE_APPWRITE_ENDPOINT?.toString() ?? `${window?.location?.origin}/v1`;
import.meta.env.VITE_APPWRITE_ENDPOINT?.toString() ?? `${globalThis?.location?.origin}/v1`;
const clientConsole = new Client();
clientConsole.setEndpoint(endpoint).setProject('console');
+2 -1
View File
@@ -1,3 +1,4 @@
import { trackEvent } from '$lib/actions/analytics';
import type { SvelteComponent } from 'svelte';
import { writable } from 'svelte/store';
@@ -24,7 +25,7 @@ function createWizardStore() {
n.show = true;
n.component = component;
n.media = media;
trackEvent('wizard_start');
return n;
}),
setInterceptor: (callback: WizardStore['interceptor']) => {
+3 -1
View File
@@ -75,7 +75,9 @@
});
afterNavigate((navigation) => {
trackPageView(navigation.to.route.id);
if (navigation.type !== 'enter' && navigation.from?.route?.id !== navigation.to.route.id) {
trackPageView(navigation.to.route.id);
}
});
$: {
+6 -1
View File
@@ -1,7 +1,12 @@
import { redirect } from '@sveltejs/kit';
import { base } from '$app/paths';
import type { PageLoad } from './$types';
import { user } from '$lib/stores/user';
export const load: PageLoad = async () => {
throw redirect(302, `${base}/login`);
if (user) {
return;
} else {
throw redirect(302, `${base}/login`);
}
};
+7 -4
View File
@@ -10,7 +10,7 @@
import Delete from './delete.svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
let name: string = null,
email: string = null,
@@ -32,12 +32,13 @@
message: 'Name has been updated',
type: 'success'
});
trackEvent('submit_account_update_name');
trackEvent(Submit.AccountUpdateName);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.AccountUpdateName);
}
}
async function updateEmail() {
@@ -48,12 +49,13 @@
message: 'Email has been updated',
type: 'success'
});
trackEvent('submit_account_update_email');
trackEvent(Submit.AccountUpdateEmail);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.AccountUpdateEmail);
}
}
@@ -65,12 +67,13 @@
message: 'Password has been updated',
type: 'success'
});
trackEvent('submit_account_update_password');
trackEvent(Submit.AccountUpdatePassword);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.AccountUpdatePassword);
}
}
</script>
+3 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
@@ -18,12 +18,13 @@
type: 'success',
message: `Account was deleted `
});
trackEvent('submit_account_delete');
trackEvent(Submit.AccountDelete);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.AccountDelete);
}
};
</script>
+2 -2
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent } from '$lib/actions/analytics';
import { Tab, Tabs } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { isTabSelected } from '$lib/helpers/load';
@@ -39,7 +39,7 @@
async function logout() {
await sdkForConsole.account.deleteSession('current');
trackEvent('submit_account_logout');
trackEvent(Submit.AccountLogout);
await goto(`${base}/login`);
}
</script>
@@ -17,7 +17,7 @@
import { Dependencies } from '$lib/constants';
import type { Models } from '@aw-labs/appwrite-console';
import type { PageData } from './$types';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent } from '$lib/actions/analytics';
import { base } from '$app/paths';
export let data: PageData;
@@ -28,7 +28,7 @@
const logout = async (session: Models.Session) => {
await sdkForConsole.account.deleteSession(session.$id);
trackEvent('submit_account_delete_session');
trackEvent(Submit.AccountDeleteSession);
if (session.current) {
await goto(`${base}/login`);
}
@@ -36,7 +36,7 @@
};
const logoutAll = async () => {
await sdkForConsole.account.deleteSessions();
trackEvent('submit_account_delete_all_sessions');
trackEvent(Submit.AccountDeleteAllSessions);
await goto(`${base}/login`);
invalidate(Dependencies.ACCOUNT_SESSIONS);
};
+9 -5
View File
@@ -7,7 +7,8 @@
import { createEventDispatcher } from 'svelte';
import { goto, invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { ID } from '@aw-labs/appwrite-console';
export let show = false;
@@ -20,7 +21,7 @@
const create = async () => {
try {
const org = await sdkForConsole.teams.create(id ?? 'unique()', name);
const org = await sdkForConsole.teams.create(id ?? ID.unique(), name);
await invalidate(Dependencies.ACCOUNT);
dispatch('created');
await goto(`/console/organization-${org.$id}`);
@@ -28,12 +29,15 @@
type: 'success',
message: `${name} has been created`
});
trackEvent('submit_organization_create');
trackEvent(Submit.OrganizationCreate, {
customId: !!id
});
name = null;
id = null;
show = false;
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.OrganizationCreate);
}
};
</script>
+8 -4
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { goto, invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Card } from '$lib/components';
import CustomId from '$lib/components/customId.svelte';
import { Dependencies } from '$lib/constants';
@@ -29,13 +29,17 @@
);
await invalidate(Dependencies.ACCOUNT);
goto(`/console/project-${project.$id}`);
trackEvent('submit_project_create');
} catch ({ message }) {
trackEvent(Submit.ProjectCreate, {
customId: !!id,
teamId: org.$id
});
} catch (error) {
loading = false;
addNotification({
message,
message: error.message,
type: 'error'
});
trackError(error, Submit.ProjectCreate);
}
}
@@ -8,7 +8,7 @@
import { organization } from '$lib/stores/organization';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let showCreate = false;
@@ -32,10 +32,11 @@
type: 'success',
message: `Invite has been sent to ${email}`
});
trackEvent('submit_member_create');
trackEvent(Submit.MemberCreate);
dispatch('created', team);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.MemberCreate);
}
};
@@ -1,11 +1,12 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { InputText, Button, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { createEventDispatcher } from 'svelte';
export let show = false;
@@ -23,21 +24,25 @@
try {
isCreating = true;
const project = await sdkForConsole.projects.create(
id ?? 'unique()',
id ?? ID.unique(),
name,
teamId,
'default'
);
dispatch('created', project);
trackEvent('submit_project_create');
trackEvent(Submit.ProjectCreate, {
customId: !!id,
teamId
});
addNotification({
type: 'success',
message: `${name} has been created`
});
await goto(`/console/project-${project.$id}`);
} catch ({ message }) {
} catch (e) {
isCreating = false;
error = message;
error = e.message;
trackError(e, Submit.ProjectCreate);
}
}
</script>
@@ -8,7 +8,7 @@
import type { Models } from '@aw-labs/appwrite-console';
import { createEventDispatcher } from 'svelte';
import { user } from '$lib/stores/user';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
const dispatch = createEventDispatcher();
@@ -30,12 +30,13 @@
type: 'success',
message: `${selectedMember.userName} was deleted from ${selectedMember.teamName}`
});
trackEvent('submit_member_delete');
trackEvent(Submit.MemberDelete);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.MemberDelete);
}
};
@@ -7,7 +7,7 @@
import { goto, invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let showDelete = false;
@@ -18,7 +18,7 @@
type: 'success',
message: `${$organization.name} has been deleted`
});
trackEvent('submit_organization_delete');
trackEvent(Submit.OrganizationDelete);
if ($organizationList?.total > 1) {
await invalidate(Dependencies.ACCOUNT);
goto(`${base}/console/`);
@@ -32,6 +32,7 @@
type: 'error',
message: error.message
});
trackError(error, Submit.OrganizationDelete);
}
};
</script>
@@ -45,9 +45,8 @@
<button
class="button is-text u-padding-inline-0"
on:click={() => (showDropdown = !showDropdown)}>
<h1 class="heading-level-4">
<h1 class="heading-level-4 u-flex u-cross-center u-gap-8">
<span class="text"> {$organization.name}</span>
<span
class={`icon-cheveron-${showDropdown ? 'up' : 'down'}`}
aria-hidden="true" />
@@ -21,7 +21,7 @@
import Delete from '../../deleteMember.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { PageData } from './$types';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let data: PageData;
@@ -43,12 +43,13 @@
type: 'success',
message: `Invite has been sent to ${member.userEmail}`
});
trackEvent('submit_member_create');
trackEvent(Submit.MemberCreate);
} catch (error) {
addNotification({
type: 'error',
message: error
});
trackError(error, Submit.MemberCreate);
}
};
</script>
@@ -9,7 +9,7 @@
import { Dependencies } from '$lib/constants';
import { onMount } from 'svelte';
import Delete from '../deleteOrganization.svelte';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
let name: string;
let showDelete = false;
@@ -26,12 +26,13 @@
message: 'Name has been updated',
type: 'success'
});
trackEvent('submit_organization_update_name');
trackEvent(Submit.OrganizationUpdateName);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.OrganizationUpdateName);
}
}
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -42,14 +42,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -40,14 +40,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -40,14 +40,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
@@ -1,10 +1,11 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { InputText, Button, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -16,7 +17,7 @@
const create = async () => {
try {
const team = await sdkForProject.teams.create(id ?? 'unique()', name);
const team = await sdkForProject.teams.create(id ?? ID.unique(), name);
name = '';
showCreate = false;
showCustomId = false;
@@ -24,10 +25,13 @@
type: 'success',
message: `${team.name} has been created`
});
trackEvent('submit_team_create');
trackEvent(Submit.TeamCreate, {
customId: !!id
});
dispatch('created', team);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.TeamCreate);
}
};
@@ -1,5 +1,5 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements/';
import {
@@ -12,6 +12,7 @@
} from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -25,7 +26,7 @@
const create = async () => {
try {
const user = await sdkForProject.users.create(
id ?? 'unique()',
id ?? ID.unique(),
mail,
phone,
pass,
@@ -38,10 +39,13 @@
type: 'success',
message: `${user.name ? user.name : 'User'} has been created`
});
trackEvent('submit_user_create');
trackEvent(Submit.UserCreate, {
customId: !!id
});
dispatch('created', user);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.UserCreate);
}
};
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -40,14 +40,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -41,14 +41,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
</script>
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -41,14 +41,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
@@ -8,7 +8,7 @@
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let provider: Provider;
@@ -44,14 +44,15 @@
provider.enabled ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_provider_update', {
trackEvent(Submit.ProviderUpdate, {
provider,
enabled
});
provider = null;
invalidate(Dependencies.PROJECT);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.ProviderUpdate);
}
};
@@ -1,234 +1,12 @@
<script lang="ts">
import { CardGrid, Heading } from '$lib/components';
import { Pill } from '$lib/elements/';
import { Button, InputNumber, InputSelect, Form } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { project } from '../../store';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { clickOnEnter } from '$lib/helpers/a11y';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { timeToSeconds } from '$lib/helpers/timeConversion';
import { writable } from 'svelte/store';
const projectId = $project.$id;
let isLimited = $project.authLimit === 0 ? 'unlimited' : 'limited';
let newLimit = $project.authLimit === 0 ? 100 : $project.authLimit;
let time = $project.authDuration;
let timeInSec = time;
let period = writable('s');
let btnActive = false;
let maxSessions = $project.authSessionsLimit;
let options = [
{ label: 'days', value: 'd' },
{ label: 'hours', value: 'h' },
{ label: 'minutes', value: 'm' },
{ label: 'seconds', value: 's' }
];
$: {
if (isLimited) {
if (isLimited === 'unlimited' && $project.authLimit === 0) {
btnActive = false;
} else if (isLimited === 'limited' && $project.authLimit === newLimit) {
btnActive = false;
} else {
btnActive = true;
}
}
}
async function updateLimit() {
try {
await sdkForConsole.projects.updateAuthLimit(
projectId,
isLimited === 'unlimited' ? 0 : newLimit
);
invalidate(Dependencies.PROJECT);
btnActive = false;
addNotification({
type: 'success',
message: 'Updated project users limit successfully'
});
trackEvent('submit_auth_limit_update');
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
async function updateSessionLength() {
try {
await sdkForConsole.projects.updateAuthDuration(
projectId,
timeToSeconds(time, $period)
);
invalidate(Dependencies.PROJECT);
$period = 's';
addNotification({
type: 'success',
message: 'Updated project users limit successfully'
});
trackEvent('submit_session_length_update');
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
async function updateSessionsLimit() {
try {
await sdkForConsole.projects.updateAuthSessionsLimit(projectId, maxSessions);
addNotification({
type: 'success',
message: 'Sessions limit has been updated'
});
trackEvent('submit_sessions_limit_update');
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
period.subscribe((p) => {
if (p === 'd') {
time = timeInSec / 86400;
timeInSec = timeToSeconds(time, p);
} else if (p === 'h') {
time = timeInSec / 3600;
timeInSec = timeToSeconds(time, p);
} else if (p === 'm') {
time = timeInSec / 60;
timeInSec = timeToSeconds(time, p);
} else if (p === 's') {
time = timeInSec;
timeInSec = timeToSeconds(time, p);
}
});
$: if (time) {
timeInSec = timeToSeconds(time, $period);
}
import UpdateSessionLength from './updateSessionLength.svelte';
import UpdateSessionsLimit from './updateSessionsLimit.svelte';
import UpdateUsersLimit from './updateUsersLimit.svelte';
</script>
<Container>
<CardGrid>
<Heading tag="h2" size="6">Users Limit</Heading>
<p>
Limit new users from signing up for your project, regardless of authentication method.
You can still create users and team memberships from your Appwrite console.
<b> The maximum limit is 10,000 users.</b>
</p>
<svelte:fragment slot="aside">
<ul class="form-list">
<li class="form-item">
<label class="choice-item" for="unlimited">
<input
id="unlimited"
name="authLimit"
class=" u-cross-child-center"
required
type="radio"
checked={isLimited === 'unlimited'}
bind:group={isLimited}
value="unlimited" />
<div class="choice-item-content u-cross-child-center">
<div class="choice-item-title">Unlimited</div>
</div>
<Pill>recommended</Pill>
</label>
</li>
<li class="form-item is-multiple">
<div class="input-text-wrapper">
<label class="choice-item" for="limited">
<input
id="limited"
name="authLimit"
required
type="radio"
checked={isLimited === 'limited'}
bind:group={isLimited}
value="limited" />
<div class="choice-item-content">
<div class="choice-item-title">Limited</div>
</div>
</label>
</div>
<div
class="input-text-wrapper u-stretch"
on:click={() => (isLimited = 'limited')}
on:keyup|self={clickOnEnter}>
<input
type="number"
name="limit"
id="limit"
class="input-text"
max="10000"
disabled={isLimited === 'unlimited'}
bind:value={newLimit} />
</div>
</li>
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
disabled={!btnActive}
on:click={() => {
updateLimit();
}}>Update</Button>
</svelte:fragment>
</CardGrid>
<CardGrid>
<Heading tag="h2" size="6">Session Length</Heading>
<p>
If you reduce the limit, users who are currently logged in will be logged out of the
application.
</p>
<svelte:fragment slot="aside">
<form class="form u-grid u-gap-16">
<ul class="form-list is-multiple">
<InputNumber id="length" label="Length" bind:value={time} />
<InputSelect id="period" label="Time Period" bind:value={$period} {options} />
</ul>
</form>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
disabled={$period === 's' && time === $project.authDuration}
on:click={() => {
updateSessionLength();
}}>
Update
</Button>
</svelte:fragment>
</CardGrid>
<Form on:submit={updateSessionsLimit}>
<CardGrid>
<Heading tag="h2" size="6">Session Limit</Heading>
<p>Maximum number of active sessions allowed per user.</p>
<svelte:fragment slot="aside">
<ul>
<InputNumber id="max-session" label="Limit" bind:value={maxSessions} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={maxSessions === $project.authSessionsLimit} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
<UpdateUsersLimit />
<UpdateSessionLength />
<UpdateSessionsLimit />
</Container>
@@ -0,0 +1,105 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, InputNumber, InputSelect } from '$lib/elements/forms';
import { secsToUnit, timeToSeconds } from '$lib/helpers/timeConversion';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { writable } from 'svelte/store';
import { project } from '../../store';
enum Period {
Days = 'd',
Hours = 'h',
Minutes = 'm',
Seconds = 's'
}
const projectId = $project.$id;
const options = [
{ label: 'days', value: Period.Days },
{ label: 'hours', value: Period.Hours },
{ label: 'minutes', value: Period.Minutes },
{ label: 'seconds', value: Period.Seconds }
];
let period = writable(Period.Seconds);
function getInitialTime() {
let t = $project.authDuration;
if (t >= 86400 && t % 86400 === 0) {
$period = Period.Days;
return t / 86400;
}
if (t >= 3600 && t % 3600 === 0) {
$period = Period.Hours;
return t / 3600;
}
if (t >= 60 && t % 60 === 0) {
$period = Period.Minutes;
return t / 60;
}
return t;
}
let time = getInitialTime();
let timeInSecs = timeToSeconds(time, $period);
period.subscribe((p) => {
time = secsToUnit(timeInSecs, p);
});
$: timeInSecs = timeToSeconds(time, $period);
async function updateSessionLength() {
try {
await sdkForConsole.projects.updateAuthDuration(projectId, timeInSecs);
invalidate(Dependencies.PROJECT);
addNotification({
type: 'success',
message: 'Updated project users limit successfully'
});
trackEvent(Submit.SessionsLengthUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.SessionsLengthUpdate);
}
}
</script>
<CardGrid>
<Heading tag="h2" size="6">Session Length</Heading>
<p>
If you reduce the limit, users who are currently logged in will be logged out of the
application.
</p>
<svelte:fragment slot="aside">
<form class="form u-grid u-gap-16">
<ul class="form-list is-multiple">
<InputNumber id="length" label="Length" bind:value={time} />
<InputSelect id="period" label="Time Period" bind:value={$period} {options} />
</ul>
</form>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
disabled={timeToSeconds(time, $period) === $project.authDuration}
on:click={() => {
updateSessionLength();
}}>
Update
</Button>
</svelte:fragment>
</CardGrid>
@@ -0,0 +1,46 @@
<script lang="ts">
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Button, Form, InputNumber } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
let maxSessions = $project.authSessionsLimit;
async function updateSessionsLimit() {
try {
await sdkForConsole.projects.updateAuthSessionsLimit(projectId, maxSessions);
addNotification({
type: 'success',
message: 'Sessions limit has been updated'
});
trackEvent(Submit.SessionsLimitUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.SessionsLimitUpdate);
}
}
</script>
<Form on:submit={updateSessionsLimit}>
<CardGrid>
<Heading tag="h2" size="6">Sessions Limit</Heading>
<p>Maximum number of active sessions allowed per user.</p>
<svelte:fragment slot="aside">
<ul>
<InputNumber id="max-session" label="Limit" bind:value={maxSessions} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={maxSessions === $project.authSessionsLimit} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -0,0 +1,117 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
import { clickOnEnter } from '$lib/helpers/a11y';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
let isLimited = $project.authLimit !== 0;
let newLimit = isLimited ? $project.authLimit : 100;
let submitting = false;
$: btnDisabled = (function isBtnDisabled() {
if (
submitting ||
(!isLimited && $project.authLimit === 0) ||
(isLimited && $project.authLimit === newLimit)
) {
return true;
}
return false;
})();
async function updateLimit() {
submitting = true;
try {
await sdkForConsole.projects.updateAuthLimit(projectId, isLimited ? newLimit : 0);
invalidate(Dependencies.PROJECT).then(() => (submitting = false));
addNotification({
type: 'success',
message: 'Updated project users limit successfully'
});
trackEvent(Submit.AuthLimitUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
submitting = false;
trackError(error, Submit.AuthLimitUpdate);
}
}
</script>
<CardGrid>
<Heading tag="h2" size="6">Users Limit</Heading>
<p>
Limit new users from signing up for your project, regardless of authentication method. You
can still create users and team memberships from your Appwrite console.
<b>The maximum limit is 10,000 users.</b>
</p>
<svelte:fragment slot="aside">
<ul class="form-list">
<li class="form-item">
<label class="choice-item" for="unlimited">
<input
id="unlimited"
name="authLimit"
class="u-cross-child-center"
required
type="radio"
bind:group={isLimited}
value={false} />
<div class="choice-item-content u-cross-child-center">
<div class="choice-item-title">Unlimited</div>
</div>
<Pill>recommended</Pill>
</label>
</li>
<li class="form-item is-multiple">
<div class="input-text-wrapper">
<label class="choice-item" for="limited">
<input
id="limited"
name="authLimit"
required
type="radio"
bind:group={isLimited}
value={true} />
<div class="choice-item-content">
<div class="choice-item-title">Limited</div>
</div>
</label>
</div>
<div
class="input-text-wrapper u-stretch"
on:click={() => (isLimited = true)}
on:keyup|self={clickOnEnter}>
<input
type="number"
name="limit"
id="limit"
class="input-text"
max="10000"
disabled={!isLimited}
bind:value={newLimit} />
</div>
</li>
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
disabled={btnDisabled}
on:click={() => {
updateLimit();
}}>Update</Button>
</svelte:fragment>
</CardGrid>
@@ -11,7 +11,7 @@
import { app } from '$lib/stores/app';
import { page } from '$app/stores';
import type { Provider } from '$lib/stores/oauth-providers';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
const projectId = $page.params.project;
@@ -29,7 +29,7 @@
box.value ? 'enabled' : 'disabled'
}`
});
trackEvent('submit_auth_status_update', {
trackEvent(Submit.AuthStatusUpdate, {
method: box.method,
value: box.value
});
@@ -39,6 +39,7 @@
type: 'error',
message: error.message
});
trackError(error, Submit.AuthStatusUpdate);
}
}
@@ -48,7 +48,7 @@
<TableRowLink
href={`${base}/console/project-${project}/auth/teams/team-${team.$id}`}>
<TableCell title="Name">
<div class="u-flex u-gap-12">
<div class="u-flex u-gap-12 u-cross-center">
<AvatarInitials size={32} name={team.name} />
<span class="text u-trim">{team.name}</span>
</div>
@@ -11,7 +11,7 @@
import { Dependencies } from '$lib/constants';
import { invalidate } from '$app/navigation';
import DeleteTeam from './deleteTeam.svelte';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
let showDelete = false;
let teamName: string = null;
@@ -28,12 +28,13 @@
message: 'Name has been updated',
type: 'success'
});
trackEvent('submit_team_update_name');
trackEvent(Submit.TeamUpdateName);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.TeamUpdateName);
}
}
</script>
@@ -1,6 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal, Alert } from '$lib/components';
import { Button, InputEmail, InputText, InputTags, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -30,13 +30,14 @@
type: 'success',
message: `${name ? name : email} created successfully`
});
trackEvent('submit_member_create');
trackEvent(Submit.MemberCreate);
email = name = '';
roles = [];
showCreate = false;
dispatch('created', user);
} catch ({ message }) {
error = message;
} catch (e) {
error = e.message;
trackError(e, Submit.MemberCreate);
}
};
</script>
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -23,7 +23,7 @@
);
showDelete = false;
dispatch('deleted');
trackEvent('submit_member_delete');
trackEvent(Submit.MemberDelete);
await goto(
`${base}/console/project-${$page.params.project}/auth/teams/team-${selectedMembership.teamId}/members`
);
@@ -32,6 +32,7 @@
type: 'error',
message: error.message
});
trackError(error, Submit.MemberDelete);
}
};
</script>
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -16,13 +16,14 @@
try {
await sdkForProject.teams.delete(team.$id);
showDelete = false;
trackEvent('submit_team_delete');
trackEvent(Submit.TeamDelete);
await goto(`${base}/console/project-${$page.params.project}/auth/teams`);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.TeamDelete);
}
};
</script>
@@ -1,7 +1,7 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
@@ -20,12 +20,13 @@
type: 'success',
message: 'All sessions have been deleted'
});
trackEvent('submit_session_delete_all');
trackEvent(Submit.SessionDeleteAll);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.SessionDeleteAll);
}
};
</script>
@@ -2,7 +2,7 @@
import { goto, invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
@@ -26,7 +26,7 @@
type: 'success',
message: `Membership has been deleted`
});
trackEvent('submit_member_delete');
trackEvent(Submit.MemberDelete);
await goto(
`${base}/console/project-${$page.params.project}/auth/user-${selectedMembership.userId}/memberships`
);
@@ -35,6 +35,7 @@
type: 'error',
message: error.message
});
trackError(error, Submit.MemberDelete);
}
};
</script>
@@ -1,7 +1,7 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
@@ -19,12 +19,13 @@
type: 'success',
message: 'Session has been deleted'
});
trackEvent('submit_session_delete');
trackEvent(Submit.SessionDelete);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.SessionDelete);
}
};
</script>
@@ -8,7 +8,7 @@
import { sdkForProject } from '$lib/stores/sdk';
import { user } from './store';
import { project } from '../../store';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let showDelete = false;
@@ -20,13 +20,14 @@
type: 'success',
message: `${$user.name ? $user.name : 'User'} has been deleted`
});
trackEvent('submit_user_delete');
trackEvent(Submit.UserDelete);
await goto(`${base}/console/project-${$page.params.project}/auth`);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.UserDelete);
}
};
</script>
@@ -67,17 +67,18 @@
<TableCellText title="Session">{session.clientType}</TableCellText>
<TableCellText title="Location">{session.countryName}</TableCellText>
<TableCellText title="IP">{session.ip}</TableCellText>
<TableCellText title="">
<button
class="button is-only-icon is-text"
aria-label="Delete item"
<TableCell>
<Button
text
round
ariaLabel="Delete item"
on:click={() => {
selectedSessionId = session.$id;
showDelete = true;
}}>
<span class="icon-trash" aria-hidden="true" />
</button>
</TableCellText>
</Button>
</TableCell>
</TableRow>
{/each}
</TableBody>
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputEmail } from '$lib/elements/forms';
@@ -22,12 +22,13 @@
message: 'Email has been updated',
type: 'success'
});
trackEvent('submit_user_update_email');
trackEvent(Submit.UserUpdateEmail);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdateEmail);
}
}
</script>
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputText } from '$lib/elements/forms';
@@ -22,12 +22,13 @@
message: 'Name has been updated',
type: 'success'
});
trackEvent('submit_user_update_name');
trackEvent(Submit.UserUpdateName);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdateName);
}
}
</script>
@@ -1,5 +1,5 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Button, Form, InputPassword } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -16,12 +16,13 @@
message: 'Password has been updated',
type: 'success'
});
trackEvent('submit_user_update_password');
trackEvent(Submit.UserUpdatePassword);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdatePassword);
}
}
</script>
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputPhone } from '$lib/elements/forms';
@@ -22,12 +22,13 @@
message: 'Phone has been updated',
type: 'success'
});
trackEvent('submit_user_update_phone');
trackEvent(Submit.UserUpdatePhone);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdatePhone);
}
}
</script>
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form } from '$lib/elements/forms';
@@ -43,12 +43,13 @@
message: 'Preferences have been updated',
type: 'success'
});
trackEvent('submit_user_update_preferences');
trackEvent(Submit.UserUpdatePreferences);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdatePreferences);
}
}
</script>
@@ -110,6 +111,11 @@
<Button
noMargin
text
disabled={prefs?.length &&
prefs[prefs.length - 1][0] &&
prefs[prefs.length - 1][1]
? false
: true}
on:click={() => {
if (prefs[prefs.length - 1][0] && prefs[prefs.length - 1][1]) {
prefs.push(['', '']);
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { AvatarInitials, CardGrid, DropList, DropListItem, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Pill } from '$lib/elements';
@@ -23,12 +23,13 @@
}`,
type: 'success'
});
trackEvent('submit_user_update_verification_email');
trackEvent(Submit.UserUpdateVerificationEmail);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdateVerificationEmail);
}
}
async function updateVerificationPhone() {
@@ -42,12 +43,13 @@
}`,
type: 'success'
});
trackEvent('submit_user_update_verification_phone');
trackEvent(Submit.UserUpdateVerificationPhone);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdateVerificationPhone);
}
}
async function updateStatus() {
@@ -60,12 +62,13 @@
}`,
type: 'success'
});
trackEvent('submit_user_update_status');
trackEvent(Submit.UserUpdateStatus);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
trackError(error, Submit.UserUpdateStatus);
}
}
</script>
@@ -1,9 +1,11 @@
<script lang="ts">
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { Button, InputText, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
import { ID } from '@aw-labs/appwrite-console';
import { createEventDispatcher } from 'svelte';
export let showCreate = false;
@@ -16,19 +18,23 @@
const create = async () => {
try {
const database = await sdkForProject.databases.create(id ? id : 'unique()', name);
const database = await sdkForProject.databases.create(id ? id : ID.unique(), name);
showCreate = false;
dispatch('created', database);
addNotification({
type: 'success',
message: `${name} has been created`
});
trackEvent(Submit.DatabaseCreate, {
customId: !!id
});
name = id = null;
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.DatabaseCreate);
}
};
</script>
@@ -19,6 +19,7 @@
import { page } from '$app/stores';
import { PAGE_LIMIT } from '$lib/constants';
import CreateAttribute from '../createAttribute.svelte';
import { tooltip } from '$lib/actions/tooltip';
export let data: PageData;
let showCreateAttribute = false;
@@ -33,6 +34,44 @@
title: attribute.key
}))
];
function formatArray(array: unknown[]) {
if (array.length === 0) return '[ ]';
let formattedFields: string[] = [];
for (const item of array) {
if (typeof item === 'string') {
formattedFields.push(`"${item}"`);
} else {
formattedFields.push(`${item}`);
}
}
return `[${formattedFields.join(', ')}]`;
}
function formatColumn(column: unknown) {
let formattedColumn: string;
if (typeof column === 'string') {
formattedColumn = column;
} else if (Array.isArray(column)) {
formattedColumn = formatArray(column);
} else if (!column) {
formattedColumn = 'n/a';
} else {
formattedColumn = `${column}`;
}
return {
value:
formattedColumn.length > 20
? `${formattedColumn.slice(0, 20)}...`
: formattedColumn,
truncated: formattedColumn.length > 20,
whole: formattedColumn
};
}
</script>
<Container>
@@ -70,8 +109,15 @@
</Copy>
</TableCell>
{#each columns as column}
{@const formatted = formatColumn(document[column.key])}
<TableCell>
{document[column.key] ?? 'n/a'}
<div
use:tooltip={{
content: formatted.whole,
disabled: !formatted.truncated
}}>
{formatted.value}
</div>
</TableCell>
{/each}
</TableRowLink>
@@ -9,7 +9,7 @@
import type { Attributes } from '../store';
import { sdkForProject } from '$lib/stores/sdk';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
export let showDelete = false;
export let selectedAttribute: Attributes;
@@ -28,7 +28,7 @@
type: 'success',
message: `Attribute has been deleted`
});
trackEvent('submit_attribute_delete');
trackEvent(Submit.AttributeDelete);
await goto(
`${base}/console/project-${$page.params.project}/databases/database-${databaseId}/collection-${$page.params.collection}/attributes`
);
@@ -37,6 +37,7 @@
type: 'error',
message: error.message
});
trackError(error, Submit.AttributeDelete);
}
};
</script>
@@ -8,6 +8,7 @@
$: attr = selectedAttribute as {
type?: string;
size?: string;
format?: string;
array?: boolean;
required?: boolean;
@@ -31,6 +32,9 @@
bind:value={attr.key}
disabled />
<InputText id="type" label="Type" value={attr.type ?? ''} readonly />
{#if attr.size}
<InputText id="size" label="Size" value={attr.size} readonly />
{/if}
{#if attr.format}
<InputText id="format" label="Format" value={attr.format} readonly />
{/if}
Loaded 100 of 201 files, more files were not shown because too many files have changed in this diff. Show more