이름 변경 구현 완료
This commit is contained in:
+1
-1
@@ -42,7 +42,7 @@ public class ApiRequestMgmtController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/mgmt/collections/update.do")
|
@PostMapping("/mgmt/collections/update.do")
|
||||||
public ResponseEntity<String> updateApiCollection(@RequestBody ApiCollectionDTO dto) {
|
public ResponseEntity<String> updateApiCollection(@RequestBody ApiCollectionDTO dto) {
|
||||||
ApiCollection updated = apiRequestMapper.map(dto);
|
ApiCollection updated = apiRequestMapper.map(dto);
|
||||||
apiRequestMgmtService.updateApiCollection(updated.getId(), updated);
|
apiRequestMgmtService.updateApiCollection(updated.getId(), updated);
|
||||||
|
|||||||
@@ -7,13 +7,10 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<aside class="pt-sidebar" th:fragment="collectionFragment">
|
<aside class="pt-sidebar" th:fragment="collectionFragment">
|
||||||
<div class="input-group p-1">
|
<!-- <div class="input-group p-1">-->
|
||||||
<input type="text" class="form-control" placeholder="검색어를 입력하세요" aria-label="검색어를 입력하세요"
|
<!-- <input type="text" class="form-control" placeholder="검색어를 입력하세요" aria-label="검색어를 입력하세요" id="filter_text"-->
|
||||||
aria-describedby="button-addon2">
|
<!-- aria-describedby="button-addon2">-->
|
||||||
<div class="input-group-append">
|
<!-- </div>-->
|
||||||
<button class="btn btn-outline-secondary" type="button" id="button-addon2">검색</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- new collection button -->
|
<!-- new collection button -->
|
||||||
<div class="p-1">
|
<div class="p-1">
|
||||||
<button type="button" class="btn btn-primary btn-sm" id="new_collection"><i class="fa fa-plus"></i>새 컬렉션</button>
|
<button type="button" class="btn btn-primary btn-sm" id="new_collection"><i class="fa fa-plus"></i>새 컬렉션</button>
|
||||||
@@ -40,6 +37,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal fade" id="edit_name_modal" tabindex="-1" aria-labelledby="edit_name_modal" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">새로운 이름</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="text" class="form-control" placeholder="이름을 입력하세요" aria-label="이름을 입력하세요" aria-describedby="button-addon2" name="name" required/>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
|
||||||
|
<button type="button" class="btn btn-primary change_name">저장</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="modal fade" id="confirm_delete_modal" tabindex="-1" aria-labelledby="confirm_delete_modal" aria-hidden="true">
|
<div class="modal fade" id="confirm_delete_modal" tabindex="-1" aria-labelledby="confirm_delete_modal" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary send">Send</button>
|
<button class="btn btn-primary send">Send</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary save">저장</button>
|
<button class="btn btn-primary save" style="height: 58px;">저장</button>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav nav-tabs mt-1" role="tablist">
|
<ul class="nav nav-tabs mt-1" role="tablist">
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
@@ -272,6 +272,9 @@
|
|||||||
requests: [],
|
requests: [],
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
|
$('#filter_text').on('input', function(){
|
||||||
|
view.renderCollections();
|
||||||
|
});
|
||||||
$("#cancel-ajax").on("click", function () {
|
$("#cancel-ajax").on("click", function () {
|
||||||
if (controller.currentAjaxRequest) {
|
if (controller.currentAjaxRequest) {
|
||||||
controller.currentAjaxRequest.abort();
|
controller.currentAjaxRequest.abort();
|
||||||
@@ -467,7 +470,7 @@
|
|||||||
});
|
});
|
||||||
target.find('.save').attr('data-collection', ); //TODO
|
target.find('.save').attr('data-collection', ); //TODO
|
||||||
target.find('.save').click(function(){
|
target.find('.save').click(function(){
|
||||||
controller.saveAPIRequest(idx);
|
controller.saveAPIRequest(apiRequests[idx]);
|
||||||
});
|
});
|
||||||
|
|
||||||
let me = this;
|
let me = this;
|
||||||
@@ -535,7 +538,7 @@
|
|||||||
const parsedJson = JSON.parse(model.responseModel.body);
|
const parsedJson = JSON.parse(model.responseModel.body);
|
||||||
const formattedJson = JSON.stringify(parsedJson, null, 2);
|
const formattedJson = JSON.stringify(parsedJson, null, 2);
|
||||||
this.responses[tabIdx].setValue(formattedJson);
|
this.responses[tabIdx].setValue(formattedJson);
|
||||||
}catch(e){
|
} catch(e) {
|
||||||
this.responses[tabIdx].setValue(model.responseModel.body);
|
this.responses[tabIdx].setValue(model.responseModel.body);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < model.responseModel.headers.length; i++) {
|
for (let i = 0; i < model.responseModel.headers.length; i++) {
|
||||||
@@ -555,7 +558,13 @@
|
|||||||
select.empty();
|
select.empty();
|
||||||
sidemenu.empty();
|
sidemenu.empty();
|
||||||
|
|
||||||
|
let filter = $('#filter_text').val();
|
||||||
|
|
||||||
for (let i = 0; i < collections.length; i++) {
|
for (let i = 0; i < collections.length; i++) {
|
||||||
|
// if (filter !== '' && collections[i].name.indexOf(filter) === -1) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
let template = $('#collectionTemplate').children().clone();
|
let template = $('#collectionTemplate').children().clone();
|
||||||
template.attr('id', 'collection_' + i);
|
template.attr('id', 'collection_' + i);
|
||||||
template.find('button.new_collection').text(collections[i].name);
|
template.find('button.new_collection').text(collections[i].name);
|
||||||
@@ -566,9 +575,27 @@
|
|||||||
$('#confirm_delete_modal').modal('show');
|
$('#confirm_delete_modal').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let editCollectionBtn = template.find('button.edit_collection');
|
||||||
|
editCollectionBtn.on('click', function () {
|
||||||
|
let saveBtn = $('#edit_name_modal').find('button.change_name');
|
||||||
|
saveBtn.on('click', function(){
|
||||||
|
collections[i].name = $('#edit_name_modal').find('input').val();
|
||||||
|
controller.saveCollection(collections[i].id, collections[i].name);
|
||||||
|
view.renderCollections();
|
||||||
|
$('#edit_name_modal').modal('hide');
|
||||||
|
});
|
||||||
|
$('#edit_name_modal').find('input').val('');
|
||||||
|
$('#edit_name_modal').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
template.find('.collapse').attr('id', 'btn_collection_' + i);
|
template.find('.collapse').attr('id', 'btn_collection_' + i);
|
||||||
|
|
||||||
for (let j = 0; j < collections[i].apis.length; j++) {
|
for (let j = 0; j < collections[i].apis.length; j++) {
|
||||||
|
|
||||||
|
// if(collections[i].apis[j].name.indexOf(filter) === -1) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
let collectionApiTemplate = $('#collectionApiTemplate').children().clone();
|
let collectionApiTemplate = $('#collectionApiTemplate').children().clone();
|
||||||
let link = collectionApiTemplate.find('a');
|
let link = collectionApiTemplate.find('a');
|
||||||
let btn = collectionApiTemplate.find('button.delete_api_request');
|
let btn = collectionApiTemplate.find('button.delete_api_request');
|
||||||
@@ -576,7 +603,7 @@
|
|||||||
link.attr('data-collection', collections[i].id);
|
link.attr('data-collection', collections[i].id);
|
||||||
link.attr('data-id', collections[i].apis[j].id);
|
link.attr('data-id', collections[i].apis[j].id);
|
||||||
link.on('click', function () {
|
link.on('click', function () {
|
||||||
controller.openApiRequest($(this).attr('data-collection'), $(this).data('id'));
|
controller.openApiRequest($(this).data('collection'), $(this).data('id'));
|
||||||
})
|
})
|
||||||
btn.attr('data-collection', collections[i].id);
|
btn.attr('data-collection', collections[i].id);
|
||||||
btn.attr('data-id', collections[i].apis[j].id);
|
btn.attr('data-id', collections[i].apis[j].id);
|
||||||
@@ -584,7 +611,21 @@
|
|||||||
$('#confirm_delete_api_modal').find('.confirm_delete_api').attr('data-id', $(this).data('id'));
|
$('#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').find('.confirm_delete_api').attr('data-collection', $(this).data('collection'));
|
||||||
$('#confirm_delete_api_modal').modal('show');
|
$('#confirm_delete_api_modal').modal('show');
|
||||||
})
|
});
|
||||||
|
|
||||||
|
let editBtn = collectionApiTemplate.find('button.edit_api_request');
|
||||||
|
editBtn.on('click', function () {
|
||||||
|
let saveBtn = $('#edit_name_modal').find('button.change_name');
|
||||||
|
saveBtn.on('click', function(){
|
||||||
|
collections[i].apis[j].name = $('#edit_name_modal').find('input').val();
|
||||||
|
controller.saveAPIRequest(collections[i].apis[j]);
|
||||||
|
view.renderCollections();
|
||||||
|
$('#edit_name_modal').modal('hide');
|
||||||
|
});
|
||||||
|
$('#edit_name_modal').find('input').val('');
|
||||||
|
$('#edit_name_modal').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
template.find('.collapse ul').append(collectionApiTemplate);
|
template.find('.collapse ul').append(collectionApiTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,13 +754,33 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addCollection: function (collection) {
|
addCollection: function (name) {
|
||||||
controller.showLoadingOverlay();
|
controller.showLoadingOverlay();
|
||||||
this.currentAjaxRequest = $.ajax({
|
this.currentAjaxRequest = $.ajax({
|
||||||
url: '/mgmt/collections/create.do',
|
url: '/mgmt/collections/create.do',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify({name: collection}),
|
data: JSON.stringify({name: name}),
|
||||||
|
success: function (data) {
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function (response, textStatus, errorThrown) {
|
||||||
|
controller.hideLoadingOverlay();
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
controller.loadCollections();
|
||||||
|
controller.hideLoadingOverlay();
|
||||||
|
$('#new_collection_modal').modal('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
saveCollection: function(id, name){
|
||||||
|
controller.showLoadingOverlay();
|
||||||
|
this.currentAjaxRequest = $.ajax({
|
||||||
|
url: '/mgmt/collections/update.do',
|
||||||
|
type: 'POST',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({id: id, name: name}),
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -754,8 +815,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveAPIRequest: function(idx){
|
saveAPIRequest: function(model){
|
||||||
let model = apiRequests[idx];
|
|
||||||
console.log(model);
|
console.log(model);
|
||||||
|
|
||||||
this.currentAjaxRequest = $.ajax({
|
this.currentAjaxRequest = $.ajax({
|
||||||
|
|||||||
Reference in New Issue
Block a user