Merge pull request #119 from hongwei1/master

feature/fixed the cache issue and added the example value for the method_routings parameters
This commit is contained in:
Simon Redfern 2021-01-20 15:55:08 +01:00 committed by GitHub
commit fb07c28e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 16 deletions

View File

@ -62,7 +62,7 @@ INSTALLED_APPS = [
]
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddleware',
# 'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@ -70,11 +70,11 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
]
#cache the view page, we set 60s = 1m,
CACHE_MIDDLEWARE_SECONDS = 60
# CACHE_MIDDLEWARE_SECONDS = 60
# TIMEOUT is 31104000 seconds = 60*60*24*30*12 (1 year)
# MAX_ENTRIES is 1000000 entities

View File

@ -19,7 +19,6 @@
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
{# <a href="" class="dynamic_endpoint_id">{{ dynamic_endpoint.dynamic_endpoint_id }}</a></div>#}
<div class="dynamic_endpoint_id">{{ dynamic_endpoint.dynamic_endpoint_id }}</div></div>
</div>

View File

@ -15,12 +15,17 @@ $(document).ready(function($) {
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")){
//make sure only create one jsoneditor_div block, click once to open and then close the block.
if (typeof json_editors[json_editor_number] === 'undefined') {
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)
// json_editors[json_editor_number] = json_editors[json_editor_number].set(parameters)
if(jsoneditor_div.css("display") ==="block"){
jsoneditor_div.css("display","none");
}else{
jsoneditor_div.css("display","block");
}
}
});

View File

@ -31,8 +31,8 @@
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
{# <a href="{{ methodSwaggerUrl }}={{ method_routing.method_name }}" class="method_name">{{ method_routing.method_name }}</a></div>#}
<div class="method_name">{{ method_routing.method_name }}</div></div>
<div class="method_name"><a href="{{methodSwaggerUrl}}obp.{{method_routing.method_name}}">{{method_routing.method_name}}</a></div>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<select class="connector_name form-control " }>
@ -97,7 +97,7 @@
</select>
</div>
<div class="col-xs-12 col-sm-2">
<textarea cols="40" rows="1" class="form-control parameters"
<textarea readonly cols="40" rows="1" class="form-control parameters"
name="parameters">{{ method_routing.parameters }}</textarea>
</div>
<div class="col-xs-12 col-sm-2">
@ -105,10 +105,16 @@
class="method_routing_id">{{ method_routing.method_routing_id }}</div></div>
</div>
<div class="col-sm-12 col-sm-2">
<div class="form-group">
<button class="btn btn-primary btn-green forSave">Save</button><span style="display: none;margin-left: 5px;background-color:#00cc00">saved.</span>
<button class="btn btn-primary btn-red forDelete">Delete</button>
</div>
{% if method_routing.method_routing_id == "" %}
<div class="form-group">
<button class="btn btn-primary btn-green forSave">Create New </button>
</div>
{% else %}
<div class="form-group">
<button class="btn btn-primary btn-bule forSave">Update</button>
<button class="btn btn-primary btn-red forDelete">Delete</button>
</div>
{% endif %}
</div>
<div class="col-sm-12 col-sm-12">
<div id="jsoneditor{{forloop.counter0}}" style="display: none" class ="jsoneditor_div"></div>

View File

@ -43,11 +43,23 @@ class IndexView(LoginRequiredMixin, FormView):
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'], sort_keys=False)
#if the parameters are empty, we provide the example value.
if(str(method_routings[i]['parameters']).find("key") == -1):
method_routings[i]['parameters'] = json.dumps([{
"key":"url",
"value":"http://mydomain.com/xxx"
}], sort_keys=False)
else:
method_routings[i]['parameters'] = json.dumps(method_routings[i]['parameters'], sort_keys=False)
if(str(settings.API_ROOT).find("127.0.0.1") == -1):
methodSwaggerUrl = '{}/message-docs?connector=stored_procedure_vDec2019#'.format(settings.API_HOST.replace(".openbankproject.", "-explorer.openbankproject."))
else:
methodSwaggerUrl = "http://127.0.0.1:8082/message-docs?connector=stored_procedure_vDec2019#"
context.update({
'method_routings': method_routings,
"methodSwaggerUrl": json.dumps('{}/message-docs/rest_vMar2019/swagger2.0?functions'.format(settings.API_ROOT ))
"methodSwaggerUrl": methodSwaggerUrl
})
return context