T217 issue fixed
This commit is contained in:
		| @@ -5,6 +5,7 @@ | ||||
| var clientUUID = ''; | ||||
| var json = {}; | ||||
| var jsonIndex = 0; | ||||
| var lastId = 1; | ||||
| var htable_row = 0; | ||||
| var host = getDomain(); | ||||
| var dataModified = false; | ||||
| @@ -25,6 +26,9 @@ const setOrigin = function(){ | ||||
| const getUpdate = function(){ | ||||
|     updateData(); | ||||
| } | ||||
| const dataRefresh = function(){ | ||||
|     getData(); | ||||
| } | ||||
| $('#iconPlus').click(function(){callAddMessage()}); | ||||
| $('#btn-addRow').click(function(){addRow()}); | ||||
| //TODO remove later save onclick init | ||||
| @@ -34,7 +38,7 @@ function getData(){ | ||||
|     loadCookies(); | ||||
|     $.getJSON(host + '/mock/json/'+clientUUID, function(data) { | ||||
|         json = data; | ||||
|         clientUUID = json[jsonIndex].clientUUID; | ||||
|         clientUUID = json[0].clientUUID; | ||||
|         setCookies(); | ||||
|         console.log(JSON.stringify(json)); | ||||
|         console.log("Json received"); | ||||
| @@ -67,17 +71,33 @@ function setDataOrigin(){ | ||||
|     $('#btn-save').off(); | ||||
| } | ||||
|  | ||||
|  | ||||
| const idToDisplay = function(){ | ||||
|     let defaultId = json[0].mockedResponseId; | ||||
|     if(lastId == undefined || lastId == null) return defaultId; | ||||
|     for(let i=0; i<json.length; i++){ | ||||
|         if(json[i].mockedResponseId == lastId){ | ||||
|             return lastId; | ||||
|         } | ||||
|     } | ||||
|     if(jsonIndex <= json.length && jsonIndex > 0){ | ||||
|         jsonIndex -= 1; | ||||
|         return json[jsonIndex].mockedResponseId; | ||||
|     }  | ||||
|     return defaultId; | ||||
| } | ||||
|  | ||||
| function refreshData(){ | ||||
|     fillMessageList(); | ||||
|     console.log("List initiated"); | ||||
|     loadMessage(json[jsonIndex].mockedResponseId); | ||||
|     let id = idToDisplay(); | ||||
|     console.log('Loading message of id: ' + id); | ||||
|     loadMessage(id); | ||||
|     console.log("Message loaded"); | ||||
| } | ||||
|  | ||||
| function setCookies(){ | ||||
|     document.cookie = C_UUID + '=' +clientUUID+';'; | ||||
|     document.cookie =  | ||||
|         C_UUID + '=' +clientUUID+';' | ||||
| } | ||||
|  | ||||
| function loadCookies(){ | ||||
| @@ -120,16 +140,15 @@ function updateData(){ | ||||
|     var updatedJson = generateJson(); | ||||
|     const dataSaved = function () { | ||||
|         setDataOrigin(); | ||||
|         getData(); | ||||
|         refreshData(); | ||||
|         savedModalDisplay(); | ||||
|     } | ||||
|     var request = $.ajax({ | ||||
|     $.ajax({ | ||||
|         url: host + '/mock/json', | ||||
|         type: 'PUT', | ||||
|         data: JSON.stringify(updatedJson, null, 2), | ||||
|         contentType: "application/json", | ||||
|     }); | ||||
|     request.done(dataSaved); | ||||
|     }).done(dataSaved); | ||||
| } | ||||
|  | ||||
| function callAddMessage(){ | ||||
| @@ -143,13 +162,10 @@ function callAddMessage(){ | ||||
| } | ||||
|  | ||||
| function addMessage(){ | ||||
|     var request = $.ajax({ | ||||
|     $.ajax({ | ||||
|         url: host + '/mock/json/'+clientUUID, | ||||
|         type: 'POST', | ||||
|     }); | ||||
|     request.done(function () { | ||||
|         getData(); | ||||
|     }); | ||||
|     }).done(dataRefresh); | ||||
| } | ||||
|  | ||||
| function callRemoveMessage(id){ | ||||
| @@ -164,13 +180,10 @@ function callRemoveMessage(id){ | ||||
|  | ||||
| function removeMessage(id){ | ||||
|     var jsonObject = findJsonById(id); | ||||
|     var request = $.ajax({ | ||||
|     $.ajax({ | ||||
|         url: host + '/mock/json/'+clientUUID + '/' + id, | ||||
|         type: 'DELETE', | ||||
|     }); | ||||
|     request.done(function () { | ||||
|         getData(); | ||||
|     }); | ||||
|     }).done(dataRefresh); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -300,6 +313,7 @@ function callLoadMessage(id){ | ||||
| } | ||||
|  | ||||
| function loadMessage(id){ | ||||
|     lastId = id; | ||||
|     setDataOrigin(); | ||||
|     for(let i=0; i<json.length; i++){ | ||||
|         if(id == json[i].mockedResponseId){ | ||||
| @@ -339,12 +353,12 @@ function generateMessageTileHtml(id, httpStatus, mediaType){ | ||||
|  | ||||
|  | ||||
|  | ||||
| function onbuild(){ | ||||
| const onbuild = function(){ | ||||
|     getData(); | ||||
|     sleep(1000); | ||||
| } | ||||
|  | ||||
| $(document).ready(onbuild()); | ||||
| $(document).ready(onbuild); | ||||
|  | ||||
| function sleep(ms) { | ||||
|     return new Promise(resolve => setTimeout(resolve, ms)); | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; | ||||
|  | ||||
| @Generated( | ||||
|     value = "org.mapstruct.ap.MappingProcessor", | ||||
|     date = "2021-03-02T13:29:47+0100", | ||||
|     date = "2021-03-04T12:41:49+0100", | ||||
|     comments = "version: 1.3.1.Final, compiler: javac, environment: Java 14.0.1 (Oracle Corporation)" | ||||
| ) | ||||
| @Component | ||||
|   | ||||
		Reference in New Issue
	
	Block a user