qfix: backups using pipeline (#9396)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-07-01 22:51:20 +07:00
committed by GitHub
parent 4646d271c9
commit a23326fd6b
38 changed files with 2553 additions and 2793 deletions
@@ -15,7 +15,7 @@
<script lang="ts">
import { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
import { getMetadata } from '@hcengineering/platform'
import presentation from '@hcengineering/presentation'
import presentation, { getFileUrl } from '@hcengineering/presentation'
import { Breadcrumb, Button, Expandable, Header, Label, Loading } from '@hcengineering/ui'
import Scroller from '@hcengineering/ui/src/components/Scroller.svelte'
import view from '@hcengineering/view'
@@ -34,6 +34,7 @@
let backupInfo:
| {
files: { name: string, size: number }[]
extraBlobs: { name: string, size: number, contentType: string }[]
error?: string
info?: BackupInfo
}
@@ -116,14 +117,14 @@
return ''
}
function getFileUrl (filename: string): string {
function getBackupFileUrl (filename: string): string {
return `${backupUrl}/${workspaceUuid}/${filename}`
}
async function downloadFile (filename: string): Promise<void> {
async function doDownload (downloadUrl: string, filename?: string): Promise<void> {
const a = document.createElement('a')
try {
const response = await fetch(getFileUrl(filename), {
const response = await fetch(downloadUrl, {
headers: {
Authorization: `Bearer ${token}`
}
@@ -132,7 +133,9 @@
const blob = await response.blob()
const url = window.URL.createObjectURL(blob)
a.href = url
a.download = filename
if (filename !== undefined) {
a.download = filename
}
document.body.appendChild(a)
a.click()
window.URL.revokeObjectURL(url)
@@ -142,12 +145,23 @@
document.body.removeChild(a)
}
}
async function downloadFile (filename: string): Promise<void> {
const url = getBackupFileUrl(filename)
await doDownload(url, filename)
}
async function downloadBlobFile (filename: string): Promise<void> {
const url = getFileUrl(filename)
await doDownload(url, filename)
}
let copied = false
let copied2 = false
$: snapshots = backupInfo?.info?.snapshots ?? []
$: snapshorsr = [...(backupInfo?.info?.snapshots ?? [])].reverse()
$: blobs = (backupInfo?.extraBlobs ?? []).sort((a, b) => b.size - a.size)
</script>
<div class="hulyComponent flex-no-shrink">
@@ -281,7 +295,6 @@
<div class="error">{backupInfo.error}</div>
{/if}
</Expandable>
<Expandable expanded={true} bordered>
<svelte:fragment slot="title">
<div class="p-1">
@@ -312,13 +325,13 @@
<div class="wrap">
<Label label={setting.string.BackupLinkInfo} />
<div class="select-text anti-component p-3 border-b-1 border-divider-color">
{getFileUrl('index.html')}
{getBackupFileUrl('index.html')}
</div>
</div>
<Button
label={copied ? view.string.Copied : view.string.CopyToClipboard}
on:click={() => {
void navigator.clipboard.writeText(getFileUrl('index.html')).then(() => {
void navigator.clipboard.writeText(getBackupFileUrl('index.html')).then(() => {
copied = true
setTimeout(() => {
copied = false
@@ -344,6 +357,28 @@
</div>
</div>
</Expandable>
<Expandable expanded={false} bordered>
<svelte:fragment slot="title">
<div class="p-1">
<Label label={setting.string.NonBackupedBlobs} />
{blobs.length}
</div>
</svelte:fragment>
<div class="p-1">
{#each blobs as file}
<div class="file-item">
<div class="file-name">{file.name}</div>
<div class="file-info">
<span class="file-size">{getSize(file.size)}</span>
<span class="file-content-type">{file.contentType}</span>
<div class="file-actions">
<Button label={setting.string.BackupFileDownload} on:click={() => downloadBlobFile(file.name)} />
</div>
</div>
</div>
{/each}
</div>
</Expandable>
{/if}
</Scroller>
</div>