redo rooms page

This commit is contained in:
Josh 2018-05-31 15:04:18 -04:00
parent 9e5250353b
commit ede80075c1
27 changed files with 258 additions and 154 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -52,12 +52,22 @@ a {
text-decoration: none !important;
}
.sessions {
background-color: white;
}
.start-block {
background-color: white;
border: 3px solid lightblue;
border-radius: 4px;
}
.start-button {
font-size: 26px;
position: absolute;
bottom: 0;
}
.main-large {
font-size: 20px;
}
@ -83,16 +93,12 @@ html, body {
}
.wrapper {
min-height:100%;
position:relative;
min-height: 100%;
position: relative;
}
.footer {
width: 100%;
height: 70px;
position: absolute;
bottom: 0;
left: 0;
text-align: center;
}

View File

@ -4,6 +4,7 @@ class MainController < ApplicationController
# GET /
def index
@user = User.new
end
private

View File

@ -48,7 +48,7 @@ class RoomsController < ApplicationController
# POST /r/:room_uid
def join
opts = default_meeting_options
# If you're unauthenticated, you must enter a name to join the meeting.
if params[:join_name]
redirect_to @room.join_path(params[:join_name], opts)
@ -57,9 +57,9 @@ class RoomsController < ApplicationController
# DELETE /r/:room_uid
def destroy
@room.destroy
@room.destroy unless @room == current_user.main_room
redirect_to root_path
redirect_to current_user.main_room
end
# GET /r/:room_uid/start
@ -87,7 +87,11 @@ class RoomsController < ApplicationController
# GET /r/:room_uid/logout
def logout
# Redirect the owner to their room.
redirect_to root_path
if current_user
redirect_to current_user.main_room
else
redirect_to root_path
end
end
# GET /r/:room_uid/sessions

View File

@ -1,5 +1,5 @@
class UsersController < ApplicationController
# GET /signup
def new
@user = User.new
@ -9,11 +9,11 @@ class UsersController < ApplicationController
def create
user = User.new(user_params)
user.provider = "greenlight"
if user.save
login(user)
login(user)
else
render :new
end
end
@ -25,6 +25,6 @@ class UsersController < ApplicationController
private
def user_params
params.require(:user).permit(:name, :email, :username, :password, :password_confirmation)
params.require(:user).permit(:name, :email, :password, :password_confirmation)
end
end

View File

@ -1,9 +1,9 @@
module SessionsHelper
# Logs a user into GreenLight.
def login(user)
session[:user_id] = user.id
redirect_to root_path
#redirect_to room_path(user.room.uid)
redirect_to user.main_room
end
# Logs current user out of GreenLight.

View File

@ -1,10 +1,13 @@
class Room < ApplicationRecord
before_create :generate_uids
before_create :setup
validates :name, presence: true
belongs_to :user
has_one :meeting
ROOM_ICONS = %w(circle star certificate play cloud heart square bookmark cog)
RETURNCODE_SUCCESS = "SUCCESS"
def to_param
@ -116,9 +119,11 @@ class Room < ApplicationRecord
end
# Generates a uid for the room and BigBlueButton.
def generate_uids
self.uid = [user.firstname, (0...8).map { (65 + rand(26)).chr }.join].join('-')
def setup
self.uid = [user.firstname, (0...8).map { (65 + rand(26)).chr }.join].join('-').downcase
self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s
self.icon = ROOM_ICONS.sample
end
# Rereives the loadbalanced BigBlueButton credentials for a user.

View File

@ -1,12 +1,12 @@
class User < ApplicationRecord
after_create :initialize_room
after_create :initialize_main_room
before_save { email.downcase! unless email.nil? }
has_many :rooms
belongs_to :main_room, class_name: 'Room', foreign_key: :room_id, required: false
validates :name, length: { maximum: 24 }, presence: true
validates :username, presence: true
validates :provider, presence: true
validates :email, length: { maximum: 60 }, allow_nil: true,
uniqueness: { case_sensitive: false },
@ -27,6 +27,7 @@ class User < ApplicationRecord
user.username = send("#{auth['provider']}_username", auth)
user.email = send("#{auth['provider']}_email", auth)
user.image = send("#{auth['provider']}_image", auth)
user.save!
user
end
@ -88,7 +89,8 @@ class User < ApplicationRecord
private
# Initializes a room for the user.
def initialize_room
Room.create(user_id: self.id, name: firstname + "'s Room")
def initialize_main_room
self.main_room = Room.create!(user: self, name: firstname + "'s Room")
self.save
end
end

