Merge branch 'master' into chat-features
This commit is contained in:
commit
ccfba63f6c
|
@ -0,0 +1,12 @@
|
||||||
|
.hand {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
z-index: 10000000000;
|
||||||
|
left: 48%;
|
||||||
|
font-size: 26px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.call-container {
|
||||||
|
// position: relative;
|
||||||
|
}
|
|
@ -2,3 +2,4 @@
|
||||||
@import "alert";
|
@import "alert";
|
||||||
@import "navbar";
|
@import "navbar";
|
||||||
@import "banner";
|
@import "banner";
|
||||||
|
@import "hand";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
img {
|
img {
|
||||||
width: 3em;
|
width: 3em;
|
||||||
padding: 0.2em;
|
padding: 0.2em;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,13 @@ class ChatRoomsChannel < ApplicationCable::Channel
|
||||||
|
|
||||||
def unsubscribed
|
def unsubscribed
|
||||||
# Any cleanup needed when channel is unsubscribed
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
puts "I am now destroyed"
|
||||||
|
# redirect_to root_path
|
||||||
|
# ActionCable.server.broadcast('notifications', {
|
||||||
|
# head: 302, # redirection code, just to make it clear what you're doing
|
||||||
|
# path: chat_room_path(chat_room), # you'll need to use url_helpers, so include them in your file
|
||||||
|
# body: { caller: other_caller.id }
|
||||||
|
# }
|
||||||
|
# redirect_to root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,13 @@ class ChatRoomsController < ApplicationController
|
||||||
ActionCable.server.broadcast "chat_room_#{params[:room]}", session_params
|
ActionCable.server.broadcast "chat_room_#{params[:room]}", session_params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
# chat_room = ChatRoom.find(params[:id])
|
||||||
|
# chat_room.destroy
|
||||||
|
ActionCable.server.broadcast "chat_room_#{params[:id]}", { hangUp: true }
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def session_params
|
def session_params
|
||||||
|
|
|
@ -16,9 +16,8 @@ const userId = document.getElementById('current-user').innerText
|
||||||
App['chatroom' + chatroomId] = App.cable.subscriptions.create({
|
App['chatroom' + chatroomId] = App.cable.subscriptions.create({
|
||||||
channel: 'ChatRoomsChannel',
|
channel: 'ChatRoomsChannel',
|
||||||
room: chatroomId
|
room: chatroomId
|
||||||
}, {
|
}, {
|
||||||
connected: () => {
|
connected: () => {},
|
||||||
},
|
|
||||||
received: data => {
|
received: data => {
|
||||||
if (data["chat_message"]) {
|
if (data["chat_message"]) {
|
||||||
const chatMessage = data["chat_message"]
|
const chatMessage = data["chat_message"]
|
||||||
|
@ -35,7 +34,24 @@ App['chatroom' + chatroomId] = App.cable.subscriptions.create({
|
||||||
} else {
|
} else {
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
}
|
}
|
||||||
|
if (data.hangUp) {
|
||||||
|
document.location.pathname = '/contacts'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
disconnected: () => {
|
||||||
|
document.location.pathname = '/contacts'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const hangUpIcon = document.querySelector('.fa-hand-paper')
|
||||||
|
hangUpIcon.addEventListener('click', event => {
|
||||||
|
fetch(`/chat_rooms/${chatroomId}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-Token': document.querySelector('meta[name=csrf-token]').content
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.location.pathname = '/contacts'
|
||||||
})
|
})
|
||||||
|
|
||||||
// Testing ActionCable
|
// Testing ActionCable
|
||||||
|
|
|
@ -10,6 +10,8 @@ class User < ApplicationRecord
|
||||||
has_many :chat_rooms, through: :chat_room_participations
|
has_many :chat_rooms, through: :chat_room_participations
|
||||||
has_many :requests
|
has_many :requests
|
||||||
|
|
||||||
|
validates :email, uniqueness: true
|
||||||
|
|
||||||
mount_uploader :photo, PhotoUploader
|
mount_uploader :photo, PhotoUploader
|
||||||
|
|
||||||
def contacts
|
def contacts
|
||||||
|
|
|
@ -26,8 +26,10 @@
|
||||||
<div class="call-container">
|
<div class="call-container">
|
||||||
<div id="remote-video-container">
|
<div id="remote-video-container">
|
||||||
<div id="video_overlays">
|
<div id="video_overlays">
|
||||||
|
|
||||||
<video id="local-video" autoplay muted></video>
|
<video id="local-video" autoplay muted></video>
|
||||||
</div>
|
</div>
|
||||||
|
<i class="far fa-hand-paper hand"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="translate-container">
|
<div class="translate-container">
|
||||||
|
@ -52,4 +54,3 @@
|
||||||
<%= javascript_pack_tag 'webrtc' %>
|
<%= javascript_pack_tag 'webrtc' %>
|
||||||
<%= javascript_pack_tag 'translate' %>
|
<%= javascript_pack_tag 'translate' %>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
post '/chat_rooms/chat_room_sessions', to: 'chat_rooms#create'
|
post '/chat_rooms/chat_room_sessions', to: 'chat_rooms#create'
|
||||||
|
|
||||||
resources :chat_rooms, only: [ :show ] do
|
resources :chat_rooms, only: [ :show, :destroy ] do
|
||||||
# testing action cable
|
# testing action cable
|
||||||
post '/cable_testing', to: 'pages#cable_testing'
|
post '/cable_testing', to: 'pages#cable_testing'
|
||||||
post '/send_message', to: 'pages#send_message'
|
post '/send_message', to: 'pages#send_message'
|
||||||
|
|
Loading…
Reference in New Issue