fix webui save function

This commit is contained in:
PengfeiLi0218 2019-08-14 21:29:29 +08:00
parent 7c1c686ad3
commit c053fa3c35
8 changed files with 86 additions and 33 deletions

View File

@ -22,4 +22,26 @@ $(document).ready(function($) {
}
$('#config-json').html((syntaxHighlight(ConfigJson)));
$('.runner button.forSave').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
select1 = $(runner).find('#select1').val();
select2 = $(runner).find('#select2').val();
method = $(runner).find('#method_name').innerHTML;
bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val();
parameters = $(runner).find('textarea[name="parameters"]').val();
$.post('/methodrouting/save/method', {
'method': method,
'value': value,
'select1': select1,
'select2': select2,
'bank_id_pattern': bank_id_pattern,
'parameters': parameters,
'csrfmiddlewaretoken': window.CSRF
}, function (response) {
t.next().show().fadeOut(1000);
});
});
});

View File

@ -28,36 +28,38 @@
<form method="post">
{% csrf_token %}
{% for method_routhing in method_routhings %}
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1"><strong>{{ method_routhing.method_name }}</strong></div>
</div>
<div class="col-xs-12 col-sm-2" >
<select>
<option value="LocalMapped">LocalMapped</option>
<option value="kafka_vSept2018">kafka_vSept2018</option>
<option value="akka_vDec2018">akka_vDec2018</option>
<option value="rest_vMar2019">rest_vMar2019</option>
</select>
</div>
<div class="col-xs-12 col-sm-2">
<textarea class="form-group" rows="1" >{{ method_routhing.bank_id_pattern }}</textarea>
</div>
<div class="col-xs-12 col-sm-2">
<select>
<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">{{ method_routhing.parameters }}</textarea>
</div>
<div class="col-sm-12 col-sm-2">
<div class="form-group">
<button type="submit" class="btn btn-primary btn-green">Save</button>
<li class="runner">
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1" id="method_name"><strong>{{ method_routhing.method_name }}</strong></div>
</div>
<div class="col-xs-12 col-sm-2" >
<select id="select1">
<option value="LocalMapped">LocalMapped</option>
<option value="kafka_vSept2018">kafka_vSept2018</option>
<option value="akka_vDec2018">akka_vDec2018</option>
<option value="rest_vMar2019">rest_vMar2019</option>
</select>
</div>
<div class="col-xs-12 col-sm-2">
<textarea class="form-group" rows="1" name="bank_id_pattern">{{ method_routhing.bank_id_pattern }}</textarea>
</div>
<div class="col-xs-12 col-sm-2">
<select id="select2">
<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_routhing.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>
</div>
</div>
</div>
</div>
</li>
{% endfor %}
</form>
</div>

View File

@ -5,10 +5,12 @@ URLs for config app
from django.conf.urls import url
from .views import IndexView
from .views import IndexView, methodrouting_save
urlpatterns = [
url(r'^$',
IndexView.as_view(),
name='methodrouting-index'),
url(r'save/method', methodrouting_save,
name='methodrouting-save'),
]

View File

@ -5,6 +5,7 @@ Views of config app
import json
from django.http import JsonResponse
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import FormView
@ -246,4 +247,7 @@ class IndexView(LoginRequiredMixin, FormView):
return super(IndexView, self).form_valid(form)
msg = 'Submission successfully!'
messages.success(self.request, msg)
return super(IndexView, self).form_valid(form)
return super(IndexView, self).form_valid(form)
def methodrouting_save(request):
return JsonResponse({'state': True})

View File

@ -22,4 +22,19 @@ $(document).ready(function($) {
}
$('#config-json').html((syntaxHighlight(ConfigJson)));
$('.runner button.forSave').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
method = $(runner).find('#id_webui_props_key').innerHTML;
value = $(runner).find('textarea[name="webui_props_value"]').val();
$.post('/webui/save/method', {
'method': method,
'value': value,
'csrfmiddlewaretoken': window.CSRF
}, function (response) {
t.next().show().fadeOut(1000);
});
});
});

View File

@ -30,6 +30,7 @@
</div>
{% for webui_prop in webui_props %}
<li class="runner">
<div class="row">
<div class="col-xs-12 col-sm-4">
<div class="form-group" name="webui_props_value" cols="20" rows="1" id="id_webui_props_key"><strong>{{ webui_prop.name }}</strong></div>
@ -41,10 +42,11 @@
</div>
<div class="col-sm-12 col-sm-4">
<div class="form-group">
<button type="submit" class="btn btn-primary btn-green">Save</button>
<button class="btn btn-primary btn-green" id="forSave">Save</button>
</div>
</div>
</div>
</li>
{% endfor %}
</form>

View File

@ -5,10 +5,12 @@ URLs for config app
from django.conf.urls import url
from .views import IndexView
from .views import IndexView, webui_save
urlpatterns = [
url(r'^$',
IndexView.as_view(),
name='webui-index'),
url(r'save/method', webui_save,
name='methodrouting-save'),
]

View File

@ -9,6 +9,7 @@ from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import FormView
from obp.api import API, APIError
from django.http import JsonResponse
from .forms import WebuiForm
from django.urls import reverse_lazy
@ -78,4 +79,7 @@ class IndexView(LoginRequiredMixin, FormView):
return super(IndexView, self).form_valid(form)
msg = 'Submission successfully!'
messages.success(self.request, msg)
return super(IndexView, self).form_valid(form)
return super(IndexView, self).form_valid(form)
def webui_save(request):
return JsonResponse({'state': True})