Skip to content

Commit

Permalink
Merge pull request #102 from wazo-platform/WAZO-2307_add_sccp_line
Browse files Browse the repository at this point in the history
add sccp line support

Reviewed-by: https://github.com/apps/wazo-production-sf
  • Loading branch information
wazo-community-zuul[bot] authored May 31, 2021
2 parents abd80cb + b71b007 commit cd7fb47
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 444 deletions.
2 changes: 1 addition & 1 deletion wazo_ui/plugins/general_settings/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class IaxGeneralSettingsForm(BaseForm):
submit = SubmitField(l_('Submit'))


class SccpGeneralSettingsForm(GeneralSettingsOptionsForm):
class SCCPGeneralSettingsForm(GeneralSettingsOptionsForm):
submit = SubmitField(l_('Submit'))


Expand Down
16 changes: 11 additions & 5 deletions wazo_ui/plugins/general_settings/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
PJSIPDocService,
PJSIPGlobalSettingsService,
PJSIPSystemSettingsService,
SccpGeneralSettingsService,
SCCPDocService,
SCCPGeneralSettingsService,
TimezoneService,
VoicemailGeneralSettingsService,
)
Expand All @@ -24,7 +25,8 @@
PJSIPDocListingView,
PJSIPGlobalSettingsView,
PJSIPSystemSettingsView,
SccpGeneralSettingsView,
SCCPDocListingView,
SCCPGeneralSettingsView,
TimezoneListingView,
VoicemailGeneralSettingsView,
)
Expand All @@ -42,6 +44,10 @@ def load(self, dependencies):
PJSIPDocListingView.register(general_settings, route_base='/list_json_by_section')
register_listing_url('pjsip_doc', 'general_settings.PJSIPDocListingView:list_json_by_section')

SCCPDocListingView.service = SCCPDocService()
SCCPDocListingView.register(general_settings, route_base='/sccp_documentation')
register_listing_url('sccp_doc', 'general_settings.SCCPDocListingView:list_json')

PJSIPGlobalSettingsView.service = PJSIPGlobalSettingsService(clients['wazo_confd'])
PJSIPGlobalSettingsView.register(general_settings, route_base='/pjsip_global_settings')
register_flaskview(general_settings, PJSIPGlobalSettingsView)
Expand All @@ -54,9 +60,9 @@ def load(self, dependencies):
IaxGeneralSettingsView.register(general_settings, route_base='/iax_general_settings')
register_flaskview(general_settings, IaxGeneralSettingsView)

SccpGeneralSettingsView.service = SccpGeneralSettingsService(clients['wazo_confd'])
SccpGeneralSettingsView.register(general_settings, route_base='/sccp_general_settings')
register_flaskview(general_settings, SccpGeneralSettingsView)
SCCPGeneralSettingsView.service = SCCPGeneralSettingsService(clients['wazo_confd'])
SCCPGeneralSettingsView.register(general_settings, route_base='/sccp_general_settings')
register_flaskview(general_settings, SCCPGeneralSettingsView)

VoicemailGeneralSettingsView.service = VoicemailGeneralSettingsService(clients['wazo_confd'])
VoicemailGeneralSettingsView.register(general_settings, route_base='/voicemail_general_settings')
Expand Down
13 changes: 12 additions & 1 deletion wazo_ui/plugins/general_settings/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,18 @@ def update(self, resource):
self._confd.iax_general.update(resource['general'])


class SccpGeneralSettingsService(object):
class SCCPDocService(object):

def get(self):
return [
{'id': 'cid_name', 'text': 'cid_name'},
{'id': 'cid_num', 'text': 'cid_num'},
{'id': 'allow', 'text': 'allow'},
{'id': 'disallow', 'text': 'disallow'},
]


class SCCPGeneralSettingsService(object):

def __init__(self, confd_client):
self._confd = confd_client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ add_tab_navigation_item('general', _('General'), active=True) }}
{% endcall %}

{% call build_form(action=url_for('.SccpGeneralSettingsView:put')) %}
{% call build_form(action=url_for('.SCCPGeneralSettingsView:put')) %}
{% call build_tabs_content() %}

