forked from External/greenlight
		
	finish settings and public recordings
This commit is contained in:
		@@ -25,9 +25,10 @@ class RoomsController < ApplicationController
 | 
			
		||||
  # GET /r/:room_uid
 | 
			
		||||
  def show
 | 
			
		||||
    if current_user && @room.owned_by?(current_user)
 | 
			
		||||
      @is_running = @room.is_running?
 | 
			
		||||
      @recordings = @room.recordings
 | 
			
		||||
      @is_running = @room.is_running?
 | 
			
		||||
    else
 | 
			
		||||
      @recordings = @room.public_recordings
 | 
			
		||||
      render :join
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
@@ -97,10 +98,8 @@ class RoomsController < ApplicationController
 | 
			
		||||
    meta = {
 | 
			
		||||
      "meta_#{META_LISTED}": (params[:state] == "public")
 | 
			
		||||
    }
 | 
			
		||||
    puts '-------------'
 | 
			
		||||
    puts params[:record_id]
 | 
			
		||||
 | 
			
		||||
    res = @room.update_recording(params[:record_id], meta)
 | 
			
		||||
    puts res
 | 
			
		||||
    redirect_to @room if res[:updated]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,10 @@ class UsersController < ApplicationController
 | 
			
		||||
    # Update account information if passed.
 | 
			
		||||
    @user.name = user_params[:name] if user_params[:name]
 | 
			
		||||
    @user.email = user_params[:email] if user_params[:email]
 | 
			
		||||
    @user.image = user_params[:image] if user_params[:image]
 | 
			
		||||
 | 
			
		||||
    # Custom errors not generated by validations.
 | 
			
		||||
    errors = {}
 | 
			
		||||
 | 
			
		||||
    # Verify that the provided password is correct.
 | 
			
		||||
    if user_params[:password] && @user.authenticate(user_params[:password])
 | 
			
		||||
@@ -50,17 +54,20 @@ class UsersController < ApplicationController
 | 
			
		||||
        @user.password = user_params[:new_password]
 | 
			
		||||
      else
 | 
			
		||||
        # New passwords don't match.
 | 
			
		||||
 | 
			
		||||
        errors[:password_confirmation] = "'s don't match"
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      # Original password is incorrect, can't update.
 | 
			
		||||
 | 
			
		||||
      errors[:password] = "is incorrect"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if @user.save
 | 
			
		||||
      # Notify the use that their account has been updated.
 | 
			
		||||
      redirect_to edit_user_path(@user), notice: "Information successfully updated."
 | 
			
		||||
    else
 | 
			
		||||
      # Append custom errors.
 | 
			
		||||
      errors.each do |k, v| @user.errors.add(k, v) end
 | 
			
		||||
 | 
			
		||||
      # Handle validation errors.
 | 
			
		||||
      render :edit
 | 
			
		||||
    end
 | 
			
		||||
@@ -82,6 +89,6 @@ class UsersController < ApplicationController
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def user_params
 | 
			
		||||
    params.require(:user).permit(:name, :email, :password, :password_confirmation, :new_password, :provider)
 | 
			
		||||
    params.require(:user).permit(:name, :email, :image, :password, :password_confirmation, :new_password, :provider)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -109,7 +109,7 @@ class Room < ApplicationRecord
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Fetches all recordings for a meeting.
 | 
			
		||||
  # Fetches all recordings for a room.
 | 
			
		||||
  def recordings
 | 
			
		||||
    res = bbb.get_recordings(meetingID: bbb_id)
 | 
			
		||||
 | 
			
		||||
