Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for community plugins services listing #110

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions wazo_ui/plugins/plugin/service.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Copyright 2017-2019 The Wazo Authors (see the AUTHORS file)
# Copyright 2017-2021 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

import logging

import requests

logger = logging.getLogger(__name__)

PLUGIN_URL = "https://plugins.wazo.community/0.1/plugins"


class PluginService(object):

Expand Down Expand Up @@ -33,3 +35,10 @@ def list(self, search, namespace, installed):
results.append(plugin)

return {'items': results}

def list_community_plugins(self):
try:
r = requests.get(PLUGIN_URL)
return r.json()
except (requests.RequestException, ValueError):
return []
59 changes: 58 additions & 1 deletion wazo_ui/plugins/plugin/templates/wazo_engine/plugin/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,69 @@
<div class="col-md-12">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#market" data-toggle="tab">{{ _('Installed') }}</a></li>
<li class="active"><a href="#market" data-toggle="tab">{{ _('Market') }}</a></li>
<li><a href="#installed" data-toggle="tab">{{ _('Installed') }}</a></li>
<li><a href="#git" data-toggle="tab">{{ _('Git') }}</a></li>
</ul>
<div class="tab-content">

<div class="tab-pane active" id="market">
<div class="row">
<div class="col-md-2 pull-right">
<div class="input-group">
<input class="form-control" placeholder="{{ _('Search plugin') }}" type="text" id="search_plugin_community"
data-search-url="{{ url_for('wazo_engine.plugin.PluginView:search_plugin_community') }}">
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
</div>
</div>
<div class="row"><hr></div>
<div class="row">
<div id="market">
{% if plugins|length < 1 %}
<div class="col-md-12">
<div class="callout callout-warning">
<h4>No response from the community service plugins!</h4>
<p>There is no public plugins for the moment. Please try again or wait for plugins.</p>
</div>
</div>
{% else %}
{% for plugin in plugins['items'] %}
<div class="col-md-4">
<div class="box box-solid box-primary">
<div class="box-header with-border">
<i class="fa fa-cubes"></i>
<h3 class="box-title">{{ plugin.name }} v{{ plugin.version}}</h3>
<div class="pull-right box-tools">
<i class="fa fa-star"></i>
<span>{{ plugin.stars }}</span>
</div>
</div>

<div class="box-body">
<dl>
<dt><i class="fa fa-book"></i> Description</dt>
<dd>{{ plugin.description }}</dd>
<br>
<dt><i class="fa fa-user"></i> Author</dt>
<dd>{{ plugin.author }}</dd>
<br>
<dt><i class="fa fa-tags"></i> Tags</dt>
<dd>{% for tag in plugin.tags %} <span class="label label-default">{{ tag }}</span> {% endfor %}</dd>
</dl>
<span class="pull-right"><a href="#">Details</a> <i class="fa fa-arrow-right"></i></span>
</div>
</div>
</div>
{% endfor %}
{% endif %}
</div>
</div>
</div>

<div class="tab-pane" id="installed">
<div class="row">
<div class="col-md-2 pull-right">
<div class="input-group">
Expand Down
7 changes: 6 additions & 1 deletion wazo_ui/plugins/plugin/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class PluginView(LoginRequiredView):

@menu_item('.ipbx.global_settings.plugins', l_('Plugins'), icon="cubes", multi_tenant=False)
def index(self):
return render_template('wazo_engine/plugin/list.html')
plugins = self.service.list_community_plugins()
return render_template('wazo_engine/plugin/list.html', plugins=plugins)

@route('/install_plugin/', methods=['POST'])
def install_plugin(self):
Expand All @@ -44,3 +45,7 @@ def search_plugin(self):
except HTTPError as error:
flash(error, category='error')
return render_template('flashed_messages.html')

@route('/search_plugin_community/', methods=['POST'])
def search_plugin_community(self):
return ""