View File

@ -32,12 +32,12 @@
<%= yield %>
<%= render "shared/footer" %>
<!-- Modal Load -->
<% if current_user %>
<%= render "shared/modals/create_room_modal" %>
<% end %>
</div>
<%= render "shared/footer" %>
</body>
</html>

View File

@ -1,28 +1,11 @@
<div class="container">
<% if current_user %>
<h1 id="user-text" class="display-3 text-center text-primary mt-9"><%= "Welcome, #{current_user.firstname}." %></h1>
<% else %>
<h1 id="main-text" class="display-3 text-center text-primary mt-9">Teach Students Online.</h1>
<%= render "shared/modals/video_modal" %>
<% end %>
<h1 id="main-text" class="display-3 text-center text-primary mt-9">Teach Students Online.</h1>
<%= render "shared/modals/video_modal" %>
<hr class="small-rule">
<% if current_user %>
<div class="row">
<% current_user.rooms.each do |room| %>
<div class="col-4">
<%= link_to room do %>
<%= render "shared/components/room_block", room: room %>
<% end %>
</div>
<% end %>
</div>
<br>
<% else %>
<%= render "shared/features" %>
<% end %>
<%= render "shared/features" %>
</div>
<script>

View File

@ -2,7 +2,7 @@
<%= render "shared/components/subtitle", subtitle: "Sessions" %>
<div class="col-10 offset-1">
<div class="col-12">
<div class="card">
<div class="table-responsive">
<table class="table table-hover table-outline table-vcenter text-nowrap card-table">
@ -48,6 +48,10 @@
</div>
Unlisted
</td>
<td>
<a href="#" class="btn btn-secondary">One</a>
<a href="#" class="btn btn-secondary">One</a>
</td>
<td class="text-center">
<div class="item-action dropdown">
<a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>

View File

@ -1,15 +1,56 @@
<p>This is a room.</p>
<div class="container">
<div class="row mt-9">
<div class="col-9">
<h1 id="user-text" class="display-3 text-left text-primary mb-5"><%= @room.name %></h1>
<label class="form-label text-primary">Invite Participants</label>
<form class="form-inline">
<input id="invite-url" type="text" class="form-control mb-5" value="<%= request.base_url + @room.invite_path %>" readonly="" style="width: 40%;">
<div id="copy" class="btn btn-primary mx-2 mb-5">
<i class="fas fa-copy"></i>
Copy
</div>
<div id="email" class="btn btn-primary mb-5">
<i class="fas fa-envelope"></i>
Email
</div>
</form>
<h4 class="text-left text-primary">2 Sessions | 3 Recordings</h4>
</div>
<div class="col-3">
<%= link_to "Start", start_room_path(@room), class: "btn btn-primary btn-block px-7 start-button float-right" %>
</div>
</div>
<p><%= @room.user.name %><p>
<p><%= @room.uid %><p>
<div class="row mt-8 mb-6">
<% (current_user.rooms - [@room]).each do |room| %>
<div class="col-4">
<%= link_to room do %>
<%= render "shared/components/room_block", room: room %>
<% end %>
</div>
<% end %>
</div>
</div>
<p>Click below to join the meeting.</p>
<%= render "shared/sessions" %>
<% if @room.is_running? %>
<p>meeting is already running</p>
<% else %>
<%= link_to "Start Room", start_room_path(@room) %>
<% end %>
<script>
var invite_url;
var copy = $('#copy');
<br><br>
<%= link_to "Sessions", sessions_path(@room) %>
copy.on('click', function(){
var inviteURL = $('#invite-url');
inviteURL.select();
var success = document.execCommand("copy");
if (success) {
inviteURL.blur();
copy.addClass('btn-success');
copy.html("<i class='fas fa-check'></i> Copy")
setTimeout(function(){
copy.removeClass('btn-success');
copy.html("<i class='fas fa-copy'></i> Copy")
}, 2000)
}
});
</script>

