From e5cc78d32aeffa98f6c17deb57e30d54facf134f Mon Sep 17 00:00:00 2001 From: yuanxiaojun <461149543@qq.com> Date: Tue, 26 Nov 2019 15:25:53 +0800 Subject: [PATCH 01/10] bugfix/methodrouting: fix messages display error --- .../static/methodrouting/js/methodrouting.js | 11 ++++++++--- apimanager/methodrouting/views.py | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apimanager/methodrouting/static/methodrouting/js/methodrouting.js b/apimanager/methodrouting/static/methodrouting/js/methodrouting.js index 83d5ff7..05a1970 100644 --- a/apimanager/methodrouting/static/methodrouting/js/methodrouting.js +++ b/apimanager/methodrouting/static/methodrouting/js/methodrouting.js @@ -8,7 +8,8 @@ $(document).ready(function($) { bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val(); is_bank_id_exact_match = $(runner).find('.is_bank_id_exact_match').val(); parameters = $(runner).find('textarea[name="parameters"]').val(); - + $('.runner button.forSave').attr("disabled","disabled"); + $('.runner button.forDelete').attr("disabled","disabled"); $.post('methodrouting/save/method', { 'method_routing_id': method_routing_id, 'method_name': method_name, @@ -17,18 +18,22 @@ $(document).ready(function($) { 'is_bank_id_exact_match': is_bank_id_exact_match, 'parameters': parameters }, function (response) { - t.next().show().fadeOut(1000); + location.reload(); }); + return false; }); $('.runner button.forDelete').click(function() { var t = $(this); var runner = $(this).parent().parent().parent(); method_routing_id = $(runner).find('.method_routing_id').text(); + $('.runner button.forSave').attr("disabled","disabled"); + $('.runner button.forDelete').attr("disabled","disabled"); $.post('methodrouting/delete/method', { 'method_routing_id': method_routing_id }, function (response) { - t.parent().parent().parent().remove(); + location.reload(); }); + return false; }); }); diff --git a/apimanager/methodrouting/views.py b/apimanager/methodrouting/views.py index 5783000..c27cfa4 100644 --- a/apimanager/methodrouting/views.py +++ b/apimanager/methodrouting/views.py @@ -33,8 +33,6 @@ class IndexView(LoginRequiredMixin, FormView): if 'code' in response and response['code'] >= 400: error_once_only(self.request, response['message']) else: - msg = 'Submit successfully!' - messages.success(self.request, msg) method_routings=response['method_routings'] except APIError as err: error_once_only(self.request, Exception("OBP-API server is not running or do not response properly. " @@ -75,7 +73,6 @@ def methodrouting_save(request): 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) - return result From d39239d11cf209998f0719b21414ff9b9c1cbc01 Mon Sep 17 00:00:00 2001 From: hongwei Date: Tue, 26 Nov 2019 20:12:42 +0100 Subject: [PATCH 02/10] fix messages display error --- .../static/methodrouting/js/methodrouting.js | 11 ++++++++--- apimanager/methodrouting/views.py | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apimanager/methodrouting/static/methodrouting/js/methodrouting.js b/apimanager/methodrouting/static/methodrouting/js/methodrouting.js index 83d5ff7..05a1970 100644 --- a/apimanager/methodrouting/static/methodrouting/js/methodrouting.js +++ b/apimanager/methodrouting/static/methodrouting/js/methodrouting.js @@ -8,7 +8,8 @@ $(document).ready(function($) { bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val(); is_bank_id_exact_match = $(runner).find('.is_bank_id_exact_match').val(); parameters = $(runner).find('textarea[name="parameters"]').val(); - + $('.runner button.forSave').attr("disabled","disabled"); + $('.runner button.forDelete').attr("disabled","disabled"); $.post('methodrouting/save/method', { 'method_routing_id': method_routing_id, 'method_name': method_name, @@ -17,18 +18,22 @@ $(document).ready(function($) { 'is_bank_id_exact_match': is_bank_id_exact_match, 'parameters': parameters }, function (response) { - t.next().show().fadeOut(1000); + location.reload(); }); + return false; }); $('.runner button.forDelete').click(function() { var t = $(this); var runner = $(this).parent().parent().parent(); method_routing_id = $(runner).find('.method_routing_id').text(); + $('.runner button.forSave').attr("disabled","disabled"); + $('.runner button.forDelete').attr("disabled","disabled"); $.post('methodrouting/delete/method', { 'method_routing_id': method_routing_id }, function (response) { - t.parent().parent().parent().remove(); + location.reload(); }); + return false; }); }); diff --git a/apimanager/methodrouting/views.py b/apimanager/methodrouting/views.py index 5783000..c27cfa4 100644 --- a/apimanager/methodrouting/views.py +++ b/apimanager/methodrouting/views.py @@ -33,8 +33,6 @@ class IndexView(LoginRequiredMixin, FormView): if 'code' in response and response['code'] >= 400: error_once_only(self.request, response['message']) else: - msg = 'Submit successfully!' - messages.success(self.request, msg) method_routings=response['method_routings'] except APIError as err: error_once_only(self.request, Exception("OBP-API server is not running or do not response properly. " @@ -75,7 +73,6 @@ def methodrouting_save(request): 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) - return result From 534fd0ebe806a3f47655d212558ac356eb44ec19 Mon Sep 17 00:00:00 2001 From: yuanxiaojun <461149543@qq.com> Date: Thu, 28 Nov 2019 09:17:11 +0800 Subject: [PATCH 03/10] bugfix/webui: fix messages display error --- apimanager/obp/api.py | 2 +- apimanager/utils/ErrorHandler.py | 3 +- apimanager/webui/static/webui/js/webui.js | 31 ++++++--- apimanager/webui/templates/webui/index.html | 20 ++++-- apimanager/webui/views.py | 75 ++++----------------- 5 files changed, 53 insertions(+), 78 deletions(-) diff --git a/apimanager/obp/api.py b/apimanager/obp/api.py index 2906a83..feaa18d 100644 --- a/apimanager/obp/api.py +++ b/apimanager/obp/api.py @@ -136,7 +136,7 @@ class API(object): return response.text else: data = response.json() - if 'error' in data: + if isinstance(data,dict) and 'error' in data: self.handle_response_error(prefix, data['error']) return data diff --git a/apimanager/utils/ErrorHandler.py b/apimanager/utils/ErrorHandler.py index e40c5cb..c4d6d00 100644 --- a/apimanager/utils/ErrorHandler.py +++ b/apimanager/utils/ErrorHandler.py @@ -2,6 +2,7 @@ from django.contrib import messages import functools from obp.api import API, APIError from django.http import JsonResponse +import traceback def error_once_only(request, err): """ @@ -19,7 +20,7 @@ def exception_handle(fn): def wrapper(request, *args, **kwargs): try: result = fn(request, *args, **kwargs) - if 'code' in result and result['code'] >= 400: + if isinstance(result,dict) and 'code' in result and result['code'] >= 400: error_once_only(request, result['message']) else: msg = 'Submit successfully!' diff --git a/apimanager/webui/static/webui/js/webui.js b/apimanager/webui/static/webui/js/webui.js index d9e56d1..b3e1f25 100644 --- a/apimanager/webui/static/webui/js/webui.js +++ b/apimanager/webui/static/webui/js/webui.js @@ -5,9 +5,7 @@ $(document).ready(function($) { var runner = t.parent().parent().parent(); var web_ui_props_name = $(runner).find('.web_ui_props_name').text(); var web_ui_props_value = $(runner).find('.web_ui_props_value').val(); - $('.dynamic-message').each(function(i, d_msg){ - $(d_msg).remove(); - }); + var webui = $('#webui'); if(web_ui_props_value.trim() === '') { $('