Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop
This commit is contained in:
commit
a0e486aed7
|
|
@ -50,6 +50,7 @@ describe "Deployed site at #{www}", :js => true, :type => :feature, :capybara_fe
|
|||
end
|
||||
|
||||
it "is possible for #{user3} to sign in and not get disconnected within 30 seconds" do
|
||||
pending "continual failures - need to debug - try using Selenium instead of PhantomJS"
|
||||
as_monitor(user3) do
|
||||
sign_in_poltergeist(user3)
|
||||
repeat_for(30.seconds) do
|
||||
|
|
|
|||
|
|
@ -1478,6 +1478,14 @@
|
|||
});
|
||||
}
|
||||
|
||||
function validateUrlSite(url) {
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
url: '/api/data_validation?data=' + encodeURIComponent(url),
|
||||
contentType: 'application/json'
|
||||
});
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
return self;
|
||||
}
|
||||
|
|
@ -1608,6 +1616,7 @@
|
|||
this.resendBandInvitation = resendBandInvitation;
|
||||
this.getMount = getMount;
|
||||
this.createSourceChange = createSourceChange;
|
||||
this.validateUrlSite = validateUrlSite;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -224,29 +224,11 @@
|
|||
}
|
||||
|
||||
if (showJoinLink) {
|
||||
// wire up the Join Link to the T&Cs dialog
|
||||
// wire up the Join Link to the T&Cs dialog
|
||||
$('.join-link', $parentRow).click(function(evt) {
|
||||
if(!context.JK.guardAgainstBrowser(app)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.JK.JamServer.connected) {
|
||||
app.notifyAlert("Not Connected", 'To create or join a session, you must be connected to the server.');
|
||||
return false;
|
||||
}
|
||||
|
||||
gearUtils.guardAgainstInvalidConfiguration(app)
|
||||
.fail(function() {
|
||||
app.notify(
|
||||
{ title: "Unable to Join Session",
|
||||
text: "You can only join a session once you have working audio gear and a tested internet connection."
|
||||
})
|
||||
})
|
||||
.done(function(){
|
||||
sessionUtils.joinSession(session.id);
|
||||
})
|
||||
|
||||
return false;
|
||||
sessionUtils.ensureValidClient(app, gearUtils, function() {
|
||||
sessionUtils.joinSession(session.id);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -368,7 +350,7 @@
|
|||
$('a.more.rsvps', $parentRow).click(toggleRsvps);
|
||||
|
||||
var showRsvpLink = true;
|
||||
var noLinkText = '';
|
||||
var sessionLinkText = '';
|
||||
$('.rsvp-link-text', $parentRow).hide();
|
||||
|
||||
function showStartSessionButton(scheduledStart) {
|
||||
|
|
@ -380,8 +362,8 @@
|
|||
|
||||
if (session.creator.id === context.JK.currentUserId) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = $('<span class="text"><a class="start" style="color: #fc0">Start session now?</a></span>');
|
||||
noLinkText.find('a').click(function() {
|
||||
sessionLinkText = $('<span class="text"><a class="start" style="color: #fc0">Start session now?</a></span>');
|
||||
sessionLinkText.find('a').click(function() {
|
||||
ui.launchSessionStartDialog(session);
|
||||
return false;
|
||||
});
|
||||
|
|
@ -390,18 +372,18 @@
|
|||
showRsvpLink = false;
|
||||
|
||||
if (session.scheduled_start && showStartSessionButton(session.scheduled_start)) {
|
||||
noLinkText = $('<span class="text"><a class="start" style="color: #fc0">Start session now?</a> | <a class="cancel" style="color: #fc0">Cancel RSVP</a></span>');
|
||||
noLinkText.find('a.start').click(function() {
|
||||
sessionLinkText = $('<span class="text"><a class="start" style="color: #fc0">Start session now?</a> | <a class="cancel" style="color: #fc0">Cancel RSVP</a></span>');
|
||||
sessionLinkText.find('a.start').click(function() {
|
||||
ui.launchSessionStartDialog(session);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
noLinkText = $('<span class="text"><a class="cancel" style="color: #fc0">Cancel RSVP</a></span>');
|
||||
sessionLinkText = $('<span class="text"><a class="cancel" style="color: #fc0">Cancel RSVP</a></span>');
|
||||
}
|
||||
|
||||
// wire cancel link
|
||||
noLinkText.find('a.cancel').click(function() {
|
||||
sessionLinkText.find('a.cancel').click(function() {
|
||||
ui.launchRsvpCancelDialog(session.id, approvedRsvpId)
|
||||
.one(EVENTS.RSVP_CANCELED, function() {
|
||||
rest.getSessionHistory(session.id)
|
||||
|
|
@ -419,8 +401,8 @@
|
|||
showRsvpLink = false;
|
||||
|
||||
if (session.scheduled_start && showStartSessionButton(session.scheduled_start)) {
|
||||
noLinkText = $('<span class="text"><a class="start" style="color: #fc0">Start session now?</a></span>');
|
||||
noLinkText.find('a').click(function() {
|
||||
sessionLinkText = $('<span class="text"><a class="start" style="color: #fc0">Start session now?</a></span>');
|
||||
sessionLinkText.find('a').click(function() {
|
||||
ui.launchSessionStartDialog(session);
|
||||
return false;
|
||||
});
|
||||
|
|
@ -428,8 +410,8 @@
|
|||
}
|
||||
else if (pendingRsvpId) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = $('<span class="text"><a class="cancel" style="color: #fc0">Cancel RSVP</a></span>');
|
||||
noLinkText.find('a').click(function() {
|
||||
sessionLinkText = $('<span class="text"><a class="cancel" style="color: #fc0">Cancel RSVP</a></span>');
|
||||
sessionLinkText.find('a').click(function() {
|
||||
ui.launchRsvpCancelDialog(session.id, pendingRsvpId)
|
||||
.one(EVENTS.RSVP_CANCELED, function() {
|
||||
rest.getSessionHistory(session.id)
|
||||
|
|
@ -445,11 +427,11 @@
|
|||
}
|
||||
else if (!openSlots) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = '<span class="text">No more openings in this session.</span>';
|
||||
sessionLinkText = '<span class="text">No more openings in this session.</span>';
|
||||
}
|
||||
else if (!openRsvps && !hasInvitation) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = '<span class="text">You need an invitation to RSVP to this session.</span>';
|
||||
sessionLinkText = '<span class="text">You need an invitation to RSVP to this session.</span>';
|
||||
}
|
||||
|
||||
if (showRsvpLink) {
|
||||
|
|
@ -472,7 +454,7 @@
|
|||
});
|
||||
}
|
||||
else {
|
||||
$('.rsvp-msg', $parentRow).html(noLinkText).show();
|
||||
$('.rsvp-msg', $parentRow).html(sessionLinkText).show();
|
||||
$('.rsvp-link', $parentRow).hide();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,33 @@
|
|||
}
|
||||
}
|
||||
|
||||
sessionUtils.ensureValidClient = function(app, gearUtils, successCallback) {
|
||||
|
||||
if(!context.JK.guardAgainstBrowser(app)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.JK.JamServer.connected) {
|
||||
app.notifyAlert("Not Connected", 'To create or join a session, you must be connected to the server.');
|
||||
return false;
|
||||
}
|
||||
|
||||
gearUtils.guardAgainstInvalidConfiguration(app)
|
||||
.fail(function() {
|
||||
app.notify(
|
||||
{ title: "Unable to Join Session",
|
||||
text: "You can only join a session once you have working audio gear and a tested internet connection."
|
||||
});
|
||||
})
|
||||
.done(function() {
|
||||
if (successCallback) {
|
||||
successCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sessionUtils.joinSession = function(sessionId) {
|
||||
|
||||
var hasInvitation = false;
|
||||
var session = null;
|
||||
// we need to do a real-time check of the session in case the settings have
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
context.JK.UIHelper = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = new context.JK.Rest();
|
||||
var sessionUtils = context.JK.SessionUtils;
|
||||
|
||||
function addSessionLike(sessionId, userId, $likeCountSelector, $likeButtonSelector) {
|
||||
rest.addSessionLike(sessionId, userId)
|
||||
|
|
@ -54,9 +55,11 @@
|
|||
}
|
||||
|
||||
function launchSessionStartDialog(session) {
|
||||
var sessionStartDialog = new JK.SessionStartDialog(JK.app, session);
|
||||
sessionStartDialog.initialize();
|
||||
return sessionStartDialog.showDialog();
|
||||
sessionUtils.ensureValidClient(app, context.JK.GearUtils, function() {
|
||||
var sessionStartDialog = new JK.SessionStartDialog(JK.app, session);
|
||||
sessionStartDialog.initialize();
|
||||
return sessionStartDialog.showDialog();
|
||||
});
|
||||
}
|
||||
|
||||
this.addSessionLike = addSessionLike;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
$ = jQuery
|
||||
context = window
|
||||
context.JK ||= {};
|
||||
|
||||
context.JK.WebsiteValidator = class WebsiteValidator
|
||||
|
||||
constructor: (input_div) ->
|
||||
@EVENTS = context.JK.EVENTS
|
||||
@rest = context.JK.Rest()
|
||||
@input_div = input_div
|
||||
@url_input = @input_div.find('input')
|
||||
this.show_format_status()
|
||||
@logger = context.JK.logger
|
||||
@site_status = null
|
||||
@spinner = @input_div.find('span.spinner-small')
|
||||
@checkmark = @input_div.find('.validate-checkmark')
|
||||
|
||||
init: () =>
|
||||
this.renderErrors({})
|
||||
@spinner.hide()
|
||||
validator = this
|
||||
@url_input.bind 'blur', ->
|
||||
if validator.show_format_status()
|
||||
validator.validate_url_site()
|
||||
@url_input.bind 'focus', ->
|
||||
validator.show_format_status()
|
||||
|
||||
url_to_validate: () =>
|
||||
url = @url_input.val()
|
||||
if 0 < url.length
|
||||
url.substring(0,2000)
|
||||
else
|
||||
null
|
||||
|
||||
validate_url_format: () =>
|
||||
regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
|
||||
regexp.test(this.url_to_validate())
|
||||
|
||||
show_format_status: () =>
|
||||
url = this.url_to_validate()
|
||||
yn = true
|
||||
if url
|
||||
yn = this.validate_url_format()
|
||||
if yn
|
||||
@checkmark.show()
|
||||
else
|
||||
@checkmark.hide()
|
||||
yn
|
||||
|
||||
validate_url_site: () =>
|
||||
@site_status = null
|
||||
@spinner.show()
|
||||
@checkmark.hide()
|
||||
@rest.validateUrlSite(this.url_to_validate())
|
||||
.done(this.processSiteCheck)
|
||||
.fail(this.processSiteCheckFail)
|
||||
|
||||
processSiteCheck: (response) =>
|
||||
@spinner.hide()
|
||||
if 'Valid Site' == response.message
|
||||
@site_status = 'valid'
|
||||
this.renderErrors({})
|
||||
else
|
||||
@site_status = 'invalid'
|
||||
this.renderErrors(response)
|
||||
@logger.debug("site_status = "+@site_status)
|
||||
|
||||
processSiteCheckFail: (response) =>
|
||||
@spinner.hide()
|
||||
@checkmark.hide()
|
||||
@logger.error("site check error")
|
||||
@site_status = 'invalid'
|
||||
|
||||
renderErrors: (errors) =>
|
||||
errdiv = @input_div.find('.error')
|
||||
if errmsg = context.JK.format_errors("site", errors)
|
||||
@checkmark.hide()
|
||||
errdiv.show()
|
||||
errdiv.html(errmsg)
|
||||
else
|
||||
@checkmark.show()
|
||||
errdiv.hide()
|
||||
errdiv.html('')
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
@import "client/common";
|
||||
|
||||
.website_validator {
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 5px;
|
||||
float: left;
|
||||
}
|
||||
.validate-checkmark {
|
||||
background-image: url('/assets/content/icon_checkmark_circle.png');
|
||||
background-repeat:no-repeat;
|
||||
background-position:center;
|
||||
width:32px;
|
||||
height:32px;
|
||||
background-size: 50% 50%;
|
||||
display:inline-block;
|
||||
vertical-align: middle;
|
||||
position: absolute;
|
||||
margin-top: 0px;
|
||||
margin-left: 520px;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
}
|
||||
.error {
|
||||
}
|
||||
span.spinner-small {
|
||||
display:inline-block;
|
||||
vertical-align: middle;
|
||||
position: absolute;
|
||||
margin-top: 0px;
|
||||
margin-left: 520px;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
require 'sanitize'
|
||||
class ApiUsersController < ApiController
|
||||
|
||||
before_filter :api_signed_in_user, :except => [:create, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring, :add_play, :crash_dump]
|
||||
before_filter :api_signed_in_user, :except => [:create, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring, :add_play, :crash_dump, :validate_data]
|
||||
before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete,
|
||||
:liking_create, :liking_destroy, # likes
|
||||
:following_create, :following_show, :following_destroy, # followings
|
||||
|
|
@ -699,6 +699,28 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
end
|
||||
|
||||
def validate_data
|
||||
data = params[:data]
|
||||
vtype = data =~ /^http/ ? 'url' : 'username'
|
||||
if 'url' == vtype
|
||||
if data.present?
|
||||
result = `curl --output /dev/null --silent --head --fail --show-error '#{data}' 2>&1`.chomp
|
||||
if $?.success?
|
||||
render json: { message: 'Valid Site' }, status: 200
|
||||
else
|
||||
result =~ /curl: \(\d+\) (.*)/
|
||||
render json: { message: 'Invalid Site', errors: { site: [$1] } }, status: 200
|
||||
end
|
||||
else
|
||||
render json: { message: "blank data #{data}" }, status: :unprocessable_entity
|
||||
end
|
||||
return
|
||||
elsif 'username' == vtype
|
||||
end
|
||||
|
||||
render json: { message: "unknown validation type #{params[:validation_type]}" }, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
###################### RECORDINGS #######################
|
||||
# def recording_index
|
||||
# @recordings = User.recording_index(current_user, params[:id])
|
||||
|
|
|
|||
|
|
@ -37,4 +37,9 @@ class SpikesController < ApplicationController
|
|||
Notification.send_subscription_message('test', '2', '{"msg": "oh hai 2"}')
|
||||
render text: 'oh hai'
|
||||
end
|
||||
|
||||
def site_validate
|
||||
render :layout => 'web'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
div class="website_validator" id="#{siteid}_url"
|
||||
span class="validate-checkmark"
|
||||
span class="spinner-small upload-spinner"
|
||||
input type='text' id="url_input_#{siteid}" maxlength="2000"
|
||||
br
|
||||
div class="error"
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
= javascript_include_tag "website_validator"
|
||||
div style="width:50%"
|
||||
= render "clients/website_validator", siteid: 'foobar'
|
||||
= stylesheet_link_tag "client/website_validator"
|
||||
|
||||
javascript:
|
||||
var initialized = false;
|
||||
$(document).on('JAMKAZAM_READY', function(e, data) {
|
||||
setTimeout(function() {
|
||||
window.website_validator = new JK.WebsiteValidator($(".website_validator#foobar_url"))
|
||||
website_validator.init()
|
||||
$('#url_input_foobar').val('http://www.jamkazam.com')
|
||||
}, 1)
|
||||
})
|
||||
|
|
@ -92,6 +92,7 @@ SampleApp::Application.routes.draw do
|
|||
match '/launch_app', to: 'spikes#launch_app'
|
||||
match '/websocket', to: 'spikes#websocket'
|
||||
match '/test_subscription', to: 'spikes#subscription'
|
||||
match '/site_validate', to: 'spikes#site_validate'
|
||||
|
||||
# junk pages
|
||||
match '/help', to: 'static_pages#help'
|
||||
|
|
@ -230,6 +231,9 @@ SampleApp::Application.routes.draw do
|
|||
# users
|
||||
match '/users/isp_scoring' => 'api_users#isp_scoring', :via => :post , :as => 'isp_scoring'
|
||||
|
||||
# validation
|
||||
match '/data_validation' => 'api_users#validate_data', :via => :get
|
||||
|
||||
match '/users' => 'api_users#index', :via => :get
|
||||
match '/users/:id' => 'api_users#show', :via => :get, :as => 'api_user_detail'
|
||||
#match '/users' => 'api_users#create', :via => :post
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
= stylesheet_link_tag "client/website_validator"
|
||||
= javascript_include_tag "website_validator"
|
||||
div style="width:50%"
|
||||
= render "clients/website_validator", siteid: 'teaspoon'
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
describe "WebsiteValidator", ->
|
||||
|
||||
beforeEach ->
|
||||
this.fixtures = fixture.load("website_validator_spec.html", append=false)
|
||||
this.server = sinon.fakeServer.create();
|
||||
window.jamClient = sinon.stub()
|
||||
this.website_validator = new JK.WebsiteValidator($(".website_validator#teaspoon_url"))
|
||||
this.website_validator.init()
|
||||
$('body').append(this.website_validator.input_div)
|
||||
this.website_validator.url_input.val('http://www.jamkazam.com')
|
||||
window.gon = {}
|
||||
window.gon.isNativeClient = true
|
||||
|
||||
afterEach ->
|
||||
this.server.restore();
|
||||
|
||||
it "displays validator widget", ->
|
||||
# this.website_validator.url_input.focus()
|
||||
# expect(this.website_validator.checkmark).toBeVisible()
|
||||
Loading…
Reference in New Issue