View File

@ -2,16 +2,14 @@
<div class="container">
<div class="d-flex">
<%= link_to root_path, class: "header-brand" do %>
<%= image_tag("bbb_logo.png", class: "header-brand-img") %>
<%= image_tag("logo_with_text.png", class: "header-brand-img") %>
<% end %>
<div class="d-flex order-lg-2 ml-auto">
<% if current_user %>
<a class="px-3" href="" data-toggle="modal" data-target="#createRoomModal">
<a class="px-5" href="" data-toggle="modal" data-target="#createRoomModal">
<i class="fas fa-plus"></i> Create Room
</a>
<%= render "shared/modals/login_modal" %>
<a class="px-3" href="">Sessions</a>
<div class="dropdown">
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
<% if current_user.image.nil? %>
@ -41,8 +39,11 @@
</div>
</div>
<% else %>
<button type="submit" class="btn btn-pill btn-outline-primary ml-auto" data-toggle="modal" data-target="#loginModal">Login</button>
<button type="submit" class="btn btn-pill btn-outline-primary mx-2" data-toggle="modal" data-target="#loginModal">Login</button>
<button type="submit" class="btn btn-pill btn-outline-primary mx-2" data-toggle="modal" data-target="#signupModal">Signup</button>
<%= render "shared/modals/login_modal" %>
<%= render "shared/modals/signup_modal" %>
<% end %>
</div>
</div>

View File

@ -1,42 +0,0 @@
<div <%= "hidden" if hidden %> class="meeting-url-wrapper">
<div class="meeting-url-group">
<input type="text" class="form-control meeting-url"/>
</div>
<% if current_user %>
<% body = t('meeting_invite.signed_in.body', user: current_user.name) %>
<% subject = t('meeting_invite.signed_in.subject', user: current_user.name) %>
<% else %>
<% body = t('meeting_invite.not_signed_in.body') %>
<% subject = t('meeting_invite.not_signed_in.subject') %>
<% end %>
<div class="meeting-url-button-group center-block">
<button type="button" class="btn btn-default meeting-url-copy has-tooltip"
title="<%= t('url_copy_explanation') %>"
data-copied-hint="<%= t('copied') %>"
data-copy-error="<%= t('copy_error') %>"
data-copy-hint="<%= t('url_copy_explanation') %>"
>
<%= icon('clipboard') %>
</button>
<button type="button" class="btn btn-default meeting-invite has-tooltip"
title="<%= t('meeting_invite.explanation') %>"
data-invite-body="<%= body %>"
data-invite-subject="<%= subject %>"
>
<%= icon('envelope-o') %>
</button>
<button type="button" class="btn btn-default meeting-url-qrcode has-tooltip"
title="<%= t('qrcode.explanation') %>"
data-qrcode-generated-hint="<%= t('qrcode.generated') %>"
data-qrcode-generate-error="<%= t('qrcode.generate_error') %>"
data-qrcode-generate-hint="<%= t('qrcode.explanation') %>"
>
<%= icon('qrcode') %>
</button>
</div>
<div class="meeting-url-qrcode-group center-block has-tooltip"></div>
</div>

View File

