mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-14 19:36:15 +00:00
UBERF-10248: Fix local time (#8623)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
parent
cb9a0d5017
commit
7575fa08ec
@ -111,7 +111,6 @@
|
|||||||
"ViberPlaceholder": "Viber",
|
"ViberPlaceholder": "Viber",
|
||||||
"UserProfile": "Uživatelský profil",
|
"UserProfile": "Uživatelský profil",
|
||||||
"DeactivatedAccount": "Deaktivovaný účet",
|
"DeactivatedAccount": "Deaktivovaný účet",
|
||||||
"LocalTime": "místní čas",
|
"LocalTime": "místní čas"
|
||||||
"LocalTimeNotSet": "Místní čas není nastaven"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@
|
|||||||
"ViberPlaceholder": "Viber",
|
"ViberPlaceholder": "Viber",
|
||||||
"UserProfile": "Benutzerprofil",
|
"UserProfile": "Benutzerprofil",
|
||||||
"DeactivatedAccount": "Deaktivierter Account",
|
"DeactivatedAccount": "Deaktivierter Account",
|
||||||
"LocalTime": "Ortszeit",
|
"LocalTime": "Ortszeit"
|
||||||
"LocalTimeNotSet": "Ortszeit nicht festgelegt"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "Confirmed",
|
"Confirmed": "Confirmed",
|
||||||
"UserProfile": "User profile",
|
"UserProfile": "User profile",
|
||||||
"DeactivatedAccount": "Deactivated account",
|
"DeactivatedAccount": "Deactivated account",
|
||||||
"LocalTime": "local time",
|
"LocalTime": "local time"
|
||||||
"LocalTimeNotSet": "Local time not set"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "Confirmado",
|
"Confirmed": "Confirmado",
|
||||||
"UserProfile": "Perfil de usuario",
|
"UserProfile": "Perfil de usuario",
|
||||||
"DeactivatedAccount": "Cuenta desactivada",
|
"DeactivatedAccount": "Cuenta desactivada",
|
||||||
"LocalTime": "hora local",
|
"LocalTime": "hora local"
|
||||||
"LocalTimeNotSet": "Hora local no establecida"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "Confirmé",
|
"Confirmed": "Confirmé",
|
||||||
"UserProfile": "Profil utilisateur",
|
"UserProfile": "Profil utilisateur",
|
||||||
"DeactivatedAccount": "Compte désactivé",
|
"DeactivatedAccount": "Compte désactivé",
|
||||||
"LocalTime": "heure locale",
|
"LocalTime": "heure locale"
|
||||||
"LocalTimeNotSet": "Heure locale non définie"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "Confermato",
|
"Confirmed": "Confermato",
|
||||||
"UserProfile": "Profilo utente",
|
"UserProfile": "Profilo utente",
|
||||||
"DeactivatedAccount": "Account disattivato",
|
"DeactivatedAccount": "Account disattivato",
|
||||||
"LocalTime": "ora locale",
|
"LocalTime": "ora locale"
|
||||||
"LocalTimeNotSet": "Ora locale non impostata"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "Confirmado",
|
"Confirmed": "Confirmado",
|
||||||
"UserProfile": "Perfil do usuário",
|
"UserProfile": "Perfil do usuário",
|
||||||
"DeactivatedAccount": "Conta desativada",
|
"DeactivatedAccount": "Conta desativada",
|
||||||
"LocalTime": "hora local",
|
"LocalTime": "hora local"
|
||||||
"LocalTimeNotSet": "Hora local não definida"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "Подтвержден",
|
"Confirmed": "Подтвержден",
|
||||||
"UserProfile": "Профиль пользователя",
|
"UserProfile": "Профиль пользователя",
|
||||||
"DeactivatedAccount": "Деактивированный аккаунт",
|
"DeactivatedAccount": "Деактивированный аккаунт",
|
||||||
"LocalTime": "местного времени",
|
"LocalTime": "местного времени"
|
||||||
"LocalTimeNotSet": "Местное время не задано"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@
|
|||||||
"Confirmed": "已确认",
|
"Confirmed": "已确认",
|
||||||
"UserProfile": "用户资料",
|
"UserProfile": "用户资料",
|
||||||
"DeactivatedAccount": "已停用账户",
|
"DeactivatedAccount": "已停用账户",
|
||||||
"LocalTime": "当地时间",
|
"LocalTime": "当地时间"
|
||||||
"LocalTimeNotSet": "未设置当地时间"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
import ModernProfilePopup from './ModernProfilePopup.svelte'
|
import ModernProfilePopup from './ModernProfilePopup.svelte'
|
||||||
import contact from '../../plugin'
|
import contact from '../../plugin'
|
||||||
import Avatar from '../Avatar.svelte'
|
import Avatar from '../Avatar.svelte'
|
||||||
import { employeeByIdStore, getAccountClient } from '../../utils'
|
import { employeeByIdStore } from '../../utils'
|
||||||
|
import { getPersonTimezone } from './utils'
|
||||||
import { EmployeePresenter } from '../../index'
|
import { EmployeePresenter } from '../../index'
|
||||||
import TimePresenter from './TimePresenter.svelte'
|
import TimePresenter from './TimePresenter.svelte'
|
||||||
import DeactivatedHeader from './DeactivatedHeader.svelte'
|
import DeactivatedHeader from './DeactivatedHeader.svelte'
|
||||||
@ -36,7 +37,6 @@
|
|||||||
|
|
||||||
let employee: Employee | undefined = undefined
|
let employee: Employee | undefined = undefined
|
||||||
let timezone: string | undefined = undefined
|
let timezone: string | undefined = undefined
|
||||||
let isTimezoneLoading = true
|
|
||||||
|
|
||||||
$: employee = $employeeByIdStore.get(_id)
|
$: employee = $employeeByIdStore.get(_id)
|
||||||
$: void loadPersonTimezone(employee?.personUuid)
|
$: void loadPersonTimezone(employee?.personUuid)
|
||||||
@ -50,15 +50,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadPersonTimezone (personId: AccountUuid | undefined): Promise<void> {
|
async function loadPersonTimezone (personId: AccountUuid | undefined): Promise<void> {
|
||||||
if (personId === undefined) return
|
timezone = await getPersonTimezone(personId)
|
||||||
isTimezoneLoading = true
|
|
||||||
try {
|
|
||||||
const accountInfo = await getAccountClient().getAccountInfo(personId)
|
|
||||||
timezone = accountInfo.timezone
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
}
|
|
||||||
isTimezoneLoading = false
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -95,9 +87,10 @@
|
|||||||
on:click={viewProfile}
|
on:click={viewProfile}
|
||||||
/>
|
/>
|
||||||
<div class="flex-col flex-gap-0-5">
|
<div class="flex-col flex-gap-0-5">
|
||||||
|
<div class="status-container" />
|
||||||
<EmployeePresenter value={employee} shouldShowAvatar={false} showPopup={false} compact accent />
|
<EmployeePresenter value={employee} shouldShowAvatar={false} showPopup={false} compact accent />
|
||||||
<span class="flex-presenter cursor-default">
|
<span class="flex-presenter cursor-default">
|
||||||
<TimePresenter {timezone} {isTimezoneLoading} />
|
<TimePresenter {timezone} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -151,4 +144,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
background-color: var(--theme-button-container-color);
|
background-color: var(--theme-button-container-color);
|
||||||
}
|
}
|
||||||
|
.status-container {
|
||||||
|
display: flex;
|
||||||
|
min-height: 1rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -13,13 +13,11 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Icon, Label } from '@hcengineering/ui'
|
import { Label } from '@hcengineering/ui'
|
||||||
|
|
||||||
import contact from '@hcengineering/contact'
|
import contact from '@hcengineering/contact'
|
||||||
import view from '@hcengineering/view'
|
|
||||||
|
|
||||||
export let timezone: string | undefined
|
export let timezone: string | undefined
|
||||||
export let isTimezoneLoading: boolean
|
|
||||||
|
|
||||||
function displayTimeInTimezone (timezone: string): string {
|
function displayTimeInTimezone (timezone: string): string {
|
||||||
const options: Intl.DateTimeFormatOptions = {
|
const options: Intl.DateTimeFormatOptions = {
|
||||||
@ -35,30 +33,19 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="time-container">
|
<div class="time-container">
|
||||||
<div class="clock-icon">
|
<div class="text-normal font-normal content-color">
|
||||||
<Icon icon={contact.icon.Clock} size={'smaller'} />
|
{#if timezone != null}
|
||||||
</div>
|
|
||||||
<div class="text-normal font-normal content-color select-text">
|
|
||||||
{#if isTimezoneLoading}
|
|
||||||
<span class="time-text-span"><Label label={view.string.Loading} /></span>
|
|
||||||
{:else if timezone != null}
|
|
||||||
<span class="time-text-span">{displayTimeInTimezone(timezone)} <Label label={contact.string.LocalTime} /></span>
|
<span class="time-text-span">{displayTimeInTimezone(timezone)} <Label label={contact.string.LocalTime} /></span>
|
||||||
{:else}
|
|
||||||
<span class="time-text-span"><Label label={contact.string.LocalTimeNotSet} /></span>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.clock-icon {
|
|
||||||
position: relative;
|
|
||||||
color: var(--theme-content-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.time-container {
|
.time-container {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
min-height: 1.25rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -10,12 +10,16 @@
|
|||||||
//
|
//
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
import { get, writable } from 'svelte/store'
|
||||||
|
|
||||||
|
import type { AccountUuid, Class, Ref } from '@hcengineering/core'
|
||||||
import type { Person } from '@hcengineering/contact'
|
import type { Person } from '@hcengineering/contact'
|
||||||
import { getClient } from '@hcengineering/presentation'
|
import { getClient } from '@hcengineering/presentation'
|
||||||
import type { LabelAndProps } from '@hcengineering/ui'
|
import type { LabelAndProps } from '@hcengineering/ui'
|
||||||
|
|
||||||
import contact from '../../plugin'
|
import contact from '../../plugin'
|
||||||
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte'
|
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte'
|
||||||
import type { Class, Ref } from '@hcengineering/core'
|
import { getAccountClient } from '../../utils'
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const h = client.getHierarchy()
|
const h = client.getHierarchy()
|
||||||
@ -35,3 +39,28 @@ export function getPreviewPopup (
|
|||||||
noArrow: true
|
noArrow: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const timezoneByAccountStore = writable<Map<AccountUuid, string>>(new Map())
|
||||||
|
|
||||||
|
export async function getPersonTimezone (personId: AccountUuid | undefined): Promise<string | undefined> {
|
||||||
|
if (personId === undefined) return undefined
|
||||||
|
|
||||||
|
const storedTimezone = get(timezoneByAccountStore).get(personId)
|
||||||
|
if (storedTimezone !== undefined) return storedTimezone
|
||||||
|
|
||||||
|
try {
|
||||||
|
const accountInfo = await getAccountClient().getAccountInfo(personId)
|
||||||
|
if (accountInfo.timezone !== undefined) {
|
||||||
|
timezoneByAccountStore.update((store: Map<AccountUuid, string>) => {
|
||||||
|
if (accountInfo.timezone !== undefined) {
|
||||||
|
store.set(personId, accountInfo.timezone)
|
||||||
|
}
|
||||||
|
return store
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return accountInfo.timezone
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -336,8 +336,7 @@ export const contactPlugin = plugin(contactId, {
|
|||||||
Confirmed: '' as IntlString,
|
Confirmed: '' as IntlString,
|
||||||
UserProfile: '' as IntlString,
|
UserProfile: '' as IntlString,
|
||||||
DeactivatedAccount: '' as IntlString,
|
DeactivatedAccount: '' as IntlString,
|
||||||
LocalTime: '' as IntlString,
|
LocalTime: '' as IntlString
|
||||||
LocalTimeNotSet: '' as IntlString
|
|
||||||
},
|
},
|
||||||
viewlet: {
|
viewlet: {
|
||||||
TableMember: '' as Ref<Viewlet>,
|
TableMember: '' as Ref<Viewlet>,
|
||||||
|
@ -527,7 +527,8 @@ export async function selectWorkspace (
|
|||||||
workspaceUrl: string
|
workspaceUrl: string
|
||||||
kind: 'external' | 'internal' | 'byregion'
|
kind: 'external' | 'internal' | 'byregion'
|
||||||
externalRegions?: string[]
|
externalRegions?: string[]
|
||||||
}
|
},
|
||||||
|
meta?: Meta
|
||||||
): Promise<WorkspaceLoginInfo> {
|
): Promise<WorkspaceLoginInfo> {
|
||||||
const { workspaceUrl, kind, externalRegions = [] } = params
|
const { workspaceUrl, kind, externalRegions = [] } = params
|
||||||
const { account: accountUuid, workspace: tokenWorkspaceUuid, extra } = decodeTokenVerbose(ctx, token ?? '')
|
const { account: accountUuid, workspace: tokenWorkspaceUuid, extra } = decodeTokenVerbose(ctx, token ?? '')
|
||||||
@ -581,6 +582,10 @@ export async function selectWorkspace (
|
|||||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUrl }))
|
throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUrl }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (accountUuid !== systemAccountUuid) {
|
||||||
|
void setTimezoneIfNotDefined(ctx, db, accountUuid, account, meta)
|
||||||
|
}
|
||||||
|
|
||||||
if (accountUuid === systemAccountUuid || extra?.admin === 'true') {
|
if (accountUuid === systemAccountUuid || extra?.admin === 'true') {
|
||||||
return {
|
return {
|
||||||
account: accountUuid,
|
account: accountUuid,
|
||||||
|
Loading…
Reference in New Issue
Block a user