uberf-7434: show dowload progress (#5944)

This commit is contained in:
Alexey Zinoviev 2024-06-29 17:22:19 +04:00 committed by GitHub
parent 6af082e66f
commit d8b4b84c9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 58 additions and 21 deletions

View File

@ -704,3 +704,13 @@ export function setPresentationCookie (token: string, workspaceId: string): void
}
setToken('/files/' + workspaceId)
}
export const upgradeDownloadProgress = writable(0)
export function setDownloadProgress (percent: number): void {
if (Number.isNaN(percent)) {
return
}
upgradeDownloadProgress.set(Math.round(percent))
}

View File

@ -15,6 +15,7 @@
<script lang="ts">
import { getMetadata } from '@hcengineering/platform'
import { Label, Loading, Notifications, location } from '@hcengineering/ui'
import { upgradeDownloadProgress } from '@hcengineering/presentation'
import { connect, versionError } from '../connect'
import { guestId } from '@hcengineering/guest'
@ -31,6 +32,11 @@
<div class="antiPopup version-popup">
<h1><Label label={workbench.string.ServerUnderMaintenance} /></h1>
{$versionError}
{#if $upgradeDownloadProgress > 0}
<div class="mt-1">
<Label label={workbench.string.UpgradeDownloadProgress} params={{ percent: $upgradeDownloadProgress }} />
</div>
{/if}
</div>
</div>
{:else if client}

View File

@ -28,6 +28,7 @@
"MobileNotSupported": "Sorry, mobile devices support coming soon. In the meantime, please use Desktop",
"LogInAnyway": "Log in anyway",
"WorkspaceCreating": "Creation in progress...",
"AccessDenied": "Object doesn't exist or you are not permitted to access it."
"AccessDenied": "Object doesn't exist or you are not permitted to access it.",
"UpgradeDownloadProgress": "Downloading upgrade: {percent}%"
}
}

View File

@ -28,6 +28,7 @@
"MobileNotSupported": "Disculpa, el soporte para dispositivos móviles estará disponible próximamente. Mientras tanto, por favor usa el escritorio.",
"LogInAnyway": "Iniciar sesión de todas formas",
"WorkspaceCreating": "Creation in progress...",
"AccessDenied": "El objeto no existe o no tienes permiso para acceder a él."
"AccessDenied": "El objeto no existe o no tienes permiso para acceder a él.",
"UpgradeDownloadProgress": "Descargando actualización: {percent}%"
}
}

View File

@ -28,6 +28,7 @@
"MobileNotSupported": "Désolé, le support pour les appareils mobiles arrive bientôt. En attendant, veuillez utiliser un ordinateur de bureau",
"LogInAnyway": "Se connecter quand même",
"WorkspaceCreating": "Création en cours...",
"AccessDenied": "L'objet n'existe pas ou vous n'êtes pas autorisé à y accéder."
"AccessDenied": "L'objet n'existe pas ou vous n'êtes pas autorisé à y accéder.",
"UpgradeDownloadProgress": "Téléchargement de la mise à jour: {percent}%"
}
}

View File

@ -28,6 +28,7 @@
"MobileNotSupported": "Desculpe, o suporte para dispositivos móveis estará disponível em breve. Enquanto isso, por favor, use o Desktop.",
"LogInAnyway": "Entrar de qualquer maneira",
"WorkspaceCreating": "Creation in progress...",
"AccessDenied": "O objeto não existe ou você não tem permissão para acessá-lo."
"AccessDenied": "O objeto não existe ou você não tem permissão para acessá-lo.",
"UpgradeDownloadProgress": "Baixando atualização: {percent}%"
}
}

View File

@ -28,6 +28,7 @@
"MobileNotSupported": "Простите, поддержка мобильных устройств скоро будет доступна. Пока воспользуйтесь компьютером.",
"LogInAnyway": "Все равно войти",
"WorkspaceCreating": "Пространство создается...",
"AccessDenied": "Объект не существует или у вас нет прав доступа."
"AccessDenied": "Объект не существует или у вас нет прав доступа.",
"UpgradeDownloadProgress": "Загрузка обновления: {percent}%"
}
}

View File

