mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 13:06:45 +00:00
added the delete button
This commit is contained in:
parent
322e6751c4
commit
9f24623563
@ -1,14 +1,16 @@
|
||||
$(document).ready(function($) {
|
||||
$('.runner button#forSave').click(function() {
|
||||
$('.runner button.forSave').click(function() {
|
||||
var t = $(this);
|
||||
var runner = $(this).parent().parent().parent();
|
||||
method_name = $(runner).find('#method_name').html();
|
||||
connector_name = $(runner).find('#connector_name').val();
|
||||
method_routing_id = $(runner).find('.method_routing_id').val();
|
||||
method_name = $(runner).find('.method_name').text();
|
||||
connector_name = $(runner).find('.connector_name').val();
|
||||
bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val();
|
||||
is_bank_id_exact_match = $(runner).find('#is_bank_id_exact_match').val();
|
||||
is_bank_id_exact_match = $(runner).find('.is_bank_id_exact_match').val();
|
||||
parameters = $(runner).find('textarea[name="parameters"]').val();
|
||||
|
||||
$.post('methodrouting/save/method', {
|
||||
'method_routing_id': method_routing_id,
|
||||
'method_name': method_name,
|
||||
'connector_name': connector_name,
|
||||
'bank_id_pattern': bank_id_pattern,
|
||||
@ -18,4 +20,15 @@ $(document).ready(function($) {
|
||||
t.next().show().fadeOut(1000);
|
||||
});
|
||||
});
|
||||
|
||||
$('.runner button.forDelete').click(function() {
|
||||
var t = $(this);
|
||||
var runner = $(this).parent().parent().parent();
|
||||
method_routing_id = $(runner).find('.method_routing_id').val();
|
||||
$.post('methodrouting/delete/method', {
|
||||
'method_routing_id': method_routing_id
|
||||
}, function (response) {
|
||||
t.next().show().fadeOut(1000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -29,15 +29,18 @@
|
||||
<label class="form-group">Parameters:</label> <br>
|
||||
</div>
|
||||
</div>
|
||||
{% for method_routing in method_routings %}
|
||||
<div class="row">
|
||||
<div class="runner">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{% for method_routing in method_routings %}
|
||||
<div class="runner">
|
||||
<div class="row">
|
||||
<input type="hidden", class="method_routing_id", value="{{ method_routing.method_routing_id }}">
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<div class="form-group" cols="1" rows="1" >
|
||||
<strong id="method_name">{{ method_routing.method_name }}</strong></div>
|
||||
<div class="form-group" cols="1" rows="1"><strong
|
||||
class="method_name">{{ method_routing.method_name }}</strong></div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<select id="connector_name">
|
||||
<select class="connector_name form-control " }>
|
||||
<option value="LocalMapped">LocalMapped</option>
|
||||
<option value="kafka_vSept2018">kafka_vSept2018</option>
|
||||
<option value="akka_vDec2018">akka_vDec2018</option>
|
||||
@ -45,28 +48,27 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<textarea class="form-group"
|
||||
rows="1"
|
||||
name="bank_id_pattern">{{ method_routing.bank_id_pattern }}</textarea>
|
||||
<textarea class="form-control" rows="1"
|
||||
name="bank_id_pattern">{{ method_routing.bank_id_pattern }}</textarea>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2" align="center">
|
||||
<select id="is_bank_id_exact_match" >
|
||||
<select class="is_bank_id_exact_match form-control">
|
||||
<option value="False">False</option>
|
||||
<option value="True">True</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-2">
|
||||
<textarea cols="40"
|
||||
rows="1"
|
||||
class="form-control"
|
||||
name="parameters">{{ method_routing.parameters }}</textarea>
|
||||
<textarea cols="40" rows="1" class="form-control"
|
||||
name="parameters">{{ method_routing.parameters }}</textarea>
|
||||
</div>
|
||||
<div class="col-sm-12 col-sm-2">
|
||||
<div class="form-group">
|
||||
<button id="forSave" class="btn btn-primary btn-green">Save</button>
|
||||
<button class="btn btn-primary btn-green forSave">Save</button>
|
||||
<button class="btn btn-primary btn-green forDelete">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
@ -5,7 +5,7 @@ URLs for config app
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from .views import IndexView, methodrouting_save
|
||||
from .views import IndexView, methodrouting_save, methodrouting_delete
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$',
|
||||
@ -13,4 +13,6 @@ urlpatterns = [
|
||||
name='methodrouting-index'),
|
||||
url(r'save/method', methodrouting_save,
|
||||
name='methodrouting-save'),
|
||||
url(r'delete/method', methodrouting_delete,
|
||||
name='methodrouting-delete'),
|
||||
]
|
||||
|
||||
@ -55,20 +55,46 @@ def methodrouting_save(request):
|
||||
bank_id_pattern = request.POST.get('bank_id_pattern')
|
||||
is_bank_id_exact_match = request.POST.get('is_bank_id_exact_match')
|
||||
parameters = request.POST.get('parameters')
|
||||
method_routing_id = request.POST.get('method_routing_id')
|
||||
|
||||
payload = {
|
||||
'method_name' : method_name,
|
||||
'connector_name': connector_name,
|
||||
'is_bank_id_exact_match': bool(is_bank_id_exact_match),
|
||||
'bank_id_pattern':bank_id_pattern,
|
||||
'parameters':eval(parameters)
|
||||
'parameters':eval(parameters),
|
||||
'method_routing_id':method_routing_id
|
||||
}
|
||||
|
||||
api = API(request.session.get('obp'))
|
||||
try:
|
||||
if(""==method_routing_id): # if method_routing_id=="". we will create a new method routing .
|
||||
urlpath = '/management/method_routings'
|
||||
result = api.post(urlpath, payload=payload)
|
||||
else: # if method_routing_id not empty. we will update the current method routing ..
|
||||
urlpath = '/management/method_routings/{}'.format(method_routing_id)
|
||||
result = api.put(urlpath, payload=payload)
|
||||
except APIError as err:
|
||||
error_once_only(request, APIError(Exception("OBP-API server is not running or do not response properly. "
|
||||
"Please check OBP-API server. Details: " + str(err))))
|
||||
except Exception as err:
|
||||
error_once_only(request, "Unknown Error. Details: " + str(err))
|
||||
if 'code' in result and result['code'] >= 400:
|
||||
error_once_only(request, result['message'])
|
||||
msg = 'Submission successfully!'
|
||||
messages.success(request, msg)
|
||||
return JsonResponse({'state': True})
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def methodrouting_delete(request):
|
||||
method_routing_id = request.POST.get('method_routing_id')
|
||||
|
||||
api = API(request.session.get('obp'))
|
||||
|
||||
try:
|
||||
urlpath = '/management/method_routings'
|
||||
result = api.post(urlpath, payload=payload)
|
||||
urlpath = '/management/method_routings/{}'.format(method_routing_id)
|
||||
result = api.delete(urlpath)
|
||||
except APIError as err:
|
||||
error_once_only(request, APIError(Exception("OBP-API server is not running or do not response properly. "
|
||||
"Please check OBP-API server. Details: " + str(err))))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user