reformat, misc fixes.

This commit is contained in:
ItzNotABug committed 2024-09-22 13:21:51 +05:30
1 parent 734198588c
commit 2814b6d991
4 files changed
+48 -32

No files matched your search

+6 -4
View File
@@ -4,10 +4,12 @@ import type { Models } from '@appwrite.io/console';
import { browser } from '$app/environment';
import type { NotificationPrefItem } from '$lib/helpers/notifications';
export type Account = Models.User<{
organization?: string;
notificationPrefs: Record<string, NotificationPrefItem>
} & Record<string, string>>;
export type Account = Models.User<
{
organization?: string;
notificationPrefs: Record<string, NotificationPrefItem>;
} & Record<string, string>
>;
export const user = derived(page, ($page) => {
if (browser) sessionStorage.setItem('account', JSON.stringify($page.data.account));
@@ -1,6 +1,14 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { Button, FormList, Helper, InputCheckbox, InputSelect, InputText, InputTime } from '$lib/elements/forms';
import {
Button,
FormList,
Helper,
InputCheckbox,
InputSelect,
InputText,
InputTime
} from '$lib/elements/forms';
import { ID } from '@appwrite.io/console';
import { capitalize } from '$lib/helpers/string';
import { backupRetainingOptions, database } from '../store';
@@ -118,10 +126,12 @@
resetFormVariables();
showCustomPolicy = false;
listOfCustomPolicies = [];
presetPolicies.update((all) => all.map((policy) => {
policy.checked = false;
return policy;
}));
presetPolicies.update((all) =>
all.map((policy) => {
policy.checked = false;
return policy;
})
);
}
</script>
@@ -173,7 +183,8 @@
policyRetention = policy.retained;
selectedTime = policy.selectedTime;
policyFrequency = policy.plainTextFrequency;
monthlyBackupFrequency = policy.monthlyBackupFrequency;
monthlyBackupFrequency =
policy.monthlyBackupFrequency;
// do not show in the list can cause confusion.
listOfCustomPolicies = [
@@ -268,8 +279,8 @@
<span>
{#if policyRetention === 365 * 100}
Every backup created under this policy will be retained <b
>forever</b
>.
>forever</b
>.
{:else}
Every backup created under this policy will be retained for <b>
{backupRetainingOptions.find(
@@ -300,7 +311,7 @@
on:click={() => {
showCustomPolicy = false;
}}
>Cancel
>Cancel
</Button>
<Button
@@ -323,7 +334,7 @@
{:else}
<div class="u-flex u-main-space-between u-padding-inline-4 u-width-full-line">
<button class="custom-policy-text" on:click={() => (showCustomPolicy = true)}
>Custom policy
>Custom policy
</button>
<span>Total: ${totalPolicies.length * policyPricing}.00</span>
</div>
@@ -91,13 +91,6 @@
return 'Runs daily';
}
};
// Switches to UTC for non-hourly,
// keeps local time for hourly schedules.
const isHourlySchedule = (cron: string): boolean => {
const [_, hour, dayOfMonth, month, dayOfWeek] = cron.split(' ');
return hour === '*' && dayOfMonth === '*' && month === '*' && dayOfWeek === '*';
};
</script>
<div class="u-flex u-flex-vertical u-gap-16">
@@ -112,7 +105,7 @@
class:u-padding-block-start-10={index !== 0}
class:opacity-gradient-bottom={index === 2}
data-show-every={showEveryPolicy}
data-visible={index < 3 || showEveryPolicy}>
data-visible={index <= 3 || showEveryPolicy}>
<div class="u-flex-vertical u-gap-2">
<div class="u-flex u-main-space-between">
<h3 class="body-text-2 u-bold darker-neutral-color">{policy.name}</h3>
@@ -174,7 +167,7 @@
class="u-flex u-gap-4 u-cross-center policy-item-subtitles darker-neutral-color">
{toLocaleDateTime(
parseExpression(policy.schedule, {
utc: !isHourlySchedule(policy.schedule)
utc: true
})
.next()
.toString()
@@ -215,7 +208,8 @@
{/each}
</div>
{#if !showEveryPolicy && policies.policies.length > 3}
{#if !showEveryPolicy && policies.policies.length >= 3}
<!-- TODO: @itznotabug show doesn't show on 3rd item if there are only 3 items. -->
<div class="is-only-mobile show-more-policy-wrapper">
<Button
secondary
@@ -367,11 +361,16 @@
.policy-card-item-padding[data-visible='true'][data-show-every='true']:nth-child(3) {
opacity: 1;
}
.policy-card-item-padding[data-visible='true'][data-show-every='true']:nth-child(3):not(
:last-child
) {
border-block-end: solid 0.0625rem hsl(var(--color-border)) !important;
}
.policy-card-item-padding[data-visible='true'][data-show-every='true']:nth-child(3)
.policy-cycles {
.policy-card-item-padding[data-visible='true'][data-show-every='true']:nth-child(3),
.policy-cycles {
height: auto !important;
visibility: visible !important;
}
@@ -76,16 +76,20 @@
}
};
$: cleanBackupName = (backup: Models.BackupArchive) =>
const policyName = (policyId: string | null) =>
data.policies.policies.find((policy) => policy.$id === policyId)?.name || 'Manual';
const cleanBackupName = (backup: Models.BackupArchive) =>
toLocaleDateTime(backup.$createdAt).replaceAll(',', '');
</script>
<TableScroll class="custom-height-table-column">
<TableScroll isSticky class="custom-height-table-column">
<TableHeader>
<TableCellHead width={192}>Backups</TableCellHead>
<TableCellHead width={120}>Size</TableCellHead>
<TableCellHead width={120}>Status</TableCellHead>
<TableCellHead width={120}>Policy</TableCellHead>
<TableCellHead width={48} />
</TableHeader>
<TableBody>
{#each data.backups.archives as backup, index}
@@ -93,7 +97,7 @@
<TableCell width={192} title={backup.$createdAt}>
{cleanBackupName(backup)}
</TableCell>
<TableCell width={90} title="Backup Size">
<TableCell width={120} title="Backup Size">
{#if backup.status === 'completed'}
{calculateSize(backup.size)}
{:else}
@@ -113,13 +117,13 @@
<!--{/if}-->
</div>
</TableCell>
<TableCell width={120} title="Backup Policy">
<TableCell width={168} title="Backup Policy">
<div class="u-flex u-main-space-between u-cross-baseline">
{backup.policyId ? backup.policyId : 'Manual'}
{policyName(backup.policyId)}
</div>
</TableCell>
<TableCell right>
<TableCell width={48}>
<div class="u-flex u-cross-center">
<DropList bind:show={showDropdown[index]} placement="bottom-end">
<button