Skip to content
Snippets Groups Projects
Commit db173d5a authored by Rysev, Gleb (UG - SISC)'s avatar Rysev, Gleb (UG - SISC)
Browse files

Minor visuals and fixes

parent 33261eff
No related branches found
No related tags found
No related merge requests found
Pipeline #30749 failed
...@@ -33,6 +33,8 @@ class RoomsController < ApplicationController ...@@ -33,6 +33,8 @@ class RoomsController < ApplicationController
end end
def show def show
@rooms = Room.where(leaderboard: Leaderboard.where(board_users: BoardUser.where(user: current_user, status: "accepted")))
if Room.where(id: @room.id,leaderboard: Leaderboard.where(board_users: BoardUser.where(user: current_user, status: "accepted"))).exists? if Room.where(id: @room.id,leaderboard: Leaderboard.where(board_users: BoardUser.where(user: current_user, status: "accepted"))).exists?
@room_message = RoomMessage.new room: @room @room_message = RoomMessage.new room: @room
@room_messages = @room.room_messages.includes(:user) @room_messages = @room.room_messages.includes(:user)
......
...@@ -9,57 +9,6 @@ ...@@ -9,57 +9,6 @@
<div class="Insp_Quote"></div><br> <div class="Insp_Quote"></div><br>
</div> </div>
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<script>
Cookies.set('name', 'value');
var Text = ""
var Auth = ""
var ImgURL = ""
if (Cookies.get('visible') == "false") {
$(".Insp_Pic").hide();
$(".Insp_Quote").hide();
Cookies.set("visible", "false");
}
$("#expand-hidden").click(function () {
if (Cookies.get('visible') != "false") {
$(".Insp_Pic").hide();
$(".Insp_Quote").hide();
Cookies.set("visible", "false");
$("#expand-hidden").html("Show cute dogs");
} else {
$(".Insp_Pic").show();
$(".Insp_Quote").show();
Cookies.set("visible", "true");
$("#expand-hidden").html("<i class='fa fa-window-close fa-lg'></i>");
}
});
fetch("https://dog.ceo/api/breeds/image/random")
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data.message);
ImgURL = data.message;
$(".Insp_Pic").attr("src",ImgURL);
});
fetch("https://type.fit/api/quotes")
.then(function(response) {
return response.json();
})
.then(function(data) {
let quote = data[Math.floor(Math.random() * data.length)];
Text = quote.text;
Auth = quote.author;
$(".Insp_Quote").text(Text + " - " + Auth + "\n");
$(".Insp_Quote").css({
'width': ($(".Insp_Pic").width() + 'px')
});
});
</script>
</div> </div>
<div class="container-md"> <div class="container-md">
<%unless current_user.habits.nil? %> <%unless current_user.habits.nil? %>
...@@ -69,3 +18,54 @@ ...@@ -69,3 +18,54 @@
<%= javascript_pack_tag 'react_habitCard' %> <%= javascript_pack_tag 'react_habitCard' %>
<%end%> <%end%>
</div> </div>
<script>
Cookies.set('name', 'value');
var Text = ""
var Auth = ""
var ImgURL = ""
if (Cookies.get('visible') == "false") {
$(".Insp_Pic").hide();
$(".Insp_Quote").hide();
Cookies.set("visible", "false");
}
$("#expand-hidden").click(function () {
if (Cookies.get('visible') != "false") {
$(".Insp_Pic").hide();
$(".Insp_Quote").hide();
Cookies.set("visible", "false");
$("#expand-hidden").html("Show cute dogs");
} else {
$(".Insp_Pic").show();
$(".Insp_Quote").show();
Cookies.set("visible", "true");
$("#expand-hidden").html("<i class='fa fa-window-close fa-lg'></i>");
}
});
fetch("https://dog.ceo/api/breeds/image/random")
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data.message);
ImgURL = data.message;
$(".Insp_Pic").attr("src",ImgURL);
});
fetch("https://type.fit/api/quotes")
.then(function(response) {
return response.json();
})
.then(function(data) {
let quote = data[Math.floor(Math.random() * data.length)];
Text = quote.text;
Auth = quote.author;
$(".Insp_Quote").text(Text + " - " + Auth + "\n");
$(".Insp_Quote").css({
'width': ($(".Insp_Pic").width() + 'px')
});
});
</script>
<h2>Active Leaderboards</h2> <div class="container-md">
<table class = "table table-striped table-dark"> <h2><%= t(".active_leaderboards") %></h2>
<thead class = "thead-light"> <table class = "table table-striped table-dark">
<tr> <thead class = "thead-light">
<th>Title</th><th>Interactions</th><th></th><th></th>
</tr>
</thead>
<tbody>
<% @leaderboards.each do |leaderboard| %>
<tr> <tr>
<td> <th><%= t(".title") %></th><th><%= t(".interactions") %></th><th></th><th></th>
<%= leaderboard.title %>
</td>
<td><%= link_to 'Show', leaderboard %></td>
<td><%= link_to 'Edit', edit_leaderboard_path(leaderboard) %></td>
<td><%= link_to 'Destroy', leaderboard, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr> </tr>
<% end %> </thead>
</tbody> <tbody>
</table> <% @leaderboards.each do |leaderboard| %>
<hr> <tr>
<br> <td>
<%= link_to 'New Leaderboard', new_leaderboard_path %> <%= leaderboard.title %>
<br> </td>
<hr> <td><%= link_to 'Show', leaderboard %></td>
<h2>Join a leaderboard</h2> <td><%= link_to 'Edit', edit_leaderboard_path(leaderboard) %></td>
<%=form_tag joinWcode_path, method: :post do%> <td><%= link_to 'Destroy', leaderboard, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<%= label_tag("Invite Code") %> </tr>
<%= text_field_tag('code')%> <% end %>
<%= submit_tag("Join")%> </tbody>
<%end %>
<hr>
<%invites = BoardUser.where(status: "pending", user_id:current_user.id) %>
<%unless invites.empty?%>
<h2>Pending Invites</h2>
<table>
<th>Name</th><th>Description</th> <th></th> <th></th>
<%invites.each do |invite|%>
<tr>
<td><h6><%=invite.leaderboard.title%></h6></td>
<td><h6><%=invite.leaderboard.description%></h6></td>
<td><%=button_to "Accept", acceptInvite_path, method: :post, class:"btn btn-info",
params: {:id => invite.id}%></td>
<td><%=button_to "Reject", rejectInvite_path, method: :post, class:"btn btn-info",
params: {:id => invite.id}%></td>
</tr>
<%end%>
</table> </table>
<%end%> <hr>
\ No newline at end of file <br>
<%= link_to 'New Leaderboard', new_leaderboard_path %>
<br>
<hr>
<h2>Join a leaderboard</h2>
<%=form_tag joinWcode_path, method: :post do%>
<%= label_tag("Invite Code") %>
<%= text_field_tag('code')%>
<%= submit_tag("Join")%>
<%end %>
<hr>
<%invites = BoardUser.where(status: "pending", user_id:current_user.id) %>
<%unless invites.empty?%>
<h2>Pending Invites</h2>
<table>
<th>Name</th><th>Description</th> <th></th> <th></th>
<%invites.each do |invite|%>
<tr>
<td><h6><%=invite.leaderboard.title%></h6></td>
<td><h6><%=invite.leaderboard.description%></h6></td>
<td><%=button_to "Accept", acceptInvite_path, method: :post, class:"btn btn-info",
params: {:id => invite.id}%></td>
<td><%=button_to "Reject", rejectInvite_path, method: :post, class:"btn btn-info",
params: {:id => invite.id}%></td>
</tr>
<%end%>
</table>
<%end%>
</div>
<div class="container text-center custom-page-heading"> <div class="container-md">
<%= link_to t('.back'), leaderboards_path, :class => "btn float-left habit-back-btn" %> <div class="container text-center custom-page-heading">
<h1>New Leaderboard</h1> <%= link_to t('.back'), leaderboards_path, :class => "btn float-left habit-back-btn" %>
<h1><%= t(".new_leaderboard") %></h1>
</div>
<%= render 'form', leaderboard: @leaderboard %>
</div> </div>
<%= render 'form', leaderboard: @leaderboard %>
<h1><%=@room.leaderboard.title%></h1> <div class="container-md">
<h3><%=@leaderboard.description%></h3> <h1><%=@room.leaderboard.title%></h1>
<%= link_to t('.leaderboard_chat'), room_path(@room), class: 'btn btn-info btn-md' %> <h3><%=@leaderboard.description%></h3>
<table class="table table-striped table-dark"> <%= link_to t('.leaderboard_chat'), room_path(@room), class: 'btn btn-info btn-md' %>
<thead> <table class="table table-striped table-dark">
<tr> <thead>
<th>Rank</th><th></th><th>Name</th><th>Score</th>
</tr>
</thead>
<tbody>
<%if @leaderboard == Leaderboard.find_by_id(0)%>
<%get_all_users(@leaderboard) %>
<%end %>
<%@users = sort_users(@leaderboard) %>
<% @users.each_with_index do |user,i| %>
<tr> <tr>
<td><%= i + 1 %></td> <th>Rank</th><th></th><th>Name</th><th>Score</th>
<td>
<%unless user.image.nil?%>
<%= image_tag user.image %>
<%end %>
</td>
<td>
<%if user.name.nil?%>
<%= user.email%>
<%else %>
<%= user.name %>
<%end %>
</td>
<td>
<%=
score = @leaderboard.board_users.find_by(user: user).score
if score.nil?
0
else
score
end
%>
</td>
</tr> </tr>
<% end %> </thead>
</tbody> <tbody>
</table> <%if @leaderboard == Leaderboard.find_by_id(0)%>
<br/> <%get_all_users(@leaderboard) %>
<hr> <%end %>
<%unless current_user.auths.empty? %> <%@users = sort_users(@leaderboard) %>
<h3>Invite Your Friends</h3> <% @users.each_with_index do |user,i| %>
<table>
<th></th><th></th>
<%data = User.get_friends(session[:fb_token])%>
<%data.each do |person|%>
<tr> <tr>
<td><h5><%=person['name'] %></h5></td> <td><%= i + 1 %></td>
<td><%=button_to "Invite", inviteUser_path, method: :post, class:"btn btn-info", <td>
params: {:name => person['name'], :leaderboard => @leaderboard.id}%></td> <%unless user.image.nil?%>
<%= image_tag user.image %>
<%end %>
</td>
<td>
<%if user.name.nil?%>
<%= user.email%>
<%else %>
<%= user.name %>
<%end %>
</td>
<td>
<%=
score = @leaderboard.board_users.find_by(user: user).score
if score.nil?
0
else
score
end
%>
</td>
</tr> </tr>
<%end%> <% end %>
</tbody>
</table> </table>
<%end %> <br/>
<button class="btn btn-info codeGen-button"> Generate Invite Code </button> <hr>
<script> <%unless current_user.auths.empty? %>
let lbID = <%=@leaderboard.id.to_s%>; <h3>Invite Your Friends</h3>
let lbTitle = "<%=@leaderboard.title.to_s%>"; <table>
let gener = <%=current_user.id.to_s.to_s%>; <th></th><th></th>
$(document).ready(function(){ <%data = User.get_friends(session[:fb_token])%>
$(".codeGen-button").on("click", e => { <%data.each do |person|%>
if(lbTitle.length > 10){lbTitle = lbTitle.substring(0,10)} <tr>
let invCode = (lbID+"|"+lbTitle+"|"+gener).toString(); <td><h5><%=person['name'] %></h5></td>
$(".InvCode").text("Your Invite Code is: "+invCode); <td><%=button_to "Invite", inviteUser_path, method: :post, class:"btn btn-info",
}) params: {:name => person['name'], :leaderboard => @leaderboard.id}%></td>
}) </tr>
</script> <%end%>
<h3 class="InvCode"></h3> </table>
<%=button_to "Leave the Board", leaveBoard_path, method: :post, class:"btn btn-info", <%end %>
params: {:id => @leaderboard.id}%> <button class="btn btn-info codeGen-button"> Generate Invite Code </button>
<script>
let lbID = <%=@leaderboard.id.to_s%>;
let lbTitle = "<%=@leaderboard.title.to_s%>";
let gener = <%=current_user.id.to_s.to_s%>;
$(document).ready(function(){
$(".codeGen-button").on("click", e => {
if(lbTitle.length > 10){lbTitle = lbTitle.substring(0,10)}
let invCode = (lbID+"|"+lbTitle+"|"+gener).toString();
$(".InvCode").text("Your Invite Code is: "+invCode);
})
})
</script>
<h3 class="InvCode"></h3>
<%=button_to "Leave the Board", leaveBoard_path, method: :post, class:"btn btn-info",
params: {:id => @leaderboard.id}%>
</div>
<div class="row"> <div class="container-md">
<div class="col-12 col-md-3"> <div class="row">
<%= render partial: 'rooms' %> <div class="col-12 col-md-3">
<%= render partial: 'rooms' %>
</div>
</div> </div>
</div> </div>
...@@ -6,6 +6,9 @@ en: ...@@ -6,6 +6,9 @@ en:
registrations: registrations:
edit: edit:
back: Back back: Back
cancel_account: Cancel account
push_me: Push me
unsubscribe: Unsubscribe
sessions: sessions:
new: new:
email: Email email: Email
...@@ -23,6 +26,9 @@ en: ...@@ -23,6 +26,9 @@ en:
errors: errors:
messages: messages:
not_saved: Not saved not_saved: Not saved
goals:
showgoals:
back: Back
habits: habits:
edit: edit:
back: Back back: Back
...@@ -71,8 +77,13 @@ en: ...@@ -71,8 +77,13 @@ en:
leaderboard_title: Leaderboard title leaderboard_title: Leaderboard title
target_placeholder: Target placeholder target_placeholder: Target placeholder
title_placeholder: Title placeholder title_placeholder: Title placeholder
index:
active_leaderboards: Active leaderboards
interactions: Interactions
title: Title
new: new:
back: Back back: Back
new_leaderboard: New leaderboard
show: show:
leaderboard_chat: Leaderboard chat leaderboard_chat: Leaderboard chat
rooms: rooms:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment