cleared code
This commit is contained in:
@@ -13,100 +13,32 @@ const sendToParent = () => {
|
|||||||
options.value.forEach((value) => {console.log("KID" + value + options.value.indexOf(value))})
|
options.value.forEach((value) => {console.log("KID" + value + options.value.indexOf(value))})
|
||||||
emit('update-value', options.value);
|
emit('update-value', options.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const nameInput = ref('')
|
const nameInput = ref('')
|
||||||
const valueInput = ref('')
|
const valueInput = ref('')
|
||||||
|
|
||||||
|
|
||||||
const selectedOption = ref(options.value[0].name)
|
const selectedOption = ref(options.value[0].name)
|
||||||
|
|
||||||
|
const isNumeric = (string) => /^[+-]?\d+(\.\d+)?$/.test(string)
|
||||||
|
|
||||||
const selectedFunction = () => {
|
const selectedFunction = () => {
|
||||||
if (selectOption(selectedOption.value) === 'Add Param') {
|
const action = selectOption(selectedOption.value);
|
||||||
if(!valueInput.value.length == 0 && !nameInput.value.length == 0){
|
const name = nameInput.value.trim();
|
||||||
options.value.push({name: nameInput.value + " = " + valueInput.value});
|
const value = valueInput.value.trim();
|
||||||
valueInput.value = "";
|
|
||||||
nameInput.value = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (action === "Add Param" && name && value && !isNumeric(name)) {
|
||||||
|
options.value.push({ name: `${name} = ${value}` });
|
||||||
|
nameInput.value = valueInput.value = "";
|
||||||
}
|
}
|
||||||
if (selectOption(selectedOption.value) === 'Remove Param') {
|
|
||||||
const foundOption = options.value.find(option => option.name === selectedOption.value);
|
if (action === "Remove Param") {
|
||||||
if (foundOption) {
|
options.value = options.value.filter(option => option.name !== selectedOption.value);
|
||||||
const currentIndex = options.value.indexOf(foundOption);
|
selectedOption.value = options.value.length ? options.value[0].name : "";
|
||||||
if (currentIndex !== -1) {
|
nameInput.value = valueInput.value = "";
|
||||||
options.value.splice(currentIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (options.value.length > 0) {
|
|
||||||
selectedOption.value = options.value[0].name;
|
|
||||||
} else {
|
|
||||||
selectedOption.value = "";
|
|
||||||
}
|
|
||||||
valueInput.value = "";
|
|
||||||
nameInput.value = "";
|
|
||||||
}
|
}
|
||||||
sendToParent()
|
sendToParent();
|
||||||
/*
|
};
|
||||||
|
|
||||||
if(selectedOption.value === "Add Param") {
|
|
||||||
sendRequest("add");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sendRequest("remove");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
const sendRequest = (type:string) => {
|
|
||||||
console.log(type)
|
|
||||||
let request: Request = prepareRequest(type)
|
|
||||||
fetchRequest(request).then((body) => {
|
|
||||||
|
|
||||||
const {status} = body as any;
|
|
||||||
console.log(status)
|
|
||||||
if (status === "OK") {
|
|
||||||
options.value.push({ name: nameInput.value + " = " + valueInput.value });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
function selectOption(option: string): string {
|
function selectOption(option: string): string {
|
||||||
return option == "Add Param" ? "Add Param" : "Remove Param"
|
return option == "Add Param" ? "Add Param" : "Remove Param"
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// function prepareRequest(type :string): Request {
|
|
||||||
// let request = new Request(prepareURL(), {
|
|
||||||
// body: prepareRequestBody(type),
|
|
||||||
// method: "POST"
|
|
||||||
// });
|
|
||||||
// return request
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// function prepareURL(): string {
|
|
||||||
// //const engineEndpoint = engine.value == "libxml" ? "libxml" : "java";
|
|
||||||
// return document.location.protocol + "//" + document.location.hostname + "/" + "java" + "/xslt/param";
|
|
||||||
// //return "http://localhost:8081/xslt/param";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// function prepareRequestBody(type: string): string {
|
|
||||||
// let requestBody = JSON.stringify({
|
|
||||||
// "paramName": nameInput.value,
|
|
||||||
// "paramValue": valueInput.value,
|
|
||||||
// "type": type
|
|
||||||
// });
|
|
||||||
// console.log(requestBody);
|
|
||||||
// return requestBody;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// async function fetchRequest(request: Request): Promise<JSON> {
|
|
||||||
// console.log(request)
|
|
||||||
// let responseBody = await fetch(request)
|
|
||||||
// return await responseBody.json()
|
|
||||||
// }
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ const emit = defineEmits(["update"]);
|
|||||||
const result = ref('');
|
const result = ref('');
|
||||||
|
|
||||||
let enginesForCurrentTool = ref(["saxon", "xalan", "libxml"]);
|
let enginesForCurrentTool = ref(["saxon", "xalan", "libxml"]);
|
||||||
|
const formattedParams = ref();
|
||||||
|
|
||||||
|
|
||||||
const allVersions = ["1.0", "2.0", "3.0", "3.1"];
|
const allVersions = ["1.0", "2.0", "3.0", "3.1"];
|
||||||
let versionsForCurrentEngine = ref([""]);
|
let versionsForCurrentEngine = ref([""]);
|
||||||
@@ -100,6 +102,7 @@ function updateOutputField(data: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prepareRequest():Request {
|
function prepareRequest():Request {
|
||||||
|
formattedParams.value = formatParams()
|
||||||
let request = new Request(prepareURL(), {
|
let request = new Request(prepareURL(), {
|
||||||
body: selectRequestBodyType(),
|
body: selectRequestBodyType(),
|
||||||
method: "POST"
|
method: "POST"
|
||||||
@@ -135,10 +138,8 @@ function formatParams() {
|
|||||||
|
|
||||||
function prepareRequestBodySingleXml(data: string):string {
|
function prepareRequestBodySingleXml(data: string):string {
|
||||||
|
|
||||||
const formattedParams = formatParams();
|
|
||||||
|
|
||||||
let requestBody = JSON.stringify({
|
let requestBody = JSON.stringify({
|
||||||
"params": formattedParams,
|
"params": formattedParams.value,
|
||||||
"data": data,
|
"data": data,
|
||||||
"processorData": props.query,
|
"processorData": props.query,
|
||||||
"processor": engine.value,
|
"processor": engine.value,
|
||||||
@@ -149,7 +150,6 @@ function prepareRequestBodySingleXml(data: string):string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prepareRequestBodyMultiXml():string {
|
function prepareRequestBodyMultiXml():string {
|
||||||
const formattedParams = formatParams();
|
|
||||||
|
|
||||||
if (!Array.isArray(props.xml))
|
if (!Array.isArray(props.xml))
|
||||||
return "";
|
return "";
|
||||||
@@ -157,7 +157,7 @@ function prepareRequestBodyMultiXml():string {
|
|||||||
let xmlFilesArray = convertDataArray(props.xml);
|
let xmlFilesArray = convertDataArray(props.xml);
|
||||||
|
|
||||||
let requestBody = JSON.stringify({
|
let requestBody = JSON.stringify({
|
||||||
"params": formattedParams,
|
"params": formattedParams.value,
|
||||||
"data": xmlFilesArray,
|
"data": xmlFilesArray,
|
||||||
"processorData": props.query,
|
"processorData": props.query,
|
||||||
"processor": engine.value,
|
"processor": engine.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user