From 81ed01010cec613f8035192622a6302431b4f705 Mon Sep 17 00:00:00 2001 From: Benjamin Myara Date: Fri, 31 Aug 2018 10:17:26 +0100 Subject: [PATCH 1/3] done brand --- app/assets/stylesheets/users/_index.scss | 1 + app/assets/stylesheets/users/_setting.scss | 0 app/assets/stylesheets/users/_show.scss | 2 + app/controllers/users_controller.rb | 8 +- app/javascript/packs/application.js | 3 + app/views/shared/_navbar.html.erb | 2 +- app/views/users/setting.html.erb | 158 ++++++++++++++++++ app/views/users/show.html.erb | 3 +- config/routes.rb | 1 + .../20180830100110_add_columns_to_users.rb | 8 + db/schema.rb | 6 +- 11 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 app/assets/stylesheets/users/_setting.scss create mode 100644 app/views/users/setting.html.erb create mode 100644 db/migrate/20180830100110_add_columns_to_users.rb diff --git a/app/assets/stylesheets/users/_index.scss b/app/assets/stylesheets/users/_index.scss index 7147706..949abee 100644 --- a/app/assets/stylesheets/users/_index.scss +++ b/app/assets/stylesheets/users/_index.scss @@ -1,2 +1,3 @@ @import "show"; @import "edit"; +@import "setting"; diff --git a/app/assets/stylesheets/users/_setting.scss b/app/assets/stylesheets/users/_setting.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/users/_show.scss b/app/assets/stylesheets/users/_show.scss index b978a08..e800dd4 100644 --- a/app/assets/stylesheets/users/_show.scss +++ b/app/assets/stylesheets/users/_show.scss @@ -34,6 +34,7 @@ display: flex; flex-direction: column; justify-content: center; + color: #f2321f; h1 { margin: 0 0 .5em 0 ; } @@ -49,3 +50,4 @@ } + diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3901dc9..d1090e6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -26,6 +26,11 @@ class UsersController < ApplicationController redirect_to root_path end + def setting + @user = current_user + end + + private def find_user @@ -33,7 +38,8 @@ class UsersController < ApplicationController #authorize @user end + def user_params - params.require(:user).permit(:email, :first_name, :last_name, :description, :photo) + params.require(:user).permit(:email, :first_name, :last_name, :description, :photo, :language, :caption_font, :caption_font_size, :enable_transcript) end end diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 01dfd79..b4593fd 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -1 +1,4 @@ import "bootstrap"; + +import { profilePageAnimation } from '../users/lesson'; +profilePageAnimation(); diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 6810141..c5ea4c9 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -6,7 +6,7 @@
<% if current_user.nil? %> diff --git a/app/views/users/setting.html.erb b/app/views/users/setting.html.erb new file mode 100644 index 0000000..131f531 --- /dev/null +++ b/app/views/users/setting.html.erb @@ -0,0 +1,158 @@ +
+ <%= simple_form_for(@user) do |t| %> +
+
+
+ +
<%= t.input :language, collection: +[ +"Afrikaans (South Africa)", +"Amharic (Ethiopia)", +"Armenian (Armenia)", +"Azerbaijani (Azerbaijan)", +"Indonesian (Indonesia)", +"Malay (Malaysia)", +"Bengali (Bangladesh)", +"Bengali (India)", +"Catalan (Spain)", +"Czech (Czech Republic)", +"Danish (Denmark)", +"German (Germany)", +"English (Australia)", +"English (Canada)", +"English (Ghana)", +"English (United Kingdom)", +"English (India)", +"English (Ireland)", +"English (Kenya)", +"English (New Zealand)", +"English (Nigeria)", +"English (Philippines)", +"English (South Africa)", +"English (Tanzania)", +"English (United States)", +"Spanish (Argentina)", +"Spanish (Bolivia)", +"Spanish (Chile)", +"Spanish (Colombia)", +"Spanish (Costa Rica)", +"Spanish (Ecuador)", +"Spanish (El Salvador)", +"Spanish (Spain)", +"Spanish (United States)", +"Spanish (Guatemala)", +"Spanish (Honduras)", +"Spanish (Mexico)", +"Spanish (Nicaragua)", +"Spanish (Panama)", +"Spanish (Paraguay)", +"Spanish (Peru)", +"Spanish (Puerto Rico)", +"Spanish (Dominican Republic)", +"Spanish (Uruguay)", +"Spanish (Venezuela)", +"Basque (Spain)", +"Filipino (Philippines)", +"French (Canada)", +"French (France)", +"Galician (Spain)", +"Georgian (Georgia)", +"Gujarati (India)", +"Croatian (Croatia)", +"Zulu (South Africa)", +"Icelandic (Iceland)", +"Italian (Italy)", +"Javanese (Indonesia)", +"Kannada (India)", +"Khmer (Cambodia)", +"Lao (Laos)", +"Latvian (Latvia)", +"Lithuanian (Lithuania)", +"Hungarian (Hungary)", +"Malayalam (India)", +"Marathi (India)", +"Dutch (Netherlands)", +"Nepali (Nepal)", +"Norwegian Bokmål (Norway)", +"Polish (Poland)", +"Portuguese (Brazil)", +"Portuguese (Portugal)", +"Romanian (Romania)", +"Sinhala (Sri Lanka)", +"Slovak (Slovakia)", +"Slovenian (Slovenia)", +"Sundanese (Indonesia)", +"Swahili (Tanzania)", +"Swahili (Kenya)", +"Finnish (Finland)", +"Swedish (Sweden)", +"Tamil (India)", +"Tamil (Singapore)", +"Tamil (Sri Lanka)", +"Tamil (Malaysia)", +"Telugu (India)", +"Vietnamese (Vietnam)", +"Turkish (Turkey)", +"Urdu (Pakistan)", +"Urdu (India)", +"Greek (Greece)", +"Bulgarian (Bulgaria)", +"Russian (Russia)", +"Serbian (Serbia)", +"Ukrainian (Ukraine)", +"Hebrew (Israel)", +"Arabic (Israel)", +"Arabic (Jordan)", +"Arabic (United Arab Emirates)", +"Arabic (Bahrain)", +"Arabic (Algeria)", +"Arabic (Saudi Arabia)", +"Arabic (Iraq)", +"Arabic (Kuwait)", +"Arabic (Morocco)", +"Arabic (Tunisia)", +"Arabic (Oman)", +"Arabic (Qatar)", +"Arabic (Lebanon)", +"Arabic (Egypt)", +"Persian (Iran)", +"Hindi (India)", +"Thai (Thailand)", +"Korean (South Korea)", +"Chinese, Mandarin (Traditional, Taiwan)", +"Chinese, Cantonese (Traditional, Hong Kong)", +"Japanese (Japan)", +"Chinese, Mandarin (Simplified, Hong Kong)", +"Chinese, Mandarin (Simplified, China)"] %> + +
+
+
<%= t.input :caption_font %>
+
<%= t.input :caption_font_size %>
+
<%= t.input :enable_transcript %>
+ + <%= link_to "Save", contacts_path, class: "btn btn-primary save-btn form-control" %> +

