T157 table converted to json
This commit is contained in:
		
							
								
								
									
										5
									
								
								.idea/workspace.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								.idea/workspace.xml
									
									
									
										generated
									
									
									
								
							| @@ -20,10 +20,9 @@ | ||||
|   </component> | ||||
|   <component name="ChangeListManager"> | ||||
|     <list default="true" id="458cde88-df3d-44bc-9d57-a33823e2f1a6" name="Default Changelist" comment=""> | ||||
|       <change afterPath="$PROJECT_DIR$/src/main/resources/static/json/generated.json" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/src/main/resources/static/css/main.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/static/css/main.css" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/static/js/datatransfer.js" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/src/main/resources/templates/mock.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/templates/mock.html" afterDir="false" /> | ||||
|     </list> | ||||
|     <option name="SHOW_DIALOG" value="false" /> | ||||
|     <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||||
| @@ -309,7 +308,7 @@ | ||||
|       <workItem from="1611826821050" duration="10679000" /> | ||||
|       <workItem from="1611915874625" duration="15194000" /> | ||||
|       <workItem from="1612178634549" duration="20097000" /> | ||||
|       <workItem from="1612259068808" duration="7541000" /> | ||||
|       <workItem from="1612259068808" duration="8608000" /> | ||||
|     </task> | ||||
|     <task id="LOCAL-00077" summary="testing jenkins docker"> | ||||
|       <created>1601453886631</created> | ||||
|   | ||||
| @@ -66,9 +66,9 @@ function generateHeaderTable(headers){ | ||||
|     } | ||||
|     for(let i=0; i<count; i++){ | ||||
|         innerHTML+= | ||||
|             '<tr>' + | ||||
|             '<tr class="httpStatusValue">' + | ||||
|                 '<td>' + | ||||
|                     '<input type="text" name="headerKey" placeholder="key" class="tableField headerName httpStatusValue" value="' + keys[i] + '"/></td>' + | ||||
|                     '<input type="text" name="headerKey" placeholder="key" class="tableField headerName" value="' + keys[i] + '"/></td>' + | ||||
|                 '<td>' + | ||||
|                     '<input type="text" name="headerKey" placeholder="key" class="tableField" value="' + values[i] + '"/></td>' + | ||||
|             '</tr>'; | ||||
| @@ -148,27 +148,20 @@ function generateJson(){ | ||||
|             httpStatus: $('#httpStatus').val(), | ||||
|             httpHeaders: {}, | ||||
|         }; | ||||
|     newJson['httpHeaders'] = convertTableToJson(); | ||||
|     document.write(JSON.stringify(newJson, null, 2)); | ||||
| } | ||||
|  | ||||
| // $("table tr").eq(row).find("td").eq(i%2).append("<img src='"+dataJson[i].imagen+"' width='100'/>"); | ||||
|  | ||||
| function convertTableToJson(){ | ||||
|     var table = $('#headerTable'); | ||||
|     console.log("Length of header table: " + table.length); | ||||
|     console.log("Length of children of header table: " + table.children().length); | ||||
|     var hKey = new Array(table.children().length); | ||||
|     var hVal = new Array(table.children().length); | ||||
|     if(table.children().length == 0) return; | ||||
|     for(let i=1; i<table.children.length;i++){ | ||||
|        hKey[i-1] = table.eq(i).eq(0).val(); | ||||
|        hVal[i-1] = table.eq(i).eq(1).val(); | ||||
|        console.log('Key='+hKey[i-1]+' Value='+hVal[i-1]); | ||||
|     var rows = $('.httpStatusValue'); | ||||
|     console.log("Rows: "+rows.length); | ||||
|     var obj = {}; | ||||
|     var key; | ||||
|     for(let i=0; i<rows.length; i++){ | ||||
|         key = rows.eq(i).children().eq(0).children().eq(0).val(); | ||||
|         obj[key] = rows.eq(i).children().eq(1).children().eq(0).val(); | ||||
|     } | ||||
|     return obj; | ||||
| } | ||||
|  | ||||
| //TODO: children is an array | ||||
| // add class for each row | ||||
| // divide table into th and tb | ||||
| // children().eq(0).text() | ||||
| // jsfiddle.net | ||||
							
								
								
									
										12
									
								
								src/main/resources/static/json/generated.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/main/resources/static/json/generated.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| { | ||||
|   "clientUUID": "9bfddcc1-ef89-4c53-84e8-c88f13ecc7ec", | ||||
|   "mockedResponseId": 1, | ||||
|   "mediaType": "application/xml", | ||||
|   "messageBody": "\n\n Tove\n Jani\n Reminder\n Don't forget me this weekend!\n", | ||||
|   "httpStatus": "200", | ||||
|   "httpHeaders": { | ||||
|     "Keep-Alive": "timeout=60", | ||||
|     "Connection": "keep-alive", | ||||
|     "Date": "2021-02-02T12:15:22.164035" | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user