mirror of https://github.com/jumpserver/jumpserver
[Update] 创建/更新 远程应用 使用api (#2940)
* [Update] 创建/更新 远程应用 使用api * [Update] 优化 params * [Update] 修改小问题pull/2945/head
parent
ab9744d529
commit
9219786f2d
|
@ -107,6 +107,18 @@ function hiddenFields(){
|
||||||
});
|
});
|
||||||
$('.' + app_type + '-fields').removeClass('hidden');
|
$('.' + app_type + '-fields').removeClass('hidden');
|
||||||
}
|
}
|
||||||
|
function constructParams(obj) {
|
||||||
|
var type = ['chrome', 'mysql_workbench', 'vmware_client', 'custom'];
|
||||||
|
var params = {};
|
||||||
|
type.forEach(function (attr) {
|
||||||
|
if (obj.type === attr){
|
||||||
|
for (var k in obj){
|
||||||
|
if (k.startsWith(obj.type)){params[k] = obj[k]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return params
|
||||||
|
}
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('.select2').select2({
|
$('.select2').select2({
|
||||||
closeOnSelect: true
|
closeOnSelect: true
|
||||||
|
@ -118,6 +130,28 @@ $(document).ready(function () {
|
||||||
.on('change', app_type_id, function(){
|
.on('change', app_type_id, function(){
|
||||||
hiddenFields();
|
hiddenFields();
|
||||||
setDefaultValue();
|
setDefaultValue();
|
||||||
});
|
})
|
||||||
|
.on("submit", "form", function (evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
var the_url = '{% url "api-applications:remote-app-list" %}';
|
||||||
|
var redirect_to = '{% url "applications:remote-app-list" %}';
|
||||||
|
var method = "POST";
|
||||||
|
{% if type == "update" %}
|
||||||
|
the_url = '{% url "api-applications:remote-app-detail" object.id %}';
|
||||||
|
method = "PUT";
|
||||||
|
{% endif %}
|
||||||
|
var form = $("form");
|
||||||
|
var data = form.serializeObject();
|
||||||
|
data["params"] = constructParams(data);
|
||||||
|
var props = {
|
||||||
|
url: the_url,
|
||||||
|
data: data,
|
||||||
|
method: method,
|
||||||
|
form: form,
|
||||||
|
redirect_to: redirect_to
|
||||||
|
};
|
||||||
|
formSubmit(props);
|
||||||
|
})
|
||||||
|
;
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -46,6 +46,7 @@ class RemoteAppCreateView(PermissionsMixin, SuccessMessageMixin, CreateView):
|
||||||
context = {
|
context = {
|
||||||
'app': _('Applications'),
|
'app': _('Applications'),
|
||||||
'action': _('Create RemoteApp'),
|
'action': _('Create RemoteApp'),
|
||||||
|
'type': 'create'
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
@ -68,6 +69,7 @@ class RemoteAppUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView):
|
||||||
context = {
|
context = {
|
||||||
'app': _('Applications'),
|
'app': _('Applications'),
|
||||||
'action': _('Update RemoteApp'),
|
'action': _('Update RemoteApp'),
|
||||||
|
'type': 'update'
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
Loading…
Reference in New Issue