Browse Source

KAZOO-2379: Added the inbound call recording feature on Users

4.3
Maxime Roux 12 years ago
parent
commit
001023d1ff
5 changed files with 188 additions and 3 deletions
  1. +8
    -2
      i18n/en-US.json
  2. +8
    -0
      i18n/fr-FR.json
  3. +1
    -1
      submodules/users/users.css
  4. +133
    -0
      submodules/users/users.js
  5. +38
    -0
      views/users-feature-call_recording.html

+ 8
- 2
i18n/en-US.json View File

@ -357,8 +357,14 @@
"requireKeyPress": "Leave voicemails on forwarded numbers",
"title": "Call Forwarding"
},
"call_recording": {
"title": "Call Recording"
"callRecording": {
"title": "Inbound Call Recording",
"headline": "User Call Recording Settings",
"formatLabel": "Format:",
"urlLabel": "URL:",
"urlPlaceholder": "http://your.server.com/place/to/store/recordings",
"timeLimitLabel": "Time Limit (sec):",
"noNumber": "Before configuring the Inbound Call Recording feature for this user, you need to assign him a number or an extension"
},
"conferencing": {
"title": "Conference Bridge",


+ 8
- 0
i18n/fr-FR.json View File

@ -357,6 +357,14 @@
"requireKeyPress": "Laisser message sur le répondeur du numéro transferé",
"title": "Transfert d'appels"
},
"callRecording": {
"title": "Enregistrement d'appel entrant",
"headline": "Réglages de l'enregistrement d'appel",
"formatLabel": "Format:",
"urlLabel": "URL:",
"urlPlaceholder": "http://votre.serveur.com/vos/enregistrements",
"timeLimitLabel": "Durée maximale (Sec):"
},
"call_recording": {
"title": "Enregistrement d'appel"
},


+ 1
- 1
submodules/users/users.css View File

@ -428,7 +428,7 @@
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 25%;
width: 33.33%;
height: 150px;
border: 1px solid #FFF;
text-align: center;


+ 133
- 0
submodules/users/users.js View File

@ -289,6 +289,11 @@ define(function(require){
icon: 'icon-music',
iconColor: 'icon-pink',
title: self.i18n.active().users.music_on_hold.title
},
call_recording: {
icon: 'icon-microphone',
iconColor: 'icon-blue',
title: self.i18n.active().users.callRecording.title
}
}
};
@ -1041,6 +1046,28 @@ define(function(require){
);
});
template.on('click', '.feature[data-feature="call_recording"]', function() {
self.usersListCallflowsUser(currentUser.id, function(data) {
if(data.length > 0) {
monster.request({
resource: 'voip.users.getCallflow',
data: {
accountId: self.accountId,
callflowId: data[0].id
},
success: function(callflow) {
self.usersRenderCallRecording({
userCallflow: callflow.data,
currentUser: currentUser
});
}
});
} else {
monster.ui.alert('error', self.i18n.active().users.call_recording.noNumber);
}
});
});
template.on('click', '.feature[data-feature="music_on_hold"]', function() {
self.usersRenderMusicOnHold(currentUser);
});
@ -1825,6 +1852,112 @@ define(function(require){
}
},
usersRenderCallRecording: function(params) {
var self = this,
templateData = $.extend(true, {
user: params.currentUser
},
(params.currentUser.extra.mapFeatures.call_recording.active ? {
url: params.userCallflow.flow.data.url,
format: params.userCallflow.flow.data.format,
timeLimit: params.userCallflow.flow.data.time_limit
} : {})
),
featureTemplate = $(monster.template(self, 'users-feature-call_recording', templateData)),
switchFeature = featureTemplate.find('.switch').bootstrapSwitch(),
featureForm = featureTemplate.find('#call_recording_form'),
popup;
monster.ui.validate(featureForm, {
rules: {
'time_limit': {
digits: true
}
}
});
featureTemplate.find('.cancel-link').on('click', function() {
popup.dialog('close').remove();
});
switchFeature.on('switch-change', function(e, data) {
data.value ? featureTemplate.find('.content').slideDown() : featureTemplate.find('.content').slideUp();
});
featureTemplate.find('.save').on('click', function() {
if(monster.ui.valid(featureForm)) {
var formData = form2object('call_recording_form'),
enabled = switchFeature.bootstrapSwitch('status');
if(!('smartpbx' in params.currentUser)) { params.currentUser.smartpbx = {}; }
if(!('call_recording' in params.currentUser.smartpbx)) {
params.currentUser.smartpbx.call_recording = {
enabled: false
};
}
if(params.currentUser.smartpbx.call_recording.enabled || enabled) {
params.currentUser.smartpbx.call_recording.enabled = enabled;
var newCallflow = $.extend(true, {}, params.userCallflow);
if(enabled) {
if(newCallflow.flow.module === 'record_call') {
newCallflow.flow.data = $.extend(true, { action: "start" }, formData);
} else {
newCallflow.flow = {
children: {
"_": $.extend(true, {}, params.userCallflow.flow)
},
module: "record_call",
data: $.extend(true, { action: "start" }, formData)
}
var flow = newCallflow.flow;
while(flow.children && '_' in flow.children) {
if(flow.children['_'].module === 'record_call' && flow.children['_'].data.action === 'stop') {
break; // If there is already a Stop Record Call
} else if(flow.children['_'].module === 'voicemail') {
var voicemailNode = $.extend(true, {}, flow.children['_']);
flow.children['_'] = {
module: 'record_call',
data: { action: "stop" },
children: { '_': voicemailNode }
}
break;
} else {
flow = flow.children['_'];
}
}
}
} else {
newCallflow.flow = $.extend(true, {}, params.userCallflow.flow.children["_"]);
var flow = newCallflow.flow;
while(flow.children && '_' in flow.children) {
if(flow.children['_'].module === 'record_call') {
flow.children = flow.children['_'].children;
break;
} else {
flow = flow.children['_'];
}
}
}
self.usersUpdateCallflow(newCallflow, function(updatedCallflow) {
self.usersUpdateUser(params.currentUser, function(updatedUser) {
popup.dialog('close').remove();
self.usersRender({ userId: params.currentUser.id });
});
});
} else {
popup.dialog('close').remove();
self.usersRender({ groupId: params.currentUser.id });
}
}
});
popup = monster.ui.dialog(featureTemplate, {
title: params.currentUser.extra.mapFeatures.call_recording.title,
position: ['center', 20]
});
},
usersRenderMusicOnHold: function(currentUser) {
var self = this,
silenceMediaId = 'silence_stream://300000';


+ 38
- 0
views/users-feature-call_recording.html View File

@ -0,0 +1,38 @@
<div class="feature-popup-container" data-feature="call_recording">
<div class="feature-popup-title">
<div class="feature-icon-wrapper">
<i class="{{user.extra.mapFeatures.call_recording.icon}}"></i>
</div>
{{ i18n.users.callRecording.headline }}
<div class="switch" data-on="success" data-off="default" data-on-label="{{i18n.enabled}}" data-off-label="{{i18n.disabled}}">
<input type="checkbox"{{#if user.extra.mapFeatures.call_recording.active}} checked="checked"{{/if}}></input>
</div>
</div>
<div class="content{{#unless user.extra.mapFeatures.call_recording.active}} disabled{{/unless}}">
<form id="call_recording_form">
<div>
<span>{{ i18n.users.callRecording.urlLabel }}</span>
<input required name="url" type="url" placeholder="{{ i18n.users.callRecording.urlPlaceholder }}" value="{{url}}">
</div>
<div>
<span>{{ i18n.users.callRecording.formatLabel }}</span>
<select name="format" class="input-medium">
<option value="mp3" {{#if format}}{{#compare format '===' 'mp3'}}selected{{/compare}}{{else}}selected{{/if}}>mp3</option>
<option value=2"wav" {{#compare format '===' 'wav'}}selected{{/compare}}>wav</option>
</select>
</div>
<div>
<span>{{ i18n.users.callRecording.timeLimitLabel }}</span>
<input required name="time_limit" type="text" class="input-small" value="{{#if timeLimit}}{{timeLimit}}{{else}}600{{/if}}">
</div>
</form>
</div>
<div class="actions clearfix">
<div class="pull-right">
<a class="cancel-link monster-link blue" href="javascript:void(0);">{{ i18n.cancel }}</a>
<button type="button" class="btn btn-success save">{{ i18n.saveChanges }}</button>
</div>
</div>
</div>

Loading…
Cancel
Save