ultimatepos/Modules/Communication/Resources/views/layouts/boot.blade.php

64 lines
3.6 KiB
PHP

@php
$commLangKeys = [
'chat', 'meetings', 'module_name', 'search_chats', 'search_messages', 'filter_all', 'filter_direct', 'filter_group',
'new_direct_chat', 'new_group', 'select_colleague', 'start_chat', 'group_name', 'group_members',
'create_group', 'add_member', 'add', 'remove', 'leave_group', 'select_chat', 'no_rooms', 'no_messages',
'send_failed', 'type_message', 'online', 'offline', 'user_typing', 'members', 'group', 'host',
'participant', 'meeting_title', 'scheduled_at', 'participants', 'select_participants', 'start_now',
'status_scheduled', 'status_active', 'status_ended', 'no_meetings', 'join_meeting', 'end_meeting',
'joining', 'created_by', 'meeting_created', 'join_opened', 'confirm_end_meeting', 'meeting_ended_success',
'connecting_to_meeting', 'meeting_connected', 'connection_failed', 'you', 'leave_meeting',
'toggle_mic', 'toggle_camera', 'left_meeting', 'media_permission_denied', 'camera_unavailable',
'mic_unavailable', 'enabling_camera', 'back_to_meetings', 'prejoin_title', 'prejoin_subtitle',
'join_meeting_room', 'select_camera', 'select_microphone', 'no_camera_preview', 'camera_in_use', 'permission_denied', 'secure_context_required',
'my_language', 'enable_live_translation', 'translation_hint', 'meeting_connected_translation', 'toggle_captions',
'meeting_invite_notification', 'cancel', 'go_back', 'error',
];
$commLang = [];
foreach ($commLangKeys as $key) {
$commLang[$key] = __("communication::lang.{$key}");
}
if (empty($commLang['cancel'])) {
$commLang['cancel'] = __('messages.cancel');
}
if (empty($commLang['error'])) {
$commLang['error'] = __('messages.something_went_wrong');
}
if (empty($commLang['go_back'])) {
$commLang['go_back'] = __('messages.go_back');
}
$chatBase = url('communication/chat');
$meetingsBase = url('communication/meetings');
$boot = [
'userId' => auth()->id(),
'userName' => trim(auth()->user()->user_full_name ?? auth()->user()->first_name ?? 'User'),
'businessId' => (int) session('user.business_id'),
'typingTimeoutMs' => (int) config('communication.typing_timeout_ms', 2500),
'pollingFallbackSeconds' => (int) config('communication.polling_fallback_seconds', 30),
'presenceHeartbeatSeconds' => (int) config('communication.presence_heartbeat_seconds', 60),
'lang' => $commLang,
'translationEnabled' => (bool) config('communication.translation_enabled', true),
'translationLanguages' => config('communication.translation_languages', ['fa' => 'فارسی', 'en' => 'English']),
'defaultMeetingLanguage' => config('communication.default_meeting_language', 'fa'),
'routes' => [
'chat' => [
'colleagues' => action([\Modules\Communication\Http\Controllers\ChatController::class, 'colleagues']),
'rooms' => $chatBase.'/rooms',
'createRoom' => $chatBase.'/rooms',
'heartbeat' => action([\Modules\Communication\Http\Controllers\ChatController::class, 'heartbeat']),
],
'meetings' => [
'index' => action([\Modules\Communication\Http\Controllers\MeetingController::class, 'index']),
'store' => action([\Modules\Communication\Http\Controllers\MeetingController::class, 'store']),
'base' => $meetingsBase,
'roomBase' => $meetingsBase,
],
],
];
@endphp
<script>
window.__COMM__ = @json(!empty($commBootExtra) ? array_replace_recursive($boot, $commBootExtra) : $boot);
</script>