mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 17:06:45 +00:00
feature/tweaked the api_collection form fields
This commit is contained in:
parent
cfa10d9102
commit
56b93d841d
@ -3,12 +3,16 @@ $(document).ready(function($) {
|
||||
e.preventDefault();
|
||||
var t = $(this);
|
||||
var runner = t.parent().parent().parent();
|
||||
var api_collection_body = $(runner).find('.api-collection-body').val();
|
||||
var api_collection_name = $(runner).find('.api_collection_name').val();
|
||||
var api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val();
|
||||
var api_collection_description = $(runner).find('.api_collection_description').val();
|
||||
|
||||
$('.runner button.forSave').attr("disabled","disabled");
|
||||
$('.runner button.forDelete').attr("disabled","disabled");
|
||||
$.post('save/apicollection', {
|
||||
'api-collection-body': api_collection_body,
|
||||
'api_collection_name': api_collection_name,
|
||||
'api_collection_is_sharable': api_collection_is_sharable,
|
||||
'api_collection_description': api_collection_description,
|
||||
}, function (response) {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<div id="api-collection-detail">
|
||||
<h2>Add Api Collection</h2>
|
||||
<h2>Add Endpoint to API Collection</h2>
|
||||
<form class="form" action="" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h2>Existing API Collections</h2>
|
||||
<h2>Endpoints</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
||||
@ -6,13 +6,16 @@
|
||||
<h1>API Collections</h1>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<label class="form-group">Api Collection Id:</label> <br>
|
||||
<label class="form-group">API Collection Id:</label> <br>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<label class="form-group">Collection Name:</label> <br>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<label class="form-group">Json Body:</label> <br>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<label class="form-group">Is Sharable:</label> <br>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<label class="form-group">Description:</label> <br>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post">
|
||||
@ -23,20 +26,43 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="form-group" cols="1" rows="1">
|
||||
<a class="api_collection_id" href="{{ url_collection_detail }}">{{ api_collection.api_collection_id }}
|
||||
</a></div>
|
||||
<a class="api_collection_id" href="{{ url_collection_detail }}">{{ api_collection.api_collection_id }}</a></div>
|
||||
</div>
|
||||
{% if api_collection.api_collection_id %}
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="form-group" cols="1" rows="1">
|
||||
<div>{{ api_collection.api_collection_name }}</div></div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="form-group" cols="1" rows="1">
|
||||
<div class="api_collection_name">{{ api_collection.api_collection_name }}</div></div>
|
||||
<div>{{ api_collection.is_sharable }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<textarea cols="40" rows="1" class="form-control api-collection-body">{{api_collection}}</textarea>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<div cols="40" rows="1" class="form-control">{{api_collection.description}}</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="form-group" cols="1" rows="1">
|
||||
<input class="api_collection_name" value="Customer">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="form-group" cols="1" rows="1">
|
||||
<select class="api_collection_is_sharable form-control">
|
||||
<option value="True">True</option>
|
||||
<option value="False">False</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<textarea cols="40" rows="1" class="form-control api_collection_description">Describe the purpose of the collection</textarea>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if forloop.counter0 == 0 %}
|
||||
<div class="col-sm-12 col-sm-2">
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary btn-green forSave">Create </button><span style="display: none;margin-left: 5px;background-color:#00cc00">saved.</span>
|
||||
<button class="btn btn-primary btn-green forSave">Create </button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@ -47,9 +73,6 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-sm-12 col-sm-12">
|
||||
<div id="jsoneditor{{forloop.counter0}}" style="display: none" ></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@ -136,17 +136,21 @@ class DeleteCollectionEndpointView(LoginRequiredMixin, FormView):
|
||||
@exception_handle
|
||||
@csrf_exempt
|
||||
def apicollections_save(request):
|
||||
api_collection_body = request.POST.get('api-collection-body')
|
||||
api = API(request.session.get('obp'))
|
||||
urlpath = '/my/api-collections'
|
||||
result = api.post(urlpath, payload =json.loads( api_collection_body))
|
||||
payload = {
|
||||
'api_collection_name': request.POST.get('api_collection_name').strip(),
|
||||
'is_sharable': bool(request.POST.get('api_collection_is_sharable')),
|
||||
'description': request.POST.get('api_collection_description').strip()
|
||||
}
|
||||
result = api.post(urlpath, payload = payload)
|
||||
return result
|
||||
|
||||
|
||||
@exception_handle
|
||||
@csrf_exempt
|
||||
def apicollections_delete(request):
|
||||
api_collection_id = request.POST.get('api_collection_id')
|
||||
api_collection_id = request.POST.get('api_collection_id').strip()
|
||||
|
||||
api = API(request.session.get('obp'))
|
||||
urlpath = '/my/api-collections/{}'.format(api_collection_id)
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
<li{% if webui_props_index_url in request.path %} class="active"{% endif %}><a href="{{ webui_props_index_url }}">Webui Props</a></li><hr class="dropdown-hr">
|
||||
<li{% if methodrouting_index_url in request.path %} class="active"{% endif %}><a href="{{ methodrouting_index_url }}">Method Routings</a></li><hr class="dropdown-hr">
|
||||
<li{% if dynamic_endpoints_index_url in request.path %} class="active"{% endif %}><a href="{{ dynamic_endpoints_index_url }}">Dynamic Endpoints</a></li><hr class="dropdown-hr">
|
||||
<li{% if api_collections_index_url in request.path %} class="active"{% endif %}><a href="{{ api_collections_index_url }}">My Api Collections</a></li>
|
||||
<li{% if api_collections_index_url in request.path %} class="active"{% endif %}><a href="{{ api_collections_index_url }}">My API Collections</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user