Skip to content

Commit

Permalink
modify ui a bit and avoid duplicated message
Browse files Browse the repository at this point in the history
  • Loading branch information
rizalfr committed Jun 6, 2018
1 parent 5c5291e commit 0049c7b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
33 changes: 25 additions & 8 deletions locust/static/locust.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,41 @@ $("#directories .select2").select2({
placeholder: "Select a state"
});

var whichform = $('.upload_file_form')[0];

$('#upload_py_submit').click(function(event){
event.preventDefault();
whichform = $('.upload_file_form')[0];
$('.upload_file_form').submit();
$('.upload_file_form_test_file').submit();
});

$('#upload_json_submit').click(function(event){
event.preventDefault();
whichform = $('.upload_file_form')[1];
$('.upload_file_form').submit();
$('.upload_file_form_json').submit();
});

$('.upload_file_form').submit(function(event) {
$('.upload_file_form_test_file').submit(function(event) {
event.preventDefault();
var form = whichform;
var form_data = new FormData(form);
var form_data = new FormData($('.upload_file_form_test_file')[0]);
$.ajax({
type: 'POST',
url: "/upload_file",
enctype: "multipart/form-data",
contentType: false,
data: form_data,
cache: false,
processData: false,
success: function (response) {
if (response.success) {
location.reload(true);
} else {
alert(response.message);
}
}
})
});

$('.upload_file_form_json').submit(function(event) {
event.preventDefault();
var form_data = new FormData($('.upload_file_form_json')[0]);
$.ajax({
type: 'POST',
url: "/upload_file",
Expand Down
2 changes: 1 addition & 1 deletion locust/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ ul.tabs li a.current:after {
#add-new-file-modal .modal-title, #new-test-confirmation .modal-title, #upload-json-modal .modal-title {
color:#addf82;
}
.upload_file_form, #new-test-confirmation {
.upload_file_form_test_file, .upload_file_form_json, #new-test-confirmation {
color: white;
}
.about {
Expand Down
9 changes: 5 additions & 4 deletions locust/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h4 class="modal-title">Are you sure?</h4>
<h4 class="modal-title">Upload Test File</h4>
</div>
<div class="modal-body">
<form method="POST" class="upload_file_form" enctype="multipart/form-data" action="/upload_file">
<form method="POST" class="upload_file_form_test_file" enctype="multipart/form-data" action="/upload_file">
<label>Path :</label>
<select name="upload_directory" id="directories" class="select2">
{% for value in test_file_directories %}
Expand Down Expand Up @@ -230,7 +230,7 @@ <h2>Ramping</h2>
<div class="edit_config" id="edit_config" style="display:none;">
<div class="head_section">
<div class="container">
<div class="title_header">Configuration</div>
<div class="title_header">Main Configuration</div>
<ul id="link_navigation">
<li><a href="#" class="config_new_test">New Test</a></li>
{% if ramp %}
Expand Down Expand Up @@ -274,7 +274,8 @@ <h5 class="modal-title" id="myModalLabel">Unsaved Configuration</h5>
</div>
</div>
<div class="custom_padder container body_section">
<label>Upload JSON</label>
<div class="title_header">Team Configuration</div>
<br/>
<button type="button" data-toggle="modal" data-target="#upload-json-modal" >Upload JSON</button>
</div>
</div>
Expand All @@ -289,7 +290,7 @@ <h5 class="modal-title" id="myModalLabel">Unsaved Configuration</h5>
<h4 class="modal-title">Upload JSON</h4>
</div>
<div class="modal-body">
<form method="POST" class="upload_file_form" enctype="multipart/form-data" action="/upload_file">
<form method="POST" class="upload_file_form_json" enctype="multipart/form-data" action="/upload_file">
<label>Path :</label>
<select name="upload_directory" id="directories" class="select2">
{% for value in all_test_file_directories %}
Expand Down

0 comments on commit 0049c7b

Please sign in to comment.