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