mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +03:00
UBER-460: Fix admin view (#3420)
This commit is contained in:
parent
5475231ec9
commit
fec129ee31
@ -143,6 +143,13 @@ export async function refreshClient (): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export async function closeClient (): Promise<void> {
|
||||||
|
await client?.close()
|
||||||
|
}
|
||||||
|
|
||||||
const globalQueries: LiveQuery[] = []
|
const globalQueries: LiveQuery[] = []
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import { getMetadata } from '@hcengineering/platform'
|
import { getMetadata } from '@hcengineering/platform'
|
||||||
import presentation from '@hcengineering/presentation'
|
import presentation from '@hcengineering/presentation'
|
||||||
import { themeStore } from '@hcengineering/theme'
|
import { themeStore } from '@hcengineering/theme'
|
||||||
|
import workbench from '@hcengineering/workbench'
|
||||||
import { onDestroy } from 'svelte'
|
import { onDestroy } from 'svelte'
|
||||||
import Confirmation from './Confirmation.svelte'
|
import Confirmation from './Confirmation.svelte'
|
||||||
import ConfirmationSend from './ConfirmationSend.svelte'
|
import ConfirmationSend from './ConfirmationSend.svelte'
|
||||||
@ -30,7 +31,6 @@
|
|||||||
import SelectWorkspace from './SelectWorkspace.svelte'
|
import SelectWorkspace from './SelectWorkspace.svelte'
|
||||||
import SignupForm from './SignupForm.svelte'
|
import SignupForm from './SignupForm.svelte'
|
||||||
import LoginIcon from './icons/LoginIcon.svelte'
|
import LoginIcon from './icons/LoginIcon.svelte'
|
||||||
import workbench from '@hcengineering/workbench'
|
|
||||||
|
|
||||||
import loginBack from '../../img/login_back.png'
|
import loginBack from '../../img/login_back.png'
|
||||||
import loginBack2x from '../../img/login_back_2x.png'
|
import loginBack2x from '../../img/login_back_2x.png'
|
||||||
@ -50,9 +50,23 @@
|
|||||||
}
|
}
|
||||||
$: token = getToken($ticker)
|
$: token = getToken($ticker)
|
||||||
|
|
||||||
|
const pages = [
|
||||||
|
'login',
|
||||||
|
'signup',
|
||||||
|
'createWorkspace',
|
||||||
|
'password',
|
||||||
|
'recovery',
|
||||||
|
'selectWorkspace',
|
||||||
|
'join',
|
||||||
|
'confirm',
|
||||||
|
'confirmationSend'
|
||||||
|
]
|
||||||
onDestroy(
|
onDestroy(
|
||||||
location.subscribe(async (loc) => {
|
location.subscribe(async (loc) => {
|
||||||
page = loc.path[1] ?? (token ? 'selectWorkspace' : 'login')
|
page = loc.path[1] ?? (token ? 'selectWorkspace' : 'login')
|
||||||
|
if (!pages.includes(page)) {
|
||||||
|
page = 'login'
|
||||||
|
}
|
||||||
|
|
||||||
navigateUrl = loc.query?.navigateUrl ?? undefined
|
navigateUrl = loc.query?.navigateUrl ?? undefined
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
|
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
|
||||||
import login, { loginId } from '@hcengineering/login'
|
import login, { loginId } from '@hcengineering/login'
|
||||||
import { setMetadata } from '@hcengineering/platform'
|
import { setMetadata } from '@hcengineering/platform'
|
||||||
import presentation, { createQuery } from '@hcengineering/presentation'
|
import presentation, { closeClient, createQuery } from '@hcengineering/presentation'
|
||||||
import setting, { SettingsCategory } from '@hcengineering/setting'
|
import setting, { SettingsCategory } from '@hcengineering/setting'
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
@ -76,6 +76,7 @@
|
|||||||
setMetadata(presentation.metadata.Token, null)
|
setMetadata(presentation.metadata.Token, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
||||||
|
closeClient()
|
||||||
navigate({ path: [loginId] })
|
navigate({ path: [loginId] })
|
||||||
}
|
}
|
||||||
function selectWorkspace (): void {
|
function selectWorkspace (): void {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { getCurrentAccount } from '@hcengineering/core'
|
import { getCurrentAccount } from '@hcengineering/core'
|
||||||
import login, { loginId } from '@hcengineering/login'
|
import login, { loginId } from '@hcengineering/login'
|
||||||
import { setMetadata } from '@hcengineering/platform'
|
import { setMetadata } from '@hcengineering/platform'
|
||||||
import presentation from '@hcengineering/presentation'
|
import presentation, { closeClient } from '@hcengineering/presentation'
|
||||||
import setting, { SettingsCategory, settingId } from '@hcengineering/setting'
|
import setting, { SettingsCategory, settingId } from '@hcengineering/setting'
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
@ -57,6 +57,7 @@
|
|||||||
setMetadata(presentation.metadata.Token, null)
|
setMetadata(presentation.metadata.Token, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
||||||
|
closeClient()
|
||||||
navigate({ path: [loginId] })
|
navigate({ path: [loginId] })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
|
import { AccountRole, getCurrentAccount } from '@hcengineering/core'
|
||||||
import login, { loginId } from '@hcengineering/login'
|
import login, { loginId } from '@hcengineering/login'
|
||||||
import { setMetadata } from '@hcengineering/platform'
|
import { setMetadata } from '@hcengineering/platform'
|
||||||
import presentation, { createQuery } from '@hcengineering/presentation'
|
import presentation, { closeClient, createQuery } from '@hcengineering/presentation'
|
||||||
import setting, { SettingsCategory, settingId } from '@hcengineering/setting'
|
import setting, { SettingsCategory, settingId } from '@hcengineering/setting'
|
||||||
import {
|
import {
|
||||||
Action,
|
Action,
|
||||||
@ -87,6 +87,7 @@
|
|||||||
setMetadata(presentation.metadata.Token, null)
|
setMetadata(presentation.metadata.Token, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
||||||
|
closeClient()
|
||||||
navigate({ path: [loginId] })
|
navigate({ path: [loginId] })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
export let token: string
|
export let token: string
|
||||||
|
|
||||||
let data: any
|
let data: any
|
||||||
|
let admin = false
|
||||||
onDestroy(
|
onDestroy(
|
||||||
ticker.subscribe(() => {
|
ticker.subscribe(() => {
|
||||||
fetch(endpoint + `/api/v1/statistics?token=${token}`, {}).then(async (json) => {
|
fetch(endpoint + `/api/v1/statistics?token=${token}`, {}).then(async (json) => {
|
||||||
data = await json.json()
|
data = await json.json()
|
||||||
|
admin = data?.admin ?? false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -87,7 +88,7 @@
|
|||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
{#if data}
|
{#if data}
|
||||||
{#if selectedTab === 'general'}
|
{#if selectedTab === 'general'}
|
||||||
<Scroller>
|
{#if admin}
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="flex-row-center p-1">
|
<div class="flex-row-center p-1">
|
||||||
<div class="p-3">1.</div>
|
<div class="p-3">1.</div>
|
||||||
@ -120,44 +121,42 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Scroller>
|
{/if}
|
||||||
{:else if selectedTab === 'users'}
|
{:else if selectedTab === 'users'}
|
||||||
<div class="flex-column p-3">
|
<div class="flex-column p-3 h-full" style:overflow="auto">
|
||||||
<Scroller>
|
{#each Object.entries(activeSessions) as act}
|
||||||
{#each Object.entries(activeSessions) as act}
|
<span class="flex-col">
|
||||||
<span class="flex-col">
|
<div class="fs-title">
|
||||||
<div class="fs-title">
|
Workspace: {act[0]}: {act[1].length}
|
||||||
Workspace: {act[0]}: {act[1].length}
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-col">
|
<div class="flex-col">
|
||||||
{#each act[1] as user}
|
{#each act[1] as user}
|
||||||
{@const employee = employees.get(user.userId)}
|
{@const employee = employees.get(user.userId)}
|
||||||
<div class="p-1 flex-row-center">
|
<div class="p-1 flex-row-center">
|
||||||
{#if employee}
|
{#if employee}
|
||||||
<ObjectPresenter
|
<ObjectPresenter
|
||||||
_class={contact.class.Employee}
|
_class={contact.class.Employee}
|
||||||
objectId={employee.employee}
|
objectId={employee.employee}
|
||||||
props={{ shouldShowAvatar: true }}
|
props={{ shouldShowAvatar: true }}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
{user.userId}
|
{user.userId}
|
||||||
{/if}
|
{/if}
|
||||||
<div class="p-1">
|
<div class="p-1">
|
||||||
Total: {user.total.find}/{user.total.tx}
|
Total: {user.total.find}/{user.total.tx}
|
||||||
</div>
|
|
||||||
<div class="p-1">
|
|
||||||
Previous 5 mins: {user.mins5.find}/{user.mins5.tx}
|
|
||||||
</div>
|
|
||||||
<div class="p-1">
|
|
||||||
Current 5 mins: {user.current.find}/{user.current.tx}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
<div class="p-1">
|
||||||
</div>
|
Previous 5 mins: {user.mins5.find}/{user.mins5.tx}
|
||||||
</span>
|
</div>
|
||||||
{/each}
|
<div class="p-1">
|
||||||
</Scroller>
|
Current 5 mins: {user.current.find}/{user.current.tx}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{:else if selectedTab === 'statistics'}
|
{:else if selectedTab === 'statistics'}
|
||||||
<Scroller>
|
<Scroller>
|
||||||
|
@ -289,7 +289,7 @@
|
|||||||
const specialRef = getMetadata(workbench.metadata.DefaultSpecial) as Ref<Space>
|
const specialRef = getMetadata(workbench.metadata.DefaultSpecial) as Ref<Space>
|
||||||
const loc = getCurrentLocation()
|
const loc = getCurrentLocation()
|
||||||
// Be sure URI is not yet changed
|
// Be sure URI is not yet changed
|
||||||
if (loc.path[2] === undefined) {
|
if (loc.path[2] === undefined && loc.path[0] === 'workbench') {
|
||||||
loc.path[2] = appShort
|
loc.path[2] = appShort
|
||||||
let len = 3
|
let len = 3
|
||||||
if (spaceRef !== undefined && specialRef !== undefined) {
|
if (spaceRef !== undefined && specialRef !== undefined) {
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import client from '@hcengineering/client'
|
import client from '@hcengineering/client'
|
||||||
import core, {
|
import core, {
|
||||||
|
AccountClient,
|
||||||
AccountRole,
|
AccountRole,
|
||||||
Client,
|
Client,
|
||||||
AccountClient,
|
|
||||||
setCurrentAccount,
|
|
||||||
Version,
|
Version,
|
||||||
|
getCurrentAccount,
|
||||||
|
setCurrentAccount,
|
||||||
versionToString
|
versionToString
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import login, { loginId } from '@hcengineering/login'
|
import login, { loginId } from '@hcengineering/login'
|
||||||
import { addEventListener, getMetadata, getResource, setMetadata } from '@hcengineering/platform'
|
import { addEventListener, getMetadata, getResource, setMetadata } from '@hcengineering/platform'
|
||||||
import presentation, { refreshClient, setClient } from '@hcengineering/presentation'
|
import presentation, { closeClient, refreshClient, setClient } from '@hcengineering/presentation'
|
||||||
import ui, {
|
import ui, {
|
||||||
fetchMetadataLocalStorage,
|
fetchMetadataLocalStorage,
|
||||||
getCurrentLocation,
|
getCurrentLocation,
|
||||||
@ -153,14 +154,19 @@ export async function connect (title: string): Promise<Client | undefined> {
|
|||||||
ep = ep.substring(0, ep.length - 1)
|
ep = ep.substring(0, ep.length - 1)
|
||||||
}
|
}
|
||||||
setMetadata(ui.metadata.ShowNetwork, (evt: MouseEvent) => {
|
setMetadata(ui.metadata.ShowNetwork, (evt: MouseEvent) => {
|
||||||
showPopup(
|
if (getMetadata(presentation.metadata.Token) == null) {
|
||||||
ServerManager,
|
return
|
||||||
{
|
}
|
||||||
endpoint: ep,
|
if (getCurrentAccount()?.role === AccountRole.Owner) {
|
||||||
token
|
showPopup(
|
||||||
},
|
ServerManager,
|
||||||
'content'
|
{
|
||||||
)
|
endpoint: ep,
|
||||||
|
token
|
||||||
|
},
|
||||||
|
'content'
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,4 +184,5 @@ function clearMetadata (ws: string): void {
|
|||||||
setMetadata(presentation.metadata.Token, null)
|
setMetadata(presentation.metadata.Token, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
|
||||||
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
setMetadataLocalStorage(login.metadata.LoginEmail, null)
|
||||||
|
void closeClient()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user