테스터 save 구현 완료

This commit is contained in:
현성필
2023-05-16 19:03:37 +09:00
parent 2d4fa5370b
commit 47107b8fd4
2 changed files with 40 additions and 9 deletions
@@ -32,6 +32,6 @@ public class ApiRequestKeyValueDTO {
}
public String toString() {
return (enabled?"//":"")+ key + "=" + value;
return (enabled?"":"//")+ key + "=" + value;
}
}
@@ -439,13 +439,13 @@
target.find('.request_headers').on('click', 'button', function () {
if ($(this).hasClass('btn_remove')) {
controller.removeHeader(idx, $(this).attr("data-id"));
controller.removeHeader(idx, $(this).data("id"));
}
});
target.find('.query_params').on('click', 'button', function () {
if ($(this).hasClass('btn_remove')) {
controller.removeQueryParam(idx, $(this).attr("data-id"));
controller.removeQueryParam(idx, $(this).data("id"));
}
});
@@ -465,11 +465,17 @@
target.find('.send').click(function () {
controller.send(idx);
});
target.find('.save').attr('data-collection', ); //TODO
target.find('.save').click(function(){
controller.saveAPIRequest(idx);
});
let me = this;
require(['vs/editor/editor.main'], function () {
let requestBodyEditor = monaco.editor.create(target.find(".request_body")[0], {
value: '',
value: model.requestBody,
language: 'json',
theme: 'vs-light',
automaticLayout: true
@@ -556,7 +562,7 @@
template.find('button.new_collection').attr('data-bs-target', '#btn_collection_' + i);
template.find('button.delete_collection').attr('data-id', collections[i].id);
template.find('button.delete_collection').on('click', function () {
$('#confirm_delete_modal').find('.confirm_delete').attr('data-id', $(this).attr('data-id'));
$('#confirm_delete_modal').find('.confirm_delete').attr('data-id', $(this).data('id'));
$('#confirm_delete_modal').modal('show');
});
@@ -570,14 +576,13 @@
link.attr('data-collection', collections[i].id);
link.attr('data-id', collections[i].apis[j].id);
link.on('click', function () {
controller.openApiRequest($(this).attr('data-collection'), $(this).attr('data-id'));
controller.openApiRequest($(this).attr('data-collection'), $(this).data('id'));
})
btn.attr('data-collection', collections[i].id);
btn.attr('data-id', collections[i].apis[j].id);
btn.on('click', function () {
//controller.deleteApiRequest($(this).attr('data-collection'), $(this).attr('data-id'));
$('#confirm_delete_api_modal').find('.confirm_delete_api').attr('data-id', $(this).attr('data-id'));
$('#confirm_delete_api_modal').find('.confirm_delete_api').attr('data-collection', $(this).attr('data-collection'));
$('#confirm_delete_api_modal').find('.confirm_delete_api').attr('data-id', $(this).data('id'));
$('#confirm_delete_api_modal').find('.confirm_delete_api').attr('data-collection', $(this).data('collection'));
$('#confirm_delete_api_modal').modal('show');
})
template.find('.collapse ul').append(collectionApiTemplate);
@@ -691,6 +696,13 @@
contentType: 'application/json',
success: function (data) {
collections = data;
for (let i = 0; i < collections.length; i++) {
if(collections[i].apis !== undefined){
for (let j = 0; j< collections[i].apis.length; j++) {
collections[i].apis[j].collectionId = collections[i].id;
}
}
}
},
error: function (response, textStatus, errorThrown) {
controller.hideLoadingOverlay();
@@ -742,6 +754,25 @@
}
});
},
saveAPIRequest: function(idx){
let model = apiRequests[idx];
console.log(model);
this.currentAjaxRequest = $.ajax({
url: '/mgmt/collections/{id}/apis/save.do'.replace('{id}', model.collectionId),
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(model),
success: function (data) {
},
error: function (response, textStatus, errorThrown) {
controller.hideLoadingOverlay();
},
complete: function () {
controller.hideLoadingOverlay();
}
});
},
addAPIRequest: function (collectionId) {
let name = 'New Request';