+
+ + + +
+ <% if @user.photo.url.nil? %> + <%= image_tag "https://upload.wikimedia.org/wikipedia/commons/8/89/Portrait_Placeholder.png"%> + <% else %> + <%= cl_image_tag current_user.photo%> + <% end %> + + <%#= t.input_field :photo, onchange: 'this.form.submit();' %> + <%#= t.input_field :photo, as: :hidden %> + +
+ +
+ <% end %> +
+ + + + diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 5d17cda..fcd054c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -22,5 +22,6 @@ confirm: "Are you sure?" } %>
-
+ + diff --git a/config/routes.rb b/config/routes.rb index 84772b8..6e91251 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,7 @@ Rails.application.routes.draw do get '/call', to: 'pages#call' get '/contacts', to: 'pages#index' + get '/setting', to: 'users#setting' post '/sessions', to: 'video_sessions#create' mount ActionCable.server, at: '/cable' diff --git a/db/migrate/20180830100110_add_columns_to_users.rb b/db/migrate/20180830100110_add_columns_to_users.rb new file mode 100644 index 0000000..1a23916 --- /dev/null +++ b/db/migrate/20180830100110_add_columns_to_users.rb @@ -0,0 +1,8 @@ +class AddColumnsToUsers < ActiveRecord::Migration[5.2] + def change + add_column :users, :language, :string + add_column :users, :caption_font, :string + add_column :users, :caption_font_size, :integer + add_column :users, :enable_transcript, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 3502be3..2b17520 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_08_29_105638) do +ActiveRecord::Schema.define(version: 2018_08_30_100110) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -33,6 +33,10 @@ ActiveRecord::Schema.define(version: 2018_08_29_105638) do t.string "first_name" t.string "last_name" t.string "photo" + t.string "language" + t.string "caption_font" + t.integer "caption_font_size" + t.boolean "enable_transcript" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end From 0b377cbe204eca6be10635b1e0a97c63de01e163 Mon Sep 17 00:00:00 2001 From: Beatrice Olivera Date: Fri, 31 Aug 2018 11:29:24 +0100 Subject: [PATCH 2/3] fixed calling modal --- app/controllers/pages_controller.rb | 1 - app/javascript/packs/modal.js | 8 ++++++++ app/views/pages/_contact.html.erb | 6 +++++- config/application.rb | 2 ++ db/schema.rb | 4 +--- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 app/javascript/packs/modal.js diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index efd5757..e7676ac 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -36,7 +36,6 @@ class PagesController < ApplicationController chat_room_id: chat_room.id } }) - end def accept_call diff --git a/app/javascript/packs/modal.js b/app/javascript/packs/modal.js new file mode 100644 index 0000000..e9249f1 --- /dev/null +++ b/app/javascript/packs/modal.js @@ -0,0 +1,8 @@ +import "bootstrap"; + +const btn = document.getElementById("modalTrigger"); +const modal = document.getElementById("myModal"); + +btn.addEventListener('click', function(event) { + $('#myModal').modal('show'); +}); diff --git a/app/views/pages/_contact.html.erb b/app/views/pages/_contact.html.erb index 08f0a36..1a77dbf 100644 --- a/app/views/pages/_contact.html.erb +++ b/app/views/pages/_contact.html.erb @@ -18,13 +18,14 @@ end
- <%= link_to establish_call_path(contact.id), 'data-toggle':"modal", 'data-target':"#myModal" do %> + <%= link_to establish_call_path(contact.id), remote: true, id: "modalTrigger" do %> <% end %>
+ + + +<%= javascript_pack_tag 'modal' %> diff --git a/config/application.rb b/config/application.rb index a72f336..1a5c6c8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,6 +15,8 @@ module Polyglot end # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 + config.action_view.embed_authenticity_token_in_remote_forms = true + # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/db/schema.rb b/db/schema.rb index 050711c..46b1487 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,9 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. - -# ActiveRecord::Schema.define(version: 2018_08_30_100110) do -ActiveRecord::Schema.define(version: 2018_08_29_123204) do +ActiveRecord::Schema.define(version: 2018_08_30_100110) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 4eecfe6291fc24df5495450c915bcf4ce1d04ab5 Mon Sep 17 00:00:00 2001 From: Beatrice Olivera Date: Fri, 31 Aug 2018 11:55:03 +0100 Subject: [PATCH 3/3] fixed issue where modal trigger broke navbar --- app/assets/javascripts/signaling-server.js | 22 +++++++++++++++------- app/javascript/components/modal.js | 11 +++++++++++ app/javascript/packs/application.js | 9 +++++++-- app/javascript/packs/modal.js | 8 -------- app/views/layouts/application.html.erb | 1 + app/views/pages/_contact.html.erb | 1 - 6 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 app/javascript/components/modal.js delete mode 100644 app/javascript/packs/modal.js diff --git a/app/assets/javascripts/signaling-server.js b/app/assets/javascripts/signaling-server.js index 25db06a..25d1e5e 100644 --- a/app/assets/javascripts/signaling-server.js +++ b/app/assets/javascripts/signaling-server.js @@ -16,10 +16,12 @@ let pcPeers = {}; // peer connection let localstream; window.onload = () => { - currentUser = document.getElementById("current-user").innerHTML; - console.log(currentUser) - localVideo = document.getElementById("local-video"); - remoteVideoContainer = document.getElementById("remote-video-container"); + if (document.getElementById("current-user")) { + currentUser = document.getElementById("current-user").innerHTML; + console.log(currentUser) + localVideo = document.getElementById("local-video"); + remoteVideoContainer = document.getElementById("remote-video-container"); + } }; // Ice Credentials @@ -35,8 +37,10 @@ document.onreadystatechange = async () => { }) localstream = stream; - localVideo.srcObject = stream - localVideo.muted = true + if (localVideo) { + localVideo.srcObject = stream + localVideo.muted = true + } } catch (e) { console.error(e); } } }; @@ -67,7 +71,11 @@ document.onreadystatechange = async () => { // } // }); // }; -const chatroomId = document.getElementById('chatroom-hook').dataset["chatroomId"] + +if (document.getElementById('chatroom-hook')) { + const chatroomId = document.getElementById('chatroom-hook').dataset["chatroomId"] + +} const handleJoinSession = async () => { App['chatroom' + chatroomId] = await App.cable.subscriptions.create({ diff --git a/app/javascript/components/modal.js b/app/javascript/components/modal.js new file mode 100644 index 0000000..25eb307 --- /dev/null +++ b/app/javascript/components/modal.js @@ -0,0 +1,11 @@ + +const triggerModalEvent = () => { + const btn = document.getElementById("modalTrigger"); + const modal = document.getElementById("myModal"); + + btn.addEventListener('click', function(event) { + $('#myModal').modal('show'); + }); +} + +export { triggerModalEvent } diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index b4593fd..8a54864 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -1,4 +1,9 @@ import "bootstrap"; -import { profilePageAnimation } from '../users/lesson'; -profilePageAnimation(); +import { triggerModalEvent } from "../components/modal.js"; + +triggerModalEvent(); + +// import { profilePageAnimation } from '../users/lesson'; + +// profilePageAnimation(); diff --git a/app/javascript/packs/modal.js b/app/javascript/packs/modal.js deleted file mode 100644 index e9249f1..0000000 --- a/app/javascript/packs/modal.js +++ /dev/null @@ -1,8 +0,0 @@ -import "bootstrap"; - -const btn = document.getElementById("modalTrigger"); -const modal = document.getElementById("myModal"); - -btn.addEventListener('click', function(event) { - $('#myModal').modal('show'); -}); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7118264..cfec1f6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,5 +15,6 @@ <%= yield %> <%= javascript_include_tag 'application' %> <%= javascript_pack_tag 'application' %> + diff --git a/app/views/pages/_contact.html.erb b/app/views/pages/_contact.html.erb index 1a77dbf..0551402 100644 --- a/app/views/pages/_contact.html.erb +++ b/app/views/pages/_contact.html.erb @@ -61,4 +61,3 @@ end -<%= javascript_pack_tag 'modal' %>