Skip to content

Commit 5bbe22f

Browse files
committed
Bug fixing for sprint 1 (#131)
* QBWEBSDK-263 * QBWEBSDK-265 * QBWEBSDK-249 * upd text error * QBWEBSDK-270 * QBWEBSDK-273
1 parent 8321794 commit 5bbe22f

File tree

3 files changed

+84
-55
lines changed

3 files changed

+84
-55
lines changed

samples/webrtc/index.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ <h3 class="join__title">
4040

4141
<div class="join__body">
4242
<div class="join__row">
43-
<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}$">
43+
<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}$">
4444
</div>
4545

4646
<div class="join__row">
47-
<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}$">
47+
<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}$">
4848
</div>
4949

5050
<div class="join__row">
@@ -103,6 +103,21 @@ <h4>Connect to chat is failed</h4>
103103
</div>
104104
</div>
105105

106+
<div class="modal fade" id="already_auth" tabindex="-1">
107+
<div class="modal-dialog modal-sm">
108+
<div class="modal-content">
109+
<div class="modal-header">
110+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
111+
<h4 class="modal-title">Warning</h4>
112+
</div>
113+
114+
<div class="modal-body">
115+
<p class="text-danger">User has already authorized.</p>
116+
</div>
117+
</div>
118+
</div>
119+
</div>
120+
106121
<div class="modal fade" id="error_no_calles" tabindex="-1">
107122
<div class="modal-dialog modal-sm">
108123
<div class="modal-content">
@@ -284,7 +299,7 @@ <h4 class="caller__name">
284299
</button>
285300
</div>
286301

287-
<div class="wait users__list j-users">
302+
<div class="users__list j-users">
288303
</div>
289304
</script>
290305

samples/webrtc/js/app.js

Lines changed: 60 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,28 @@
1212
var ui = {
1313
'income_call': '#income_call',
1414
'filterSelect': '.j-filter',
15-
'sourceFilter': '.j-source'
15+
'sourceFilter': '.j-source',
16+
'insertOccupants': function() {
17+
var $occupantsCont = $('.j-users');
18+
19+
function cb($cont, res) {
20+
$cont.empty()
21+
.append(res)
22+
.removeClass('wait');
23+
}
24+
25+
return new Promise(function(resolve, reject) {
26+
$occupantsCont.addClass('wait');
27+
28+
app.helpers.renderUsers().then(function(res) {
29+
cb($occupantsCont, res.usersHTML);
30+
resolve(res.users);
31+
}, function(error) {
32+
cb($occupantsCont, error.message);
33+
reject(null);
34+
});
35+
});
36+
}
1637
};
1738

1839
var call = {
@@ -86,20 +107,8 @@
86107

87108
/** render users wrapper */
88109
$('.j-users_wrap').append( $('#users_tpl').html() );
89-
90-
/** render users */
91-
app.helpers.renderUsers().then(function(res) {
92-
$('.j-users').empty()
93-
.append(res.usersHTML)
94-
.removeClass('wait');
95-
96-
app.users = res.users;
97-
}, function(error) {
98-
if(error.title === 'not found') {
99-
$('.j-users').empty()
100-
.append(error.message)
101-
.removeClass('wait');
102-
}
110+
ui.insertOccupants(function(users) {
111+
app.users = users;
103112
});
104113

105114
/** render frames */
@@ -154,6 +163,11 @@
154163
return [item.name, item.value.trim()];
155164
}));
156165

166+
if(localStorage.getItem('isAuth')) {
167+
$('#already_auth').modal();
168+
return false;
169+
}
170+
157171
$form.addClass('join-wait');
158172

