Skip to content

Commit

Permalink
Added connector metrics #26
Browse files Browse the repository at this point in the history
And reworked API metrics to use a Django form
  • Loading branch information
sebtesobe committed Jul 3, 2017
1 parent b340764 commit 9f8c839
Show file tree
Hide file tree
Showing 12 changed files with 630 additions and 251 deletions.
1 change: 1 addition & 0 deletions apimanager/apimanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@


API_DATETIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
API_DATEFORMAT = '%Y-%m-%d'


OAUTH_API = 'http://127.0.0.1:8080'
Expand Down
4 changes: 4 additions & 0 deletions apimanager/base/static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ footer a:hover, .footer a:focus {
margin-left: 15px;
}

.dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:active {
background-color: #53c4ef;
}

.btn-primary {
background-color: #53c4ef;
border-color: #33a4cf;
Expand Down
11 changes: 9 additions & 2 deletions apimanager/base/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@
<li{% if consumers_index_url in request.path %} class="active"{% endif %}><a href="{{ consumers_index_url }}">Consumers</a></li>
{% url "users-index" as users_index_url %}
<li{% if users_index_url in request.path %} class="active"{% endif %}><a href="{{ users_index_url }}">Users</a></li>
{% url "metrics-index" as metrics_index_url %}
<li{% if metrics_index_url in request.path %} class="active"{% endif %}><a href="{{ metrics_index_url }}">Metrics</a></li>
{% url "api-metrics" as api_metrics_url %}
{% url "connector-metrics" as connector_metrics_url %}
<li class="dropdown{% if api_metrics_url in request.path or connector_metrics_url in request.path %} active{% endif %}">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Metrics</a>
<ul class="dropdown-menu">
<li{% if api_metrics_url in request.path %} class="active"{% endif %}><a href="{{ api_metrics_url }}">API Metrics</a></li>
<li{% if connector_metrics_url in request.path %} class="active"{% endif %}><a href="{{ connector_metrics_url }}">Connector Metrics</a></li>
</ul>
</li>
{% url "customers-create" as customers_create_url %}
<li{% if customers_create_url in request.path %} class="active"{% endif %}><a href="{{ customers_create_url }}">Customers</a></li>
{% url "config-index" as config_index_url %}
Expand Down
204 changes: 204 additions & 0 deletions apimanager/metrics/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# -*- coding: utf-8 -*-
"""
Forms of metrics app
"""

from django import forms
from django.conf import settings


class MetricsForm(forms.Form):
start_date = forms.DateTimeField(
label='Start Date',
input_formats=[settings.API_DATEFORMAT],
widget=forms.DateTimeInput(
attrs={
'placeholder': 'yyyy-mm-dd',
'class': 'form-control',
}
),
required=False,
)
end_date = forms.DateTimeField(
label='End Date',
input_formats=[settings.API_DATEFORMAT],
widget=forms.DateTimeInput(
attrs={
'placeholder': 'yyyy-mm-dd',
'class': 'form-control',
}
),
required=False,
)
limit = forms.IntegerField(
label='Limit',
widget=forms.NumberInput(
attrs={
'class': 'form-control',
}
),
initial=100,
required=False,
)
offset = forms.IntegerField(
label='Offset',
widget=forms.NumberInput(
attrs={
'class': 'form-control',
}
),
initial=0,
required=False,
)

def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '')
super(MetricsForm, self).__init__(*args, **kwargs)


class APIMetricsForm(MetricsForm):
ANONYMOUS = (
('', 'Anonymous and Non-Anonymous'),
('true', 'Yes'),
('false', 'No'),
)
VERB = (
('', 'Any'),
('DELETE', 'DELETE'),
('GET', 'GET'),
('POST', 'POST'),
('PUT', 'PUT'),
)
VERSION = (
('', 'Any'),
('v1.2', '1.2'),
('v1.2.1', '1.2.1'),
('v1.3.0', '1.3.0'),
('v1.4.0', '1.4.0'),
('v2.0.0', '2.0.0'),
('v2.1.0', '2.1.0'),
('v2.2.0', '2.2.0'),
('v3.0.0', '3.0.0'),
)

consumer_id = forms.CharField(
label='Consumer ID',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
user_id = forms.CharField(
label='User ID',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
anon = forms.ChoiceField(
label='Anonymous',
choices=ANONYMOUS,
widget=forms.Select(
attrs={
'class': 'form-control',
}
),
initial='',
required=False,
)
app_name = forms.CharField(
label='App Name',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
verb = forms.ChoiceField(
label='Verb',
choices=VERB,
widget=forms.Select(
attrs={
'class': 'form-control',
}
),
initial='',
required=False,
)
url = forms.CharField(
label='URL',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
implemented_by_partial_function = forms.CharField(
label='Implemented By Partial Function',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
implemented_in_version = forms.ChoiceField(
label='Implemented In Version',
choices=VERSION,
widget=forms.Select(
attrs={
'class': 'form-control',
}
),
initial='',
required=False,
)


class ConnectorMetricsForm(MetricsForm):
# override start_date until API returns values without given date
start_date = forms.DateTimeField(
label='Start Date',
input_formats=[settings.API_DATEFORMAT],
widget=forms.DateTimeInput(
attrs={
'placeholder': 'yyyy-mm-dd',
'class': 'form-control',
}
),
initial='1970-01-01',
required=True,
)
connector_name = forms.CharField(
label='Connector Name',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
function_name = forms.CharField(
label='Function Name',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
obp_api_request_id = forms.CharField(
label='OBP API Request ID',
widget=forms.TextInput(
attrs={
'class': 'form-control',
}
),
required=False,
)
6 changes: 3 additions & 3 deletions apimanager/metrics/static/metrics/css/metrics.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
margin-bottom: 10px;
}

#metrics #metrics-list {
margin-top: 20px;
#metrics #metrics-data {
margin-top: 40px;
}

#metrics #metrics-list ul {
margin-left: -25px;
}
Loading

0 comments on commit 9f8c839

Please sign in to comment.