Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwill committed Sep 6, 2016
1 parent 5b53796 commit 7ef2bd0
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 35 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@

# Ignore Byebug command history file.
.byebug_history

/shared/log/*
/shared/pids/*

/public/assets/*

.rbenv-vars

.DS_Store
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ gem 'coffee-rails', '~> 4.2'

# Use jquery as the JavaScript library
gem 'jquery-rails'

gem 'therubyracer'

# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
Expand All @@ -30,6 +33,8 @@ gem 'jbuilder', '~> 2.5'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'mysql2', group: :production

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jwt (1.5.4)
libv8 (3.16.14.15)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -83,6 +84,7 @@ GEM
multi_json (1.12.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
mysql2 (0.4.4)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
Expand Down Expand Up @@ -137,6 +139,7 @@ GEM
rb-inotify (0.9.7)
ffi (>= 0.5.0)
redis (3.3.1)
ref (2.0.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand All @@ -156,6 +159,9 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
Expand Down Expand Up @@ -184,6 +190,7 @@ DEPENDENCIES
jbuilder (~> 2.5)
jquery-rails
listen (~> 3.0.5)
mysql2
omniauth-google-oauth2
puma (~> 3.0)
rails (~> 5.0.0, >= 5.0.0.1)
Expand All @@ -192,6 +199,7 @@ DEPENDENCIES
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
therubyracer
turbolinks (~> 5)
tzinfo-data
uglifier (>= 1.3.0)
Expand Down
24 changes: 12 additions & 12 deletions app/assets/javascripts/channels/queue_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ function CourseQueueClientActionHandler(subscription) {
}

CourseQueueClientActionHandler.prototype.fire = function (e) {
let target = e.currentTarget;
let action = $(target).data('cable-action');
var target = e.currentTarget;
var action = $(target).data('cable-action');

if (action === 'new_request') {
this.newRequest(target);
Expand All @@ -24,10 +24,10 @@ CourseQueueClientActionHandler.prototype.fire = function (e) {
}

CourseQueueClientActionHandler.prototype.newRequest = function (selector) {
let form = $(selector).parent();
var form = $(selector).parent();

let location = form.find('input[name=location]').val();
let description = form.find('textarea[name=description]').val();
var location = form.find('input[name=location]').val();
var description = form.find('textarea[name=description]').val();

this.subscription.perform('new_request', {
location: location,
Expand All @@ -40,7 +40,7 @@ CourseQueueClientActionHandler.prototype.queuePop = function (selector) {
};

CourseQueueClientActionHandler.prototype.instructorStatusToggle = function (selector) {
let newStatus = !$(selector).data('online');
var newStatus = !$(selector).data('online');

$(selector).data('online', newStatus);

Expand All @@ -50,26 +50,26 @@ CourseQueueClientActionHandler.prototype.instructorStatusToggle = function (sele
};

CourseQueueClientActionHandler.prototype.resolveRequest = function (selector) {
let requestId = $(selector).data('id');
var requestId = $(selector).data('id');

this.subscription.perform('resolve_request', {
id: requestId,
});
};

CourseQueueClientActionHandler.prototype.destroyRequest = function (selector) {
let requestId = $(selector).data('id');
var requestId = $(selector).data('id');

this.subscription.perform('destroy_request', {
id: requestId,
});
};

$(document).ready(function () {
let queueId = $('#course-queue-name').data('course-queue-id');
var queueId = $('#course-queue-name').data('course-queue-id');

// Create the new ActionCable subscription for this course queue
let courseQueueSubscription = App.cable.subscriptions.create({
var courseQueueSubscription = App.cable.subscriptions.create({
channel: 'QueueChannel',
id: $('#course-queue-name').data('course-queue-id'),
}, {
Expand Down Expand Up @@ -104,8 +104,8 @@ $(document).ready(function () {
},
});

let handler = new CourseQueueClientActionHandler(courseQueueSubscription);
var handler = new CourseQueueClientActionHandler(courseQueueSubscription);

// Attach the handler to click actions
$(document).on('click', '[data-cable-action]', e => handler.fire(e));
$(document).on('click', '[data-cable-action]', handler.fire.bind(handler));
});
34 changes: 17 additions & 17 deletions app/assets/javascripts/course_queues.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// TODO: function findContainerFor()
const requestsContainerSelector = '[data-cable-container="requests"]';
const requestsCountContainerSelector = '[data-cable-container="requests-count"]';
const actionContentContainerSelector = '[data-cable-container="action-content"]';
const instructorsContainerSelector = '[data-cable-container="instructors"]';
const messagesContainerSelector = '[data-cable-container="messages"]';
var requestsContainerSelector = '[data-cable-container="requests"]';
var requestsCountContainerSelector = '[data-cable-container="requests-count"]';
var actionContentContainerSelector = '[data-cable-container="action-content"]';
var instructorsContainerSelector = '[data-cable-container="instructors"]';
var messagesContainerSelector = '[data-cable-container="messages"]';

/**
* Remove everything from the requests container.
Expand Down Expand Up @@ -44,15 +44,15 @@ function enablePage() {
* sync. This function should be called whenever data is changed.
*/
function fixupPage() {
let newCount = updateRequestsCount();
var newCount = updateRequestsCount();

if (newCount === 0) {
renderEmptyRequests();
} else {
// handled in renderRequest()
}

let numRequestsFromCurrentUser = $('[data-requester-id=' + getCurrentUserId() + ']').length;
var numRequestsFromCurrentUser = $('[data-requester-id=' + getCurrentUserId() + ']').length;
if (isCurrentUserInstructor()) {
renderInstructorForm();
fixMyInstructorOnlineStatus();
Expand All @@ -66,7 +66,7 @@ function fixupPage() {

toggleQueuePop(newCount > 0);

let onlineInstructors = countOnlineInstructors();
var onlineInstructors = countOnlineInstructors();
if (onlineInstructors > 0) {
deleteMessages(); // TODO: this assumes there are no other messages
$(actionContentContainerSelector).parent().show();
Expand Down Expand Up @@ -94,7 +94,7 @@ function getRequestsCount() {
* TODO: this could listen for changes on the container.
*/
function updateRequestsCount() {
let count = getRequestsCount();
var count = getRequestsCount();

$(requestsCountContainerSelector).html(count);

Expand Down Expand Up @@ -187,12 +187,12 @@ function getOnlineInstructors(queueId, callback) {
* Either append or overwrite the container contents. Optionally munge the
* template to insert any item-specific data via callback.
*/
function renderTemplate(template, parentContainer, append = true, munge = null) {
let parentElt = $('[data-cable-container="' + parentContainer + '"]');
let templateElt = $('[data-cable-template="' + template + '"]');
let elt = $(templateElt.html());
function renderTemplate(template, parentContainer, append, munge) {
var parentElt = $('[data-cable-container="' + parentContainer + '"]');
var templateElt = $('[data-cable-template="' + template + '"]');
var elt = $(templateElt.html());

if (munge !== null) {
if (typeof munge !== 'undefined') {
munge(elt);
}

Expand Down Expand Up @@ -283,7 +283,7 @@ function isCurrentUserInstructor() {
/**
* Display a message to the user.
*/
function renderMessage(header, text, append = true) {
function renderMessage(header, text, append) {
renderTemplate('message', 'messages', append, function (elt) {
elt.find('[data-content=header]').html(header);
elt.find('[data-content=text]').html(text);
Expand All @@ -305,7 +305,7 @@ function toggleQueuePop(enabled) {
* TODO: write me
*/
function fixMyInstructorOnlineStatus() {
let amIOnline = $(instructorsContainerSelector)
var amIOnline = $(instructorsContainerSelector)
.find('[data-id=' + getCurrentUserId() + ']').length > 0;

setInstructorStatus(amIOnline);
Expand All @@ -316,7 +316,7 @@ function fixMyInstructorOnlineStatus() {
* Set the instructor button to the appropriate text.
*/
function setInstructorStatus(online) {
let text;
var text;

if (online) {
text = 'Offline';
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/course_queues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def online_instructors

private
def set_course_queue
@course_queue = CourseQueue.open_queues.find(params[:id])
@course_queue = CourseQueue.find(params[:id])
end
end
6 changes: 5 additions & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ test:

production:
<<: *default
database: db/production.sqlite3
adapter: mysql2
encoding: utf8
database: <%= ENV['EECSHELP_DATABASE'] %>
username: <%= ENV['EECSHELP_DATABASE_USER'] %>
password: <%= ENV['EECSHELP_DATABASE_PASSWORD'] %>
2 changes: 2 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

Rails.application.config.action_cable.allowed_request_origins = ['https://eecshelp.mwt.io']
end
6 changes: 2 additions & 4 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
OmniAuth.config.logger = Rails.logger

# OmniAuth.config.full_host = Rails.env.production? ? 'https://domain.com' : 'http://localhost:3000'
OmniAuth.config.full_host = 'http://dev.eecs.help:3000'
# provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"]
OmniAuth.config.full_host = Rails.env.production? ? 'https://eecshelp.mwt.io' : 'http://dev.eecs.help:3000'

Rails.application.config.middleware.use OmniAuth::Builder do
provider(
:google_oauth2,
ENV['GOOGLE_CLIENT_ID'],
ENV['GOOGLE_CLIENT_SECRET'],
# hd: ENV['GOOGLE_HD'],
hd: ENV['GOOGLE_HD'],
access_type: 'online'
)
end

0 comments on commit 7ef2bd0

Please sign in to comment.