forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
402b28b
commit 2711020
Showing
12 changed files
with
1,085 additions
and
4 deletions.
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
app/assets/javascripts/app/controllers/_integration/placetel.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
class Index extends App.ControllerIntegrationBase | ||
featureIntegration: 'placetel_integration' | ||
featureName: 'Placetel' | ||
featureConfig: 'placetel_config' | ||
description: [ | ||
['This service shows you contacts of incoming calls and a caller list in realtime.'] | ||
['Also caller id of outbound calls can be changed.'] | ||
] | ||
events: | ||
'click .js-select': 'selectAll' | ||
'change .js-switch input': 'switch' | ||
|
||
render: => | ||
super | ||
new Form( | ||
el: @$('.js-form') | ||
) | ||
|
||
new App.HttpLog( | ||
el: @$('.js-log') | ||
facility: 'placetel' | ||
) | ||
|
||
class Form extends App.Controller | ||
events: | ||
'submit form': 'update' | ||
'click .js-inboundBlockCallerId .js-add': 'addInboundBlockCallerId' | ||
'click .js-outboundRouting .js-add': 'addOutboundRouting' | ||
'click .js-inboundBlockCallerId .js-remove': 'removeInboundBlockCallerId' | ||
'click .js-outboundRouting .js-remove': 'removeOutboundRouting' | ||
|
||
constructor: -> | ||
super | ||
@render() | ||
|
||
currentConfig: -> | ||
config = App.Setting.get('placetel_config') | ||
if !config.outbound | ||
config.outbound = {} | ||
if !config.outbound.routing_table | ||
config.outbound.routing_table = [] | ||
if !config.inbound | ||
config.inbound = {} | ||
if !config.inbound.block_caller_ids | ||
config.inbound.block_caller_ids = [] | ||
config | ||
|
||
setConfig: (value) -> | ||
App.Setting.set('placetel_config', value, {notify: true}) | ||
|
||
render: => | ||
@config = @currentConfig() | ||
|
||
@html App.view('integration/placetel')( | ||
config: @config | ||
placetel_token: App.Setting.get('placetel_token') | ||
) | ||
|
||
updateCurrentConfig: => | ||
config = @config | ||
cleanupInput = @cleanupInput | ||
|
||
# default caller_id | ||
default_caller_id = @$('input[name=default_caller_id]').val() | ||
config.outbound.default_caller_id = cleanupInput(default_caller_id) | ||
|
||
# routing table | ||
config.outbound.routing_table = [] | ||
@$('.js-outboundRouting .js-row').each(-> | ||
dest = cleanupInput($(@).find('input[name="dest"]').val()) | ||
caller_id = cleanupInput($(@).find('input[name="caller_id"]').val()) | ||
note = $(@).find('input[name="note"]').val() | ||
config.outbound.routing_table.push { | ||
dest: dest | ||
caller_id: caller_id | ||
note: note | ||
} | ||
) | ||
|
||
# blocked caller ids | ||
config.inbound.block_caller_ids = [] | ||
@$('.js-inboundBlockCallerId .js-row').each(-> | ||
caller_id = $(@).find('input[name="caller_id"]').val() | ||
note = $(@).find('input[name="note"]').val() | ||
config.inbound.block_caller_ids.push { | ||
caller_id: cleanupInput(caller_id) | ||
note: note | ||
} | ||
) | ||
|
||
@config = config | ||
|
||
update: (e) => | ||
e.preventDefault() | ||
@updateCurrentConfig() | ||
@setConfig(@config) | ||
|
||
cleanupInput: (value) -> | ||
return value if !value | ||
value.replace(/\s/g, '').trim() | ||
|
||
addInboundBlockCallerId: (e) => | ||
e.preventDefault() | ||
@updateCurrentConfig() | ||
element = $(e.currentTarget).closest('tr') | ||
caller_id = element.find('input[name="caller_id"]').val() | ||
note = element.find('input[name="note"]').val() | ||
return if _.isEmpty(caller_id) || _.isEmpty(note) | ||
@config.inbound.block_caller_ids.push { | ||
caller_id: @cleanupInput(caller_id) | ||
note: note | ||
} | ||
@render() | ||
|
||
addOutboundRouting: (e) => | ||
e.preventDefault() | ||
@updateCurrentConfig() | ||
element = $(e.currentTarget).closest('tr') | ||
dest = @cleanupInput(element.find('input[name="dest"]').val()) | ||
caller_id = @cleanupInput(element.find('input[name="caller_id"]').val()) | ||
note = element.find('input[name="note"]').val() | ||
return if _.isEmpty(caller_id) || _.isEmpty(dest) || _.isEmpty(note) | ||
@config.outbound.routing_table.push { | ||
dest: dest | ||
caller_id: caller_id | ||
note: note | ||
} | ||
@render() | ||
|
||
removeInboundBlockCallerId: (e) => | ||
e.preventDefault() | ||
@updateCurrentConfig() | ||
element = $(e.currentTarget).closest('tr') | ||
element.remove() | ||
@updateCurrentConfig() | ||
|
||
removeOutboundRouting: (e) => | ||
e.preventDefault() | ||
@updateCurrentConfig() | ||
element = $(e.currentTarget).closest('tr') | ||
element.remove() | ||
@updateCurrentConfig() | ||
|
||
class State | ||
@current: -> | ||
App.Setting.get('placetel_integration') | ||
|
||
App.Config.set( | ||
'IntegrationPlacetel' | ||
{ | ||
name: 'Placetel' | ||
target: '#system/integration/placetel' | ||
description: 'VoIP service provider with realtime push.' | ||
controller: Index | ||
state: State | ||
} | ||
'NavBarIntegrations' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
app/assets/javascripts/app/views/integration/placetel.jst.eco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<form> | ||
|
||
<h2>Placetel <%- @T('Settings') %></h2> | ||
|
||
<p><%- @T('You need to configure the Zammad endpoints in the %s', 'Placetel') %>:<p> | ||
|
||
<div class="settings-entry"> | ||
<table class="settings-list" style="width: 100%;"> | ||
<thead> | ||
<tr> | ||
<th width="20%"><%- @T('Type') %> | ||
<th width="80%"><%- @T('URL') %> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td class="settings-list-row-control"><%- @T('Endpoint') %> | ||
<td class="settings-list-control-cell"><input type="url" class="form-control form-control--small js-select" readonly value="<%- @C('http_type') %>://<%- @C('fqdn') %>/api/v1/placetel/<%= @placetel_token %>"> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<h2><%- @T('Inbound') %></h2> | ||
|
||
<p><%- @T('Blocked caller ids based on sender caller id.') %> | ||
|
||
<div class="settings-entry"> | ||
<table class="settings-list js-inboundBlockCallerId" style="width: 100%;"> | ||
<thead> | ||
<tr> | ||
<th width="50%"><%- @T('Caller id to block') %> | ||
<th width="40%"><%- @T('Note') %> | ||
<th width="10%"><%- @T('Action') %> | ||
</thead> | ||
<tbody> | ||
<% for row in @config.inbound.block_caller_ids: %> | ||
<tr class="js-row"> | ||
<td class="settings-list-control-cell"><input name="caller_id" value="<%= row.caller_id %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-control-cell"><input name="note" value="<%= row.note %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-row-control"><div class="btn btn--text js-remove"><%- @Icon('trash') %> <%- @T('Remove') %></div> | ||
<% end %> | ||
<tr> | ||
<td class="settings-list-control-cell"><input name="caller_id" value="" placeholder="4930609854189" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-control-cell"><input name="note" value="" placeholder="<%- @Ti('my own note') %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-row-control"><div class="btn btn--text btn--create js-add"><%- @Icon('plus-small') %> <%- @T('Add') %></div> | ||
</tbody> | ||
</table> | ||
</div> | ||
<!-- disabled until api is supporting it | ||
<h2><%- @T('Outbound') %></h2> | ||
|
||
<p><%- @T('Set caller id of outbound calls based on destination caller id.') %> | ||
|
||
<div class="settings-entry js-outboundRouting"> | ||
<table class="settings-list" style="width: 100%;"> | ||
<thead> | ||
<tr> | ||
<th width="30%"><%- @T('Destination caller id') %> | ||
<th width="30%"><%- @T('Set outbound caller id') %> | ||
<th width="30%"><%- @T('Note') %> | ||
<th width="10%"><%- @T('Action') %> | ||
</thead> | ||
<tbody> | ||
<% for row in @config.outbound.routing_table: %> | ||
<tr class="js-row"> | ||
<td class="settings-list-control-cell"><input name="dest" value="<%= row.dest %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-control-cell"><input name="caller_id" value="<%= row.caller_id %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-control-cell"><input name="note" value="<%= row.note %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-row-control"><div class="btn btn--text js-remove"><%- @Icon('trash') %> <%- @T('Remove') %></div> | ||
<% end %> | ||
<tr> | ||
<td class="settings-list-control-cell"><input name="dest" value="" placeholder="49* or 3230123456789" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-control-cell"><input name="caller_id" value="" placeholder="4930609854189" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-control-cell"><input name="note" value="" placeholder="<%- @Ti('my own note') %>" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-row-control"><div class="btn btn--text btn--create js-add"><%- @Icon('plus-small') %> <%- @T('Add') %></div> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<p><%- @T('Default caller id.') %> | ||
|
||
<div class="settings-entry"> | ||
<table class="settings-list" style="width: 100%;"> | ||
<thead> | ||
<tr> | ||
<th width="50%"><%- @T('Default caller id') %> | ||
<th width="50%"><%- @T('Note') %> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td class="settings-list-control-cell"><input name="default_caller_id" value="<%= @config.outbound.default_caller_id %>" placeholder="4930609854189" class="form-control form-control--small js-summary"> | ||
<td class="settings-list-row-control"><%- @T('Default caller id for outbound calls.') %> | ||
</tbody> | ||
</table> | ||
</div> | ||
--> | ||
<button type="submit" class="btn btn--primary js-submit"><%- @T('Save') %></button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.