Skip to content

Commit

Permalink
finishing up hold/resume
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Glinski authored and Kevin Glinski committed Nov 2, 2015
1 parent cdaf651 commit e6d050a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 36 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
Installing the Add-in
=====================
Prerequisites
-------------
* CIC 2016r1 or later

Deploy Add-in
-------------
See http://help.inin.com/developer/cic/docs/connectaddin/tutorial-03-deployment.html for the latest deployment instructions.

Copy the src/jabra folder into your /client/addins directory and in the addins.json file, set the baseUrl to jabra.


Developing Locally
==================
Configuring Interaction Connect Proxy
-------------------------------------
So that everything can be run locally without actually setting up the Interaction Connect app on the dev machine, a reverse proxy will serve up a remote client and the local addin.

edit development_config.json and change the value of the connectUrl to point to an installed instance of Interaction Connect.

Running the Server Locally
--------------------------
Execute

npm start

to start the server. Then open a web browser and go to http://localhost:8888

Unit Testing
------------
to run Karma execute

karma start
Expand Down
6 changes: 3 additions & 3 deletions src/jabra/addin.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@
<div class='clearfix form-inline'>
<div class='form-group'>
<label >Active Device:</label> <div>{{activeDevice}}</div>

</div>
<!--
<div class='clearfix form-inline'>
<div class='form-group'>
<label >Mute State:</label>
<label class='label label-danger'>Muted</label>
</div>-->
</div>
</div>
<div class='clearfix form-inline'>
<div class='form-group'>
<label >Hook State:</label>
<label class='label '>On hook</label>
</div>
</div>
</div>-->
</div>
</body>
</html>
14 changes: 10 additions & 4 deletions src/jabra/js/icwsSessionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ clientaddin.factory('IcwsSessionService', function ($rootScope, $log, $interval,
timeout: 2000,
data: connectData
};

http(requestData, function (data, status) {
$log.debug("got icws session");
sessionId = data.sessionId;
Expand Down Expand Up @@ -81,15 +82,20 @@ clientaddin.factory('IcwsSessionService', function ($rootScope, $log, $interval,

return{
post:function(url, data, onSuccess, onFailure){
http({
var options = {
method:'POST',
url: serverUrl + '/icws/' + sessionId + url,
headers:{
'ININ-ICWS-CSRF-Token' : csrfToken
},
timeout:2000,
data: data
},function (data, status) {
timeout:2000
};

if(data){
options.data = data;
}

http(options,function (data, status) {
if(onSuccess){
onSuccess(data,status);
}
Expand Down
25 changes: 24 additions & 1 deletion src/jabra/js/interactionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,41 @@ clientaddin.factory('InteractionService', function ($rootScope, $log, QueueServi
if(alertingInteractionId != null){
IcwsSessionService.post('/interactions/'+ alertingInteractionId + '/pickup')
}
else{
throw "can't find call"
}
},
disconnectConnectedCall: function(){
$log.debug("disconnecting selected call")
var selectedCallId = QueueService.connectedCall();

if(selectedCallId == null){
return;
throw "can't find call"
}

$log.debug("Disconnecting " + selectedCallId);

IcwsSessionService.post('/interactions/'+ selectedCallId + '/disconnect')
},
holdConnectedCall: function(onSuccess, onFailure){
var selectedCallId = QueueService.connectedCall()
if(selectedCallId != null){
IcwsSessionService.post('/interactions/'+ selectedCallId + '/hold',{on:true}, onSuccess, onFailure)
}else{
if(onFailure){
onFailure();
}
}
},
pickupHeldCall: function(onSuccess, onFailure){
var selectedCallId = QueueService.heldInteraction()
if(selectedCallId != null){
IcwsSessionService.post('/interactions/'+ selectedCallId + '/pickup', null, onSuccess, onFailure)
}else{
if(onFailure){
onFailure();
}
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/jabra/js/jabraDeviceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ clientaddin.factory('JabraDeviceService', function($interval, $rootScope, $log,
}
}
else if (data.indexOf(deviceevent.HoldCall) == 0){
sendCommand(command.Hold);
InteractionService.holdConnectedCall(function(){
sendCommand(command.Hold);
});
}
else if (data.indexOf(deviceevent.ResumeCall) == 0){
sendCommand(command.Resume);
sendCommand(command.OffHook);
InteractionService.pickupHeldCall(function(){
sendCommand(command.Resume);
});
}
else if(data.indexOf(deviceevent.HoldState) ==0){
holdState = Boolean(data.replace(deviceevent.HoldState,''));
}
else if(data.indexOf(deviceevent.HookState) ==0){

offHookState = data.replace(deviceevent.HookState,'') == "True";
}else if (data == 'ConfirmRequestOk' && onOkGetDeviceState){
onOkGetDeviceState = false;
Expand Down
32 changes: 24 additions & 8 deletions src/jabra/js/queueService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ clientaddin.factory('QueueService', function ($rootScope, $log, InitializationSe
interactions={};
queue = null;

var lastConnectedInteractionCount = -1;

function broadcastConnectedInteractionCount(){

var interactionCount = 0;
Expand All @@ -17,8 +19,10 @@ clientaddin.factory('QueueService', function ($rootScope, $log, InitializationSe
}
}

$rootScope.$broadcast("ConnectedInteractionCount" , interactionCount);

if(lastConnectedInteractionCount != interactionCount){
$rootScope.$broadcast("ConnectedInteractionCount" , interactionCount);
lastConnectedInteractionCount = interactionCount;
}
}

function startWatches(){
Expand Down Expand Up @@ -54,15 +58,15 @@ queue.on("interactionChanged", function(changedInteraction) {
return;
}
*/
$log.debug("The interaction with ID", changedInteraction.interactionId, "was changed.");
$log.debug("The interaction with ID", changedInteraction.interactionId, "was changed.");

interactions[changedInteraction.interactionId] = changedInteraction;
interactions[changedInteraction.interactionId] = changedInteraction;

broadcastConnectedInteractionCount();
broadcastConnectedInteractionCount();

if (!$rootScope.$$phase) {
$rootScope.$apply();
}
if (!$rootScope.$$phase) {
$rootScope.$apply();
}
});
queue.on("interactionRemoved", function(removedEvent) {
$log.debug("The interaction with ID", removedEvent.interactionId, "was removed.");
Expand Down Expand Up @@ -115,6 +119,18 @@ return{
}
return null;
},
heldInteraction: function(){
for(var id in interactions){
var interaction = interactions[id];

if(interaction.getAttribute(ININ.Addins.IC.Interactions.attributeNames.state) === ININ.Addins.IC.Interactions.stateAttributeValues.held)
{
return id;
}

}
return null;
},
connectedCall: function(){
for(var id in interactions){
var interaction = interactions[id];
Expand Down
16 changes: 0 additions & 16 deletions test/interactionService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ describe('InteractionService', function() {
});

describe("when calling disconnect selected call", function(){
it('should do nothing if selected interaction id == null', function(){
spyOn(IcwsSessionServiceMock, 'post').and.callThrough();

InteractionService.disconnectConnectedCall();
expect(IcwsSessionServiceMock.post).not.toHaveBeenCalled();

})

it('should call the icws disconnect on the selected call', function(){
spyOn(QueueServiceMock,'connectedCall').and.returnValue('1234')
Expand All @@ -57,15 +50,6 @@ describe('InteractionService', function() {
});

describe("when calling answer alerting call", function(){
it('should do nothing there are no alerting calls', function(){
spyOn(QueueServiceMock, 'alertingInteraction').and.returnValue(null);
spyOn(IcwsSessionServiceMock, 'post').and.callThrough();

InteractionService.answerAlertingCall();
expect(IcwsSessionServiceMock.post).not.toHaveBeenCalled();

})

it('should call the icws pickup on the alerting call', function(){
spyOn(QueueServiceMock, 'alertingInteraction').and.returnValue(1234);
spyOn(IcwsSessionServiceMock, 'post').and.callThrough();
Expand Down

0 comments on commit e6d050a

Please sign in to comment.