@ -28,6 +28,7 @@
"MobileNotSupported": "抱歉,移动设备支持即将推出。在此期间,请使用桌面设备",
"LogInAnyway": "仍然登录",
"WorkspaceCreating": "创建进行中...",
"AccessDenied": "对象不存在或您无权访问"
"AccessDenied": "对象不存在或您无权访问",
"UpgradeDownloadProgress": "正在下载更新:{percent}%"
}
}

View File

@ -25,65 +25,79 @@
location,
setMetadataLocalStorage
} from '@hcengineering/ui'
import { upgradeDownloadProgress } from '@hcengineering/presentation'
import { connect, disconnect, versionError } from '../connect'
import { workbenchId } from '@hcengineering/workbench'
import workbench, { workbenchId } from '@hcengineering/workbench'
import { onDestroy } from 'svelte'
import workbench from '../plugin'
import workbenchRes from '../plugin'
import { workspaceCreating } from '../utils'
const isNeedUpgrade = window.location.host === ''
let mobileAllowed = fetchMetadataLocalStorage(workbench.metadata.MobileAllowed)
let mobileAllowed = fetchMetadataLocalStorage(workbenchRes.metadata.MobileAllowed)
function allowMobile () {
setMetadataLocalStorage(workbench.metadata.MobileAllowed, true)
setMetadataLocalStorage(workbenchRes.metadata.MobileAllowed, true)
mobileAllowed = true
}
onDestroy(disconnect)
</script>
{#if $location.path[0] === workbenchId || $location.path[0] === workbench.component.WorkbenchApp}
{#if $location.path[0] === workbenchId || $location.path[0] === workbenchRes.component.WorkbenchApp}
{#if $deviceOptionsStore.isMobile && mobileAllowed !== true}
<div class="version-wrapper">
<div class="antiPopup version-popup">
<h1><Label label={workbench.string.MobileNotSupported} /></h1>
<Button label={workbench.string.LogInAnyway} on:click={allowMobile} />
<h1><Label label={workbenchRes.string.MobileNotSupported} /></h1>
<Button label={workbenchRes.string.LogInAnyway} on:click={allowMobile} />
</div>
</div>
{:else}
{#key $location.path[1]}
{#await connect(getMetadata(workbench.metadata.PlatformTitle) ?? 'Platform')}
{#await connect(getMetadata(workbenchRes.metadata.PlatformTitle) ?? 'Platform')}
<Loading>
{#if ($workspaceCreating ?? -1) > 0}
<div class="ml-1">
<Label label={workbench.string.WorkspaceCreating} />
<Label label={workbenchRes.string.WorkspaceCreating} />
{$workspaceCreating} %
</div>
{/if}
{#if $versionError}
<div class="ml-1">
<div class="ml-2">
{$versionError}
</div>
{/if}
{#if $upgradeDownloadProgress > 0}
<div class="ml-2" class:mt-1={$versionError !== undefined}>
<Label label={workbench.string.UpgradeDownloadProgress} params={{ percent: $upgradeDownloadProgress }} />
</div>
{/if}
</Loading>
{:then client}
{#if $versionError}
<div class="version-wrapper">
<div class="antiPopup version-popup">
{#if isNeedUpgrade}
<h1><Label label={workbench.string.NewVersionAvailable} /></h1>
<span class="please-update"><Label label={workbench.string.PleaseUpdate} /></span>
<h1><Label label={workbenchRes.string.NewVersionAvailable} /></h1>
<span class="please-update"><Label label={workbenchRes.string.PleaseUpdate} /></span>
{:else}
<h1><Label label={workbench.string.ServerUnderMaintenance} /></h1>
<h1><Label label={workbenchRes.string.ServerUnderMaintenance} /></h1>
{/if}
{$versionError}
{#if $upgradeDownloadProgress > 0}
<div class="mt-1">
<Label
label={workbench.string.UpgradeDownloadProgress}
params={{ percent: $upgradeDownloadProgress }}
/>
</div>
{/if}
</div>
</div>
{:else if client}
<Notifications>
<Component is={workbench.component.Workbench} />
<Component is={workbenchRes.component.Workbench} />
</Notifications>
{/if}
{:catch error}

View File

@ -154,7 +154,8 @@ export default plugin(workbenchId, {
string: {
Archive: '' as IntlString,
View: '' as IntlString,
ServerUnderMaintenance: '' as IntlString
ServerUnderMaintenance: '' as IntlString,
UpgradeDownloadProgress: '' as IntlString
},
icon: {
Search: '' as Asset