Merge remote-tracking branch 'origin/feat-pink-v2' into feat-pink-v2

This commit is contained in:
ernstmul
2025-03-24 12:20:59 +01:00
20 changed files with 223 additions and 107 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
"e2e:ui": "playwright test tests/e2e --ui"
},
"dependencies": {
"@appwrite.io/console": "https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@74f9464",
"@appwrite.io/console": "https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@08b7400",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@64948b6 ",
"@appwrite.io/pink-legacy": "^1.0.3",
+5 -5
View File
@@ -9,8 +9,8 @@ importers:
.:
dependencies:
'@appwrite.io/console':
specifier: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@74f9464
version: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@74f9464
specifier: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@08b7400
version: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@08b7400
'@appwrite.io/pink-icons':
specifier: 0.25.0
version: 0.25.0
@@ -211,8 +211,8 @@ packages:
'@analytics/type-utils@0.6.2':
resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==}
'@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@74f9464':
resolution: {tarball: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@74f9464}
'@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@08b7400':
resolution: {tarball: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@08b7400}
version: 1.2.1
'@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@11e065399ceac01b462887282f593271ec8b29a4':
@@ -4241,7 +4241,7 @@ snapshots:
'@analytics/type-utils@0.6.2': {}
'@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@74f9464': {}
'@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@08b7400': {}
'@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@11e065399ceac01b462887282f593271ec8b29a4(svelte@4.2.19)':
dependencies:
+26
View File
@@ -114,3 +114,29 @@ export function formatTimeDetailed(time: number): string {
return parts.join(' ');
}
/**
* Calculates the time difference between a starting date/time and the current time.
* Returns the difference formatted in seconds, minutes, or hours depending on the magnitude.
*
* @export
* @param {Date | number | string} startTime - The starting date/time, timestamp in milliseconds, or ISO date string (e.g., '2025-03-20T15:50:43.495+00:00')
* @returns {string} The formatted time difference
*/
export function timer(startTime: Date | number | string): string {
let start: number;
if (startTime instanceof Date) {
start = startTime.getTime();
} else if (typeof startTime === 'number') {
start = startTime;
} else {
// Handle ISO date string format
start = new Date(startTime).getTime();
}
const now = new Date().getTime();
const diffInSeconds = (now - start) / 1000;
return calculateTime(diffInSeconds);
}
@@ -67,7 +67,17 @@
</Layout.Stack>
{#if requestTab === 'parameters'}
{#if parameters?.length}
<Table.Root columns={2} let:root>
<Table.Root
columns={[
{
id: 'key',
width: 200
},
{
id: 'value'
}
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell {root}>Key</Table.Header.Cell>
<Table.Header.Cell {root}>Value</Table.Header.Cell>
@@ -86,7 +96,17 @@
{/if}
{:else if requestTab === 'headers'}
{#if selectedLog.requestHeaders?.length}
<Table.Root columns={2} let:root>
<Table.Root
columns={[
{
id: 'key',
width: 200
},
{
id: 'value'
}
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell {root}>Key</Table.Header.Cell>
<Table.Header.Cell {root}>Value</Table.Header.Cell>
@@ -81,7 +81,17 @@
{/if}
{:else if responseTab === 'headers'}
{#if selectedLog.responseHeaders?.length}
<Table.Root columns={2} let:root>
<Table.Root
columns={[
{
id: 'key',
width: 200
},
{
id: 'value'
}
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell {root}>Key</Table.Header.Cell>
<Table.Header.Cell {root}>Value</Table.Header.Cell>
@@ -2,12 +2,12 @@ import type { Column } from '$lib/helpers/types';
import { writable } from 'svelte/store';
export const columns = writable<Column[]>([
{ id: '$id', title: 'Execution ID', type: 'string', width: 200 },
{ id: '$id', title: 'Execution ID', type: 'string', width: { min: 200, max: 250 } },
{
id: 'requestPath',
title: 'Path',
type: 'string',
width: 90,
width: { min: 100, max: 200 },
format: 'string'
},
@@ -16,7 +16,7 @@ export const columns = writable<Column[]>([
title: 'Trigger',
type: 'string',
hide: true,
width: 90,
width: { min: 90, max: 200 },
array: true,
format: 'enum',
elements: [
@@ -30,7 +30,7 @@ export const columns = writable<Column[]>([
title: 'Method',
type: 'string',
hide: true,
width: 70,
width: { min: 90, max: 200 },
array: true,
format: 'enum',
elements: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
@@ -40,7 +40,7 @@ export const columns = writable<Column[]>([
title: 'Status code',
type: 'integer',
hide: true,
width: 100,
width: { min: 100, max: 200 },
format: 'integer',
elements: [
{
@@ -66,7 +66,7 @@ export const columns = writable<Column[]>([
id: 'status',
title: 'Status',
type: 'enum',
width: 130,
width: { min: 130, max: 200 },
array: true,
format: 'enum',
elements: ['completed', 'failed', 'waiting', 'scheduled', 'processing', 'cancelled']
@@ -75,7 +75,8 @@ export const columns = writable<Column[]>([
id: 'duration',
title: 'Duration',
type: 'integer',
width: 80,
width: { min: 80, max: 200 },
format: 'integer',
elements: [
{
@@ -96,7 +97,7 @@ export const columns = writable<Column[]>([
id: '$createdAt',
title: 'Created',
type: 'datetime',
width: 120,
width: { min: 120, max: 200 },
format: 'datetime',
elements: [
{
@@ -22,6 +22,10 @@
import { columns } from './store';
import { View } from '$lib/helpers/load';
import Table from './table.svelte';
import { onMount } from 'svelte';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
export let data;
let show = false;
@@ -41,6 +45,14 @@
]);
$updateCommandGroupRanks({ sites: 1000 });
onMount(() => {
return sdk.forConsole.client.subscribe('console', (response) => {
if (response.events.includes(`sites.*`)) {
invalidate(Dependencies.SITES);
}
});
});
</script>
<Container>
@@ -60,7 +72,7 @@
</Layout.Stack>
{#if data.siteList.total}
{#if data.view === View.Grid}
<Grid deployments={data.deployments} siteList={data.siteList} />
<Grid siteList={data.siteList} />
{:else}
<Table siteList={data.siteList} />
{/if}
@@ -17,35 +17,11 @@ export const load = async ({ url, depends, route }) => {
search || undefined
);
// TODO: @Meldiron Discuss better solution for getting screnshot IDs
const deployments: Models.Deployment[] = [];
await Promise.all(
siteList.sites.map(async (site) => {
if (!site.deploymentId) {
return;
}
// TODO: @Meldiron Tripple-check if this can ever happened
// It happened to me but on QA that might have corrupted data
try {
const deployment = await sdk.forProject.sites.getDeployment(
site.$id,
site.deploymentId
);
deployments.push(deployment);
} catch (err) {
// Active deployment no longer available (deleted?)
console.warn(err);
}
})
);
return {
offset,
limit,
search,
siteList,
deployments,
view
};
};
@@ -37,6 +37,7 @@
export let frameworks: Models.Framework[];
export let selectedFramework: Models.Framework;
$: frameworkData = frameworks.find((framework) => framework.key === selectedFramework?.key);
$: ssr = frameworkData?.adapters.find((adapter) => adapter.key === 'ssr');
export let variables: Partial<Models.Variable>[] = [];
export let installCommand = '';
@@ -54,9 +55,9 @@
let frameworkId = selectedFramework.key;
$: if (!installCommand || !buildCommand || !outputDirectory) {
installCommand ||= frameworkData?.adapters?.ssr?.installCommand;
buildCommand ||= frameworkData?.adapters?.ssr?.buildCommand;
outputDirectory ||= frameworkData?.adapters?.ssr?.outputDirectory;
installCommand ||= ssr?.installCommand;
buildCommand ||= ssr?.buildCommand;
outputDirectory ||= ssr?.outputDirectory;
}
</script>
@@ -86,15 +87,12 @@
id="installCommand"
label="Install command"
bind:value={installCommand}
placeholder={frameworkData?.adapters?.ssr?.installCommand} />
placeholder={ssr?.installCommand} />
<Button
secondary
size="s"
disabled={frameworkData?.adapters?.ssr?.installCommand ===
installCommand}
on:click={() =>
(installCommand =
frameworkData?.adapters?.ssr?.installCommand)}>
disabled={ssr?.installCommand === installCommand}
on:click={() => (installCommand = ssr?.installCommand)}>
Reset
</Button>
</Layout.Stack>
@@ -103,14 +101,12 @@
id="buildCommand"
label="Build command"
bind:value={buildCommand}
placeholder={frameworkData?.adapters?.ssr?.buildCommand} />
placeholder={ssr?.buildCommand} />
<Button
secondary
size="s"
disabled={frameworkData?.adapters?.ssr?.buildCommand ===
buildCommand}
on:click={() =>
(buildCommand = frameworkData?.adapters?.ssr?.buildCommand)}>
disabled={ssr?.buildCommand === buildCommand}
on:click={() => (buildCommand = ssr?.buildCommand)}>
Reset
</Button>
</Layout.Stack>
@@ -119,15 +115,12 @@
id="outputDirectory"
label="Output directory"
bind:value={outputDirectory}
placeholder={frameworkData?.adapters?.ssr?.outputDirectory} />
placeholder={ssr?.outputDirectory} />
<Button
secondary
size="s"
disabled={frameworkData?.adapters?.ssr?.outputDirectory ===
outputDirectory}
on:click={() =>
(outputDirectory =
frameworkData?.adapters?.ssr?.outputDirectory)}>
disabled={ssr?.outputDirectory === outputDirectory}
on:click={() => (outputDirectory = ssr?.outputDirectory)}>
Reset
</Button>
</Layout.Stack>
@@ -3,7 +3,7 @@
import { page } from '$app/stores';
import { timeFromNow } from '$lib/helpers/date';
import type { Models } from '@appwrite.io/console';
import { Card, Layout, Tooltip } from '@appwrite.io/pink-svelte';
import { Card, Icon, Layout, Popover, Tooltip, Typography } from '@appwrite.io/pink-svelte';
import { getFrameworkIcon } from './store';
import { SvgIcon } from '$lib/components';
import { app } from '$lib/stores/app';
@@ -11,25 +11,24 @@
import AddCollaboratorModal from './(components)/addCollaboratorModal.svelte';
import SitesActionMenu from './sitesActionMenu.svelte';
import { capitalize } from '$lib/helpers/string';
import { timer } from '$lib/helpers/timeConversion';
import { IconExclamation } from '@appwrite.io/pink-icons-svelte';
import { Link } from '$lib/elements';
export let siteList: Models.SiteList;
export let deployments: Models.Deployment[];
let showAddCollaborator = false;
let selectedSite: Models.Site = null;
function getScreenshot(theme: string, site: Models.Site) {
const deployment =
deployments.find((d) => site.deploymentId && d.$id === site.deploymentId) ?? null;
if (theme === 'dark') {
return deployment?.screenshotDark
? getFilePreview(deployment.screenshotDark)
return site?.deploymentScreenshotDark
? getFilePreview(site?.deploymentScreenshotDark)
: `${base}/images/sites/screenshot-placeholder-dark.svg`;
}
return deployment?.screenshotLight
? getFilePreview(deployment.screenshotLight)
return site?.deploymentScreenshotLight
? getFilePreview(site?.deploymentScreenshotLight)
: `${base}/images/sites/screenshot-placeholder-light.svg`;
}
@@ -38,6 +37,14 @@
const endpoint = getApiEndpoint();
return endpoint + `/storage/buckets/screenshots/files/${fileId}/view?project=console`;
}
function generateDesc(site: Models.Site) {
if (site.latestDeploymentStatus === 'building') {
return `Deployment building ${timer(site.latestDeploymentCreatedAt)}`;
} else {
return `Deployed ${timeFromNow(site.deploymentCreatedAt)}`;
}
}
</script>
<Layout.Grid columns={3} columnsXS={1} columnsXXS={1}>
@@ -47,7 +54,7 @@
padding="xxs">
<Card.Media
title={site.name}
description={`Updated ${timeFromNow(site.$updatedAt)}`}
description={generateDesc(site)}
src={getScreenshot($app.themeInUse, site)}
alt={site.name}
avatar>
@@ -60,6 +67,31 @@
</Tooltip>
</svelte:fragment>
<SitesActionMenu {site} bind:showAddCollaborator bind:selectedSite />
<svelte:fragment slot="description-end">
{#if site.latestDeploymentStatus === 'failed'}
<Popover let:toggle portal>
<button on:mouseenter={(e) => toggle(e)}>
<Layout.Stack alignItems="center">
<Icon
icon={IconExclamation}
size="s"
color="--bgcolor-warning" />
</Layout.Stack>
</button>
<svelte:fragment slot="tooltip">
<Typography.Text variant="m-400">
Last deployment failed {timeFromNow(
site.latestDeploymentCreatedAt
)}. <Link
href={`${base}/project-${$page.params.project}/sites/site-${site.$id}/deployments/deployment-${site.latestDeploymentId}`}>
View logs
</Link>
</Typography.Text>
</svelte:fragment>
</Popover>
{/if}
</svelte:fragment>
</Card.Media>
</Card.Link>
{/each}
@@ -25,8 +25,8 @@
}
if (message.events.includes('sites.*.deployments.*.update')) {
invalidate(Dependencies.DEPLOYMENTS);
invalidate(Dependencies.FUNCTION);
invalidate(Dependencies.SITE);
console.log(message);
return;
}
if (message.events.includes('sites.*.deployments.*.delete')) {
@@ -19,7 +19,7 @@ export const columns = writable<Column[]>([
id: 'buildDuration',
title: 'Build duration',
type: 'integer',
width: { min: 110, max: 170 },
width: { min: 110, max: 190 },
elements: [
{
@@ -37,12 +37,32 @@ export const columns = writable<Column[]>([
],
filter: false
},
{
id: 'totalSize',
title: 'Total size',
type: 'integer',
width: { min: 110, max: 190 },
elements: [
{
value: 2 * 1000 * 1000,
label: 'more than 2MB'
},
{
value: 10 * 1000 * 1000,
label: 'more than 10MB'
},
{
value: 50 * 1000 * 1000,
label: 'more than 50MB'
}
]
},
{
id: 'sourceSize',
title: 'Source size',
type: 'integer',
hide: true,
width: { min: 110, max: 170 },
width: { min: 110, max: 190 },
elements: [
{
value: 2 * 1000 * 1000,
@@ -62,14 +82,15 @@ export const columns = writable<Column[]>([
id: 'buildSize',
title: 'Build size',
type: 'integer',
hide: true,
filter: false,
width: { min: 90, max: 140 }
width: { min: 90, max: 190 }
},
{
id: 'type',
title: 'Source',
type: 'string',
width: { min: 90, max: 140 },
width: { min: 90, max: 160 },
array: true,
format: 'enum',
elements: [
@@ -68,6 +68,8 @@
{:else}
{formatTimeDetailed(deployment.buildDuration)}
{/if}
{:else if column.id === 'totalSize'}
{calculateSize(deployment.totalSize)}
{:else if column.id === 'sourceSize'}
{calculateSize(deployment.sourceSize)}
{:else if column.id === 'buildSize'}
@@ -43,7 +43,15 @@
</Button>
</Layout.Stack>
{#if deploymentList?.total}
<Table.Root columns={5} let:root>
<Table.Root
columns={[
{ id: '$id', width: 200 },
{ id: 'status' },
{ id: 'source' },
{ id: 'createdBy' },
{ id: 'actions' }
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell {root}>Deployment ID</Table.Header.Cell>
<Table.Header.Cell {root}>Status</Table.Header.Cell>
@@ -7,19 +7,19 @@ export const columns = writable<Column[]>([
title: 'Domain',
type: 'string',
format: 'string',
width: { min: 200, max: 700 }
width: { min: 200, max: 550 }
},
{
id: 'redirectUrl',
title: 'Redirect to',
type: 'string',
width: { min: 120, max: 300 }
width: { min: 120, max: 400 }
},
{
id: 'deploymentVcsProviderBranch',
title: 'Production branch',
type: 'string',
width: { min: 90, max: 200 }
width: { min: 90, max: 220 }
}
]);
@@ -86,7 +86,17 @@
{/if}
{:else if requestTab === 'headers'}
{#if selectedLog.requestHeaders?.length}
<Table.Root columns={2} let:root>
<Table.Root
columns={[
{
id: 'key',
width: 200
},
{
id: 'value'
}
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell {root}>Key</Table.Header.Cell>
<Table.Header.Cell {root}>Value</Table.Header.Cell>
@@ -73,7 +73,17 @@
{/if}
{:else if responseTab === 'headers'}
{#if selectedLog.responseHeaders?.length}
<Table.Root columns={2} let:root>
<Table.Root
columns={[
{
id: 'key',
width: 200
},
{
id: 'value'
}
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell {root}>Key</Table.Header.Cell>
<Table.Header.Cell {root}>Value</Table.Header.Cell>
@@ -52,8 +52,6 @@
showConnectRepo.set(true);
}
});
$: console.log(data);
</script>
<Container>
@@ -28,15 +28,12 @@
let fallback = site.fallbackFile;
let isButtonDisabled = true;
let showFallback = site.adapter === Adapter.Static;
$: frameworkAdapterData = selectedFramework.adapters.find((a) => a.key === adapter);
onMount(async () => {
installCommand =
site?.installCommand ?? selectedFramework.adapters[site.adapter].defaultInstallCommand;
buildCommand =
site?.buildCommand ?? selectedFramework.adapters[site.adapter].defaultBuildCommand;
outputDirectory =
site?.outputDirectory ??
selectedFramework.adapters[site.adapter].defaultOutputDirectory;
installCommand = site?.installCommand ?? frameworkAdapterData?.installCommand;
buildCommand = site?.buildCommand ?? frameworkAdapterData?.buildCommand;
outputDirectory = site?.outputDirectory ?? frameworkAdapterData?.outputDirectory;
});
async function updateName() {
@@ -89,8 +86,7 @@
$: if (adapter === Adapter.Static) {
showFallback = true;
fallback ||= selectedFramework.adapters.static.fallbackFile;
console.log(fallback, selectedFramework.adapters.static);
fallback ||= selectedFramework.adapters.find((a) => a.key === Adapter.Static).fallbackFile;
} else {
showFallback = false;
fallback = undefined;
@@ -100,15 +96,12 @@
fallback = null;
}
$: frameworkDataAdapter = selectedFramework.adapters?.length
? selectedFramework.adapters[site.adapter]
: frameworks[0].adapters[site.adapter];
//TODO: fix after backend type is fixed
$: if (selectedFramework?.adapters?.length <= 1 || !selectedFramework?.adapters?.ssr?.key) {
$: hasSSR = selectedFramework?.adapters?.some((a) => a?.key === Adapter.Ssr);
$: hasStatic = selectedFramework?.adapters?.some((a) => a?.key === Adapter.Static);
$: if (selectedFramework?.adapters?.length <= 1 || !hasSSR) {
adapter = Adapter.Static;
}
$: if (selectedFramework?.adapters?.length <= 1 || !selectedFramework?.adapters?.static?.key) {
$: if (selectedFramework?.adapters?.length <= 1 || !hasStatic) {
adapter = Adapter.Ssr;
}
</script>
@@ -139,7 +132,7 @@
(framework) => framework.key === frameworkKey
);
}} />
{#if selectedFramework.adapters?.length || (selectedFramework.adapters?.ssr?.key && selectedFramework.adapters?.static?.key)}
{#if selectedFramework.adapters?.length > 2}
<Layout.Grid columnsXS={1} columns={2} gap="l">
<Card.Selector
title="Server side rendering"
@@ -202,7 +195,7 @@
id="installCommand"
label="Install command"
bind:value={installCommand}
placeholder={frameworkDataAdapter?.defaultInstallCommand} />
placeholder={frameworkAdapterData?.installCommand} />
<Button
secondary
@@ -220,7 +213,7 @@
id="buildCommand"
label="Build command"
bind:value={buildCommand}
placeholder={frameworkDataAdapter?.defaultBuildCommand} />
placeholder={frameworkAdapterData?.buildCommand} />
<Button
secondary
size="s"
@@ -237,7 +230,7 @@
id="outputDirectory"
label="Output directory"
bind:value={outputDirectory}
placeholder={frameworkDataAdapter?.defaultOutputDirectory} />
placeholder={frameworkAdapterData?.outputDirectory} />
<Button
secondary
size="s"
@@ -309,7 +309,11 @@
</Alert.Inline>
{/if}
<Table.Root
columns={[{ id: 'key' }, { id: 'value' }, { id: 'actions', width: 30 }]}
columns={[
{ id: 'key', width: { min: 200, max: 400 } },
{ id: 'value', width: { min: 200, max: 400 } },
{ id: 'actions', width: 50 }
]}
let:root>
<svelte:fragment slot="header" let:root>
<Table.Header.Cell column="key" {root}>Key</Table.Header.Cell>