@ -0,0 +1,76 @@
<div class="sessions pb-5">
<div class="container pt-6">
<%= render "shared/components/subtitle", subtitle: "Sessions" %>
<div class="col-12">
<div class="card">
<div class="table-responsive">
<table class="table table-hover table-outline table-vcenter text-nowrap card-table">
<thead>
<tr>
<th>Name</th>
<th>Thumbnails</th>
<th class="text-left">Length</th>
<th class="text-left">Users</th>
<th class="text-left">Visibility</th>
<th class="text-center"><i class="icon-settings"></i></th>
</tr>
</thead>
<tbody>
<% 3.times do %>
<tr>
<td>
<div>Example Meeting</div>
<div class="small text-muted">
June 21, 2017 <i>(about 3 hours ago)</i>
</div>
</td>
<td>
<img class="thumbnail px-2" src="http://test-install.blindsidenetworks.com/presentation/b622495d927cd99e9898b0601c2b18a5424a0627-1527259102285/presentation/d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1527259102298/thumbnails/thumb-1.png">
<img class="thumbnail px-2" src="http://test-install.blindsidenetworks.com/presentation/b622495d927cd99e9898b0601c2b18a5424a0627-1527259102285/presentation/d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1527259102298/thumbnails/thumb-1.png">
<img class="thumbnail px-2" src="http://test-install.blindsidenetworks.com/presentation/b622495d927cd99e9898b0601c2b18a5424a0627-1527259102285/presentation/d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1527259102298/thumbnails/thumb-1.png">
</td>
<td class="text-left">
<div class="small text-muted text-uppercase">
Length
</div>
1 hr
</td>
<td class="text-left">
<div class="small text-muted text-uppercase">
Users
</div>
4
</td>
<td class="text-left">
<div class="small text-muted text-uppercase">
Visibility
</div>
Unlisted
</td>
<td>
<a href="#" class="btn btn-secondary">Presentation</a>
<a href="#" class="btn btn-secondary">Podcast</a>
</td>
<td class="text-center">
<div class="item-action dropdown">
<a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> Action </a>
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-edit-2"></i> Another action </a>
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-message-square"></i> Something else here</a>
<div class="dropdown-divider"></div>
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-link"></i> Separated link</a>
</div>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -26,34 +26,3 @@
</div>
</div>
</div>
<script>
var invite_url;
var copy = $('#copy');
$('#name-input').on('input', function(){
if ($('#name-input').val() == "") {
invite_url = window.location.href + "m/your-meeting-name";
} else {
invite_url = window.location.href + "m/" + encodeURIComponent($('#name-input').val());
}
$('#invite-url').val(invite_url);
});
copy.on('click', function(){
var inviteURL = $('#invite-url');
inviteURL.select();
var success = document.execCommand("copy");
if (success) {
inviteURL.blur();
copy.addClass('btn-success');
copy.html("<i class='fas fa-check'></i> Copy")
setTimeout(function(){
copy.removeClass('btn-success');
copy.html("<i class='fas fa-copy'></i> Copy")
}, 1500)
}
});
</script>

View File

@ -3,7 +3,9 @@
<table class="table table-hover table-outline table-vcenter text-nowrap card-table">
<tbody>
<td>
<span class="colorinput-color bg-azure"></span>
<span class="stamp stamp-md bg-azure mr-3">
<i class="fas fa-<%= room.icon %>"></i>
</span>
</td>
<td>
<div><%= room.name %></div>
@ -17,8 +19,10 @@
<div class="dropdown-menu dropdown-menu-right">
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> Action </a>
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-edit-2"></i> Another action </a>
<%= button_to room, method: :delete, data: { confirm: 'Are you sure?' }, class: "dropdown-item" do %>
<i class="dropdown-icon fe fe-trash"></i> Delete
<% if room != current_user.main_room %>
<%= button_to room, method: :delete, data: { confirm: 'Are you sure?' }, class: "dropdown-item" do %>
<i class="dropdown-icon fe fe-trash"></i> Delete
<% end %>
<% end %>
</div>
</div>

View File

@ -1,5 +1,5 @@
<div class="row">
<div class="col-10 offset-1">
<div class="col-12">
<p class="subtitle"><%= subtitle %></p>
<hr>
</div>

View File

@ -13,15 +13,14 @@
<span class="input-icon-addon">
<i class="fas fa-chalkboard-teacher"></i>
</span>
<%= f.text_field :name, class: "form-control", placeholder: "Enter a room name...", autocomplete: :off %>
</div>
<%= f.text_field :name, id: "room-name", class: "form-control", placeholder: "Enter a room name...", autocomplete: :off %> </div>
<label class="custom-switch mt-5 mb-5 float-left">
<%= f.check_box :auto_join, class: "custom-switch-input", checked: true %>
<span class="custom-switch-indicator"></span>
<span class="custom-switch-description">Automatically join me into the room when created.</span>
<span class="custom-switch-description">Automatically join me into the room.</span>
</label>
<div class="form-footer">
<%= f.submit "Create Room", class: "btn btn-outline-primary btn-block btn-pill" %>
<%= f.submit "Create Room", id: "create-room-submit", class: "btn btn-outline-primary btn-block btn-pill" %>
</div>
<% end %>
</div>
@ -32,3 +31,15 @@
</div>
</div>
</div>
<script>
var roomCreateValidations = function(){
if($('#room-name').val().length == 0){
$('#room-name').addClass("is-invalid");
}
}
$('#create-room-submit').on('click', roomCreateValidations);
</script>

