수정가능 범위 하이라이트, IMPORT 추가, 스크립트 선택 필드Select2 로 변경
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import com.eactive.httpmockserver.script.ScriptInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
@@ -21,6 +22,9 @@ public class ApiManageController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApiService apiService;
|
private ApiService apiService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ScriptInfoService scriptInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiServiceKeyService apiKeyService;
|
private ApiServiceKeyService apiKeyService;
|
||||||
|
|
||||||
@@ -47,6 +51,8 @@ public class ApiManageController {
|
|||||||
model.addAttribute("apiInfo", apiInfo);
|
model.addAttribute("apiInfo", apiInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.addAttribute("scriptInfos", scriptInfoService.findAllScriptInfos());
|
||||||
|
|
||||||
return "page/add-edit-api";
|
return "page/add-edit-api";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,12 @@ package com.eactive.httpmockserver.script;
|
|||||||
|
|
||||||
public interface Script {
|
public interface Script {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Script Process Function
|
||||||
|
* @param requestMessage 수신 받은 요청 메시지
|
||||||
|
* @param responseMessage 정의된 응답 메시지
|
||||||
|
* @return 스크립트 수행 후 응답 할 메시지
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public String postProcess(String requestMessage, String responseMessage) throws Exception;
|
public String postProcess(String requestMessage, String responseMessage) throws Exception;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package com.eactive.httpmockserver.script.dynamic;
|
package com.eactive.httpmockserver.script.dynamic;
|
||||||
import com.eactive.httpmockserver.script.Script;
|
import com.eactive.httpmockserver.script.Script;
|
||||||
|
//IMPORT 클래스는 여기에 정의해 주세요
|
||||||
|
|
||||||
public class implements Script{
|
public class implements Script{
|
||||||
@Override
|
/**
|
||||||
|
* Script Process Function
|
||||||
|
* @param requestMessage 수신 받은 요청 메시지
|
||||||
|
* @param responseMessage 정의된 응답 메시지
|
||||||
|
* @return 스크립트 수행 후 응답 할 메시지
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public String postProcess(String requestMessage, String responseMessage) throws Exception {
|
public String postProcess(String requestMessage, String responseMessage) throws Exception {
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,9 +159,9 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-sm-3 col-form-label">스크립트 명</label>
|
<label class="col-sm-3 col-form-label">스크립트 명</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input type="text" th:field="*{scriptName}"
|
<select class="form-control select2bs4" style="width: 100%;" >
|
||||||
class="form-control"
|
<option th:each="scriptInfo : ${scriptInfos}" th:value="${scriptInfo.scriptName}" th:text="${scriptInfo.scriptName + '(' + scriptInfo.scriptDesc + ')'}"></option>
|
||||||
placeholder="수행 스크립트 명">
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -230,6 +230,11 @@
|
|||||||
<link rel="stylesheet" data-name="vs/editor/editor.main"
|
<link rel="stylesheet" data-name="vs/editor/editor.main"
|
||||||
th:href="@{/plugins/vs/editor/editor.main.css}">
|
th:href="@{/plugins/vs/editor/editor.main.css}">
|
||||||
|
|
||||||
|
<link rel="stylesheet" th:href="@{/plugins/select2/css/select2.min.css}">
|
||||||
|
<link rel="stylesheet" th:href="@{/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css}">
|
||||||
|
|
||||||
|
<script th:src="@{/plugins/select2/js/select2.full.js}"></script>
|
||||||
|
|
||||||
<script>var require = { paths: { 'vs': '../../plugins/vs' } };</script>
|
<script>var require = { paths: { 'vs': '../../plugins/vs' } };</script>
|
||||||
|
|
||||||
<script th:src="@{/plugins/vs/loader.js}"></script>
|
<script th:src="@{/plugins/vs/loader.js}"></script>
|
||||||
@@ -238,6 +243,11 @@
|
|||||||
|
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
var urlForSidebar = "/manage/findAllApis";
|
var urlForSidebar = "/manage/findAllApis";
|
||||||
|
|
||||||
|
//Initialize Select2 Elements
|
||||||
|
$('.select2bs4').select2({
|
||||||
|
theme: 'bootstrap4'
|
||||||
|
})
|
||||||
|
|
||||||
function setMonaco(elementId, selectId, initValue){
|
function setMonaco(elementId, selectId, initValue){
|
||||||
var targetDivElement = document.getElementById(elementId);
|
var targetDivElement = document.getElementById(elementId);
|
||||||
|
|||||||
@@ -89,6 +89,9 @@
|
|||||||
<th:block layout:fragment="script">
|
<th:block layout:fragment="script">
|
||||||
<link rel="stylesheet" data-name="vs/editor/editor.main"
|
<link rel="stylesheet" data-name="vs/editor/editor.main"
|
||||||
th:href="@{/plugins/vs/editor/editor.main.css}">
|
th:href="@{/plugins/vs/editor/editor.main.css}">
|
||||||
|
<link rel="stylesheet"
|
||||||
|
th:href="@{/plugins/vs/plugin/constrained-editor-plugin/constrainedEditorPlugin.css}">
|
||||||
|
<script th:src="@{/plugins/vs/plugin/constrained-editor-plugin/constrainedEditorPlugin.js}"></script>
|
||||||
|
|
||||||
<script>var require = { paths: { 'vs': '../../plugins/vs' } };</script>
|
<script>var require = { paths: { 'vs': '../../plugins/vs' } };</script>
|
||||||
|
|
||||||
@@ -114,33 +117,65 @@
|
|||||||
wrappingIndent: 'none',
|
wrappingIndent: 'none',
|
||||||
automaticLayout: true
|
automaticLayout: true
|
||||||
});
|
});
|
||||||
const readonlyRange = new monaco.Range (1, 0, 7, 0)
|
|
||||||
editor.onKeyDown (e => {
|
|
||||||
const contains = editor.getSelections().findIndex (range => readonlyRange.intersectRanges (range))
|
|
||||||
let currentLineNumber = editor.getPosition().lineNumber
|
|
||||||
let lineCount = editor.getModel().getLineCount();
|
|
||||||
console.log(e.ctrlKey)
|
|
||||||
if(e.ctrlKey && e.keyCode == 33){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch(e.keyCode){
|
|
||||||
case 13:
|
|
||||||
case 14:
|
|
||||||
case 15:
|
|
||||||
case 16:
|
|
||||||
case 17:
|
|
||||||
case 18:
|
|
||||||
case 63:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const matchTailPart = lineCount == currentLineNumber || lineCount - 1 == currentLineNumber;
|
const constrainedInstance = constrainedEditor(monaco);
|
||||||
if (contains !== -1 || matchTailPart) {
|
constrainedInstance.initializeIn(editor);
|
||||||
e.stopPropagation ()
|
const model = editor.getModel();
|
||||||
e.preventDefault () // for Ctrl+C, Ctrl+V
|
let editableLine = 14
|
||||||
return false;
|
|
||||||
|
const linesContent = editor.getModel().getLinesContent();
|
||||||
|
for (let i = 0; i < linesContent.length; i++) {
|
||||||
|
const lineText = linesContent[i].trim();
|
||||||
|
|
||||||
|
if(lineText.startsWith('public String postProcess')){
|
||||||
|
editableLine = i + 2
|
||||||
|
break
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
const editableLineTextLength = linesContent[editableLine - 1].length + 1;
|
||||||
|
|
||||||
|
constrainedInstance.addRestrictionsTo(model, [{
|
||||||
|
// range : [ startLine, startColumn, endLine, endColumn ]
|
||||||
|
range: [3, 1, 3, 26], // Range of Util Variable name
|
||||||
|
label: 'import',
|
||||||
|
allowMultiline: true
|
||||||
|
}, {
|
||||||
|
range: [editableLine, 1, editableLine, editableLineTextLength], // Range of Function definition
|
||||||
|
allowMultiline: true,
|
||||||
|
label: 'funcDefinition'
|
||||||
|
}]);
|
||||||
|
model.toggleHighlightOfEditableAreas();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const readonlyRange = new monaco.Range (1, 0, 7, 0)
|
||||||
|
// editor.onKeyDown (e => {
|
||||||
|
// const contains = editor.getSelections().findIndex (range => readonlyRange.intersectRanges (range))
|
||||||
|
// let currentLineNumber = editor.getPosition().lineNumber
|
||||||
|
// let lineCount = editor.getModel().getLineCount();
|
||||||
|
// console.log(e.ctrlKey)
|
||||||
|
// if(e.ctrlKey && e.keyCode == 33){
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// switch(e.keyCode){
|
||||||
|
// case 13:
|
||||||
|
// case 14:
|
||||||
|
// case 15:
|
||||||
|
// case 16:
|
||||||
|
// case 17:
|
||||||
|
// case 18:
|
||||||
|
// case 63:
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// const matchTailPart = lineCount == currentLineNumber || lineCount - 1 == currentLineNumber;
|
||||||
|
// if (contains !== -1 || matchTailPart) {
|
||||||
|
// e.stopPropagation ()
|
||||||
|
// e.preventDefault () // for Ctrl+C, Ctrl+V
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
$('#form').submit(function(eventObj) {
|
$('#form').submit(function(eventObj) {
|
||||||
$('#scriptName').prop( "disabled", false );
|
$('#scriptName').prop( "disabled", false );
|
||||||
|
|||||||
Reference in New Issue
Block a user