diff --git a/packages/ui/src/components/Expandable.svelte b/packages/ui/src/components/Expandable.svelte index d6ea835a5f..dab2991974 100644 --- a/packages/ui/src/components/Expandable.svelte +++ b/packages/ui/src/components/Expandable.svelte @@ -26,6 +26,9 @@ export let expandable = true export let contentColor = false export let showChevron = true + + let wasExpanded = expanded + $: if (expanded) wasExpanded = true
@@ -56,7 +59,9 @@ {/if}
- + {#if wasExpanded} + + {/if} diff --git a/plugins/workbench-resources/src/components/ServerManagerUsers.svelte b/plugins/workbench-resources/src/components/ServerManagerUsers.svelte index dcbaa1b4e3..60a6dd8e77 100644 --- a/plugins/workbench-resources/src/components/ServerManagerUsers.svelte +++ b/plugins/workbench-resources/src/components/ServerManagerUsers.svelte @@ -5,7 +5,7 @@ import presentation, { createQuery, isAdminUser, type OverviewStatistics } from '@hcengineering/presentation' import { Button, CheckBox, ticker } from '@hcengineering/ui' import Expandable from '@hcengineering/ui/src/components/Expandable.svelte' - import { ObjectPresenter } from '@hcengineering/view-resources' + import { FixedColumn, ObjectPresenter } from '@hcengineering/view-resources' import { workspacesStore } from '../utils' const token: string = getMetadata(presentation.metadata.Token) ?? '' @@ -36,8 +36,14 @@ employees = emp }) let realUsers: boolean + let showActive5: boolean - $: byService = groupByArray(data?.workspaces ?? [], (it) => it.service) + $: byService = groupByArray( + (data?.workspaces ?? []).filter((it) => !showActive5 || it.sessions.some((sit) => sit.current.tx > 0)), + (it) => it.service + ) + + const isSystemAccount = (it: string): boolean => it === systemAccountEmail || it === 'huly.ai.bot@hc.engineering'
@@ -48,102 +54,136 @@
Show only users
+
+ +
Show active in 5mins
+
{#each byService.keys() as s} - Service: {s} - {#each byService.get(s) ?? [] as act} - {@const wsInstance = $workspacesStore.find((it) => it.workspaceId === act.wsId)} - {@const totalFind = act.sessions.reduce((it, itm) => itm.total.find + it, 0)} - {@const totalTx = act.sessions.reduce((it, itm) => itm.total.tx + it, 0)} + {@const ss = byService.get(s) ?? []} + + +
+ + + Service: {s} + + + + Workspaces: {ss.length} + - {@const currentFind = act.sessions.reduce((it, itm) => itm.current.find + it, 0)} - {@const currentTx = act.sessions.reduce((it, itm) => itm.current.tx + it, 0)} - {@const employeeGroups = Array.from(new Set(act.sessions.map((it) => it.userId))).filter( - (it) => systemAccountEmail !== it || !realUsers - )} - {@const realGroup = Array.from(new Set(act.sessions.map((it) => it.userId))).filter( - (it) => systemAccountEmail !== it - )} - {#if employeeGroups.length > 0} - - - -
-
- Workspace: {wsInstance?.workspaceName ?? act.wsId}: {employeeGroups.length} current 5 mins => {currentFind}/{currentTx}, - total => {totalFind}/{totalTx} -
- {#if isAdminUser()} -
-
-
- {#each employeeGroups as employeeId} - {@const employee = employees.get(employeeId)} - {@const connections = act.sessions.filter((it) => it.userId === employeeId)} + + Connections: {ss.reduce((it, itm) => it + itm.sessions.length, 0)} + + + Users: {ss.reduce((it, itm) => it + itm.sessions.filter((it) => !isSystemAccount(it.userId)).length, 0)} + + + Active {ss.reduce((it, itm) => it + itm.sessions.filter((it) => it.current.tx > 0).length, 0)} / + {ss.reduce((it, itm) => it + itm.sessions.filter((it) => it.mins5.tx > 0 || it.current.tx > 0).length, 0)} + +
+ +
+ {#each ss as act} + {@const wsInstance = $workspacesStore.find((it) => it.workspaceId === act.wsId)} + {@const totalFind = act.sessions.reduce((it, itm) => itm.total.find + it, 0)} + {@const totalTx = act.sessions.reduce((it, itm) => itm.total.tx + it, 0)} - {@const find = connections.reduce((it, itm) => itm.current.find + it, 0)} - {@const txes = connections.reduce((it, itm) => itm.current.tx + it, 0)} -
- - -
- {#if employee} - - {:else} - {employeeId} - {/if} - : {connections.length} -
-
{find} rx/{txes} tx
-
-
-
- {#each connections as user, i} -
- #{i} - {user.userId} -
- Total: {user.total.find} rx/{user.total.tx} tx -
-
- Previous 5 mins: {user.mins5.find} rx/{user.mins5.tx} tx -
-
- Current 5 mins: {user.current.find} tx/{user.current.tx} tx -
-
-
- {#each Object.entries(user.data ?? {}) as [k, v]} -
- {k}: {JSON.stringify(v)} + {@const currentFind = act.sessions.reduce((it, itm) => itm.current.find + it, 0)} + {@const currentTx = act.sessions.reduce((it, itm) => itm.current.tx + it, 0)} + {@const employeeGroups = Array.from( + new Set(act.sessions.filter((it) => !showActive5 || it.current.tx > 0).map((it) => it.userId)) + ).filter((it) => !isSystemAccount(it) || !realUsers)} + {@const realGroup = Array.from(new Set(act.sessions.map((it) => it.userId))).filter( + (it) => !isSystemAccount(it) + )} + {#if employeeGroups.length > 0} + + + +
+
+ Workspace: {wsInstance?.workspaceName ?? act.wsId}: {employeeGroups.length} current 5 mins => {currentFind}/{currentTx}, + total => {totalFind}/{totalTx} +
+ {#if isAdminUser()} +
+
+
+ {#each employeeGroups as employeeId} + {@const employee = employees.get(employeeId)} + {@const connections = act.sessions.filter((it) => it.userId === employeeId)} + + {@const find = connections.reduce((it, itm) => itm.current.find + it, 0)} + {@const txes = connections.reduce((it, itm) => itm.current.tx + it, 0)} +
+ + +
+ {#if employee} + + {:else} + {employeeId} + {/if} + : {connections.length} +
+
{find} rx/{txes} tx
+
+
+
+ {#each connections as user, i} +
+ #{i} + {user.userId} +
+ Total: {user.total.find} rx/{user.total.tx} tx +
+
+ Previous 5 mins: {user.mins5.find} rx/{user.mins5.tx} tx +
+
+ Current 5 mins: {user.current.find} tx/{user.current.tx} tx +
+
+
+ {#each Object.entries(user.data ?? {}) as [k, v]} +
+ {k}: {JSON.stringify(v)} +
+ {/each}
{/each} -
- {/each} - + +
+ {/each}
- {/each} -
-
- - {/if} - {/each} + + + {/if} + {/each} +
+ {/each}