@@ -130,6 +130,11 @@ class Room < ApplicationRecord
 | 
			
		||||
    res[:recordings]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Fetches a rooms public recordings.
 | 
			
		||||
  def public_recordings
 | 
			
		||||
    recordings.select do |r| r[:metadata]["gl-listed"] end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def update_recording(record_id, meta)
 | 
			
		||||
    meta.merge!({recordID: record_id})
 | 
			
		||||
 
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,8 @@ class User < ApplicationRecord
 | 
			
		||||
 | 
			
		||||
  validates :name, length: { maximum: 24 }, presence: true
 | 
			
		||||
  validates :provider, presence: true
 | 
			
		||||
  validates :email, length: { maximum: 60 }, allow_nil: true,
 | 
			
		||||
  validates :image, format: {with: /\.(png|jpg)\Z/i}, allow_blank: true
 | 
			
		||||
  validates :email, length: { maximum: 60 }, allow_blank: true,
 | 
			
		||||
                    uniqueness: { case_sensitive: false },
 | 
			
		||||
                    format: {with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i }
 | 
			
		||||
 | 
			
		||||
@@ -56,7 +57,7 @@ class User < ApplicationRecord
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def twitter_image(auth)
 | 
			
		||||
      auth['info']['image']
 | 
			
		||||
      auth['info']['image'].gsub!("_normal", "")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def google_name(auth)
 | 
			
		||||
@@ -72,7 +73,7 @@ class User < ApplicationRecord
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def google_image(auth)
 | 
			
		||||
      auth['info']['picture']
 | 
			
		||||
      auth['info']['image']
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<%= render "shared/sessions", recordings: @recordings %>
 | 
			
		||||
<%= render "shared/sessions", recordings: @recordings, only_public: false %>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
var invite_url;
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
					</a>
 | 
			
		||||
					<div class="dropdown">
 | 
			
		||||
						<a href="#" class="nav-link pr-0" data-toggle="dropdown">
 | 
			
		||||
							<% if current_user.image.nil? %>
 | 
			
		||||
							<% if current_user.image.blank? %>
 | 
			
		||||
								<span class="avatar"><%= current_user.name.first %></span>
 | 
			
		||||
							<% else %>
 | 
			
		||||
								<span class="avatar" style="background-image: url(<%= current_user.image %>)"></span>
 | 
			
		||||
 
 | 
			
		||||
@@ -24,3 +24,5 @@
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<%= render "shared/sessions", recordings: @recordings, only_public: true %>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<div class="sessions pb-5">
 | 
			
		||||
  <div class="container pt-6">
 | 
			
		||||
 | 
			
		||||
    <%= render "shared/components/subtitle", subtitle: "Recordings", search: true %>
 | 
			
		||||
    <%= render "shared/components/subtitle", subtitle: (only_public ? "Public " : "") + "Recordings", search: true %>
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col-12">
 | 
			
		||||
        <div class="card">
 | 
			
		||||
@@ -22,7 +22,7 @@
 | 
			
		||||
              <% if recordings.empty? %>
 | 
			
		||||
                <tr>
 | 
			
		||||
                  <td colspan="7" class="text-center h4 p-6 font-weight-normal">
 | 
			
		||||
                    This room has no recordings.
 | 
			
		||||
                    <%= "This room has no #{(only_public ? "public " : "")} recordings." %>
 | 
			
		||||
                  </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
              <% else %>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,10 @@
 | 
			
		||||
    <div class="modal-content text-center">
 | 
			
		||||
      <div class="modal-body">
 | 
			
		||||
        <div class="card-body p-6">
 | 
			
		||||
          <div class="card-title text-primary">
 | 
			
		||||
          <div class="card-title">
 | 
			
		||||
            <h3>Create New Room</h3>
 | 
			
		||||
          </div>
 | 
			
		||||
 | 
			
		||||
          <hr class="small-rule">
 | 
			
		||||
          <%= form_for(:room, url: rooms_path) do |f| %>
 | 
			
		||||
            <div class="input-icon">
 | 
			
		||||
              <span class="input-icon-addon">
 | 
			
		||||
 
 | 
			
		||||
