feature/ add update button in api-collection

This commit is contained in:
Reena-cell 2023-01-03 12:41:17 +01:00
parent d4222a29a2
commit 2f4e2dc48a
5 changed files with 37 additions and 15 deletions

View File

@ -5,7 +5,7 @@ $(document).ready(function($) {
let api_collection_name = $(runner).find('.api_collection_name').val();
let api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val();
let api_collection_description = $(runner).find('.api_collection_description').val();
$('.runner button.forUpdate').attr("disabled","disabled");
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('save/apicollection', {
@ -16,11 +16,31 @@ $(document).ready(function($) {
location.reload();
});
});
$('.runner button.forUpdate').click(function(e) {
e.preventDefault();
let runner = $(this).parent().parent().parent();
let api_collection_id = $(runner).find('.api_collection_id').attr("value");
let api_collection_name = $(runner).find('.api_collection_name').val();
let api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val();
let api_collection_description = $(runner).find('.api_collection_description').val();
$('.runner button.forUpdate').attr("disabled","disabled");
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('update/apicollection', {
'api_collection_id': api_collection_id,
'api_collection_name': api_collection_name,
'api_collection_is_sharable': api_collection_is_sharable,
'api_collection_description': api_collection_description,
}, function (response) {
location.reload();
});
});
$('.runner button.forDelete').click(function(e) {
e.preventDefault();
let runner = $(this).parent().parent().parent();
let api_collection_id = $(runner).find('.api_collection_id').html();
let api_collection_id = $(runner).find('.api_collection_id').attr("value");
$('.runner button.forUpdate').attr("disabled","disabled");
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('delete/apicollection', {

View File

@ -27,7 +27,7 @@
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
{% if api_collection.api_collection_id %}
<a class="api_collection_id btn btn-primary" onclick="api_explorer_url_locale('{{api_collection.collection_on_api_explorer_url}}')">Try It</a>
<a class="api_collection_id btn btn-primary" onclick="api_explorer_url_locale('{{api_collection.collection_on_api_explorer_url}}')" value="{{api_collection.api_collection_id}}">Try It</a>
{% endif %}
</div>
</div>
@ -35,7 +35,7 @@
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
<div>
<input class="api_collection_is_sharable form-control" value="{{ api_collection.api_collection_name }}">
<input class="api_collection_name form-control" value="{{ api_collection.api_collection_name }}">
</div>
</div>
</div>
@ -50,7 +50,7 @@
</div>
</div>
<div class="col-xs-6 col-sm-3">
<textarea cols="40" rows="1" class="form-control api_collection_method_body_update" style="margin: 5px -2px 5px 0px; height: 138px; width: 100%;">{{api_collection.description}}</textarea>
<textarea cols="40" rows="1" class="form-control api_collection_description" style="margin: 5px -2px 5px 0px; height: 138px; width: 100%;">{{api_collection.description}}</textarea>
</div>
{% else %}
<div class="col-xs-12 col-sm-2">
@ -83,11 +83,11 @@
<a type= "button" class="btn btn-primary" href="{{ url_collection_detail }}">{% trans "Edit" %}</a>
</div>
</div>
<!--<div class="col-sm-3 col-sm-1">
<div class="col-sm-3 col-sm-1">
<div class="form-group">
<button class="btn btn-primary forUpdate">{% trans "Update" %}</button>
</div>
</div>-->
</div>
<div class="col-sm-3 col-sm-1">
<div class="form-group">
<button class="btn btn-primary btn-red forDelete">{% trans "Delete" %}</button>

View File

@ -6,7 +6,7 @@ URLs for config app
from django.conf.urls import url
from apicollections.views import IndexView, apicollections_save, \
apicollections_delete, DetailView, DeleteCollectionEndpointView
apicollections_delete, DetailView, DeleteCollectionEndpointView, apicollections_update
urlpatterns = [
url(r'^$',
@ -14,6 +14,8 @@ urlpatterns = [
name='apicollections-index'),
url(r'save/apicollection', apicollections_save,
name='apicollection-save'),
url(r'update/apicollection', apicollections_update,
name='apicollection-update'),
url(r'delete/apicollection', apicollections_delete,
name='apicollection-delete'),
url(r'^my-api-collection-ids/(?P<api_collection_id>[\w\@\.\+-]+)$',

View File

@ -146,14 +146,14 @@ def apicollections_save(request):
@exception_handle
@csrf_exempt
def connectormethod_update(request):
def apicollections_update(request):
connector_method_id = request.POST.get('api_collection_id').strip()
urlpath = '/management/api-collection/{}'.format(connector_method_id) #TODO : Wainting for URL
urlpath = '/my/api-collections/{}'.format(connector_method_id)
api = API(request.session.get('obp'))
#Update Endpoint Payload define
payload = {
'api_collection_is_sharable': request.POST.get('api_collection_is_sharable'),
'method_body': request.POST.get('api_collection_method_body_update').strip()
'api_collection_name': request.POST.get('api_collection_name').strip(),
'is_sharable': True if request.POST.get('api_collection_is_sharable').strip().lower() == "true" else False,
'description': request.POST.get('api_collection_description').strip()
}
result = api.put(urlpath, payload=payload)
return result

View File

@ -257,7 +257,7 @@ API_EXPLORER = 'http://127.0.0.1:8082'
# Only override this if you have a separate portal instance
API_PORTAL = API_HOST
API_BASE_PATH = '/obp/v'
API_VERSION = '5.0.0'
API_VERSION = '5.1.0'
# URL to API Tester
API_TESTER_URL = 'https://www.example.com'
@ -308,7 +308,7 @@ CALLBACK_BASE_URL = ""
UNDEFINED = "<undefined>"
# Local settings can replace any value ABOVE
from apimanager.local_settings import BASE_DIR, EXCLUDE_APPS, EXCLUDE_FUNCTIONS, EXCLUDE_URL_PATTERN, API_EXPLORER_APP_NAME, API_DATEFORMAT, SECRET_KEY, API_HOST, OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET # noqa
from apimanager.local_settings import BASE_DIR, EXCLUDE_APPS, EXCLUDE_FUNCTIONS, EXCLUDE_URL_PATTERN, API_EXPLORER_APP_NAME, API_DATEFORMAT, SECRET_KEY, API_HOST, OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET
# EVERYTHING BELOW HERE WILL *NOT* BE OVERWRITTEN BY LOCALSETTINGS!
# DO NOT TRY TO DO SO YOU WILL BE IGNORED!