159173
app.helpers.join(data).then(function (user) {
@@ -186,6 +200,7 @@
186200
} else {
187201
$form.removeClass('join-wait');
188202
$form.trigger('reset');
203+
localStorage.setItem('isAuth', true);
189204
app.router.navigate('dashboard', { trigger: true });
190205
}
191206
});
@@ -201,33 +216,20 @@
201216
*/
202217
/** REFRESH USERS */
203218
$(document).on('click', '.j-users__refresh', function() {
204-
var $btn = $(this),
205-
$usersCont = $('.j-users');
219+
var $btn = $(this);
206220

221+
app.callees = {};
207222
$btn.prop('disabled', true);
208-
$usersCont.addClass('wait');
209-
210-
app.helpers.renderUsers().then(function(res) {
211-
$usersCont.empty()
212-
.append(res.usersHTML)
213-
.removeClass('wait');
214223

215-
app.users = res.users;
224+
ui.insertOccupants().then(function(users) {
225+
app.users = users;
216226

217227
$btn.prop('disabled', false);
218-
}, function(error) {
219-
if(error.title === 'not found') {
220-
$('.j-users').empty()
221-
.append(error.message)
222-
.removeClass('wait');
223-
}
224-
228+
app.helpers.setFooterPosition();
229+
}, function() {
225230
$btn.prop('disabled', false);
231+
app.helpers.setFooterPosition();
226232
});
227-
228-
app.callees = {};
229-
230-
app.helpers.setFooterPosition();
231233
});
232234

233235
/** Check / uncheck user (callee) */
@@ -494,6 +496,7 @@
494496
app.users = [];
495497

496498
QB.chat.disconnect();
499+
localStorage.removeItem('isAuth');
497500
app.router.navigate('join', {'trigger': true});
498501
app.helpers.setFooterPosition();
499502
} else {
@@ -502,6 +505,11 @@
502505
});
503506
});
504507

508+
/** Close tab or browser */
509+
$( window ).unload(function() {
510+
localStorage.removeItem('isAuth');
511+
});
512+
505513
/**
506514
* QB Event listener.
507515
*
@@ -606,18 +614,19 @@
606614
console.log('Extension: ', extension);
607615
console.groupEnd();
608616

609-
var initiator = _.findWhere(app.users, {id: session.initiatorID});
610-
app.currentSession = session;
617+
ui.insertOccupants().then(function(users) {
618+
app.users = users;
611619

612-
/** close previous modal */
613-
$(ui.income_call).modal('hide');
614-
/**
615-
* set name of caller
616-
* TODO: what if user doesn't sync all users
617-
*/
618-
$('.j-ic_initiator').text( initiator.full_name ? initiator.full_name : 'Unknown' );
619-
$(ui.income_call).modal('show');
620-
document.getElementById(sounds.rington).play();
620+
var initiator = _.findWhere(app.users, {id: session.initiatorID});
621+
app.currentSession = session;
622+
623+
/** close previous modal */
624+
$(ui.income_call).modal('hide');
625+
626+
$('.j-ic_initiator').text(initiator.full_name);
627+
$(ui.income_call).modal('show');
628+
document.getElementById(sounds.rington).play();
629+
});
621630
};
622631

623632
QB.webrtc.onRejectCallListener = function onRejectCallListener(session, userId, extension) {
@@ -776,17 +785,17 @@
776785
app.calleesAnwered = [];
777786
}
778787

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

783-
app.helpers.stateBoard.update({
792+
app.helpers.stateBoard.update({
784793
'title': 'tpl_accept_call',
785794
'property': {
786795
'users': app.calleesAnwered
787796
}
788-
});
789-
}
797+
});
798+
}
790799

791800
if( _.isEmpty(app.currentSession) || isCallEnded ) {
792801
if(call.callTimer) {

samples/webrtc/styles.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ b {
118118
.wait:after {
119119
content: "";
120120
display: block;
121-
min-width: 100px;
122121
min-height: 100px;
122+
min-width: 100px;
123123
position: absolute;
124124

125125
top: 0;
@@ -596,6 +596,11 @@ b {
596596

597597
font-size: 14px;
598598
}
599+
.frames_callee.wait:after {
600+
min-width: auto;
601+
min-height: auto;
602+
background-size: 30%;
603+
}
599604

600605
.frames_callee__inner {
601606
position: relative;

0 commit comments

Comments
 (0)