@@ -5,26 +5,34 @@
 | 
			
		||||
      <div class="col-6">
 | 
			
		||||
        <%= f.label "Fullname", class: "form-label" %>
 | 
			
		||||
        <div class="input-icon">
 | 
			
		||||
          <span class="input-icon-addon">
 | 
			
		||||
            <i class="fas fa-user"></i>
 | 
			
		||||
          </span>
 | 
			
		||||
          <%= f.text_field :name, class: "form-control", value: @user.name, placeholder: "Fullname" %>
 | 
			
		||||
          <%= f.text_field :name, class: "form-control #{form_is_invalid?(@user, :name)}", value: @user.name, placeholder: "Fullname" %>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="col-6">
 | 
			
		||||
        <%= f.label "Email", class: "form-label" %>
 | 
			
		||||
        <div class="input-icon">
 | 
			
		||||
          <span class="input-icon-addon">
 | 
			
		||||
            <i class="fas fa-at"></i>
 | 
			
		||||
          </span>
 | 
			
		||||
          <%= f.text_field :email, class: "form-control #{'is-invalid' if !@user.errors.messages[:email].empty?}", value: @user.email, placeholder: "Email" %>
 | 
			
		||||
          <%= f.text_field :email, class: "form-control #{form_is_invalid?(@user, :email)}", value: @user.email, placeholder: "Email" %>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <br>
 | 
			
		||||
    <%= f.label "Provider", class: "form-label" %>
 | 
			
		||||
    <%= f.text_field :provider, class: "form-control", value: @user.provider.capitalize, readonly: "" %>
 | 
			
		||||
 | 
			
		||||
    <%= f.label "Image", class: "form-label mt-5" %>
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col-2">
 | 
			
		||||
        <% if current_user.image.blank? %>
 | 
			
		||||
          <span class="avatar avatar-xxl mr-5 mt-2"><%= current_user.name.first %></span>
 | 
			
		||||
        <% else %>
 | 
			
		||||
          <span class="avatar avatar-xxl mr-5 mt-2" style="background-image: url(<%= current_user.image %>)"></span>
 | 
			
		||||
        <% end %>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="col-10" style="transform: translateY(25%);">
 | 
			
		||||
        <%= f.text_field :image, class: "form-control #{form_is_invalid?(@user, :image)}", value: @user.image, placeholder: "Profile Image URL" %>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="card-footer">
 | 
			
		||||
    <%= f.submit "Update", class: "btn btn-primary float-right" %>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<div class="form-group">
 | 
			
		||||
  <div class="row">
 | 
			
		||||
    <div class="col-6">
 | 
			
		||||
 | 
			
		||||
    <div class="col-12">
 | 
			
		||||
      <center>Customization not currently supported.</center>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
<div class="form-group">
 | 
			
		||||
  <div class="row">
 | 
			
		||||
    
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
@@ -4,13 +4,13 @@
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col-8">
 | 
			
		||||
        <%= f.label "Old Password", class: "form-label" %>
 | 
			
		||||
        <%= f.password_field :password, class: "form-control" %>
 | 
			
		||||
        <%= f.password_field :password, class: "form-control #{form_is_invalid?(@user, :password)}" %>
 | 
			
		||||
        <br>
 | 
			
		||||
        <%= f.label "New Password", class: "form-label" %>
 | 
			
		||||
        <%= f.password_field :new_password, class: "form-control" %>
 | 
			
		||||
        <%= f.password_field :new_password, class: "form-control #{form_is_invalid?(@user, :password)}" %>
 | 
			
		||||
        <br>
 | 
			
		||||
        <%= f.label "New Password Confirmation", class: "form-label" %>
 | 
			
		||||
        <%= f.password_field :password_confirmation, class: "form-control" %>
 | 
			
		||||
        <%= f.password_field :password_confirmation, class: "form-control #{form_is_invalid?(@user, :password_confirmation)}" %>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -5,23 +5,19 @@
 | 
			
		||||
  <div class="row">
 | 
			
		||||
    <div class="col-lg-3 mb-4">
 | 
			
		||||
      <div class="list-group list-group-transparent mb-0">
 | 
			
		||||
        <%= link_to edit_user_path(@user, setting: "account"), id: "account", class: "list-group-item list-group-item-action setting-btn" do %>
 | 
			
		||||
        <button id="account" class="list-group-item list-group-item-action setting-btn active">
 | 
			
		||||
          <span class="icon mr-3"><i class="fe fe-user"></i></span>Account
 | 
			
		||||
        <% end %>
 | 
			
		||||
 | 
			
		||||
        <%= link_to edit_user_path(@user, setting: "image"), id: "image", class: "list-group-item list-group-item-action setting-btn" do %>
 | 
			
		||||
          <span class="icon mr-3"><i class="fe fe-image"></i></span>Profile Image
 | 
			
		||||
        <% end %>
 | 
			
		||||
        </button>
 | 
			
		||||
 | 
			
		||||
        <% if @user.social_uid.nil? %>
 | 
			
		||||
          <%= link_to edit_user_path(@user, setting: "password"), id: "password", class: "list-group-item list-group-item-action setting-btn" do %>
 | 
			
		||||
          <button id="password" class="list-group-item list-group-item-action setting-btn">
 | 
			
		||||
            <span class="icon mr-3"><i class="fe fe-lock"></i></span>Password
 | 
			
		||||
          <% end %>
 | 
			
		||||
          </button>
 | 
			
		||||
        <% end %>
 | 
			
		||||
 | 
			
		||||
        <%= link_to edit_user_path(@user, setting: "design"), id: "design", class: "list-group-item list-group-item-action setting-btn" do %>
 | 
			
		||||
        <button id="design" class="list-group-item list-group-item-action setting-btn">
 | 
			
		||||
          <span class="icon mr-3"><i class="fe fe-edit-2"></i></span>Design
 | 
			
		||||
        <% end %>
 | 
			
		||||
        </button>
 | 
			
		||||
      </div>
 | 
			
		||||
  
 | 
			
		||||
      <% if @user.errors.any? %>
 | 
			
		||||
