Bugfixes
This commit is contained in:
		| @@ -2,14 +2,11 @@ | ||||
| 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, required: false}, | ||||
|         multiXml: {type: Array<TabData>, required: false}, | ||||
|         xml: {type: [String, Array<TabData>], required: true}, | ||||
|         query: {type: String} | ||||
|     } | ||||
| ) | ||||
| @@ -18,10 +15,10 @@ const emit = defineEmits(["update"]); | ||||
|  | ||||
| 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"]; | ||||
| var versionsForCurrentEngine = ref([""]); | ||||
| let versionsForCurrentEngine = ref([""]); | ||||
|  | ||||
| const engine = ref(''); | ||||
| const version = ref(''); | ||||
| @@ -85,14 +82,20 @@ function selectDefaultVersion() { | ||||
| } | ||||
|  | ||||
| function process() { | ||||
|     var request:Request = prepareRequest(); | ||||
|     let request:Request = prepareRequest(); | ||||
|     fetchRequest(request).then((data) => { | ||||
|         updateOutputField(data); | ||||
|     }) | ||||
| } | ||||
|  | ||||
| function updateOutputField(data: any) { | ||||
|     result.value = data.result | ||||
|     errorOccurred.value = data.status != "OK" | ||||
|     successOccurred.value = data.status == "OK" | ||||
| } | ||||
|  | ||||
| function prepareRequest():Request { | ||||
|     var request = new Request(prepareURL(), { | ||||
|     let request = new Request(prepareURL(), { | ||||
|         body: selectRequestBodyType(), | ||||
|         method: "POST" | ||||
|     }); | ||||
| @@ -103,43 +106,44 @@ function prepareRequest():Request { | ||||
| function prepareURL(): string { | ||||
|     const engineEndpoint = engine.value == "libxml" ? "libxml" : "java"; | ||||
|     | ||||
|     var tool = props.tool; | ||||
|     if (props.multiXml && props.multiXml.length > 1) | ||||
|     let tool = props.tool; | ||||
|     if (Array.isArray(props.xml) && props.xml.length > 1) | ||||
|         tool = "multiple/xslt"; | ||||
|  | ||||
|     return document.location.protocol + "//" + document.location.hostname + "/" + engineEndpoint + "/" + tool; | ||||
| } | ||||
|  | ||||
| function selectRequestBodyType() : string { | ||||
|     if (props.multiXml && props.multiXml.length > 1) | ||||
|     if (Array.isArray(props.xml) && props.xml.length > 1) | ||||
|         return prepareRequestBodyMultiXml(); | ||||
|     else if (props.multiXml) | ||||
|         return prepareRequestBodySingleXml(props.multiXml.at(0)!.data); | ||||
|     else if (Array.isArray(props.xml)) | ||||
|         return prepareRequestBodySingleXml(props.xml.at(0)!.data); | ||||
|     else | ||||
|         return prepareRequestBodySingleXml(props.xml!); | ||||
| } | ||||
|  | ||||
| function prepareRequestBodySingleXml(data: string):string { | ||||
|     var requestBody = JSON.stringify({ | ||||
|     let requestBody = JSON.stringify({ | ||||
|         "data": data, | ||||
|         "processorData": props.query, | ||||
|         "processor": engine.value, | ||||
|         "version": version.value | ||||
|     }); | ||||
|     console.log(requestBody); | ||||
|     return requestBody; | ||||
| } | ||||
|  | ||||
| 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, | ||||
|         "processorData": props.query, | ||||
|         "processor": engine.value, | ||||
|         "version": version.value | ||||
|     }); | ||||
|     console.log(requestBody); | ||||
|     return requestBody; | ||||
| } | ||||
|  | ||||
| @@ -161,17 +165,13 @@ function convertDataArray(data: Array<TabData>) { | ||||
| } | ||||
|  | ||||
| async function fetchRequest(request: Request):Promise<JSON> { | ||||
|     var responseBody = await fetch(request) | ||||
|     let responseBody = await fetch(request) | ||||
|     .then(response => response.json()) | ||||
|     .then((body) => body) | ||||
|     return responseBody | ||||
| } | ||||
|  | ||||
| function updateOutputField(data: any) { | ||||
|     result.value = data.result | ||||
|     errorOccurred.value = data.status != "OK" | ||||
|     successOccurred.value = data.status == "OK" | ||||
| } | ||||
|  | ||||
|  | ||||
| function clear() { | ||||
|     result.value = "" | ||||
|   | ||||
| @@ -54,18 +54,19 @@ function readFile(file : any) { | ||||
|      | ||||
|     const reader = new FileReader() | ||||
|     reader.onloadend = () => { | ||||
|         var result = reader.result!.toString(); | ||||
|         console.log(result); | ||||
|         let result = reader.result!.toString(); | ||||
|          | ||||
|         let activeIndex = findIndexWithID(activeTabId.value); | ||||
|          | ||||
|         let filePath = inputFile.value.value.split("\\"); | ||||
|         let fileName = filePath.at(filePath.length - 1); | ||||
|          | ||||
|         tabs.value.at(activeIndex)!.name = fileName; | ||||
|         updateData(result); | ||||
|              | ||||
|          | ||||
|     } | ||||
|     reader.readAsText(file.target.files[0]); | ||||
|     let activeIndex = findIndexWithID(activeTabId.value); | ||||
|      | ||||
|     let filePath = inputFile.value.value.split("\\"); | ||||
|     let fileName = filePath.at(filePath.length - 1); | ||||
|      | ||||
|     tabs.value.at(activeIndex)!.name = fileName; | ||||
| } | ||||
|  | ||||
| function changeActiveTab(id : number) { | ||||
| @@ -84,9 +85,7 @@ function addTab() { | ||||
|         id: newTabId.value++, | ||||
|         name: "XML" + newTabId.value, | ||||
|         data: "" | ||||
|     }) | ||||
|  | ||||
|     console.log(tabs.value); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function removeTab(id : number) { | ||||
| @@ -94,7 +93,7 @@ function removeTab(id : number) { | ||||
|         return | ||||
|  | ||||
|     let indexToRemove = findIndexWithID(id); | ||||
|      | ||||
|  | ||||
|     switchToExistingTab(indexToRemove) | ||||
|      | ||||
|     tabs.value.splice(indexToRemove, 1); | ||||
|   | ||||
| @@ -16,22 +16,16 @@ function updateVersion(newVersion: string) { | ||||
|     version.value = newVersion; | ||||
| } | ||||
|  | ||||
| function updateXML(data: Array<TabData>) { | ||||
|     xml.value = data; | ||||
|     console.log("Update:" + data); | ||||
|     console.log(data); | ||||
| } | ||||
|  | ||||
| </script> | ||||
|  | ||||
| <template> | ||||
|     <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 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> | ||||
|             </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> | ||||
|         <TooltipComponent tool-type="xslt" :version="version"></TooltipComponent> | ||||
|     </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user