View File

@ -35,11 +35,7 @@
<button type="submit" class="btn btn-outline-primary btn-block btn-pill">Login</button>
</div>
</div>
<div class="card-footer">
<%= link_to "Don't have an account, sign up!", "google.com" %>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,38 @@
<div class="modal fade" id="signupModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content text-center">
<div class="modal-body">
<div class="card-body p-6">
<div class="card-title text-primary">
<h3>Signup</h3>
</div>
<hr class="small-rule">
<%= form_for(@user, url: signup_path) do |f| %>
<div class="form-group">
<%= f.label :name, "Full Name", class: "form-label text-left" %>
<%= f.text_field :name, class: "form-control", placeholder: "Full Name" %>
</div>
<div class="form-group">
<%= f.label :email, "Email", class: "form-label text-left" %>
<%= f.text_field :email, class: "form-control", placeholder: "Email" %>
</div>
<div class="form-group">
<%= f.label :password, "Password", class: "form-label text-left" %>
<%= f.password_field :password, class: "form-control", placeholder: "Password" %>
</div>
<div class="form-group">
<%= f.label :password, "Password Confirmation", class: "form-label text-left" %>
<%= f.password_field :password, class: "form-control", placeholder: "Password Confirmation" %>
</div>
<div class="form-footer">
<%= f.submit "Signup", class: "btn btn-outline-primary btn-block btn-pill" %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>

View File

@ -3,13 +3,13 @@
<%= render "shared/components/subtitle", subtitle: "Settings" %>
<div class="row">
<div class="col-2 offset-1">
<div class="col-2">
<button id="account" class="setting-btn btn btn-primary btn-sm btn-block m-2">Account</button>
<button id="password" class="setting-btn btn btn-primary btn-sm btn-block m-2">Password</button>
<button id="design" class="setting-btn btn btn-primary btn-sm btn-block m-2">Design</button>
</div>
<div class="col-8">
<div class="col-10">
<div id="account" class="setting-view card">
<div class="card-body p-6">
<div class="card-title text-primary">
@ -58,7 +58,7 @@
<hr>
<div class="form-group">
<div class="row">
<div class="col-9">
<div class="col-8">
<label class="form-label">Old Password</label>
<input type="password" class="form-control">
<br>

View File

@ -12,8 +12,7 @@ Rails.application.routes.draw do
get '/sessions', to: 'rooms#sessions', as: :sessions
end
# Signup routes.
get '/signup', to: 'users#new'
# Signup route.
post '/signup', to: 'users#create'
# User settings.

View File

@ -1,6 +1,7 @@
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.belongs_to :room, index: true
t.string :provider
t.string :uid
t.string :name

View File

@ -5,6 +5,7 @@ class CreateRooms < ActiveRecord::Migration[5.0]
t.string :name, index: true
t.string :uid, index: true
t.string :bbb_id, index: true
t.string :icon, index: true
t.timestamps
end

View File

@ -17,15 +17,18 @@ ActiveRecord::Schema.define(version: 20180504131705) do
t.string "name"
t.string "uid"
t.string "bbb_id"
t.string "icon"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["bbb_id"], name: "index_rooms_on_bbb_id"
t.index ["icon"], name: "index_rooms_on_icon"
t.index ["name"], name: "index_rooms_on_name"
t.index ["uid"], name: "index_rooms_on_uid"
t.index ["user_id"], name: "index_rooms_on_user_id"
end
create_table "users", force: :cascade do |t|
t.integer "room_id"
t.string "provider"
t.string "uid"
t.string "name"
@ -36,6 +39,7 @@ ActiveRecord::Schema.define(version: 20180504131705) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["password_digest"], name: "index_users_on_password_digest", unique: true
t.index ["room_id"], name: "index_users_on_room_id"
end
end