Skip to content

Bug fixing for sprint 1 #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions samples/webrtc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ <h3 class="join__title">

<div class="join__body">
<div class="join__row">
<input type="text" class="join__input" name="username" placeholder="Username" autofocus required title="Should contain only latin characters and alphanumeric characters in a range from 3 to 20, starts with a letter." pattern="^[a-zA-Z\s][a-zA-Z\d-_\.\s]{3,20}$">
<input type="text" class="join__input" name="username" placeholder="Username" autofocus required title="Field should contain alphanumeric characters only in a range 3 to 20. The first character must be a letter." pattern="^[a-zA-Z][\w]{2,19}$">
</div>

<div class="join__row">
<input type="text" class="join__input" name="room" placeholder="Chat room name" required title="Should contain only latin characters and alphanumeric characters in a range from 3 to 15, without space." pattern="^[a-zA-Z\s][a-zA-Z\d\s]{3,15}$">
<input type="text" class="join__input" name="room" placeholder="Chat room name" required title="Field should contain alphanumeric characters only in a range 3 to 15, without space. The first character must be a letter." pattern="^[a-zA-Z][\w]{2,14}$">
</div>

<div class="join__row">
Expand Down Expand Up @@ -103,6 +103,21 @@ <h4>Connect to chat is failed</h4>
</div>
</div>

<div class="modal fade" id="already_auth" tabindex="-1">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Warning</h4>
</div>

<div class="modal-body">
<p class="text-danger">User has already authorized.</p>
</div>
</div>
</div>
</div>

<div class="modal fade" id="error_no_calles" tabindex="-1">
<div class="modal-dialog modal-sm">
<div class="modal-content">
Expand Down Expand Up @@ -284,7 +299,7 @@ <h4 class="caller__name">
</button>
</div>

<div class="wait users__list j-users">
<div class="users__list j-users">
</div>
</script>

Expand Down
111 changes: 60 additions & 51 deletions samples/webrtc/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,28 @@
var ui = {
'income_call': '#income_call',
'filterSelect': '.j-filter',
'sourceFilter': '.j-source'
'sourceFilter': '.j-source',
'insertOccupants': function() {
var $occupantsCont = $('.j-users');

function cb($cont, res) {
$cont.empty()
.append(res)
.removeClass('wait');
}

return new Promise(function(resolve, reject) {
$occupantsCont.addClass('wait');

app.helpers.renderUsers().then(function(res) {
cb($occupantsCont, res.usersHTML);
resolve(res.users);
}, function(error) {
cb($occupantsCont, error.message);
reject(null);
});
});
}
};

var call = {
Expand Down Expand Up @@ -86,20 +107,8 @@

/** render users wrapper */
$('.j-users_wrap').append( $('#users_tpl').html() );

/** render users */
app.helpers.renderUsers().then(function(res) {
$('.j-users').empty()
.append(res.usersHTML)
.removeClass('wait');

app.users = res.users;
}, function(error) {
if(error.title === 'not found') {
$('.j-users').empty()
.append(error.message)
.removeClass('wait');
}
ui.insertOccupants(function(users) {
app.users = users;
});

/** render frames */
Expand Down Expand Up @@ -154,6 +163,11 @@
return [item.name, item.value.trim()];
}));

if(localStorage.getItem('isAuth')) {
$('#already_auth').modal();
return false;
}

$form.addClass('join-wait');

app.helpers.join(data).then(function (user) {
Expand Down Expand Up @@ -186,6 +200,7 @@
} else {
$form.removeClass('join-wait');
$form.trigger('reset');
localStorage.setItem('isAuth', true);
app.router.navigate('dashboard', { trigger: true });
}
});
Expand All @@ -201,33 +216,20 @@
*/
/** REFRESH USERS */
$(document).on('click', '.j-users__refresh', function() {
var $btn = $(this),
$usersCont = $('.j-users');
var $btn = $(this);

app.callees = {};
$btn.prop('disabled', true);
$usersCont.addClass('wait');

app.helpers.renderUsers().then(function(res) {
$usersCont.empty()
.append(res.usersHTML)
.removeClass('wait');

app.users = res.users;
ui.insertOccupants().then(function(users) {
app.users = users;

$btn.prop('disabled', false);
}, function(error) {
if(error.title === 'not found') {
$('.j-users').empty()
.append(error.message)
.removeClass('wait');
}

app.helpers.setFooterPosition();
}, function() {
$btn.prop('disabled', false);
app.helpers.setFooterPosition();
});

app.callees = {};

app.helpers.setFooterPosition();
});

/** Check / uncheck user (callee) */
Expand Down Expand Up @@ -494,6 +496,7 @@
app.users = [];

QB.chat.disconnect();
localStorage.removeItem('isAuth');
app.router.navigate('join', {'trigger': true});
app.helpers.setFooterPosition();
} else {
Expand All @@ -502,6 +505,11 @@
});
});

/** Close tab or browser */
$( window ).unload(function() {
localStorage.removeItem('isAuth');
});

/**
* QB Event listener.
*
Expand Down Expand Up @@ -606,18 +614,19 @@
console.log('Extension: ', extension);
console.groupEnd();

var initiator = _.findWhere(app.users, {id: session.initiatorID});
app.currentSession = session;
ui.insertOccupants().then(function(users) {
app.users = users;

/** close previous modal */
$(ui.income_call).modal('hide');
/**
* set name of caller
* TODO: what if user doesn't sync all users
*/
$('.j-ic_initiator').text( initiator.full_name ? initiator.full_name : 'Unknown' );
$(ui.income_call).modal('show');
document.getElementById(sounds.rington).play();
var initiator = _.findWhere(app.users, {id: session.initiatorID});
app.currentSession = session;

/** close previous modal */
$(ui.income_call).modal('hide');

$('.j-ic_initiator').text(initiator.full_name);
$(ui.income_call).modal('show');
document.getElementById(sounds.rington).play();
});
};

QB.webrtc.onRejectCallListener = function onRejectCallListener(session, userId, extension) {
Expand Down Expand Up @@ -776,17 +785,17 @@
app.calleesAnwered = [];
}

if (app.currentSession.currentUserID === app.currentSession.initiatorID && !isCallEnded) {
if (app.currentSession.currentUserID === app.currentSession.initiatorID && !isCallEnded) {
/** get array if users without user who ends call */
app.calleesAnwered = _.reject(app.calleesAnwered, function(num){ return num.id === +userId; });
app.calleesAnwered = _.reject(app.calleesAnwered, function(num){ return num.id === +userId; });

app.helpers.stateBoard.update({
app.helpers.stateBoard.update({
'title': 'tpl_accept_call',
'property': {
'users': app.calleesAnwered
}
});
}
});
}

if( _.isEmpty(app.currentSession) || isCallEnded ) {
if(call.callTimer) {
Expand Down
7 changes: 6 additions & 1 deletion samples/webrtc/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ b {
.wait:after {
content: "";
display: block;
min-width: 100px;
min-height: 100px;
min-width: 100px;
position: absolute;

top: 0;
Expand Down Expand Up @@ -596,6 +596,11 @@ b {

font-size: 14px;
}
.frames_callee.wait:after {
min-width: auto;
min-height: auto;
background-size: 30%;
}

.frames_callee__inner {
position: relative;
Expand Down