From d3ad6980d9fcdb8b446ed961fb423545e67f460e Mon Sep 17 00:00:00 2001 From: Zachary Chai Date: Tue, 25 Oct 2016 10:11:36 -0400 Subject: [PATCH] redesigned meeting and room page --- app/assets/javascripts/landing.js | 66 ++++++++++++++++++++---------- app/models/user.rb | 8 ++++ app/views/landing/meeting.html.erb | 45 +++++++++++--------- app/views/landing/room.html.erb | 47 +++++++++++++-------- 4 files changed, 107 insertions(+), 59 deletions(-) diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index b3e24d18..9ede6b12 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -1,10 +1,12 @@ (function() { - var initIndex = function() { - $('#join_form_button').click (function (event) { + var init = function() { + + $('.meeting-join').click (function (event) { + var url = $('.meeting-url').val(); + var name = $('.meeting-user-name').val(); $.ajax({ - url : $(this).data ('url') + "?name=" + $('#join_form_name').val(), + url : url + "/join?name=" + name, dataType : "json", - async : true, type : 'GET', success : function(data) { $(location).attr("href", data.response.join_url); @@ -16,30 +18,50 @@ }); }); - $('#url_form_button').click (function (event) { - $.ajax({ - url : $(this).data ('url'), - dataType : "json", - async : true, - type : 'GET', - success : function(data) { - $('#meeting_url').html(data.response.meeting_url); - $('#text_meeting_url').attr("href", data.response.meeting_url); - $('#text_meeting_url').text(data.response.meeting_url); - }, - error : function(xhr, status, error) { - }, - complete : function(xhr, status) { - } - }); + $('.meeting-url-copy').click (function (e) { + meetingURL = $('.meeting-url'); + meetingURL.select(); + document.execCommand("copy"); + meetingURL.blur(); }); }; + var initIndex = function() { + + $('.generate-link').click (function (e) { + e.preventDefault(); + var link = window.location.protocol + + '//' + + window.location.hostname + + '/' + + 'meetings/' + + Math.trunc(Math.random() * 1000000000); + + $('.meeting-url').val(link); + }); + + + $('.meeting-url').val(''); + $('.generate-link').click(); + }; + + var initRooms = function() { + meetingURL = $('.meeting-url'); + var link = window.location.protocol + + '//' + + window.location.hostname + + meetingURL.data('path'); + meetingURL.val(link); + }; + $(document).on("turbolinks:load", function() { + init(); if ($("body[data-controller=landing]").get(0)) { - if ($("body[data-action=meeting]").get(0) || $("body[data-action=room]").get(0)) { + if ($("body[data-action=meetings]").get(0)) { initIndex(); + } else if ($("body[data-action=rooms]").get(0)) { + initRooms(); } } }); -}).call(this); \ No newline at end of file +}).call(this); diff --git a/app/models/user.rb b/app/models/user.rb index 9cfb2add..0d9f7aa5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,6 +19,14 @@ class User < ApplicationRecord auth_hash['info']['nickname'] end + def ownership_name + if username.end_with? 's' + "#{username}'" + else + "#{username}'s" + end + end + def room_url "/rooms/#{username}" end diff --git a/app/views/landing/meeting.html.erb b/app/views/landing/meeting.html.erb index 7ae51bf0..d853e2fc 100644 --- a/app/views/landing/meeting.html.erb +++ b/app/views/landing/meeting.html.erb @@ -1,28 +1,33 @@ - -
-
-
-
- <% if !current_user.nil? %> - Hello <%= current_user.name %> - <%= link_to "Logout", user_logout_url() %> - <% if current_user.username %> -
<%= link_to 'Personal Room', current_user.room_url %>
- <% else %> -
<%= link_to 'Set Username', edit_user_path(current_user) %>
- <% end %> - <% end %> -
+ +<% content_for :title do %> +
+ Hi Everyone +
+ + The session will be taking place using the following URL + +<% end %> + +<% content_for :footer do %> + +<% end %> -
- <%= render 'landing/join_form' %> +
+
- <%= render 'landing/footer_message' %> + <%= render 'shared/title', title: 'Start A New Session' %> + + <%= render layout: 'shared/center_panel' do %> +
+ <%= render 'shared/meeting_url', hidden: false %> + <%= render 'shared/join_form', user: current_user %> +
+ <% end %> - <%= render 'landing/footer_oauth_append' %>
-
diff --git a/app/views/landing/room.html.erb b/app/views/landing/room.html.erb index b19b97b3..55870e01 100644 --- a/app/views/landing/room.html.erb +++ b/app/views/landing/room.html.erb @@ -1,23 +1,36 @@ - -
+<% if current_user %> + <% page_title = "Welcome, #{current_user.name.split(' ').first}" %> +<% else %> + <% page_title = "Welcome to #{@user.ownership_name} Meeting Space" %> +<% end %> -
-
-
- <% if admin? %> - Hello <%= current_user.name %> - <%= link_to "Logout", user_logout_url() %> +<% content_for :title do %> +
+ <% if current_user == @user %> + Start a new session + <% elsif current_user && current_user != @user %> + <%= "Join #{@user.ownership_name} session" %> + <% else %> + Join the current session + <% end %> +
+<% end %> + +
+
+ + <%= render 'shared/title', title: page_title %> + + <%= render layout: 'shared/center_panel' do %> +
+ <% if current_user == @user %> + <%= render 'shared/meeting_url', hidden: false %> <% else %> - <%= link_to "Login", "/auth/#{@user.provider}" %> + <%= render 'shared/meeting_url', hidden: true %> <% end %> + <%= render 'shared/join_form', user: current_user %>
-
+ <% end %> +
- -
- <%= render 'landing/join_form' %> - - <%= render 'landing/footer_message' %> -
-