fix: leftovers

This commit is contained in:
Torsten Dittmann
2024-12-10 02:29:01 +01:00
parent 5c4b6ed016
commit b4fc5324fc
3 changed files with 19 additions and 14 deletions
+5 -3
View File
@@ -50,10 +50,11 @@ function createPreferences() {
update,
get: (route?: Page['route']): Preferences => {
const $page = get(page);
const projectId = get(page).params.project;
route ??= $page.route;
const projectId = $page.params.project;
const routeId = route?.id ?? $page.route.id;
return (
preferences[projectId]?.[route.id] ?? {
preferences[projectId]?.[routeId] ?? {
limit: null,
view: null,
columns: null
@@ -64,6 +65,7 @@ function createPreferences() {
getCustomCollectionColumns: (collectionId: string): Preferences['columns'] => {
const $page = get(page);
const projectId = $page.params.project;
return preferences[projectId]?.collections?.[collectionId] ?? null;
},
setLimit: (limit: Preferences['limit']) =>
+2 -3
View File
@@ -1,4 +1,3 @@
import { getProjectId } from '$lib/helpers/project';
import { VARS } from '$lib/system';
import {
Account,
@@ -40,7 +39,7 @@ export function getApiEndpoint(region?: string): string {
const protocol = url.protocol;
const hostname = url.hostname;
const subdomain = getSubdomain(region);
console.log(`${protocol}//${subdomain}${hostname}/v1`);
return `${protocol}//${subdomain}${hostname}/v1`;
}
@@ -63,7 +62,7 @@ const clientConsole = new Client();
clientConsole.setEndpoint(endpoint).setProject('console');
const clientProject = new Client();
clientProject.setEndpoint(endpoint).setMode('admin');
clientProject.setMode('admin');
const sdkForProject = {
client: clientProject,
@@ -3,10 +3,10 @@ import { getLimit, getPage, getView, pageToOffset, View } from '$lib/helpers/loa
import { sdk } from '$lib/stores/sdk';
import { type Models, Query } from '@appwrite.io/console';
import { timeFromNow } from '$lib/helpers/date';
import type { PageLoad } from './$types';
import type { PageLoad, RouteParams } from './$types';
import type { BackupPolicy } from '$lib/sdk/backups';
export const load: PageLoad = async ({ url, route, depends }) => {
export const load: PageLoad = async ({ url, route, depends, params }) => {
depends(Dependencies.DATABASES);
const page = getPage(url);
@@ -14,7 +14,11 @@ export const load: PageLoad = async ({ url, route, depends }) => {
const view = getView(url, route, View.Grid);
const offset = pageToOffset(page, limit);
const { databases, policies, lastBackups } = await fetchDatabasesAndBackups(limit, offset);
const { databases, policies, lastBackups } = await fetchDatabasesAndBackups(
limit,
offset,
params
);
return {
offset,
@@ -27,20 +31,20 @@ export const load: PageLoad = async ({ url, route, depends }) => {
};
// TODO: @itznotabug we should improve this!
async function fetchDatabasesAndBackups(limit: number, offset: number) {
async function fetchDatabasesAndBackups(limit: number, offset: number, params: RouteParams) {
const databases = await sdk
.forProject(params.region, params.project)
.databases.list([Query.limit(limit), Query.offset(offset), Query.orderDesc('$createdAt')]);
const [policies, lastBackups] = await Promise.all([
await fetchPolicies(databases),
await fetchLastBackups(databases)
await fetchPolicies(databases, params),
await fetchLastBackups(databases, params)
]);
return { databases, policies, lastBackups };
}
async function fetchPolicies(databases: Models.DatabaseList) {
async function fetchPolicies(databases: Models.DatabaseList, params: RouteParams) {
const databasePolicies: Record<string, BackupPolicy[]> = {};
await Promise.all(
@@ -67,7 +71,7 @@ async function fetchPolicies(databases: Models.DatabaseList) {
return databasePolicies;
}
async function fetchLastBackups(databases: Models.DatabaseList) {
async function fetchLastBackups(databases: Models.DatabaseList, params: RouteParams) {
const lastBackups: Record<string, string> = {};
await Promise.all(