Skip to content

Commit

Permalink
Added room settings alerts and made fixes to other alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Jan 31, 2019
1 parent e8e8b35 commit d4d5b4f
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 51 deletions.
16 changes: 9 additions & 7 deletions app/controllers/password_resets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,29 @@ def create
if @user
@user.create_reset_digest
@user.send_password_reset_email(request.base_url)
redirect_to root_url, notice: I18n.t("email_sent")
flash[:success] = I18n.t("email_sent")
redirect_to root_url
else
redirect_to new_password_reset_path, notice: I18n.t("no_user_email_exists")
redirect_to new_password_reset_path, alert: I18n.t("no_user_email_exists")
end
rescue => e
logger.error "Error in email delivery: #{e}"
redirect_to root_path, notice: I18n.t(params[:message], default: I18n.t("delivery_error"))
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("delivery_error"))
end

def edit
end

def update
if params[:user][:password].empty?
flash.now[:notice] = I18n.t("password_empty_notice")
flash.now[:alert] = I18n.t("password_empty_notice")
render 'edit'
elsif params[:user][:password] != params[:user][:password_confirmation]
flash.now[:notice] = I18n.t("password_different_notice")
flash.now[:alert] = I18n.t("password_different_notice")
render 'edit'
elsif current_user.update_attributes(user_params)
redirect_to root_path, notice: I18n.t("password_reset_success")
flash[:success] = I18n.t("password_reset_success")
redirect_to root_path
else
render 'edit'
end
Expand All @@ -73,7 +75,7 @@ def user_params
# Checks expiration of reset token.
def check_expiration
if current_user.password_reset_expired?
redirect_to new_password_reset_url, notice: I18n.t("expired_reset_token")
redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token")
end
end

Expand Down
17 changes: 11 additions & 6 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def start
begin
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
rescue BigBlueButton::BigBlueButtonException => exc
redirect_to room_path, notice: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
redirect_to room_path, alert: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception"))
end

# Notify users that the room has started.
Expand All @@ -129,12 +129,17 @@ def start

# POST /:room_uid/update_settings
def update_settings
@room = Room.find_by!(uid: params[:room_uid])
# Update the rooms settings
update_room_attributes("settings")
# Update the rooms name if it has been changed
update_room_attributes("name") if @room.name != room_params[:name]
begin
@room = Room.find_by!(uid: params[:room_uid])
# Update the rooms settings
update_room_attributes("settings")
# Update the rooms name if it has been changed
update_room_attributes("name") if @room.name != room_params[:name]
rescue StandardError => ex
flash[:alert] = I18n.t("room.update_settings_error")
end

flash[:success] = I18n.t("room.update_settings_success")
redirect_to room_path
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def destroy
def create
user = User.find_by(email: session_params[:email])
if user && !user.greenlight_account?
redirect_to root_path, notice: I18n.t("invalid_login_method")
redirect_to root_path, alert: I18n.t("invalid_login_method")
elsif user.try(:authenticate, session_params[:password])
login(user)
else
redirect_to root_path, notice: I18n.t("invalid_credentials")
redirect_to root_path, alert: I18n.t("invalid_credentials")
end
end

Expand All @@ -48,7 +48,7 @@ def omniauth

# POST /auth/failure
def omniauth_fail
redirect_to root_path, notice: I18n.t(params[:message], default: I18n.t("omniauth_error"))
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("omniauth_error"))
end

private
Expand Down
11 changes: 7 additions & 4 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,21 @@ def update

if errors.empty? && @user.save
# Notify the user that their account has been updated.
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
flash[:success] = I18n.t("info_update_success")
redirect_to edit_user_path(@user)
else
# Append custom errors.
errors.each { |k, v| @user.errors.add(k, v) }
render :edit, params: { settings: params[:settings] }
end
elsif user_params[:email] != @user.email && @user.update_attributes(user_params)
@user.update_attributes(email_verified: false)
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
flash[:success] = I18n.t("info_update_success")
redirect_to edit_user_path(@user)
elsif @user.update_attributes(user_params)
update_locale(@user)
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
flash[:success] = I18n.t("info_update_success")
redirect_to edit_user_path(@user)
else
render :edit, params: { settings: params[:settings] }
end
Expand Down Expand Up @@ -155,7 +158,7 @@ def resend
private

def mailer_delivery_fail
redirect_to root_path, notice: I18n.t(params[:message], default: I18n.t("delivery_error"))
redirect_to root_path, alert: I18n.t(params[:message], default: I18n.t("delivery_error"))
end

def verification_link(user)
Expand Down
8 changes: 1 addition & 7 deletions app/views/main/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>
<% unless flash.empty? %>
<%= render "shared/error_banner" do %>
<% flash.each do |key, value| %>
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
<% end %>
<% end %>
<% end %>
<%= render 'shared/flash_messages' unless flash.empty? %>

<div class="background">
<div class="container pt-9 pb-8">
Expand Down
10 changes: 2 additions & 8 deletions app/views/password_resets/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>
<% unless flash.empty? %>
<%= render "shared/error_banner" do %>
<% flash.each do |key, value| %>
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
<% end %>
<% end %>
<% end %>
<%= render 'shared/flash_messages' unless flash.empty? %>

<div class="container">
<div class="row pt-7">
Expand Down Expand Up @@ -47,4 +41,4 @@
</div>
</div>
</div>
</div>
</div>
8 changes: 1 addition & 7 deletions app/views/password_resets/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>
<% unless flash.empty? %>
<%= render "shared/error_banner" do %>
<% flash.each do |key, value| %>
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
<% end %>
<% end %>
<% end %>
<%= render 'shared/flash_messages' unless flash.empty? %>

<div class="container">
<div class="row pt-7">
Expand Down
8 changes: 1 addition & 7 deletions app/views/rooms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>
<% unless flash.empty? %>
<%= render "shared/error_banner" do %>
<% flash.each do |key, value| %>
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
<% end %>
<% end %>
<% end %>
<%= render 'shared/flash_messages' unless flash.empty? %>

<div class="background pb-1">
<div class="container">
Expand Down
12 changes: 10 additions & 2 deletions app/views/shared/_flash_messages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>
<% flash.each do |key, value| %>
<%= content_tag :div, value, class: "flash #{key} d-inline-block text-success" %>
<% flash.each do |key,value| %>
<% if key.eql? "success" %>
<%= render "shared/success_banner" do %>
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
<% end %>
<% elsif key.eql? "alert" %>
<%= render "shared/error_banner" do %>
<%= content_tag :div, value, class: "flash #{key} d-inline" %>
<% end %>
<% end %>
<% end %>
18 changes: 18 additions & 0 deletions app/views/shared/_success_banner.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<%
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%>

<div class="alert alert-icon alert-success text-center mb-0">
<%= yield %>
</div>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ en:
sessions: Sessions
settings: Room Settings
start: Start
update_settings_error: "There was an error updating the room settings."
update_settings_success: "Room settings successfully updated"
wait:
message: Oops! The meeting hasn't started yet.
auto: You will automatically join when the meeting starts.
Expand Down

0 comments on commit d4d5b4f

Please sign in to comment.