Add workflow panel

Change-Id: I81307a5a532123528ff2ab9616e7b5e3c5091bf7
This commit is contained in:
lawrancejing 2015-11-24 14:17:48 +00:00
parent 7a5efa146f
commit ca630e652f
11 changed files with 206 additions and 1 deletions

View File

@ -1,4 +1,4 @@
from evoquedashboard import exceptions
from evoque_dashboard import exceptions
DASHBOARD = 'ticket'
ADD_INSTALLED_APPS = [

View File

View File

@ -0,0 +1,47 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.conf import settings
from horizon.utils import memoized
from openstack_dashboard.api import base
from evoqueclient import client as evoque_client
USER_AGENT = 'python-senlinclient'
class Workflow(base.APIResourceWrapper):
_attrs = ['id', 'name', 'created_at', 'updated_at']
def _get_endpoint(request):
endpoint = getattr(
settings, 'EVOQUE_API_URL', "http://127.0.0.1:8808")
return endpoint
@memoized.memoized
def evoqueclient(request):
endpoint = _get_endpoint(request)
return evoque_client.Client(1, endpoint=endpoint,
token=request.user.token.id,
tenant=request.user.tenant_id)
def workflow_list(request):
"""Returns all workflows."""
workflows = evoqueclient(request).workflows.list()
return [Workflow(c) for c in workflows]

View File

@ -0,0 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
class Ticket(horizon.Dashboard):
name = _("Ticket")
slug = "ticket"
panels = ('workflows',)
default_panel = 'workflows'
horizon.register(Ticket)

View File

View File

@ -0,0 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from evoque_dashboard import dashboard
class Workflows(horizon.Panel):
name = _("Workflows")
slug = 'workflows'
dashboard.Ticket.register(Workflows)

View File

@ -0,0 +1,41 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from horizon.utils import filters
class WorkflowsTable(tables.DataTable):
name = tables.Column("name", verbose_name=_("Name"))
created = tables.Column(
"created_at",
verbose_name=_("Created"),
filters=(
filters.parse_isotime,
filters.timesince_or_never
)
)
updated = tables.Column(
"updated_at",
verbose_name=_("Updated"),
filters=(
filters.parse_isotime,
filters.timesince_or_never
)
)
class Meta(object):
name = "workflows"
verbose_name = _("Workflows")
table_actions = (tables.FilterAction,)

View File

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Workflows" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Workflows") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -0,0 +1,22 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
from evoque_dashboard.workflows import views
urlpatterns = patterns(
'',
url(r'^$', views.IndexView.as_view(), name='index'),
)

View File

@ -0,0 +1,33 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.utils.translation import ugettext_lazy as _
from evoque_dashboard.api import evoque
from evoque_dashboard.workflows.tables import WorkflowsTable
from horizon import exceptions
from horizon import tables
class IndexView(tables.DataTableView):
table_class = WorkflowsTable
template_name = 'ticket/workflows/index.html'
def get_data(self):
try:
workflows = evoque.workflow_list(self.request)
except Exception:
workflows = []
exceptions.handle(self.request,
_('Unable to retrieve workflows.'))
return workflows

View File

@ -5,6 +5,7 @@
hacking<0.11,>=0.10.0
# Testing Requirements
http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon
http://tarballs.openstack.org/python-evoqueclient/python-evoqueclient-master.tar.gz#egg=python-evoqueclient
coverage>=3.6
django-nose>=1.2