Resolved merge conflict
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { type TabData } from '../common/TabData'
|
||||
import CodeEditor from '../CodeEditorComponent.vue';
|
||||
import { xml } from '@codemirror/lang-xml';
|
||||
|
||||
|
||||
const props = defineProps(
|
||||
{
|
||||
tool: {type: String, required: true},
|
||||
xml: {type: String},
|
||||
xml: {type: String, required: false},
|
||||
multiXml: {type: Array<TabData>, required: false},
|
||||
query: {type: String}
|
||||
}
|
||||
)
|
||||
@@ -90,28 +93,71 @@ function process() {
|
||||
|
||||
function prepareRequest():Request {
|
||||
var request = new Request(prepareURL(), {
|
||||
body: prepareRequestBody(),
|
||||
body: selectRequestBodyType(),
|
||||
method: "POST"
|
||||
});
|
||||
return request
|
||||
|
||||
}
|
||||
|
||||
function prepareURL(): string {
|
||||
const engineEndpoint = engine.value == "libxml" ? "libxml" : "java";
|
||||
return document.location.protocol + "//" + document.location.hostname + "/" + engineEndpoint + "/" + props.tool;
|
||||
const engineEndpoint = engine.value == "libxml" ? "libxml" : "java";
|
||||
|
||||
var tool = props.tool;
|
||||
if (props.multiXml && props.multiXml.length > 1)
|
||||
tool = "multiple/xslt";
|
||||
|
||||
return document.location.protocol + "//" + document.location.hostname + "/" + engineEndpoint + "/" + tool;
|
||||
}
|
||||
|
||||
function prepareRequestBody():string {
|
||||
function selectRequestBodyType() : string {
|
||||
if (props.multiXml && props.multiXml.length > 1)
|
||||
return prepareRequestBodyMultiXml();
|
||||
else if (props.multiXml)
|
||||
return prepareRequestBodySingleXml(props.multiXml.at(0)!.data);
|
||||
else
|
||||
return prepareRequestBodySingleXml(props.xml!);
|
||||
}
|
||||
|
||||
function prepareRequestBodySingleXml(data: string):string {
|
||||
var requestBody = JSON.stringify({
|
||||
"data": props.xml,
|
||||
"data": data,
|
||||
"processorData": props.query,
|
||||
"processor": engine.value,
|
||||
"version": version.value
|
||||
});
|
||||
console.log(requestBody)
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
function prepareRequestBodyMultiXml():string {
|
||||
var xmlFilesArray = convertDataArray(props.multiXml!);
|
||||
|
||||
var requestBody = JSON.stringify({
|
||||
"data": xmlFilesArray,
|
||||
"processorData": props.query,
|
||||
"processor": engine.value,
|
||||
"version": version.value
|
||||
});
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
function convertDataArray(data: Array<TabData>) {
|
||||
let result = new Array<Object>;
|
||||
data.forEach(element => {
|
||||
let fileName = element.name;
|
||||
if (!fileName.endsWith(".xml")) {
|
||||
fileName += ".xml";
|
||||
}
|
||||
|
||||
result.push({
|
||||
fileName: fileName,
|
||||
fileData: element.data,
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function fetchRequest(request: Request):Promise<JSON> {
|
||||
var responseBody = await fetch(request)
|
||||
.then(response => response.json())
|
||||
|
||||
Reference in New Issue
Block a user