fixed the single quote for the parameters bug

This commit is contained in:
hongwei 2020-03-24 13:40:27 +01:00
parent fdd80d8783
commit 0c8fd12408
2 changed files with 26 additions and 57 deletions

View File

@ -1,64 +1,27 @@
$(document).ready(function($) {
const schema = {};
var json = [
{
key: 'url',
value: 'http://localhost:8080'
},
{
"key":"outBoundMapping",
"value":{
"cc":{
"cId":"outboundAdapterCallContext.correlationId"
},
"bankId":"bankId.value + 'helloworld'",
"originalJson":"$root"
}
},
{
"key":"inBoundMapping",
"value":{
"inboundAdapterCallContext$default":{
"correlationId":"correlation_id_value",
"sessionId":"session_id_value"
},
"status$default":{
"errorCode":"",
"backendMessages":[]
},
"data":{
"bankId":{
"value":"result.bank_id"
},
"shortName":"result.name",
"fullName":"'full: ' + result.name",
"logoUrl":"result.logo",
"websiteUrl":"result.website",
"bankRoutingScheme[0]":"result.routing.routing_scheme",
"bankRoutingAddress[0]":"result.routing.routing_address",
"swiftBic":"result.swift_bic",
"nationalIdentifier":"result.national"
}
}
}];
const options = {
mode: 'code',
modes: ['code', 'text', 'tree', 'preview']
};
var jsoneditorNumber = $('.jsoneditor_div').length
for (var step = 0; step < jsoneditorNumber; step++) {
var container = $("#"+"jsoneditor"+step);
new JSONEditor(container[0], options, json);
}
// // get json
// const updatedJson = editor.get()
//each method_routing will have each own json_editor, and will put data into it when click `parameter` box
//and will use the data from click `save` button.
var json_editors = []
$('.parameters').click(function() {
var row = $(this).parent().parent();
row.find('.jsoneditor_div').css("display","block");
var runner = $(this).parent().parent().parent();
var json_editor_id= $(runner).find('.jsoneditor_div')[0].id;
var json_editor_number = json_editor_id.replace("jsoneditor","");
var container = $("#"+json_editor_id);
parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text());
var jsoneditor_div = $(runner).find('.jsoneditor_div');
//make sure only create one jsoneditor_div block
if(!(jsoneditor_div.css("display") ==="block")){
json_editors[json_editor_number] = new JSONEditor(container[0], options, parameters);
jsoneditor_div.css("display","block");
}else{
json_editors[json_editor_number] = json_editors[json_editor_number].set(parameters)
}
});
$('.runner button.forSave').click(function() {
@ -70,7 +33,10 @@ $(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();
parameters_Json_editor = JSON.stringify(editor.get());
var jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id
var json_editor_number = jsoneditor_id.replace("jsoneditor","")
parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get());
console.log("parameters_Json_editor:"+parameters_Json_editor)
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('methodrouting/save/method', {
@ -79,7 +45,7 @@ $(document).ready(function($) {
'connector_name': connector_name,
'bank_id_pattern': bank_id_pattern,
'is_bank_id_exact_match': is_bank_id_exact_match,
'parameters': parameters,
'parameters': parameters_Json_editor,
'parameters_Json_editor': parameters_Json_editor,
}, function (response) {
location.reload();

View File

@ -27,7 +27,7 @@ class IndexView(LoginRequiredMixin, FormView):
context = super(IndexView, self).get_context_data(**kwargs)
api = API(self.request.session.get('obp'))
urlpath = '/management/method_routings?active=true'
method_routings =''
method_routings =[]
try:
response = api.get(urlpath)
if 'code' in response and response['code'] >= 400:
@ -41,9 +41,12 @@ class IndexView(LoginRequiredMixin, FormView):
except BaseException as err:
error_once_only(self.request, (Exception("Unknown Error. Details:" + str(err))))
else:
for i in range(len(method_routings)):
method_routings[i]['parameters'] = json.dumps(method_routings[i]['parameters'])
context.update({
'method_routings': method_routings,
'methodSwaggerUrl': '{}/message-docs/rest_vMar2019/swagger2.0?functions'.format(settings.API_ROOT )
"methodSwaggerUrl": json.dumps('{}/message-docs/rest_vMar2019/swagger2.0?functions'.format(settings.API_ROOT ))
})
return context