Skip to content

Commit

Permalink
review plugin list installed, add community plugin services
Browse files Browse the repository at this point in the history
  • Loading branch information
sboily authored and fblackburn1 committed May 31, 2021
1 parent cd7fb47 commit f50bc0d
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 57 deletions.
13 changes: 12 additions & 1 deletion wazo_ui/plugins/plugin/service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# 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+

import logging
import requests


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -33,3 +34,13 @@ def list(self, search, namespace, installed):
results.append(plugin)

return {'items': results}

def list_community_plugins(self):
url = "https://plugins.wazo.community/0.1/plugins"
try:
r = requests.get(url)
return r.json()
except:
pass

return []
61 changes: 59 additions & 2 deletions 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 All @@ -42,7 +99,7 @@

<div class="tab-pane" id="git">
<div class="row">
<div class="col-md-6">
<div class="col-md-8">
<h4>{{ _('Give your GIT url to install a plugin!') }}</h4>
<div class="input-group">
<span class="input-group-addon">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,78 +1,54 @@
{% macro _render_plugin(entry) %}
<div class="col-md-3 col-sm-6 col-xs-12 plugin-container">
<div class="small-box bg-{{ entry.color|default('green') }} box box-solid">
<div class="inner">
<h4 style="font-size:14px">{{ entry.display_name }} ({{ entry.installed_version or (entry.versions[0]['version'] if entry.versions) }})</h4>
<p><i>{{ _('By') }} {{ entry.author }}</i></p>
{{ _render_tags(entry.tags) }}
{% if entry.installed_version %}
{{ _render_remove_button(entry.namespace, entry.name) }}

{% set version = entry.versions|selectattr('upgradable')|first %}
{{ _render_upgrade_button(entry.namespace, entry.name, version.version) if version}}
{% else %}
{{ _render_install_button(entry.namespace, entry.name) }}
{% endif %}

</div>
<div class="icon">
<i class="fa fa-{{ entry.icon|default('gears') }}"></i>
</div>
<a href="{{ entry.homepage or '#' }}" class="small-box-footer" target="_blank">
{{ _('More info') }} <i class="fa fa-arrow-circle-right"></i>
</a>
<div class="overlay {% if not entry.on_installation %}hidden{% endif %}">
<i class="fa fa-refresh fa-spin"></i>
<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">{{ entry.name }} v{{ entry.installed_version or (entry.versions[0]['version'] if entry.versions) }}</h3>
<div class="pull-right box-tools">
{% if entry.installed_version %}
{{ _render_remove_button(entry.namespace, entry.name) }}
{% set version = entry.versions|selectattr('upgradable')|first %}
{{ _render_upgrade_button(entry.namespace, entry.name, version.version) if version}}
{% endif %}
</div>
</div>
</div>
</div>
{% endmacro %}

{% macro _render_tags(tags) %}
{% for tag in tags %}
<span>
<small class="label label-default">
<i class="fa fa-tag"></i>
{{ tag }}
</small>
&nbsp;
</span>
{% endfor %}
<div class="box-body">
<dl>
<dt><i class="fa fa-book"></i> Description</dt>
<dd>{{ entry.display_name }}</dd>
<br>
<dt><i class="fa fa-user"></i> Author</dt>
<dd>{{ entry.author }}</dd>
<br>
<dt><i class="fa fa-tags"></i> Tags</dt>
<dd>{% for tag in entry.tags %} <span class="label label-default">{{ tag }}</span> {% endfor %}</dd>
</dl>
<span class="pull-right"><a href="{{ entry.homepage or '#' }}">Details</a> <i class="fa fa-arrow-right"></i></span>
</div>
</div>
</div>
{% endmacro %}

{% macro _render_remove_button(namespace, name) %}
<button type="button" class="btn btn-default btn-xs margin label btn-remove-plugin"
<button type="button" class="btn btn-default btn-sm btn-remove-plugin"
style="z-index:1;position:relative;"
data-namespace="{{ namespace }}"
data-name="{{ name }}"
data-remove-url="{{ url_for('wazo_engine.plugin.PluginView:remove_plugin') }}"
>
{{ _('Remove') }}
<i class="fa fa-trash"></i>
</button>
{% endmacro %}

{% macro _render_install_button(namespace, name) %}
<button type="button" class="btn btn-default btn-xs margin label btn-install-plugin"
style="z-index:1;position:relative;"
data-namespace="{{ namespace }}"
data-name="{{ name }}"
data-install-url="{{ url_for('wazo_engine.plugin.PluginView:install_plugin') }}"
>
{{ _('Install') }}
<i class="fa fa-download"></i>
</button>
{% endmacro %}

{% macro _render_upgrade_button(namespace, name, version) %}
<button type="button" class="btn btn-default btn-xs margin label btn-upgrade-plugin"
<button type="button" class="btn btn-warning btn-sm btn-upgrade-plugin"
style="z-index:1;position:relative;"
data-namespace="{{ namespace }}"
data-name="{{ name }}"
data-version="{{ version }}"
data-upgrade-url="{{ url_for('wazo_engine.plugin.PluginView:install_plugin') }}"
>
{{ _('Upgrade') }} ({{ version }})
<i class="fa fa-download"></i>
</button>
{% endmacro %}
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 ""
9 changes: 9 additions & 0 deletions wazo_ui/static/css/wazo-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ div.box-header {
border-left-color: transparent;
}

.box.box-solid.box-primary>.box-header {
background: #98c451 !important;
background-color: #98c451 !important;
}

.box.box-solid.box-primary {
border: 1px solid #98c451 !important;
}

.main-sidebar form {
float: none!important;
}
Expand Down

0 comments on commit f50bc0d

Please sign in to comment.