Bugfixes
This commit is contained in:
		@@ -2,14 +2,11 @@
 | 
				
			|||||||
import { onMounted, ref } from 'vue';
 | 
					import { onMounted, ref } from 'vue';
 | 
				
			||||||
import { type TabData } from '../common/TabData'
 | 
					import { type TabData } from '../common/TabData'
 | 
				
			||||||
import CodeEditor from '../CodeEditorComponent.vue';
 | 
					import CodeEditor from '../CodeEditorComponent.vue';
 | 
				
			||||||
import { xml } from '@codemirror/lang-xml';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const props = defineProps(
 | 
					const props = defineProps(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        tool: {type: String, required: true},
 | 
					        tool: {type: String, required: true},
 | 
				
			||||||
        xml: {type: String, required: false},
 | 
					        xml: {type: [String, Array<TabData>], required: true},
 | 
				
			||||||
        multiXml: {type: Array<TabData>, required: false},
 | 
					 | 
				
			||||||
        query: {type: String}
 | 
					        query: {type: String}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -18,10 +15,10 @@ const emit = defineEmits(["update"]);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const result = ref('');
 | 
					const result = ref('');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var enginesForCurrentTool = ref(["saxon", "xalan", "libxml"]);
 | 
					let enginesForCurrentTool = ref(["saxon", "xalan", "libxml"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const allVersions = ["1.0", "2.0", "3.0", "3.1"];
 | 
					const allVersions = ["1.0", "2.0", "3.0", "3.1"];
 | 
				
			||||||
var versionsForCurrentEngine = ref([""]);
 | 
					let versionsForCurrentEngine = ref([""]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const engine = ref('');
 | 
					const engine = ref('');
 | 
				
			||||||
const version = ref('');
 | 
					const version = ref('');
 | 
				
			||||||
@@ -85,14 +82,20 @@ function selectDefaultVersion() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function process() {
 | 
					function process() {
 | 
				
			||||||
    var request:Request = prepareRequest();
 | 
					    let request:Request = prepareRequest();
 | 
				
			||||||
    fetchRequest(request).then((data) => {
 | 
					    fetchRequest(request).then((data) => {
 | 
				
			||||||
        updateOutputField(data);
 | 
					        updateOutputField(data);
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function updateOutputField(data: any) {
 | 
				
			||||||
 | 
					    result.value = data.result
 | 
				
			||||||
 | 
					    errorOccurred.value = data.status != "OK"
 | 
				
			||||||
 | 
					    successOccurred.value = data.status == "OK"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function prepareRequest():Request {
 | 
					function prepareRequest():Request {
 | 
				
			||||||
    var request = new Request(prepareURL(), {
 | 
					    let request = new Request(prepareURL(), {
 | 
				
			||||||
        body: selectRequestBodyType(),
 | 
					        body: selectRequestBodyType(),
 | 
				
			||||||
        method: "POST"
 | 
					        method: "POST"
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@@ -103,43 +106,44 @@ function prepareRequest():Request {
 | 
				
			|||||||
function prepareURL(): string {
 | 
					function prepareURL(): string {
 | 
				
			||||||
    const engineEndpoint = engine.value == "libxml" ? "libxml" : "java";
 | 
					    const engineEndpoint = engine.value == "libxml" ? "libxml" : "java";
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
    var tool = props.tool;
 | 
					    let tool = props.tool;
 | 
				
			||||||
    if (props.multiXml && props.multiXml.length > 1)
 | 
					    if (Array.isArray(props.xml) && props.xml.length > 1)
 | 
				
			||||||
        tool = "multiple/xslt";
 | 
					        tool = "multiple/xslt";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return document.location.protocol + "//" + document.location.hostname + "/" + engineEndpoint + "/" + tool;
 | 
					    return document.location.protocol + "//" + document.location.hostname + "/" + engineEndpoint + "/" + tool;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function selectRequestBodyType() : string {
 | 
					function selectRequestBodyType() : string {
 | 
				
			||||||
    if (props.multiXml && props.multiXml.length > 1)
 | 
					    if (Array.isArray(props.xml) && props.xml.length > 1)
 | 
				
			||||||
        return prepareRequestBodyMultiXml();
 | 
					        return prepareRequestBodyMultiXml();
 | 
				
			||||||
    else if (props.multiXml)
 | 
					    else if (Array.isArray(props.xml))
 | 
				
			||||||
        return prepareRequestBodySingleXml(props.multiXml.at(0)!.data);
 | 
					        return prepareRequestBodySingleXml(props.xml.at(0)!.data);
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        return prepareRequestBodySingleXml(props.xml!);
 | 
					        return prepareRequestBodySingleXml(props.xml!);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function prepareRequestBodySingleXml(data: string):string {
 | 
					function prepareRequestBodySingleXml(data: string):string {
 | 
				
			||||||
    var requestBody = JSON.stringify({
 | 
					    let requestBody = JSON.stringify({
 | 
				
			||||||
        "data": data,
 | 
					        "data": data,
 | 
				
			||||||
        "processorData": props.query,
 | 
					        "processorData": props.query,
 | 
				
			||||||
        "processor": engine.value,
 | 
					        "processor": engine.value,
 | 
				
			||||||
        "version": version.value
 | 
					        "version": version.value
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    console.log(requestBody);
 | 
					 | 
				
			||||||
    return requestBody;
 | 
					    return requestBody;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function prepareRequestBodyMultiXml():string {
 | 
					function prepareRequestBodyMultiXml():string {
 | 
				
			||||||
    var xmlFilesArray = convertDataArray(props.multiXml!);
 | 
					    if (!Array.isArray(props.xml))
 | 
				
			||||||
 | 
					        return "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var requestBody = JSON.stringify({
 | 
					    let xmlFilesArray = convertDataArray(props.xml);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let requestBody = JSON.stringify({
 | 
				
			||||||
        "data": xmlFilesArray,
 | 
					        "data": xmlFilesArray,
 | 
				
			||||||
        "processorData": props.query,
 | 
					        "processorData": props.query,
 | 
				
			||||||
        "processor": engine.value,
 | 
					        "processor": engine.value,
 | 
				
			||||||
        "version": version.value
 | 
					        "version": version.value
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    console.log(requestBody);
 | 
					 | 
				
			||||||
    return requestBody;
 | 
					    return requestBody;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -161,17 +165,13 @@ function convertDataArray(data: Array<TabData>) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function fetchRequest(request: Request):Promise<JSON> {
 | 
					async function fetchRequest(request: Request):Promise<JSON> {
 | 
				
			||||||
    var responseBody = await fetch(request)
 | 
					    let responseBody = await fetch(request)
 | 
				
			||||||
    .then(response => response.json())
 | 
					    .then(response => response.json())
 | 
				
			||||||
    .then((body) => body)
 | 
					    .then((body) => body)
 | 
				
			||||||
    return responseBody
 | 
					    return responseBody
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function updateOutputField(data: any) {
 | 
					
 | 
				
			||||||
    result.value = data.result
 | 
					 | 
				
			||||||
    errorOccurred.value = data.status != "OK"
 | 
					 | 
				
			||||||
    successOccurred.value = data.status == "OK"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
function clear() {
 | 
					function clear() {
 | 
				
			||||||
    result.value = ""
 | 
					    result.value = ""
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,18 +54,19 @@ function readFile(file : any) {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    const reader = new FileReader()
 | 
					    const reader = new FileReader()
 | 
				
			||||||
    reader.onloadend = () => {
 | 
					    reader.onloadend = () => {
 | 
				
			||||||
        var result = reader.result!.toString();
 | 
					        let result = reader.result!.toString();
 | 
				
			||||||
        console.log(result);
 | 
					 | 
				
			||||||
        updateData(result);
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    reader.readAsText(file.target.files[0]);
 | 
					 | 
				
			||||||
        let activeIndex = findIndexWithID(activeTabId.value);
 | 
					        let activeIndex = findIndexWithID(activeTabId.value);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        let filePath = inputFile.value.value.split("\\");
 | 
					        let filePath = inputFile.value.value.split("\\");
 | 
				
			||||||
        let fileName = filePath.at(filePath.length - 1);
 | 
					        let fileName = filePath.at(filePath.length - 1);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        tabs.value.at(activeIndex)!.name = fileName;
 | 
					        tabs.value.at(activeIndex)!.name = fileName;
 | 
				
			||||||
 | 
					        updateData(result);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    reader.readAsText(file.target.files[0]);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function changeActiveTab(id : number) {
 | 
					function changeActiveTab(id : number) {
 | 
				
			||||||
@@ -84,9 +85,7 @@ function addTab() {
 | 
				
			|||||||
        id: newTabId.value++,
 | 
					        id: newTabId.value++,
 | 
				
			||||||
        name: "XML" + newTabId.value,
 | 
					        name: "XML" + newTabId.value,
 | 
				
			||||||
        data: ""
 | 
					        data: ""
 | 
				
			||||||
    })
 | 
					    });
 | 
				
			||||||
 | 
					 | 
				
			||||||
    console.log(tabs.value);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function removeTab(id : number) {
 | 
					function removeTab(id : number) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,22 +16,16 @@ function updateVersion(newVersion: string) {
 | 
				
			|||||||
    version.value = newVersion;
 | 
					    version.value = newVersion;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function updateXML(data: Array<TabData>) {
 | 
					 | 
				
			||||||
    xml.value = data;
 | 
					 | 
				
			||||||
    console.log("Update:" + data);
 | 
					 | 
				
			||||||
    console.log(data);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
    <div id="layout" class="flex flex-row w-full h-full">
 | 
					    <div id="layout" class="flex flex-row w-full h-full">
 | 
				
			||||||
        <div class="flex flex-col 2xl:flex-row w-full xl:w-7/12 grow overflow-hide pr-2">
 | 
					        <div class="flex flex-col 2xl:flex-row w-full xl:w-7/12 grow overflow-hide pr-2">
 | 
				
			||||||
            <div class="flex flex-col w-full 2xl:w-1/2 h-2/3 2xl:h-full flex-none items-center">
 | 
					            <div class="flex flex-col w-full 2xl:w-1/2 h-2/3 2xl:h-full flex-none items-center">
 | 
				
			||||||
                <xmlTabbedInputComponent stylized-name="XML" :data="xml" @update="updateXML"></xmlTabbedInputComponent>
 | 
					                <xmlTabbedInputComponent stylized-name="XML" :data="xml" @update="(data) => {xml = data}"></xmlTabbedInputComponent>
 | 
				
			||||||
                <xmlInputFieldComponent stylized-name="XSLT" :data="query" @update="(data) => {query = data}"></xmlInputFieldComponent>
 | 
					                <xmlInputFieldComponent stylized-name="XSLT" :data="query" @update="(data) => {query = data}"></xmlInputFieldComponent>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <xmlOutputFieldComponent tool="xslt" :multi-xml="xml" :query="query" @update="(version) => updateVersion(version)"></xmlOutputFieldComponent>
 | 
					            <xmlOutputFieldComponent tool="xslt" :xml="xml" :query="query" @update="updateVersion"></xmlOutputFieldComponent>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <TooltipComponent tool-type="xslt" :version="version"></TooltipComponent>
 | 
					        <TooltipComponent tool-type="xslt" :version="version"></TooltipComponent>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user