Skip to content

Commit

Permalink
Allow kick participant from office (#7620)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <[email protected]>
  • Loading branch information
BykhovDenis authored Jan 9, 2025
1 parent 8c3dd61 commit 5924c4a
Show file tree
Hide file tree
Showing 17 changed files with 164 additions and 74 deletions.
5 changes: 5 additions & 0 deletions plugins/love-assets/assets/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Připojit se ke schůzce",
"MeetingStart": "Začátek schůzky",
"MeetingEnd": "Konec schůzky",
"EndMeeting": "Ukončit schůzku",
"Status": "Stav",
"Active": "Aktivní",
"Finished": "Dokončeno",
"StartWithRecording": "Začít s nahráváním",
"Language": "Jazyk"
"Language": "Jazyk",
"Kick": "Vyhodit"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Join meeting",
"MeetingStart": "Meeting start",
"MeetingEnd": "Meeting end",
"EndMeeting": "End meeting",
"Status": "Status",
"Active": "Active",
"Finished": "Finished",
"StartWithRecording": "Start with recording",
"Language": "Language"
"Language": "Language",
"Kick": "Kick"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Unirse a la reunión",
"MeetingStart": "Inicio de la reunión",
"MeetingEnd": "Fin de la reunión",
"EndMeeting": "Terminar reunión",
"Status": "Estado",
"Active": "Activo",
"Finished": "Terminado",
"StartWithRecording": "Iniciar con grabación",
"Language": "Idioma"
"Language": "Idioma",
"Kick": "Expulsar"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Rejoindre la réunion",
"MeetingStart": "Début de la réunion",
"MeetingEnd": "Fin de la réunion",
"EndMeeting": "Terminer la réunion",
"Status": "Statut",
"Active": "Actif",
"Finished": "Terminé",
"StartWithRecording": "Démarrer avec l'enregistrement",
"Language": "Langue"
"Language": "Langue",
"Kick": "Expulser"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Unisciti alla riunione",
"MeetingStart": "Inizio riunione",
"MeetingEnd": "Fine riunione",
"EndMeeting": "Termina riunione",
"Status": "Stato",
"Active": "Attivo",
"Finished": "Finito",
"StartWithRecording": "Inizia con la registrazione",
"Language": "Lingua"
"Language": "Lingua",
"Kick": "Espellere"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Participar na reunião",
"MeetingStart": "Início da reunião",
"MeetingEnd": "Fim da reunião",
"EndMeeting": "Terminar reunião",
"Status": "Estado",
"Active": "Ativo",
"Finished": "Finalizado",
"StartWithRecording": "Começar com gravação",
"Language": "Idioma"
"Language": "Idioma",
"Kick": "Expulsar"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "Присоединиться к встрече",
"MeetingStart": "Начало встречи",
"MeetingEnd": "Конец встречи",
"EndMeeting": "Завершить встречу",
"Status": "Статус",
"Active": "Активно",
"Finished": "Завершено",
"StartWithRecording": "Начинать с записью",
"Language": "Язык"
"Language": "Язык",
"Kick": "Выгнать"
}
}
4 changes: 3 additions & 1 deletion plugins/love-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
"JoinMeeting": "加入会议",
"MeetingStart": "会议开始",
"MeetingEnd": "会议结束",
"EndMeeting": "结束会议",
"Status": "状态",
"Active": "活动",
"Finished": "已完成",
"StartWithRecording": "开始录制",
"Language": "语言"
"Language": "语言",
"Kick": "踢出"
}
}
3 changes: 2 additions & 1 deletion plugins/love-assets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ loadMetadata(love.icon, {
StopRecord: `${icons}#stopRecord`,
FullScreen: `${icons}#fullscreen`,
ExitFullScreen: `${icons}#exitfullscreen`,
Invite: `${icons}#invite`
Invite: `${icons}#invite`,
Kick: `${icons}#kick`
})
loadMetadata(love.sound, {
Knock: require('../assets/knock.wav')
Expand Down
49 changes: 31 additions & 18 deletions plugins/love-resources/src/components/ControlExt.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { personByIdStore } from '@hcengineering/contact-resources'
import { IdMap, Ref, toIdMap } from '@hcengineering/core'
import { getCurrentAccount, IdMap, Ref, toIdMap } from '@hcengineering/core'
import {
Invite,
isOffice,
Expand Down Expand Up @@ -42,9 +42,11 @@
import love from '../plugin'
import { activeInvites, currentRoom, infos, myInfo, myInvites, myOffice, myRequests, rooms } from '../stores'
import {
connectRoom,
createMeetingVideoWidgetTab,
createMeetingWidget,
disconnect,
endMeeting,
getRoomName,
isCurrentInstanceConnected,
leaveRoom,
Expand All @@ -57,6 +59,7 @@
import RequestingPopup from './RequestingPopup.svelte'
import RoomPopup from './RoomPopup.svelte'
import RoomButton from './RoomButton.svelte'
import { Person, PersonAccount } from '@hcengineering/contact'
const client = getClient()
Expand Down Expand Up @@ -105,7 +108,7 @@
if (activeRequest === undefined) {
activeRequest = requests.find((r) => r.room === $myInfo?.room)
if (activeRequest !== undefined) {
showPopup(RequestPopup, { request: activeRequest }, myOfficeElement, undefined, undefined, {
showPopup(RequestPopup, { request: activeRequest }, undefined, undefined, undefined, {
category: joinRequestCategory,
overlay: false,
fixed: true
Expand All @@ -120,7 +123,7 @@
function checkMyRequests (requests: JoinRequest[]): void {
if (requests.length > 0) {
if (myRequestsPopup === undefined) {
myRequestsPopup = showPopup(RequestingPopup, { request: requests[0] }, myOfficeElement, undefined, undefined, {
myRequestsPopup = showPopup(RequestingPopup, { request: requests[0] }, undefined, undefined, undefined, {
category: myJoinRequestCategory,
overlay: false,
fixed: true
Expand All @@ -134,8 +137,6 @@
$: checkMyRequests($myRequests)
let myOfficeElement: HTMLDivElement
$: checkRequests(requests, $myInfo)
function openRoom (room: Room): (e: MouseEvent) => void {
Expand All @@ -158,7 +159,7 @@
if (activeInvite === undefined) {
activeInvite = invites[0]
if (activeInvite !== undefined) {
showPopup(InvitePopup, { invite: activeInvite }, myOfficeElement, undefined, undefined, {
showPopup(InvitePopup, { invite: activeInvite }, undefined, undefined, undefined, {
category: inviteCategory,
overlay: false,
fixed: true
Expand All @@ -173,21 +174,29 @@
infos: ParticipantInfo[],
myInfo: ParticipantInfo | undefined,
myOffice: Office | undefined,
personByIdStore: IdMap<Person>,
isConnected: boolean
): Promise<void> {
if (myOffice !== undefined) {
if (myInfo !== undefined && myInfo.room === myOffice._id) {
const filtered = infos.filter((p) => p.room === myOffice._id && p.person !== myInfo.person)
if (filtered.length === 0) {
if (isConnected) {
await disconnect()
}
if (myInfo !== undefined && myInfo.room === (myOffice?._id ?? love.ids.Reception)) {
if (myOffice === undefined) {
await disconnect()
return
}
const filtered = infos.filter((p) => p.room === myOffice._id && p.person !== myInfo.person)
if (filtered.length === 0) {
if (isConnected) {
await disconnect()
}
} else if (!isConnected) {
const me = getCurrentAccount() as PersonAccount
const myPerson = personByIdStore.get(me.person)
if (myPerson === undefined) return
await connectRoom(0, 0, myInfo, myPerson, myOffice)
}
}
}
$: checkOwnRoomConnection($infos, $myInfo, $myOffice, $isCurrentInstanceConnected)
$: checkOwnRoomConnection($infos, $myInfo, $myOffice, $personByIdStore, $isCurrentInstanceConnected)
const myInvitesCategory = 'myInvites'
Expand All @@ -196,7 +205,7 @@
function checkActiveInvites (invites: Invite[]): void {
if (invites.length > 0) {
if (myInvitesPopup === undefined) {
myInvitesPopup = showPopup(ActiveInvitesPopup, { invites }, myOfficeElement, undefined, undefined, {
myInvitesPopup = showPopup(ActiveInvitesPopup, { invites }, undefined, undefined, undefined, {
category: myInvitesCategory,
overlay: false,
fixed: true
Expand Down Expand Up @@ -277,7 +286,11 @@
const beforeUnloadListener = () => {
if ($myInfo !== undefined && $isCurrentInstanceConnected) {
leaveRoom($myInfo, $myOffice)
if ($myOffice !== undefined && $myInfo.room === $myOffice._id) {
endMeeting($myOffice, $rooms, $infos, $myInfo)
} else {
leaveRoom($myInfo, $myOffice)
}
}
}
Expand All @@ -287,7 +300,7 @@
<div class="flex-row-center flex-gap-2">
{#if activeRooms.length > 0}
<!-- <div class="divider" />-->
{#each activeRooms as active, i}
{#each activeRooms as active}
<RoomButton
label={getRoomName(active, $personByIdStore)}
participants={active.participants}
Expand All @@ -296,7 +309,7 @@
/>
{/each}
{/if}
{#if reception && receptionParticipants.length > 0}
{#if reception !== undefined && receptionParticipants.length > 0}
{#if activeRooms.length > 0}
<div class="divider" />
{/if}
Expand Down
20 changes: 16 additions & 4 deletions plugins/love-resources/src/components/PersonActionPopup.svelte
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
<script lang="ts">
import { Person } from '@hcengineering/contact'
import { personByIdStore } from '@hcengineering/contact-resources'
import { Ref } from '@hcengineering/core'
import { Room, RoomAccess } from '@hcengineering/love'
import { isOffice, Room, RoomAccess } from '@hcengineering/love'
import { ActionIcon } from '@hcengineering/ui'
import love from '../plugin'
import { invite, tryConnect } from '../utils'
import { infos, invites, myInfo, myRequests } from '../stores'
import { personByIdStore } from '@hcengineering/contact-resources'
import { infos, invites, myInfo, myRequests, rooms } from '../stores'
import { invite, kick, tryConnect } from '../utils'
export let room: Room
export let person: Ref<Person>
$: isMyOffice = isOffice(room) && room.person === $myInfo?.person
$: info = $infos.filter((p) => p.room === room._id)
</script>

<div class="p-3 flex-gap-2 antiPopup">
{#if isMyOffice && person !== $myInfo?.person}
<ActionIcon
size={'small'}
label={love.string.Kick}
icon={love.icon.Kick}
action={() => {
kick(person, $rooms, $infos)
}}
/>
{/if}
{#if $myInfo?.room !== room._id}
<ActionIcon
size={'small'}
Expand Down
46 changes: 33 additions & 13 deletions plugins/love-resources/src/components/RoomPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { Person, PersonAccount } from '@hcengineering/contact'
import { personByIdStore, UserInfo } from '@hcengineering/contact-resources'
import { IdMap, getCurrentAccount, Ref, Class, Doc } from '@hcengineering/core'
import ui, {
import {
ModernButton,
SplitButton,
IconArrowLeft,
Expand Down Expand Up @@ -44,8 +44,9 @@
import { getObjectLinkFragment } from '@hcengineering/view-resources'
import { getClient } from '@hcengineering/presentation'
import love from '../plugin'
import { currentRoom, infos, invites, myInfo, myOffice, myRequests, currentMeetingMinutes } from '../stores'
import { currentRoom, infos, invites, myInfo, myOffice, myRequests, currentMeetingMinutes, rooms } from '../stores'
import {
endMeeting,
getRoomName,
isCameraEnabled,
isConnected,
Expand Down Expand Up @@ -75,7 +76,9 @@
let joined: boolean = false
$: joined = $myInfo?.room === room._id
$: allowLeave = $myInfo?.room !== ($myOffice?._id ?? love.ids.Reception)
$: isMyOffice = $myInfo?.room === $myOffice?._id
$: allowLeave = !isMyOffice && $myInfo?.room !== love.ids.Reception
let info: ParticipantInfo[] = []
$: info = $infos.filter((p) => p.room === room._id)
Expand Down Expand Up @@ -104,6 +107,13 @@
dispatch('close')
}
async function end (): Promise<void> {
if (isOffice(room) && $myInfo !== undefined) {
await endMeeting(room, $rooms, $infos, $myInfo)
}
dispatch('close')
}
async function connect (): Promise<void> {
await tryConnect($personByIdStore, $myInfo, room, info, $myRequests, $invites)
dispatch('close')
Expand Down Expand Up @@ -218,17 +228,27 @@
/>
</div>
{/if}
{#if $location.path[2] !== loveId || (joined && allowLeave) || !joined}
{#if $location.path[2] !== loveId || (joined && (allowLeave || isMyOffice)) || !joined}
<div class="btns flex-row-center flex-reverse flex-no-shrink w-full flex-gap-2">
{#if joined && allowLeave}
<ModernButton
label={love.string.LeaveRoom}
icon={love.icon.LeaveRoom}
size={'large'}
kind={'negative'}
on:click={leave}
/>
{:else if !joined}
{#if joined}
{#if allowLeave}
<ModernButton
label={love.string.LeaveRoom}
icon={love.icon.LeaveRoom}
size={'large'}
kind={'negative'}
on:click={leave}
/>
{:else if isMyOffice}
<ModernButton
label={love.string.EndMeeting}
icon={love.icon.LeaveRoom}
size={'large'}
kind={'negative'}
on:click={end}
/>
{/if}
{:else}
<ModernButton
icon={love.icon.EnterRoom}
label={love.string.EnterRoom}
Expand Down
Loading

0 comments on commit 5924c4a

Please sign in to comment.