{% call build_tab_content_item('general', active=True) %}
Expand Down
17 changes: 14 additions & 3 deletions wazo_ui/plugins/general_settings/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ConfBridgeGeneralSettingsForm,
FeaturesGeneralSettingsForm,
IaxGeneralSettingsForm,
SccpGeneralSettingsForm,
SCCPGeneralSettingsForm,
PJSIPGlobalSettingsForm,
PJSIPSystemSettingsForm,
VoicemailGeneralSettingsForm,
Expand Down Expand Up @@ -164,8 +164,8 @@ def _map_form_to_resources(self, form, form_id=None):
return data


class SccpGeneralSettingsView(BaseGeneralSettingsView):
form = SccpGeneralSettingsForm
class SCCPGeneralSettingsView(BaseGeneralSettingsView):
form = SCCPGeneralSettingsForm
resource = 'sccp_general_settings'
settings = 'sccp_general'

Expand Down Expand Up @@ -270,6 +270,17 @@ def _map_form_to_resources(self, form, form_id=None):
return data


class SCCPDocListingView(LoginRequiredView):

def list_json(self):
params = extract_select2_params(request.args)
doc = self.service.get()
term = params.get('search') or ''
with_id = [item for item in doc if term in item['text']]
params['limit'] = len(with_id) # avoid pagination
return jsonify(build_select2_response(with_id, len(with_id), params))


class PJSIPDocListingView(LoginRequiredView):

def list_json_by_section(self, section):
Expand Down
14 changes: 13 additions & 1 deletion wazo_ui/plugins/line/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
SelectField,
StringField,
SubmitField,
FieldList,
)
from wtforms.validators import InputRequired, Length

from wazo_ui.helpers.form import BaseForm
from wazo_ui.plugins.sip_template.form import EndpointSIPForm


class SCCPOptionsForm(BaseForm):
option_key = SelectField(choices=[], validators=[InputRequired()])
option_value = StringField(validators=[InputRequired()])


class EndpointSCCPForm(BaseForm):
id = HiddenField()
options = FieldList(FormField(SCCPOptionsForm))


class EndpointCustomForm(BaseForm):
id = HiddenField()
interface = StringField(l_('Interface'), validators=[InputRequired()])
Expand All @@ -23,7 +34,8 @@ class EndpointCustomForm(BaseForm):

class LineForm(BaseForm):
context = SelectField(l_('Context'), validators=[InputRequired()], choices=[])
protocol = SelectField(choices=[('sip', l_('SIP')), ('custom', l_('CUSTOM'))])
protocol = SelectField(choices=[('sip', l_('SIP')), ('sccp', l_('SCCP')), ('custom', l_('CUSTOM'))])
endpoint_sip = FormField(EndpointSIPForm)
endpoint_sccp = FormField(EndpointSCCPForm)
endpoint_custom = FormField(EndpointCustomForm)
submit = SubmitField(l_('Submit'))
8 changes: 8 additions & 0 deletions wazo_ui/plugins/line/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def get_context(self, context):
def get_endpoint_sip(self, endpoint_uuid):
return self._confd.endpoints_sip.get(endpoint_uuid)

def get_endpoint_sccp(self, endpoint_id):
return self._confd.endpoints_sccp.get(endpoint_id)

def get_endpoint_custom(self, endpoint_id):
return self._confd.endpoints_custom.get(endpoint_id)

Expand All @@ -37,6 +40,9 @@ def create(self, resource):
if resource.get('endpoint_sip'):
endpoint_sip = self._confd.endpoints_sip.create(resource['endpoint_sip'])
self._confd.lines(resource['id']).add_endpoint_sip(endpoint_sip['uuid'])
if resource.get('endpoint_sccp'):
endpoint_sccp = self._confd.endpoints_sccp.create(resource['endpoint_sccp'])
self._confd.lines(resource['id']).add_endpoint_sccp(endpoint_sccp['id'])
if resource.get('endpoint_custom'):
endpoint_custom = self._confd.endpoints_custom.create(resource['endpoint_custom'])
self._confd.lines(resource['id']).add_endpoint_custom(endpoint_custom['id'])
Expand All @@ -45,5 +51,7 @@ def update(self, resource):
super().update(resource)
if resource.get('endpoint_sip'):
self._confd.endpoints_sip.update(resource['endpoint_sip'])
if resource.get('endpoint_sccp'):
self._confd.endpoints_sccp.update(resource['endpoint_sccp'])
if resource.get('endpoint_custom'):
self._confd.endpoints_custom.update(resource['endpoint_custom'])
Loading

0 comments on commit cd7fb47

Please sign in to comment.