@@ -41,7 +37,6 @@
 | 
			
		||||
 | 
			
		||||
    <div class="col-lg-9">
 | 
			
		||||
      <%= render "shared/settings/setting_view", setting_id: "account", setting_title: "Update your Account Info" %>
 | 
			
		||||
      <%= render "shared/settings/setting_view", setting_id: "image", setting_title: "Change your Profile Image" %>
 | 
			
		||||
 | 
			
		||||
      <% if @user.social_uid.nil? %>
 | 
			
		||||
        <%= render "shared/settings/setting_view", setting_id: "password", setting_title: "Change your Password" %>
 | 
			
		||||
@@ -53,34 +48,23 @@
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
/*
 | 
			
		||||
// Helper for grabbing URL params.
 | 
			
		||||
$.urlParam = function(name){
 | 
			
		||||
  var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
 | 
			
		||||
  if (results==null){
 | 
			
		||||
    return null;
 | 
			
		||||
  } else {
 | 
			
		||||
    return results[1] || 0;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
settingsButtons = $('.setting-btn');
 | 
			
		||||
settingsViews = $('.setting-view');
 | 
			
		||||
 | 
			
		||||
$(document).ready(function(){
 | 
			
		||||
  var setting = $.urlParam("setting");
 | 
			
		||||
 | 
			
		||||
  /*if (!["account", "image", "password", "design"].includes(setting)){
 | 
			
		||||
    var url = [location.protocol, '//', location.host, location.pathname].join('');
 | 
			
		||||
    window.location.href = url + "?setting=account";
 | 
			
		||||
  }
 | 
			
		||||
  if (!["account", "image", "password", "design"].includes(setting)){ setting = "account"; }
 | 
			
		||||
 | 
			
		||||
  $("#" + setting).addClass("active");
 | 
			
		||||
 | 
			
		||||
  settingsButtons.each(function(i, btn) {
 | 
			
		||||
    if(i != 0){ $(settingsViews[i]).hide(); }
 | 
			
		||||
    $(btn).click(function(){
 | 
			
		||||
      $(btn).addClass("active");
 | 
			
		||||
      settingsViews.each(function(i, view){
 | 
			
		||||
    if($(view).attr("id") != setting){
 | 
			
		||||
        if($(view).attr("id") == $(btn).attr("id")){
 | 
			
		||||
          $(view).show();
 | 
			
		||||
        } else {
 | 
			
		||||
          $(settingsButtons[i]).removeClass("active");
 | 
			
		||||
          $(view).hide();
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
});*/
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user