client/src/routes/app/+page.svelte (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
<script lang="ts"> import { page } from '$app/stores'; let databases = [ { name: 'Database 1', lastTransaction: '2023-09-01', created: '2023-01-15', status: 'active', storageUsed: 383 // bytes }, { name: 'Database 2', lastTransaction: '2023-09-05', created: '2023-02-20', status: 'warning', storageUsed: 823548 // bytes }, { name: 'Database 3', lastTransaction: '2023-09-10', created: '2023-03-25', status: 'critical', storageUsed: 1373741824 // bytes }, { name: 'Database 1', lastTransaction: '2023-09-01', created: '2023-01-15', status: 'active', storageUsed: 383 // bytes }, { name: 'Database 2', lastTransaction: '2023-09-05', created: '2023-02-20', status: 'warning', storageUsed: 823548 // bytes }, { name: 'Database 3', lastTransaction: '2023-09-10', created: '2023-03-25', status: 'critical', storageUsed: 1373741824 // bytes }, { name: 'Database 1', lastTransaction: '2023-09-01', created: '2023-01-15', status: 'active', storageUsed: 383 // bytes }, { name: 'Database 2', lastTransaction: '2023-09-05', created: '2023-02-20', status: 'warning', storageUsed: 823548 // bytes }, { name: 'Database 3', lastTransaction: '2023-09-10', created: '2023-03-25', status: 'critical', storageUsed: 1373741824 // bytes } ]; function formatDate(dateString: string): string { const options: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'long', year: 'numeric' }; return new Date(dateString).toLocaleDateString(undefined, options); } function getStatusColor(status: string): string { switch (status) { case 'active': return 'bg-green-500'; case 'warning': return 'bg-yellow-500'; case 'critical': return 'bg-red-500'; default: return 'bg-gray-500'; } } function formatStorage(bytes: number): string { const units = ['bytes', 'KB', 'MB', 'GB', 'TB']; let unitIndex = 0; let value = bytes; while (value >= 1024 && unitIndex < units.length - 1) { value /= 1024; unitIndex++; } const formattedValue = value.toFixed(2); return `${parseFloat(formattedValue)} ${units[unitIndex]}`; } </script> <div> <div class="flex h-[50px] items-center justify-between border-b border-zinc-300 px-3"> <p>Database Manager</p> <div class="flex items-center gap-2"> <button class="rounded-lg bg-zinc-700 px-2 py-1 font-medium text-white">New Database</button> <button class="rounded-lg border border-zinc-400 bg-zinc-100 px-2 py-1 font-medium text-black" >New Server</button > </div> </div> <div class="m-3 grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5" > {#each databases as db} <div class="card cursor-pointer rounded-lg border border-zinc-200 bg-zinc-50 p-3 hover:bg-zinc-100" > <div class="mb-2 flex items-center justify-between"> <p class="mr-2">{db.name}</p> <span class="-mt-2 h-2 w-2 rounded-full {getStatusColor(db.status)}"></span> </div> <p class="mb-2 text-sm text-zinc-500"> Storage Used: {formatStorage(db.storageUsed)} </p> <p class="text-sm text-zinc-500"> Last Transaction: {formatDate(db.lastTransaction)} </p> <p class="text-sm text-zinc-500"> Created: {formatDate(db.created)} </p> </div> {/each} </div> <details class="m-3 hidden rounded-lg border border-zinc-200 bg-zinc-100 p-3"> <summary>User Details</summary> <pre> {JSON.stringify(JSON.parse(JSON.stringify($page.data.session?.user)), null, 2)} </pre> </details> </div> |