Merge pull request #654 from appwrite/feat-filters

Update Filters to not allow filtering on all columns
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2024-01-02 15:40:19 +01:00
commit 8530a2ac33
19 files changed
+244 -195

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { EmptySearch } from '.';
import { queries } from './filters';
export let resource;
</script>
<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<b class="body-text-2 u-bold">Sorry, we couldn't find any {resource}.</b>
<p>There are no {resource} that match your filters.</p>
</div>
<div class="u-flex common-section u-main-center">
<Button
secondary
on:click={() => {
queries.clearAll();
queries.apply();
}}>
Clear filters
</Button>
</div>
</div>
</EmptySearch>
+6 -4
View File
@@ -118,10 +118,12 @@
<div class="selects u-flex u-gap-8 u-margin-block-start-16">
<InputSelect
id="column"
options={$columns.map((c) => ({
label: c.title,
value: c.id
}))}
options={$columns
.filter((c) => c.filter !== false)
.map((c) => ({
label: c.title,
value: c.id
}))}
placeholder="Select column"
bind:value={columnId} />
<InputSelect
+2 -1
View File
@@ -1 +1,2 @@
export { default as filters } from './filters.svelte';
export { default as Filters } from './filters.svelte';
export { hasPageQueries, queryParamToMap, queries } from '$lib/components/filters/store';
+1
View File
@@ -15,6 +15,7 @@ export { default as UploadBox } from './uploadBox.svelte';
export { default as List } from './list.svelte';
export { default as ListItem } from './listItem.svelte';
export { default as Empty } from './empty.svelte';
export { default as EmptyFilter } from './emptyFilter.svelte';
export { default as EmptySearch } from './emptySearch.svelte';
export { default as Drop } from './drop.svelte';
export { default as DropList } from './dropList.svelte';
+7
View File
@@ -19,6 +19,13 @@ export type Column = {
id: string;
title: string;
type: ColumnType;
/**
* Set to false to hide by default
*/
show: boolean;
width?: number;
/**
* Set to false to disable filtering for this column
*/
filter?: boolean;
};
@@ -1,8 +1,7 @@
<script lang="ts">
import { page } from '$app/stores';
import { Empty, EmptySearch, Heading, PaginationWithLimit } from '$lib/components';
import Filters from '$lib/components/filters/filters.svelte';
import { hasPageQueries, queries } from '$lib/components/filters/store';
import { Filters, hasPageQueries, queries } from '$lib/components/filters';
import ViewSelector from '$lib/components/viewSelector.svelte';
import { Button } from '$lib/elements/forms';
import type { ColumnType } from '$lib/helpers/types';
@@ -3,7 +3,7 @@ import { getLimit, getPage, getQuery, getView, pageToOffset, View } from '$lib/h
import { sdk } from '$lib/stores/sdk';
import { Query } from '@appwrite.io/console';
import type { PageLoad } from './$types';
import { queries, queryParamToMap } from '$lib/components/filters/store';
import { queries, queryParamToMap } from '$lib/components/filters';
export const load: PageLoad = async ({ params, depends, url, route }) => {
depends(Dependencies.DOCUMENTS);
@@ -3,6 +3,7 @@
import { page } from '$app/stores';
import {
Empty,
EmptyFilter,
EmptySearch,
FloatingActionBar,
Heading,
@@ -30,7 +31,7 @@
import MessageStatusPill from './messageStatusPill.svelte';
import CreateMessageDropdown from './createMessageDropdown.svelte';
import ProviderType, { ProviderTypes } from './providerType.svelte';
import Filters from '$lib/components/filters/filters.svelte';
import { Filters, hasPageQueries } from '$lib/components/filters';
import FailedModal from './failedModal.svelte';
export let data: PageData;
@@ -183,6 +184,8 @@
limit={data.limit}
offset={data.offset}
total={data.messages.total} />
{:else if $hasPageQueries}
<EmptyFilter resource="messages" />
<!-- TODO: remove data.search != 'empty' when the API is ready with data -->
{:else if data.search && data.search != 'empty'}
<EmptySearch>
@@ -13,7 +13,7 @@ import { messages as data, providersById } from './store';
import type { Message } from './store';
import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { queries, queryParamToMap } from '$lib/components/filters/store';
import { queries, queryParamToMap } from '$lib/components/filters';
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
@@ -11,7 +11,7 @@
export let showCreateDropdown = false;
</script>
<DropList bind:show={showCreateDropdown} scrollable>
<DropList bind:show={showCreateDropdown} scrollable placement="bottom-end">
<slot>
<Button on:click={() => (showCreateDropdown = !showCreateDropdown)} event="create_message">
<span class="icon-plus" aria-hidden="true" />
@@ -7,12 +7,13 @@
SearchQuery,
PaginationWithLimit,
Heading,
ViewSelector
ViewSelector,
EmptyFilter
} from '$lib/components';
import { Container } from '$lib/layout';
import type { PageData } from './$types';
import { columns } from './store';
import Filters from '$lib/components/filters/filters.svelte';
import { Filters, hasPageQueries } from '$lib/components/filters';
import CreateProviderDropdown from './createProviderDropdown.svelte';
import Table from './table.svelte';
@@ -68,6 +69,8 @@
limit={data.limit}
offset={data.offset}
total={data.providers.total} />
{:else if $hasPageQueries}
<EmptyFilter resource="providers" />
{:else if data.search && data.search != 'empty'}
<EmptySearch>
<div class="u-text-center">
@@ -11,7 +11,7 @@ import {
} from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import { providersById, type Provider } from '../store';
import { queries, queryParamToMap } from '$lib/components/filters/store';
import { queries, queryParamToMap } from '$lib/components/filters';
const providers = Object.values(providersById);
@@ -16,7 +16,7 @@
): value is T[keyof T] => Object.values<string>(enumType).includes(value);
</script>
<DropList bind:show={showCreateDropdown} scrollable>
<DropList bind:show={showCreateDropdown} scrollable placement="bottom-end">
<slot>
<Button on:click={() => (showCreateDropdown = !showCreateDropdown)} event="create_provider">
<span class="icon-plus" aria-hidden="true" />
@@ -38,6 +38,179 @@ type ProvidersMap = {
};
export const providers: ProvidersMap = {
[ProviderTypes.Push]: {
name: 'Push notification',
text: 'notifications',
icon: 'device-mobile',
providers: {
[Providers.FCM]: {
imageIcon: 'firebase',
title: 'FCM',
description: 'Firebase Cloud Messaging',
configure: [
{
label: 'Server key (.json file)',
name: 'serverKey',
type: 'file',
allowedFileExtensions: ['json'],
placeholder: 'Enter server key',
popover: [
'<b>How to get the FCM server key?</b>',
'Head to <b>Project settings -> Service accounts -> Generate new private key.</b>',
'Generating the new key will result in the download of a JSON file.'
]
}
]
},
[Providers.APNS]: {
imageIcon: 'apple',
title: 'APNS',
description: 'Apple Push Notification Service',
configure: [
{
label: 'Team ID',
name: 'teamId',
type: 'text',
placeholder: 'Enter team ID',
popover: [
'<b>How to get the team ID?</b>',
'Head to <b>Apple Developer Member Center -> Membership details -> Team ID.</b>'
]
},
{
label: 'Bundle ID',
name: 'bundleId',
type: 'text',
placeholder: 'Enter bundle ID',
popover: [
'<b>How to get the bundle ID?</b>',
'Head to <b>Apple Developer Member Center -> Certificates, Identifiers & Profiles -> Identifiers.</b>',
`<a
href="/images/apns-bundle-id.png"
class="file-preview is-with-image"
target="_blank"
rel="noopener noreferrer"
aria-label="open file in new window">
<div class="file-preview-image">
<img
width="205"
height="125"
src="/images/apns-bundle-id.png"
alt="Screenshot of Bundle ID in Apple" />
</div>
<div class="file-preview-content">
<div class="avatar">
<span class="icon-external-link" aria-hidden="true" />
</div>
</div>
</a>`
]
},
{
label: 'Authentication key ID',
name: 'authKeyId',
type: 'text',
placeholder: 'Enter key ID',
popover: [
'<b>How to get the auth key ID?</b>',
'Head to <b>Apple Developer Member Center -> Certificates, Identifiers & Profiles -> Keys.</b>',
'Click on your key to view details.'
]
},
{
label: 'Auth key (.p8 file)',
name: 'authKey',
type: 'file',
allowedFileExtensions: ['p8'],
popover: [
'<b>How to get the authentication key?</b>',
'Head to <b>Apple Developer Member Center</b> (under Program resources) <b>-> Certificates, Identifiers & Profiles -> Keys.</b>',
'Create a key and give it a name. Enable the Apple Push Notifications service (APNS), and register your key.'
]
}
]
}
// [Providers.MQTT]: {
// imageIcon: 'mqtt',
// title: 'MQTT',
// description: 'Message Queuing Telemtry Transport'
// }
}
},
[ProviderTypes.Email]: {
name: 'Email',
text: 'emails',
icon: 'mail',
providers: {
[Providers.Mailgun]: {
imageIcon: 'mailgun',
title: 'Mailgun',
description: '',
configure: [
{
label: 'API key',
name: 'apiKey',
type: 'text',
placeholder: 'Enter API key',
popover: [
'<b>How to get the API key?</b>',
'Create an account in Mailgun.',
'Head to <b>Profile -> API Security -> Add new key.</b>'
]
},
{
label: 'Domain',
name: 'domain',
type: 'domain',
placeholder: 'Enter domain',
popover: [
'<b>How to create a domain?</b>',
'Head to <b>Sending -> Domains -> Add new domain.</b>',
'Follow <b>Mailgun instructions</b> to verify the domain name.'
]
},
{
label: 'EU region',
name: 'isEuRegion',
type: 'switch',
description:
'Enable the EU region setting if your domain is within the European Union.'
},
{
label: 'Sender email',
name: 'from',
type: 'email',
placeholder: 'Enter email'
}
]
},
[Providers.Sendgrid]: {
imageIcon: 'sendgrid',
title: 'Sendgrid',
description: '',
configure: [
{
label: 'API key',
name: 'apiKey',
type: 'text',
placeholder: 'Enter API key',
popover: [
'<b>How to get the API key?</b>',
'Create an account in Mailgun.',
'Head to <b>Profile -> API Security -> Add new key.</b>'
]
},
{
label: 'Sender email',
name: 'from',
type: 'email',
placeholder: 'Enter email'
}
]
}
}
},
[ProviderTypes.Sms]: {
name: 'SMS',
text: 'SMS',
@@ -205,177 +378,5 @@ export const providers: ProvidersMap = {
]
}
}
},
[ProviderTypes.Email]: {
name: 'Email',
text: 'emails',
icon: 'mail',
providers: {
[Providers.Mailgun]: {
imageIcon: 'mailgun',
title: 'Mailgun',
description: '',
configure: [
{
label: 'API key',
name: 'apiKey',
type: 'text',
placeholder: 'Enter API key',
popover: [
'<b>How to get the API key?</b>',
'Create an account in Mailgun.',
'Head to <b>Profile -> API Security -> Add new key.</b>'
]
},
{
label: 'Domain',
name: 'domain',
type: 'domain',
placeholder: 'Enter domain',
popover: [
'<b>How to create a domain?</b>',
'Head to <b>Sending -> Domains -> Add new domain.</b>',
'Follow <b>Mailgun instructions</b> to verify the domain name.'
]
},
{
label: 'EU region',
name: 'isEuRegion',
type: 'switch',
description:
'Enable the EU region setting if your domain is within the European Union.'
},
{
label: 'Sender email',
name: 'from',
type: 'email',
placeholder: 'Enter email'
}
]
},
[Providers.Sendgrid]: {
imageIcon: 'sendgrid',
title: 'Sendgrid',
description: '',
configure: [
{
label: 'API key',
name: 'apiKey',
type: 'text',
placeholder: 'Enter API key',
popover: [
'<b>How to get the API key?</b>',
'Create an account in Mailgun.',
'Head to <b>Profile -> API Security -> Add new key.</b>'
]
},
{
label: 'Sender email',
name: 'from',
type: 'email',
placeholder: 'Enter email'
}
]
}
}
},
[ProviderTypes.Push]: {
name: 'Push notification',
text: 'notifications',
icon: 'device-mobile',
providers: {
[Providers.FCM]: {
imageIcon: 'firebase',
title: 'FCM',
description: 'Firebase Cloud Messaging',
configure: [
{
label: 'Server key (.json file)',
name: 'serverKey',
type: 'file',
allowedFileExtensions: ['json'],
placeholder: 'Enter server key',
popover: [
'<b>How to get the FCM server key?</b>',
'Head to <b>Project settings -> Service accounts -> Generate new private key.</b>',
'Generating the new key will result in the download of a JSON file.'
]
}
]
},
[Providers.APNS]: {
imageIcon: 'apple',
title: 'APNS',
description: 'Apple Push Notification Service',
configure: [
{
label: 'Team ID',
name: 'teamId',
type: 'text',
placeholder: 'Enter team ID',
popover: [
'<b>How to get the team ID?</b>',
'Head to <b>Apple Developer Member Center -> Membership details -> Team ID.</b>'
]
},
{
label: 'Bundle ID',
name: 'bundleId',
type: 'text',
placeholder: 'Enter bundle ID',
popover: [
'<b>How to get the bundle ID?</b>',
'Head to <b>Apple Developer Member Center -> Certificates, Identifiers & Profiles -> Identifiers.</b>',
`<a
href="/images/apns-bundle-id.png"
class="file-preview is-with-image"
target="_blank"
rel="noopener noreferrer"
aria-label="open file in new window">
<div class="file-preview-image">
<img
width="205"
height="125"
src="/images/apns-bundle-id.png"
alt="Screenshot of Bundle ID in Apple" />
</div>
<div class="file-preview-content">
<div class="avatar">
<span class="icon-external-link" aria-hidden="true" />
</div>
</div>
</a>`
]
},
{
label: 'Authentication key ID',
name: 'authKeyId',
type: 'text',
placeholder: 'Enter key ID',
popover: [
'<b>How to get the auth key ID?</b>',
'Head to <b>Apple Developer Member Center -> Certificates, Identifiers & Profiles -> Keys.</b>',
'Click on your key to view details.'
]
},
{
label: 'Auth key (.p8 file)',
name: 'authKey',
type: 'file',
allowedFileExtensions: ['p8'],
popover: [
'<b>How to get the authentication key?</b>',
'Head to <b>Apple Developer Member Center</b> (under Program resources) <b>-> Certificates, Identifiers & Profiles -> Keys.</b>',
'Create a key and give it a name. Enable the Apple Push Notifications service (APNS), and register your key.'
]
}
]
}
// [Providers.MQTT]: {
// imageIcon: 'mqtt',
// title: 'MQTT',
// description: 'Message Queuing Telemtry Transport'
// }
}
}
};
@@ -7,7 +7,8 @@
SearchQuery,
PaginationWithLimit,
Heading,
ViewSelector
ViewSelector,
EmptyFilter
} from '$lib/components';
import Create from './create.svelte';
import { goto } from '$app/navigation';
@@ -17,7 +18,7 @@
import type { PageData } from './$types';
import { columns, showCreate } from './store';
import { View } from '$lib/helpers/load';
import Filters from '$lib/components/filters/filters.svelte';
import { Filters, hasPageQueries } from '$lib/components/filters';
import Table from './table.svelte';
export let data: PageData;
@@ -79,6 +80,8 @@
limit={data.limit}
offset={data.offset}
total={data.topics.total} />
{:else if $hasPageQueries}
<EmptyFilter resource="topics" />
<!-- TODO: remove data.search != 'empty' when the API is ready with data -->
{:else if data.search && data.search != 'empty'}
<EmptySearch>
@@ -2,7 +2,7 @@ import { Query } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getQuery, getSearch, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import { queryParamToMap, queries } from '$lib/components/filters/store';
import { queryParamToMap, queries } from '$lib/components/filters';
import type { Topic } from '../store';
export const load = async ({ depends, url, route }) => {
@@ -7,7 +7,8 @@
SearchQuery,
PaginationWithLimit,
Heading,
ViewSelector
ViewSelector,
EmptyFilter
} from '$lib/components';
import { Container } from '$lib/layout';
import { ID } from '@appwrite.io/console';
@@ -22,7 +23,7 @@
import UserTargetsModal from '../../../userTargetsModal.svelte';
import { onMount } from 'svelte';
import type { Subscriber } from './+page';
import Filters from '$lib/components/filters/filters.svelte';
import { Filters, hasPageQueries } from '$lib/components/filters';
import { columns } from './store';
import { View } from '$lib/helpers/load';
@@ -137,6 +138,8 @@
limit={data.limit}
offset={data.offset}
total={data.subscribers.total} />
{:else if $hasPageQueries}
<EmptyFilter resource="subscribers" />
<!-- TODO: remove data.search != 'empty' when the API is ready with data -->
{:else if data.search && data.search != 'empty'}
<EmptySearch>
@@ -4,7 +4,7 @@ import { getLimit, getPage, getQuery, getSearch, pageToOffset } from '$lib/helpe
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
import type { Target } from '../../../store';
import { queryParamToMap, queries } from '$lib/components/filters/store';
import { queryParamToMap, queries } from '$lib/components/filters';
export type Subscriber = {
$id: string;
@@ -5,7 +5,7 @@ export const columns = writable<Column[]>([
{ id: '$id', title: 'Subscriber ID', type: 'string', show: true, width: 140 },
{ id: 'userName', title: 'Name', type: 'string', show: true, width: 100 },
{ id: 'targetId', title: 'Target ID', type: 'string', show: true, width: 140 },
{ id: 'target', title: 'Target', type: 'string', show: true, width: 140 },
{ id: 'type', title: 'Type', type: 'string', show: true, width: 80 },
{ id: 'target', title: 'Target', type: 'string', show: true, filter: false, width: 140 },
{ id: 'type', title: 'Type', type: 'string', show: true, filter: false, width: 80 },
{ id: '$createdAt', title: 'Created', type: 'string', show: true, width: 100 }
]);