|
26 | 26 | import { addNotification } from '$lib/stores/notifications'; |
27 | 27 | import { Click, Submit, trackError, trackEvent } from '$lib/actions/analytics'; |
28 | 28 | import { isSmallViewport } from '$lib/stores/viewport'; |
29 | | - import { IconChevronDown, IconChevronUp, IconPlus } from '@appwrite.io/pink-icons-svelte'; |
| 29 | + import { |
| 30 | + IconChevronDown, |
| 31 | + IconChevronUp, |
| 32 | + IconPlus, |
| 33 | + IconRefresh |
| 34 | + } from '@appwrite.io/pink-icons-svelte'; |
30 | 35 | import type { Models } from '@appwrite.io/console'; |
31 | 36 | import EmptySheet from './layout/emptySheet.svelte'; |
32 | 37 | import CreateRow from './rows/create.svelte'; |
33 | 38 | import { onDestroy } from 'svelte'; |
34 | 39 | import { isCloud } from '$lib/system'; |
35 | 40 | import { Empty as SuggestionsEmptySheet, tableColumnSuggestions } from '../(suggestions)'; |
| 41 | + import { invalidate } from '$app/navigation'; |
| 42 | + import { Dependencies } from '$lib/constants'; |
36 | 43 |
|
37 | 44 | export let data: PageData; |
38 | 45 |
|
| 46 | + let isRefreshing = false; |
39 | 47 | let showImportCSV = false; |
40 | 48 |
|
41 | 49 | // todo: might need a type fix here. |
|
147 | 155 | <svelte:fragment slot="tooltip">Filters</svelte:fragment> |
148 | 156 | </Tooltip> |
149 | 157 | </Layout.Stack> |
150 | | - <Layout.Stack direction="row" alignItems="center" justifyContent="flex-end"> |
151 | | - <Button |
152 | | - secondary |
153 | | - event={Click.DatabaseImportCsv} |
154 | | - disabled={!(hasColumns && hasValidColumns)} |
155 | | - on:click={() => (showImportCSV = true)}> |
156 | | - Import CSV |
157 | | - </Button> |
158 | | - {#if !$isSmallViewport} |
| 158 | + <Layout.Stack |
| 159 | + direction="row" |
| 160 | + alignItems="center" |
| 161 | + justifyContent="flex-end" |
| 162 | + style="padding-right: 40px;"> |
| 163 | + <Layout.Stack direction="row" alignItems="center" justifyContent="flex-end"> |
159 | 164 | <Button |
160 | 165 | secondary |
161 | | - event="create_row" |
| 166 | + event={Click.DatabaseImportCsv} |
162 | 167 | disabled={!(hasColumns && hasValidColumns)} |
163 | | - on:click={() => ($showRowCreateSheet.show = true)}> |
164 | | - <Icon icon={IconPlus} slot="start" size="s" /> |
165 | | - Create row |
| 168 | + on:click={() => (showImportCSV = true)}> |
| 169 | + Import CSV |
166 | 170 | </Button> |
| 171 | + {#if !$isSmallViewport} |
| 172 | + <Button |
| 173 | + secondary |
| 174 | + event="create_row" |
| 175 | + disabled={!(hasColumns && hasValidColumns)} |
| 176 | + on:click={() => ($showRowCreateSheet.show = true)}> |
| 177 | + <Icon icon={IconPlus} slot="start" size="s" /> |
| 178 | + Create row |
| 179 | + </Button> |
167 | 180 |
|
168 | | - <Button |
169 | | - icon |
170 | | - size="s" |
171 | | - secondary |
172 | | - class="small-button-dimensions" |
173 | | - on:click={() => { |
174 | | - $expandTabs = !$expandTabs; |
175 | | - preferences.setKey('tableHeaderExpanded', $expandTabs); |
176 | | - }}> |
177 | | - <Icon icon={!$expandTabs ? IconChevronDown : IconChevronUp} size="s" /> |
178 | | - </Button> |
179 | | - {/if} |
| 181 | + <Button |
| 182 | + icon |
| 183 | + size="s" |
| 184 | + secondary |
| 185 | + class="small-button-dimensions" |
| 186 | + on:click={() => { |
| 187 | + $expandTabs = !$expandTabs; |
| 188 | + preferences.setKey('tableHeaderExpanded', $expandTabs); |
| 189 | + }}> |
| 190 | + <Icon |
| 191 | + icon={!$expandTabs ? IconChevronDown : IconChevronUp} |
| 192 | + size="s" /> |
| 193 | + </Button> |
| 194 | + |
| 195 | + <Tooltip disabled={isRefreshing || !data.rows.total} placement="top"> |
| 196 | + <Button |
| 197 | + icon |
| 198 | + size="s" |
| 199 | + secondary |
| 200 | + disabled={isRefreshing || |
| 201 | + !data.rows.total || |
| 202 | + !(hasColumns && hasValidColumns)} |
| 203 | + class="small-button-dimensions" |
| 204 | + on:click={async () => { |
| 205 | + isRefreshing = true; |
| 206 | + await invalidate(Dependencies.TABLE); |
| 207 | + isRefreshing = false; |
| 208 | + }}> |
| 209 | + <div style:line-height="0px" class:rotating={isRefreshing}> |
| 210 | + <Icon icon={IconRefresh} size="s" /> |
| 211 | + </div> |
| 212 | + </Button> |
| 213 | + |
| 214 | + <svelte:fragment slot="tooltip">Refresh</svelte:fragment> |
| 215 | + </Tooltip> |
| 216 | + {/if} |
| 217 | + </Layout.Stack> |
180 | 218 | </Layout.Stack> |
181 | 219 | </Layout.Stack> |
182 | 220 | {#if $isSmallViewport} |
|
282 | 320 | width: 32px !important; |
283 | 321 | height: 32px !important; |
284 | 322 | } |
| 323 | +
|
| 324 | + :global(.rotating) { |
| 325 | + animation: rotate 1s linear infinite; |
| 326 | + } |
| 327 | +
|
| 328 | + @keyframes rotate { |
| 329 | + from { |
| 330 | + transform: rotate(0deg); |
| 331 | + } |
| 332 | + to { |
| 333 | + transform: rotate(360deg); |
| 334 | + } |
| 335 | + } |
285 | 336 | </style> |
0 commit comments