Merged widlam/refactor/issue#201 to master
This commit is contained in:
@@ -51,106 +51,35 @@ public class MockController {
|
|||||||
* Returns the full list of messages. It's used by javascript on the client side to initialize homepage
|
* Returns the full list of messages. It's used by javascript on the client side to initialize homepage
|
||||||
* with data from the database.
|
* with data from the database.
|
||||||
* @param uuidValue the key-uuid of given set of messages
|
* @param uuidValue the key-uuid of given set of messages
|
||||||
* @return responds with 200 OK and list of {@link MockedMessageDto}
|
* @return responds with 200 OK and {@link MockedMessageDto}
|
||||||
*/
|
*/
|
||||||
@GetMapping({"/", "/{uuidValue}"})
|
@GetMapping({"/", "/{uuidValue}"})
|
||||||
public List<MockedMessageDto> getListOfMessages(@PathVariable(required = false) String uuidValue){
|
public MockedMessageDto getMessage(@PathVariable(required = false) String uuidValue){
|
||||||
UUID clientUUID;
|
UUID clientUUID;
|
||||||
|
MockedMessageDto message ;
|
||||||
if(uuidValue == null || uuidValue.equals("")) clientUUID = UUID.randomUUID();
|
if(uuidValue == null || uuidValue.equals("")) clientUUID = UUID.randomUUID();
|
||||||
else clientUUID = UUID.fromString(uuidValue);
|
else clientUUID = UUID.fromString(uuidValue);
|
||||||
List<MockedMessageDto> messages = klausService.getAllMockedResponses(clientUUID);
|
message = klausService
|
||||||
if(messages.size() == 0) {
|
.getMockedMessageByClientUUID(clientUUID)
|
||||||
klausService.setMockedResponse(buildDefaultMessage(clientUUID));
|
.orElse( buildDefaultMessage(clientUUID) );
|
||||||
messages = klausService.getAllMockedResponses(clientUUID);
|
|
||||||
}
|
|
||||||
Collections.sort(messages);
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If provided UUID does not exist in database returns ResponseEntity with new generated UUID(if previous UUID is not provided),
|
|
||||||
* or old UUID(if previous UUID is provided). If provided UUID exists function returns provided UUID.
|
|
||||||
* @param givenUUIDValue the UUID client wants to check exsitance in database
|
|
||||||
* @param previousUUIDValue the previous UUID used by client(optional variable)
|
|
||||||
* @return ResponseEntity with UUID
|
|
||||||
*/
|
|
||||||
@RequestMapping(
|
|
||||||
method = RequestMethod.GET ,
|
|
||||||
path = {"/check/{givenUUIDValue}/{previousUUIDValue}",
|
|
||||||
"/check/{givenUUIDValue}"})
|
|
||||||
public ResponseEntity<String> checkUUID(
|
|
||||||
@PathVariable String givenUUIDValue
|
|
||||||
,@PathVariable(required = false) String previousUUIDValue ){
|
|
||||||
try{
|
|
||||||
UUID.fromString(givenUUIDValue);
|
|
||||||
} catch (IllegalArgumentException ex){
|
|
||||||
log.error("Wrong UUID value!");
|
|
||||||
if (previousUUIDValue == null || previousUUIDValue.equals("")){
|
|
||||||
UUID newUUID = UUID.randomUUID();
|
|
||||||
log.info("New UUID generated.");
|
|
||||||
return ResponseEntity.ok(newUUID.toString());
|
|
||||||
}
|
|
||||||
log.info("Previous UUID value restored.");
|
|
||||||
return ResponseEntity.ok(previousUUIDValue);
|
|
||||||
}
|
|
||||||
return ResponseEntity.ok(givenUUIDValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Accepts empty post request and creates new message in given set. The new message has default set of data,
|
|
||||||
* which is constructed in {@link #buildDefaultMessage(UUID, int)} method.
|
|
||||||
* @param uuidValue the key-uuid of given set of messages
|
|
||||||
* @return confirmation response with 200 OK
|
|
||||||
*/
|
|
||||||
@PostMapping("/{uuidValue}")
|
|
||||||
public ResponseEntity<String> addNewMessage(@PathVariable String uuidValue){
|
|
||||||
UUID clientUUID = UUID.fromString(uuidValue);
|
|
||||||
List<MockedMessageDto> messages = klausService.getAllMockedResponses(clientUUID);
|
|
||||||
MockedMessageDto nextMessage = buildDefaultMessage(clientUUID, findNextId(messages));
|
|
||||||
return klausService.setMockedResponse(nextMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes message of given id via client request
|
|
||||||
* @param uuidValue the key-uuid of given set of messages
|
|
||||||
* @param idValue unique id of given message
|
|
||||||
* @return after deletion the confirmation is send with status 200 OK
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{uuidValue}/{idValue}")
|
|
||||||
public ResponseEntity<String> removeMessage(@PathVariable String uuidValue,
|
|
||||||
@PathVariable String idValue){
|
|
||||||
UUID clientUUID = UUID.fromString(uuidValue);
|
|
||||||
int id = Integer.parseInt(idValue);
|
|
||||||
return klausService.deleteMockedResponse(clientUUID, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recalls {@link #buildDefaultMessage(UUID)} for message construction and sets id of message
|
|
||||||
* @param uuid the key-uuid of given set of messages
|
|
||||||
* @param id unique id of given message
|
|
||||||
* @return message with default dataset and set id
|
|
||||||
*/
|
|
||||||
private static MockedMessageDto buildDefaultMessage(UUID uuid, int id){
|
|
||||||
MockedMessageDto message = buildDefaultMessage(uuid);
|
|
||||||
message.setMockedResponseId(id);
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs message with default set of data
|
* Constructs message with default set of data
|
||||||
* @param uuid the key-uuid of given set of messages
|
* @param uuid the key-uuid of given set of messages
|
||||||
* @return message with default dataset
|
* @return message with default dataset
|
||||||
*/
|
*/
|
||||||
private static MockedMessageDto buildDefaultMessage(UUID uuid){
|
private MockedMessageDto buildDefaultMessage(UUID uuid){
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("Keep-Alive", "timeout=60");
|
headers.put("Keep-Alive", "timeout=60");
|
||||||
headers.put("Connection", "keep-alive");
|
headers.put("Connection", "keep-alive");
|
||||||
headers.put("Date", LocalDateTime.now().toString());
|
headers.put("Date", LocalDateTime.now().toString());
|
||||||
return MockedMessageDto.builder()
|
MockedMessageDto mockedMessageDto = MockedMessageDto.builder()
|
||||||
.clientUUID(uuid)
|
.clientUUID(uuid)
|
||||||
.mockedResponseId(1)
|
.contentType(MediaType.APPLICATION_XML_VALUE)
|
||||||
.mediaType(MediaType.APPLICATION_XML_VALUE)
|
|
||||||
.messageBody("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
.messageBody("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||||
"<note>\n" +
|
"<note>\n" +
|
||||||
" <to>Tove</to>\n" +
|
" <to>Tove</to>\n" +
|
||||||
@@ -161,38 +90,24 @@ public class MockController {
|
|||||||
.httpHeaders(headers)
|
.httpHeaders(headers)
|
||||||
.httpStatus(200)
|
.httpStatus(200)
|
||||||
.build();
|
.build();
|
||||||
|
klausService.setMockedResponse(mockedMessageDto);
|
||||||
|
return mockedMessageDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the highest id in the list and returns it incremented by 1
|
|
||||||
* @param messages list of messages
|
|
||||||
* @return highest id incremented by 1
|
|
||||||
*/
|
|
||||||
public static int findNextId(List<MockedMessageDto> messages) {
|
|
||||||
int highestId = 0;
|
|
||||||
for (MockedMessageDto m : messages)
|
|
||||||
highestId = highestId > m.getMockedResponseId() ? highestId : m.getMockedResponseId();
|
|
||||||
return ++highestId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's one of the most important features - the bread and butter of the Mocked Service. It's link that allows
|
* It's one of the most important features - the bread and butter of the Mocked Service. It's link that allows
|
||||||
* to receive mocked response from the server and use it to mock!
|
* to receive mocked response from the server and use it to mock!
|
||||||
* @param clientUUID the key-uuid of given set of messages
|
* @param clientUUID the key-uuid of given set of messages
|
||||||
* @param mockedResponseId unique id of given message
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/r/{clientUUID}/{mockedResponseId}")
|
@RequestMapping(value = "/r/{clientUUID}")
|
||||||
public ResponseEntity getMockedResponse(
|
public ResponseEntity getMockedResponse(
|
||||||
@PathVariable UUID clientUUID,
|
@PathVariable UUID clientUUID) {
|
||||||
@PathVariable int mockedResponseId) {
|
MockedMessageDto mockedMessageDto = klausService.getMockedResponse(clientUUID);
|
||||||
MockedMessageDto mockedMessageDto = klausService.getMockedResponse(clientUUID, mockedResponseId);
|
|
||||||
HttpHeaders httpHeaders = new HttpHeaders();
|
HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
if (mockedMessageDto.getHttpHeaders() != null) mockedMessageDto.getHttpHeaders().forEach(httpHeaders::set);
|
if (mockedMessageDto.getHttpHeaders() != null) mockedMessageDto.getHttpHeaders().forEach(httpHeaders::set);
|
||||||
httpHeaders.add("Content-Type", mockedMessageDto.getMediaType());
|
httpHeaders.add("Content-Type", mockedMessageDto.getContentType());
|
||||||
return new ResponseEntity<>(mockedMessageDto.getMessageBody(), httpHeaders,
|
return new ResponseEntity<>(mockedMessageDto.getMessageBody(), httpHeaders,
|
||||||
Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus())));
|
Objects.requireNonNull(HttpStatus.valueOf(mockedMessageDto.getHttpStatus())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.r11.tools.controller;
|
package com.r11.tools.controller;
|
||||||
|
|
||||||
import com.r11.tools.mappers.RequestHistoryMapper;
|
import com.r11.tools.mappers.RequestHistoryMapper;
|
||||||
import com.r11.tools.model.HistoryRequestModel;
|
|
||||||
import com.r11.tools.model.RequestHistory;
|
import com.r11.tools.model.RequestHistory;
|
||||||
import com.r11.tools.model.RequestHistoryDTO;
|
import com.r11.tools.model.RequestHistoryDTO;
|
||||||
import com.r11.tools.service.RequestHistoryService;
|
import com.r11.tools.service.RequestHistoryService;
|
||||||
@@ -9,9 +8,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,40 +25,14 @@ public class RequestHistoryController {
|
|||||||
private final RequestHistoryMapper mapper;
|
private final RequestHistoryMapper mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of Events in given time bracket.
|
* Returns the list of Events.
|
||||||
* The list of objects is received via {@link RequestHistoryDTO}, which contains time brackets,
|
|
||||||
* as well as the key - uuid.
|
|
||||||
* @param historyRequestModel EventRequestDto object that contains data needed to query the database
|
|
||||||
* @return list of {@link RequestHistory}
|
|
||||||
*/
|
|
||||||
@PostMapping
|
|
||||||
public ResponseEntity<List<RequestHistoryDTO>> filterHistory(@RequestBody HistoryRequestModel historyRequestModel){
|
|
||||||
return ResponseEntity.ok(
|
|
||||||
service.getHistoryRecordsBetweenDatesAndByUUIDAndMessageId(historyRequestModel)
|
|
||||||
.stream()
|
|
||||||
.map(mapper::requestHistoryToRequestHistoryDTO)
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of Events of last 24h from given date.
|
|
||||||
* @param uuid unique id of message list
|
* @param uuid unique id of message list
|
||||||
* @param messageId unique id of message in message list
|
|
||||||
* @return list of {@link RequestHistory}
|
* @return list of {@link RequestHistory}
|
||||||
*/
|
*/
|
||||||
@GetMapping(path = "/{uuid}/{messageId}")
|
@GetMapping(path = "/{uuid}")
|
||||||
public ResponseEntity<List<RequestHistoryDTO>> getLastDay(@PathVariable UUID uuid,
|
public ResponseEntity<List<RequestHistoryDTO>> getLastDay(@PathVariable String uuid){
|
||||||
@PathVariable Integer messageId){
|
List<RequestHistoryDTO> requestHistory = service.getHistoryRecordsByUUID(
|
||||||
LocalDateTime requestTime = LocalDateTime.now();
|
uuid
|
||||||
LocalDateTime dayBeforeRequest = requestTime.minusDays(1L);
|
|
||||||
List<RequestHistoryDTO> requestHistory = service.getHistoryRecordsBetweenDatesAndByUUIDAndMessageId(
|
|
||||||
HistoryRequestModel.builder()
|
|
||||||
.localDateTimeFrom(dayBeforeRequest)
|
|
||||||
.localDateTimeTo(requestTime)
|
|
||||||
.clientUUID(uuid)
|
|
||||||
.mockedResponseId(messageId)
|
|
||||||
.build()
|
|
||||||
).stream()
|
).stream()
|
||||||
.map(mapper::requestHistoryToRequestHistoryDTO)
|
.map(mapper::requestHistoryToRequestHistoryDTO)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public class IncomingMockRequestInterceptor implements HandlerInterceptor {
|
|||||||
RequestHistoryDTO historyDTO = RequestHistoryDTO.builder()
|
RequestHistoryDTO historyDTO = RequestHistoryDTO.builder()
|
||||||
.httpMethod(HttpMethod.valueOf(httpRequest.getMethod()))
|
.httpMethod(HttpMethod.valueOf(httpRequest.getMethod()))
|
||||||
.headers( headers )
|
.headers( headers )
|
||||||
.messageID(Integer.valueOf(pathVariable.get("mockedResponseId")))
|
|
||||||
.clientUUID(UUID.fromString(pathVariable.get("clientUUID")))
|
.clientUUID(UUID.fromString(pathVariable.get("clientUUID")))
|
||||||
.dateTimeStamp(LocalDateTime.now())
|
.dateTimeStamp(LocalDateTime.now())
|
||||||
.requestBody(requestBody)
|
.requestBody(requestBody)
|
||||||
|
|||||||
@@ -4,15 +4,23 @@ import com.r11.tools.model.MockedMessage;
|
|||||||
import com.r11.tools.model.MockedMessageDto;
|
import com.r11.tools.model.MockedMessageDto;
|
||||||
import org.mapstruct.*;
|
import org.mapstruct.*;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates key value for redis entry
|
* Creates key value for redis entry
|
||||||
* @author Rafał Źukowicz
|
* @author Rafał Źukowicz
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MockedMessageMapper {
|
public interface MockedMessageMapper {
|
||||||
@Mapping( target = "compositePrimaryKey", expression = "java(mockedMessageDto.getClientUUID() + \"_\"" +
|
|
||||||
" + mockedMessageDto.getMockedResponseId())")
|
|
||||||
@Mapping( target = "createdAt" , expression = "java(java.time.LocalDateTime.now())")
|
@Mapping( target = "createdAt" , expression = "java(java.time.LocalDateTime.now())")
|
||||||
MockedMessage mockedMessageDtoToMockedMessage(MockedMessageDto mockedMessageDto);
|
MockedMessage mockedMessageDtoToMockedMessage(MockedMessageDto mockedMessageDto);
|
||||||
MockedMessageDto mockedMessageToMockedMessageDto(MockedMessage mockedMessage);
|
MockedMessageDto mockedMessageToMockedMessageDto(MockedMessage mockedMessage);
|
||||||
|
|
||||||
|
default Optional<MockedMessageDto> optionalMockedMessageToOptionalMockedMessageDTO(Optional<MockedMessage> optionalMockedMessage){
|
||||||
|
return optionalMockedMessage.map(this::mockedMessageToMockedMessageDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
default Optional<MockedMessage> optionalMockedMessageDTOToOptionalMockedMessage(Optional<MockedMessageDto> optionalMockedMessageDto){
|
||||||
|
return optionalMockedMessageDto.map(this::mockedMessageDtoToMockedMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.mapstruct.Mapping;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface RequestHistoryMapper {
|
public interface RequestHistoryMapper {
|
||||||
|
|
||||||
@Mapping(target = "id", expression = "java(null)")
|
|
||||||
@Mapping(target = "clientUUID", expression = "java(requestHistoryDTO.getClientUUID().toString())")
|
@Mapping(target = "clientUUID", expression = "java(requestHistoryDTO.getClientUUID().toString())")
|
||||||
RequestHistory requestHistoryDTOToRequestHistory(RequestHistoryDTO requestHistoryDTO);
|
RequestHistory requestHistoryDTOToRequestHistory(RequestHistoryDTO requestHistoryDTO);
|
||||||
@Mapping(target = "clientUUID", expression = "java(java.util.UUID.fromString(requestHistory.getClientUUID()))")
|
@Mapping(target = "clientUUID", expression = "java(java.util.UUID.fromString(requestHistory.getClientUUID()))")
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.r11.tools.model;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents all data needed to get HistoryRecord from database
|
|
||||||
* @author Mikołaj Widła
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HistoryRequestModel {
|
|
||||||
|
|
||||||
private UUID clientUUID;
|
|
||||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
|
||||||
private LocalDateTime localDateTimeFrom;
|
|
||||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
|
||||||
private LocalDateTime localDateTimeTo;
|
|
||||||
private Integer mockedResponseId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,6 @@
|
|||||||
package com.r11.tools.model;
|
package com.r11.tools.model;
|
||||||
|
|
||||||
import com.r11.tools.model.constraints.HttpCode;
|
import com.r11.tools.model.constraints.HttpCode;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.validation.constraints.Positive;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -14,6 +9,11 @@ import org.springframework.data.annotation.Id;
|
|||||||
import org.springframework.data.redis.core.RedisHash;
|
import org.springframework.data.redis.core.RedisHash;
|
||||||
import org.springframework.data.redis.core.index.Indexed;
|
import org.springframework.data.redis.core.index.Indexed;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MockedMessage redis entity pojo
|
* MockedMessage redis entity pojo
|
||||||
* @author Rafał Żukowicz
|
* @author Rafał Żukowicz
|
||||||
@@ -24,13 +24,10 @@ import org.springframework.data.redis.core.index.Indexed;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MockedMessage implements Serializable {
|
public class MockedMessage implements Serializable {
|
||||||
@Id
|
|
||||||
private String compositePrimaryKey;
|
|
||||||
@Indexed
|
@Indexed
|
||||||
|
@Id
|
||||||
private UUID clientUUID;
|
private UUID clientUUID;
|
||||||
@Positive
|
private String contentType;
|
||||||
private Integer mockedResponseId;
|
|
||||||
private String mediaType;
|
|
||||||
private String messageBody;
|
private String messageBody;
|
||||||
private Map<String, String> httpHeaders;
|
private Map<String, String> httpHeaders;
|
||||||
@HttpCode
|
@HttpCode
|
||||||
@@ -38,5 +35,3 @@ public class MockedMessage implements Serializable {
|
|||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package com.r11.tools.model;
|
package com.r11.tools.model;
|
||||||
|
|
||||||
import com.r11.tools.model.constraints.HttpCode;
|
import com.r11.tools.model.constraints.HttpCode;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Positive;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternative version of {@link MockedMessage} used in http body
|
* Alternative version of {@link MockedMessage} used in http body
|
||||||
@@ -18,19 +17,12 @@ import lombok.*;
|
|||||||
@ToString
|
@ToString
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MockedMessageDto implements Serializable, Comparable<MockedMessageDto> {
|
public class MockedMessageDto implements Serializable{
|
||||||
private UUID clientUUID;
|
private UUID clientUUID;
|
||||||
@NotNull
|
private String contentType;
|
||||||
@Positive
|
|
||||||
private Integer mockedResponseId;
|
|
||||||
private String mediaType;
|
|
||||||
private String messageBody;
|
private String messageBody;
|
||||||
private Map<String, String> httpHeaders;
|
private Map<String, String> httpHeaders;
|
||||||
@HttpCode
|
@HttpCode
|
||||||
private Integer httpStatus;
|
private Integer httpStatus;
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(MockedMessageDto message) {
|
|
||||||
return this.mockedResponseId > message.getMockedResponseId() ? 1 : -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,15 +25,12 @@ import java.util.Map;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RedisHash("mockHistory")
|
@RedisHash("mockHistory")
|
||||||
public class RequestHistory implements Comparable<RequestHistory>, Serializable {
|
public class RequestHistory implements Comparable<RequestHistory>, Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-ddTHH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-ddTHH:mm:ss")
|
||||||
private LocalDateTime dateTimeStamp;
|
private LocalDateTime dateTimeStamp;
|
||||||
@Indexed
|
@Indexed
|
||||||
private String clientUUID;
|
private String clientUUID;
|
||||||
@Indexed
|
|
||||||
private Integer messageID;
|
|
||||||
private Map<String,String> headers;
|
private Map<String,String> headers;
|
||||||
private HttpMethod httpMethod;
|
private HttpMethod httpMethod;
|
||||||
private String requestBody;
|
private String requestBody;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ public class RequestHistoryDTO {
|
|||||||
private UUID clientUUID;
|
private UUID clientUUID;
|
||||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
||||||
private LocalDateTime dateTimeStamp;
|
private LocalDateTime dateTimeStamp;
|
||||||
private Integer messageID;
|
|
||||||
private Map<String,String> headers;
|
private Map<String,String> headers;
|
||||||
private HttpMethod httpMethod;
|
private HttpMethod httpMethod;
|
||||||
private String requestBody;
|
private String requestBody;
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
@Transactional
|
@Transactional
|
||||||
public interface MockedResponseRepository extends CrudRepository<MockedMessage, String> {
|
public interface MockedResponseRepository extends CrudRepository<MockedMessage, UUID> {
|
||||||
/**
|
/**
|
||||||
* Finds all messages by their uuid
|
* Finds all messages by their uuid
|
||||||
* @param clientUUID the key-uuid of given set of messages
|
* @param clientUUID the key-uuid of given set of messages
|
||||||
* @return Optional of list of {@link com.r11.tools.model.MockedMessage}
|
* @return Optional of list of {@link com.r11.tools.model.MockedMessage}
|
||||||
*/
|
*/
|
||||||
Optional<List<MockedMessage>> findAllByClientUUID(UUID clientUUID);
|
Optional<MockedMessage> findAllByClientUUID(UUID clientUUID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,5 @@ import java.util.List;
|
|||||||
@Repository
|
@Repository
|
||||||
@Transactional
|
@Transactional
|
||||||
public interface RequestHistoryRepository extends CrudRepository<RequestHistory,String> {
|
public interface RequestHistoryRepository extends CrudRepository<RequestHistory,String> {
|
||||||
List<RequestHistory> findAllByClientUUIDAndMessageID(
|
List<RequestHistory> findAllByClientUUID(String clientUUID);
|
||||||
String clientUUID,
|
|
||||||
Integer messageID);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.r11.tools.service;
|
package com.r11.tools.service;
|
||||||
|
|
||||||
import com.r11.tools.model.MockedMessageDto;
|
import com.r11.tools.model.MockedMessageDto;
|
||||||
import java.util.List;
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -12,8 +13,7 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public interface KlausService {
|
public interface KlausService {
|
||||||
ResponseEntity<String> deleteMockedResponse(UUID clientUUID, int mockedResponseId);
|
Optional<MockedMessageDto> getMockedMessageByClientUUID(UUID clientUUID);
|
||||||
List<MockedMessageDto> getAllMockedResponses(UUID clientUUID);
|
MockedMessageDto getMockedResponse(UUID clientUUID);
|
||||||
MockedMessageDto getMockedResponse(UUID clientUUID, int mockedResponseId);
|
|
||||||
ResponseEntity<String> setMockedResponse(MockedMessageDto mockedMessageDto);
|
ResponseEntity<String> setMockedResponse(MockedMessageDto mockedMessageDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,15 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for {@link com.r11.tools.controller.MockController} and {@link com.r11.tools.controller.MockController}
|
* Service for {@link com.r11.tools.controller.MockController} and {@link com.r11.tools.controller.MockController}
|
||||||
* Allows for performing CRUD operations on {@link MockedMessageDto}
|
* Allows for performing CRUD operations on {@link MockedMessageDto}
|
||||||
* @author Rafał Żukowicz
|
* @author Rafał Żukowicz
|
||||||
* @author Gabriel Modzelewski
|
* @author Gabriel Modzelewski
|
||||||
|
* @author Mikołaj Widła
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -31,20 +30,6 @@ public class KlausServiceImpl implements KlausService {
|
|||||||
private final Logger log = LogManager.getRootLogger();
|
private final Logger log = LogManager.getRootLogger();
|
||||||
private final MockedResponseRepository mockedResponseRepository;
|
private final MockedResponseRepository mockedResponseRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes message of given id in given key-uuid set
|
|
||||||
* @param clientUUID the key-uuid of given set of messages
|
|
||||||
* @param mockedResponseId unique id of given message
|
|
||||||
* @return confirmation and status 200 OK
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> deleteMockedResponse(UUID clientUUID, int mockedResponseId) {
|
|
||||||
String key = clientUUID.toString() + "_" + mockedResponseId;
|
|
||||||
mockedResponseRepository.deleteById(key);
|
|
||||||
log.info("Message: "+mockedResponseId+" has been removed.");
|
|
||||||
return new ResponseEntity<>("MockedResponse has been removed successfully",
|
|
||||||
new HttpHeaders(), HttpStatus.ACCEPTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all messages of given key-uuid
|
* Returns all messages of given key-uuid
|
||||||
@@ -52,28 +37,23 @@ public class KlausServiceImpl implements KlausService {
|
|||||||
* @return List of {@link MockedMessageDto}
|
* @return List of {@link MockedMessageDto}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MockedMessageDto> getAllMockedResponses(UUID clientUUID){
|
public Optional<MockedMessageDto> getMockedMessageByClientUUID(UUID clientUUID){
|
||||||
Optional<List<MockedMessage>> listOptional = mockedResponseRepository.findAllByClientUUID(clientUUID);
|
Optional<MockedMessage> mockedMessageOptional = mockedResponseRepository.findAllByClientUUID(clientUUID);
|
||||||
log.info("Messages for UUID: "+clientUUID+" has been fetched from DB.");
|
log.info("Message for UUID: "+clientUUID+" has been fetched from DB.");
|
||||||
return listOptional.map(mockedMessages -> mockedMessages.stream()
|
return mockedMessageMapper.optionalMockedMessageToOptionalMockedMessageDTO(mockedMessageOptional);
|
||||||
.map(mockedMessageMapper::mockedMessageToMockedMessageDto)
|
|
||||||
.collect(Collectors.toList())).orElse(List.of());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link MockedMessageDto} of given id and key-uuid. If message doesn't then empty message is returned
|
* Returns {@link MockedMessageDto} of given id and key-uuid. If message doesn't then empty message is returned
|
||||||
* @param clientUUID the key-uuid of given set of messages
|
* @param clientUUID the key-uuid of given set of messages
|
||||||
* @param mockedResponseId unique id of given message
|
|
||||||
* @return {@link MockedMessageDto} object
|
* @return {@link MockedMessageDto} object
|
||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public MockedMessageDto getMockedResponse(UUID clientUUID, int mockedResponseId){
|
public MockedMessageDto getMockedResponse(UUID clientUUID){
|
||||||
String key = clientUUID.toString() + "_" + mockedResponseId;
|
Optional<MockedMessage> optionalMockedMessage = mockedResponseRepository.findById(clientUUID);
|
||||||
Optional<MockedMessage> optionalMockedMessage = mockedResponseRepository.findById(key);
|
|
||||||
MockedMessageDto mockedMessageDto = MockedMessageDto.builder()
|
MockedMessageDto mockedMessageDto = MockedMessageDto.builder()
|
||||||
.clientUUID(clientUUID)
|
.clientUUID(clientUUID)
|
||||||
.mockedResponseId(mockedResponseId)
|
|
||||||
.build();
|
.build();
|
||||||
if (optionalMockedMessage.isPresent()) {
|
if (optionalMockedMessage.isPresent()) {
|
||||||
mockedMessageDto = mockedMessageMapper.mockedMessageToMockedMessageDto(optionalMockedMessage.get());
|
mockedMessageDto = mockedMessageMapper.mockedMessageToMockedMessageDto(optionalMockedMessage.get());
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.r11.tools.service;
|
package com.r11.tools.service;
|
||||||
|
|
||||||
import com.r11.tools.controller.RequestHistoryController;
|
import com.r11.tools.controller.RequestHistoryController;
|
||||||
import com.r11.tools.model.HistoryRequestModel;
|
|
||||||
import com.r11.tools.model.RequestHistory;
|
import com.r11.tools.model.RequestHistory;
|
||||||
import com.r11.tools.model.RequestHistoryDTO;
|
import com.r11.tools.model.RequestHistoryDTO;
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring service interface for {@link RequestHistoryController}
|
* Spring service interface for {@link RequestHistoryController}
|
||||||
* @author Rafał Żukowicz
|
* @author Rafał Żukowicz
|
||||||
@@ -15,9 +15,9 @@ import org.springframework.stereotype.Service;
|
|||||||
public interface RequestHistoryService {
|
public interface RequestHistoryService {
|
||||||
/**
|
/**
|
||||||
* Searches for {@link RequestHistory} objects between date brackets
|
* Searches for {@link RequestHistory} objects between date brackets
|
||||||
* @param historyRequestModel object containing required data for request
|
* @param uuid user uuid
|
||||||
* @return list of {@link RequestHistory}
|
* @return list of {@link RequestHistory}
|
||||||
*/
|
*/
|
||||||
List<RequestHistory> getHistoryRecordsBetweenDatesAndByUUIDAndMessageId(HistoryRequestModel historyRequestModel);
|
List<RequestHistory> getHistoryRecordsByUUID(String uuid);
|
||||||
void saveRequest(RequestHistoryDTO requestDTO);
|
void saveRequest(RequestHistoryDTO requestDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.r11.tools.service;
|
|||||||
|
|
||||||
import com.r11.tools.controller.RequestHistoryController;
|
import com.r11.tools.controller.RequestHistoryController;
|
||||||
import com.r11.tools.mappers.RequestHistoryMapper;
|
import com.r11.tools.mappers.RequestHistoryMapper;
|
||||||
import com.r11.tools.model.HistoryRequestModel;
|
|
||||||
import com.r11.tools.model.RequestHistory;
|
import com.r11.tools.model.RequestHistory;
|
||||||
import com.r11.tools.model.RequestHistoryDTO;
|
import com.r11.tools.model.RequestHistoryDTO;
|
||||||
import com.r11.tools.repository.RequestHistoryRepository;
|
import com.r11.tools.repository.RequestHistoryRepository;
|
||||||
@@ -11,7 +10,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Service for {@link RequestHistoryController}. Contains logic required for quering
|
* Spring Service for {@link RequestHistoryController}. Contains logic required for quering
|
||||||
@@ -26,29 +24,11 @@ public class RequestHistoryServiceImpl implements RequestHistoryService {
|
|||||||
private final RequestHistoryRepository repository;
|
private final RequestHistoryRepository repository;
|
||||||
private final RequestHistoryMapper requestMapper;
|
private final RequestHistoryMapper requestMapper;
|
||||||
|
|
||||||
/**
|
|
||||||
* in order to create query via{@link com.r11.tools.repository.RequestHistoryRepository}
|
|
||||||
* @param historyRequestModel object containing required data for request
|
|
||||||
* @return list of {@link RequestHistory}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<RequestHistory> getHistoryRecordsBetweenDatesAndByUUIDAndMessageId(HistoryRequestModel historyRequestModel) {
|
public List<RequestHistory> getHistoryRecordsByUUID(String uuid) {
|
||||||
List<RequestHistory> history = repository.findAllByClientUUIDAndMessageID(
|
List<RequestHistory> history = repository.findAllByClientUUID(uuid);
|
||||||
historyRequestModel.getClientUUID().toString(),
|
|
||||||
historyRequestModel.getMockedResponseId()
|
|
||||||
);
|
|
||||||
Collections.sort(history);
|
Collections.sort(history);
|
||||||
|
return history;
|
||||||
return history.stream()
|
|
||||||
.filter( historyRecord -> historyRecord
|
|
||||||
.getDateTimeStamp()
|
|
||||||
.isAfter(historyRequestModel.getLocalDateTimeFrom())
|
|
||||||
).filter(
|
|
||||||
historyRecord-> historyRecord
|
|
||||||
.getDateTimeStamp()
|
|
||||||
.isBefore(historyRequestModel.getLocalDateTimeTo())
|
|
||||||
)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -63,10 +63,6 @@ body {
|
|||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tool.extended .tool-context {
|
|
||||||
width: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tool.extended .tool-extention {
|
.tool.extended .tool-extention {
|
||||||
width: 20%;
|
width: 20%;
|
||||||
padding-top: 2%;
|
padding-top: 2%;
|
||||||
|
|||||||
@@ -83,12 +83,21 @@ function changeActiveTools(activeCategoryButton) {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function changeTool(tool) {
|
function changeTool(tool) {
|
||||||
if (tools.has(tool)) {
|
if (! tools.has(tool)) return;
|
||||||
const url = tools.get(tool);
|
const url = tools.get(tool);
|
||||||
document.location.search = tool + "/";
|
|
||||||
localStorage.setItem("lastPage", tool);
|
localStorage.setItem("lastPage", tool);
|
||||||
document.getElementById("iframe").src = url;
|
|
||||||
|
switch (tool) { // XML category is default.
|
||||||
|
case "jsonform":
|
||||||
|
changeActiveTools('JSON');
|
||||||
|
break;
|
||||||
|
case "mock":
|
||||||
|
changeActiveTools('REST');
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
document.location.search = tool;
|
||||||
|
document.getElementById("iframe").src = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,15 +113,5 @@ function loadLastPage() {
|
|||||||
if (lastPage == null) {
|
if (lastPage == null) {
|
||||||
lastPage = "xpath";
|
lastPage = "xpath";
|
||||||
}
|
}
|
||||||
|
changeTool(lastPage);
|
||||||
switch (lastPage) { // XML category is default.
|
|
||||||
case "jsonform":
|
|
||||||
changeActiveTools('JSON');
|
|
||||||
break;
|
|
||||||
case "mock":
|
|
||||||
changeActiveTools('REST');
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
document.getElementById("iframe").src = tools.get(lastPage);
|
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,9 @@ var clientUUID = '';
|
|||||||
var advancedDisplayed = false;
|
var advancedDisplayed = false;
|
||||||
var json = {};
|
var json = {};
|
||||||
var jsonIndex = 0;
|
var jsonIndex = 0;
|
||||||
var lastId = 1;
|
|
||||||
var htable_row = 0;
|
|
||||||
var host = window.location.protocol + "//" + window.location.hostname + "/mock";
|
var host = window.location.protocol + "//" + window.location.hostname + "/mock";
|
||||||
var dataModified = false;
|
|
||||||
const addMessageName = 'addMessage';
|
|
||||||
const loadMessageName = 'changeMessage';
|
|
||||||
const removeMessageName = 'removeMessage';
|
|
||||||
|
|
||||||
const C_UUID = 'mock-uuid';
|
const C_UUID = 'mock-uuid';
|
||||||
const C_ID = 'last-displayed-id';
|
|
||||||
const C_ADV = 'advanced-mode';
|
const C_ADV = 'advanced-mode';
|
||||||
|
|
||||||
const color_red = "#ff8f8f";
|
const color_red = "#ff8f8f";
|
||||||
@@ -20,9 +13,6 @@ const color_grey = "#6b6b6b";
|
|||||||
const setModified = function(){
|
const setModified = function(){
|
||||||
setDataModified();
|
setDataModified();
|
||||||
}
|
}
|
||||||
const setOrigin = function(){
|
|
||||||
setDataOrigin();
|
|
||||||
}
|
|
||||||
|
|
||||||
const getUpdate = function(){
|
const getUpdate = function(){
|
||||||
updateData();
|
updateData();
|
||||||
@@ -30,35 +20,71 @@ const getUpdate = function(){
|
|||||||
const dataRefresh = function(){
|
const dataRefresh = function(){
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
$('#btn-newtile').click(function(){callAddMessage()});
|
|
||||||
// $('#btn-addRow').click(function(){addRow()});
|
/*
|
||||||
// $('#btn-save').click(getUpdate);
|
Listeners segment
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).on('change', '.data-field', setModified);
|
||||||
|
|
||||||
|
$('#btn-save').click(
|
||||||
|
() => {
|
||||||
|
disableSaveButton();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$('#btn-newRow').click(
|
||||||
|
()=> {
|
||||||
|
newRowInput();
|
||||||
|
setDataModified();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Functions segment
|
||||||
|
*/
|
||||||
|
|
||||||
|
function disableSaveButton(){
|
||||||
|
$('#btn-save').removeClass('active');
|
||||||
|
$('#btn-save').off();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createLink(uuid){
|
||||||
|
var link = host + '/api/mock/r/'+uuid;
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onLoad(){
|
||||||
|
loadCookies();
|
||||||
|
getData();
|
||||||
|
}
|
||||||
|
|
||||||
function getData(){
|
function getData(){
|
||||||
$.getJSON(host + '/api/mock/'+clientUUID, function(data) {
|
$.getJSON(host + '/api/mock/'+clientUUID, function(data) {
|
||||||
json = data;
|
json = data;
|
||||||
checkUuid();
|
loadFetchedMessage();
|
||||||
|
initializeUUID();
|
||||||
|
|
||||||
refreshData();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadCookies(){
|
||||||
|
clientUUID = getCookie(C_UUID);
|
||||||
|
advancedDisplayed = getCookie(C_ADV) == 'true';
|
||||||
|
}
|
||||||
|
|
||||||
function checkUuid(){
|
function setCookie(){
|
||||||
|
document.cookie = C_UUID + '=' +clientUUID;
|
||||||
|
document.cookie = C_ADV + '=' + advancedVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeUUID(){
|
||||||
if(clientUUID == null || clientUUID == undefined || clientUUID == ''){
|
if(clientUUID == null || clientUUID == undefined || clientUUID == ''){
|
||||||
clientUUID = json[0].clientUUID;
|
clientUUID = json.clientUUID;
|
||||||
setCookie();
|
setCookie();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDomain(){
|
|
||||||
var url = window.location.href;
|
|
||||||
var arr = url.split("/");
|
|
||||||
var result = arr[0] + "//" + arr[2];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function httpStatusInvalid(){
|
function httpStatusInvalid(){
|
||||||
value = $('#httpStatus').val();
|
value = $('#httpStatus').val();
|
||||||
return value == '';
|
return value == '';
|
||||||
@@ -71,58 +97,11 @@ function setDataModified(){
|
|||||||
document.getElementById("httpStatus").style.backgroundColor = color_red;
|
document.getElementById("httpStatus").style.backgroundColor = color_red;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataModified = true;
|
|
||||||
$('#btn-save').addClass('active');
|
$('#btn-save').addClass('active');
|
||||||
$('#btn-save').click(getUpdate);
|
$('#btn-save').click(getUpdate);
|
||||||
document.getElementById("httpStatus").style.backgroundColor = null;
|
document.getElementById("httpStatus").style.backgroundColor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Adding change listener to fields
|
|
||||||
$('.data-field').change(setModified);
|
|
||||||
|
|
||||||
function setDataOrigin(){
|
|
||||||
dataModified = false;
|
|
||||||
$('#btn-save').removeClass('active');
|
|
||||||
$('#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(){
|
|
||||||
$("#uuid-input").val(clientUUID);
|
|
||||||
fillMessageList();
|
|
||||||
|
|
||||||
let id = idToDisplay();
|
|
||||||
|
|
||||||
loadMessage(id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCookie(){
|
|
||||||
document.cookie = C_UUID + '=' +clientUUID;
|
|
||||||
document.cookie = C_ID + '=' + lastId;
|
|
||||||
document.cookie = C_ADV + '=' + advancedVisibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadCookies(){
|
|
||||||
clientUUID = getCookie(C_UUID);
|
|
||||||
lastId = getCookie(C_ID);
|
|
||||||
advancedDisplayed = getCookie(C_ADV) == 'true';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCookie(cname) {
|
function getCookie(cname) {
|
||||||
var name = cname + '=';
|
var name = cname + '=';
|
||||||
var decodedCookie = decodeURIComponent(document.cookie);
|
var decodedCookie = decodeURIComponent(document.cookie);
|
||||||
@@ -139,28 +118,10 @@ function getCookie(cname) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function callMethodByName(methodObject){
|
|
||||||
let name = methodObject.name;
|
|
||||||
let id = methodObject.id;
|
|
||||||
switch(name){
|
|
||||||
case addMessageName:
|
|
||||||
addMessage();
|
|
||||||
break;
|
|
||||||
case loadMessageName:
|
|
||||||
loadMessage(id);
|
|
||||||
break;
|
|
||||||
case removeMessageName:
|
|
||||||
removeMessage(id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function updateData(){
|
function updateData(){
|
||||||
var updatedJson = generateJson();
|
var updatedJson = createRequestBody();
|
||||||
const dataSaved = function () {
|
const dataSaved = function () {
|
||||||
setDataOrigin();
|
loadFetchedMessage();
|
||||||
refreshData();
|
|
||||||
savedModalDisplay();
|
savedModalDisplay();
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -169,159 +130,27 @@ function updateData(){
|
|||||||
data: JSON.stringify(updatedJson, null, 2),
|
data: JSON.stringify(updatedJson, null, 2),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
}).done(dataSaved);
|
}).done(dataSaved);
|
||||||
|
disableSaveButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
function callAddMessage(){
|
function loadFetchedMessage(){
|
||||||
if(dataModified){
|
fillStaticFields(
|
||||||
setMethodToCall(addMessageName, null);
|
json.clientUUID,
|
||||||
dataLossModalDisplay();
|
json.contentType,
|
||||||
}
|
json.messageBody,
|
||||||
else {
|
json.httpStatus);
|
||||||
addMessage();
|
fillHeaderTable(json.httpHeaders);
|
||||||
}
|
initializeHistory();
|
||||||
|
refreshHeaderTable(document.innerHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMessage(){
|
function fillStaticFields(uuid, contentType, body, httpStatus){
|
||||||
$.ajax({
|
let link = createLink(uuid);
|
||||||
url: host + '/api/mock/'+clientUUID,
|
|
||||||
type: 'POST',
|
|
||||||
}).done(dataRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callRemoveMessage(id){
|
|
||||||
if(dataModified){
|
|
||||||
setMethodToCall(removeMessageName, id);
|
|
||||||
dataLossModalDisplay();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
removeMessage(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeMessage(id){
|
|
||||||
var jsonObject = findJsonById(id);
|
|
||||||
$.ajax({
|
|
||||||
url: host + '/api/mock/'+clientUUID + '/' + id,
|
|
||||||
type: 'DELETE',
|
|
||||||
}).done(dataRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function clearMock(){
|
|
||||||
fillStaticFields('','','','');
|
|
||||||
htable_row = 0;
|
|
||||||
$('#httpStatusValues').html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeMock(index){
|
|
||||||
clearMock();
|
|
||||||
fillStaticFields(json[index].clientUUID
|
|
||||||
, json[index].mockedResponseId
|
|
||||||
, json[index].mediaType
|
|
||||||
, json[index].messageBody
|
|
||||||
, json[index].httpStatus);
|
|
||||||
fillHeaderTable(json[index].httpHeaders);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillStaticFields(uuid, id, mediaType, body, httpStatus){
|
|
||||||
let link = createLink(uuid,id);
|
|
||||||
let linkHtml = '<a class="hyperlink" target="_blank" href="'+link+'">'+link+'</a>';
|
let linkHtml = '<a class="hyperlink" target="_blank" href="'+link+'">'+link+'</a>';
|
||||||
$('#messageLink').html(linkHtml);
|
$('#messageLink').html(linkHtml);
|
||||||
$('#httpStatus').val(httpStatus);
|
$('#httpStatus').val(httpStatus);
|
||||||
$('#uuid-input').val(uuid);
|
$('#typeSelector').val(contentType);
|
||||||
$('#typeSelector').val(mediaType);
|
|
||||||
$('#bodyEditor').val(body);
|
$('#bodyEditor').val(body);
|
||||||
$('#mockedMessageId').html(id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeEditionOfUUID(element){
|
|
||||||
|
|
||||||
var inputFieldId= "#uuid-input"
|
|
||||||
var inputFieldDiv = "#uuid-edit-field"
|
|
||||||
if(element.checked){
|
|
||||||
$(inputFieldId).removeAttr('disabled');
|
|
||||||
$(inputFieldDiv).removeClass('disabled');
|
|
||||||
} else{
|
|
||||||
$(inputFieldId).attr('disabled', true);
|
|
||||||
$(inputFieldDiv).addClass('disabled');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyUUIDToClipboard(){
|
|
||||||
navigator.clipboard.writeText( document.getElementById('uuid-input').value );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function fetchUUIDCheck(givenUUID , strategy){
|
|
||||||
var newUUID = "UUID" ;
|
|
||||||
url = host + "/api/mock/check/";
|
|
||||||
|
|
||||||
switch(strategy){
|
|
||||||
case "new":{
|
|
||||||
await fetch(url + givenUUID+ "/", { method : "GET" })
|
|
||||||
.then ( response => response.text() )
|
|
||||||
.then ( data => {
|
|
||||||
newUUID = data;
|
|
||||||
|
|
||||||
} )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "restore":{
|
|
||||||
await fetch(url + givenUUID + "/" + clientUUID + "/" , { method: "GET" })
|
|
||||||
.then (response => response.text() )
|
|
||||||
.then (data => {
|
|
||||||
newUUID = data;
|
|
||||||
|
|
||||||
} )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newUUID ;
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkUUIDChars(uuid) {
|
|
||||||
uuid.replace(/ /g,'')
|
|
||||||
const regex = new RegExp("^[A-z0-9-]+$");
|
|
||||||
|
|
||||||
if(regex.test(uuid) && uuid != ""){
|
|
||||||
return uuid ;
|
|
||||||
}
|
|
||||||
return "invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeUUID(element){
|
|
||||||
|
|
||||||
const uuidStrategy = $('input[name="uuid-validation-type"]:checked').val();
|
|
||||||
const givenUUID = checkUUIDChars(element.value);
|
|
||||||
|
|
||||||
if( givenUUID == clientUUID ){
|
|
||||||
$("#uuid-input").attr("disabled", true);
|
|
||||||
uuidChangeModalDisplay("noChg");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newUUID = fetchUUIDCheck(givenUUID , uuidStrategy);
|
|
||||||
var changeMessage = uuidStrategy;
|
|
||||||
newUUID
|
|
||||||
.then( data => {
|
|
||||||
if (givenUUID == data) {
|
|
||||||
changeMessage = "success";
|
|
||||||
}
|
|
||||||
clientUUID = data;
|
|
||||||
$("#editable").attr("checked", false);
|
|
||||||
|
|
||||||
uuidChangeModalDisplay(changeMessage);
|
|
||||||
document.cookie = C_UUID + '=' + data ;
|
|
||||||
} )
|
|
||||||
loadCookies();
|
|
||||||
refreshData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function createLink(uuid, id){
|
|
||||||
var link = host + '/api/mock/r/'+uuid+'/'+id;
|
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillHeaderTable(headers){
|
function fillHeaderTable(headers){
|
||||||
@@ -331,10 +160,9 @@ function fillHeaderTable(headers){
|
|||||||
|
|
||||||
function refreshHeaderTable(html){
|
function refreshHeaderTable(html){
|
||||||
$('#headerMapTable').html(html);
|
$('#headerMapTable').html(html);
|
||||||
$('.table-map').change(function(){setDataModified()});
|
|
||||||
$('.btn-hashmap').click(function(){
|
$('.btn-hashmap').click(function(){
|
||||||
$(this).closest('tr').remove();
|
|
||||||
setDataModified();
|
setDataModified();
|
||||||
|
$(this).closest('tr').remove();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,19 +181,16 @@ function addRow(key, value){
|
|||||||
refreshHeaderTable(headersMapHtml);
|
refreshHeaderTable(headersMapHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newRowInput = function(){
|
function newRowInput(){
|
||||||
const hName = $('#headerKeyInput');
|
const hName = $('#headerKeyInput');
|
||||||
const hValue = $('#headerValueInput');
|
const hValue = $('#headerValueInput');
|
||||||
if(checkIfInputValid(hName.val()) && checkIfInputValid(hValue.val())){
|
if(checkIfInputValid(hName.val()) && checkIfInputValid(hValue.val())){
|
||||||
addRow(hName.val(), hValue.val());
|
addRow(hName.val(), hValue.val());
|
||||||
hName.val(null);
|
hName.val(null);
|
||||||
hValue.val(null);
|
hValue.val(null);
|
||||||
setDataModified();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#btn-newRow').click(newRowInput);
|
|
||||||
|
|
||||||
function checkIfInputValid(input){
|
function checkIfInputValid(input){
|
||||||
return !(input == '' || input == null || input == undefined);
|
return !(input == '' || input == null || input == undefined);
|
||||||
}
|
}
|
||||||
@@ -396,134 +221,22 @@ function buildRowHtml(key, value){
|
|||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fillMessageList(){
|
|
||||||
$("#listItems").html('');
|
|
||||||
var innerHTML = '';
|
|
||||||
for(let i=0; i<json.length; i++){
|
|
||||||
innerHTML += generateMessageTileHtml(json[i].mockedResponseId, json[i].httpStatus, json[i].mediaType);
|
|
||||||
}
|
|
||||||
$("#listItems").append(innerHTML);
|
|
||||||
$('.tile').click(function(e) {
|
|
||||||
var element = $(this);
|
|
||||||
var button = element.find('.btn-tile').children().get(0);
|
|
||||||
|
|
||||||
if(!(button == e.target)){
|
|
||||||
|
|
||||||
callLoadMessage(parseInt($(this).attr('tileid')));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('.btn-tile').click(function(){
|
|
||||||
//
|
|
||||||
callRemoveMessage($(this).closest('.tile').attr('tileId'));
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function findJsonById(id){
|
|
||||||
return json[findJsonIndexById(id)];
|
|
||||||
}
|
|
||||||
|
|
||||||
function findJsonIndexById(id){
|
|
||||||
for(let i=0; i<json.length; i++)
|
|
||||||
if(id == json[i].mockedResponseId) return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callLoadMessage(id){
|
|
||||||
if(dataModified) {
|
|
||||||
setMethodToCall(loadMessageName, id);
|
|
||||||
dataLossModalDisplay();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
loadMessage(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadMessage(id){
|
|
||||||
if(id == null || id == undefined){
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lastId = id;
|
|
||||||
setCookie();
|
|
||||||
setDataOrigin();
|
|
||||||
for(let i=0; i<json.length; i++){
|
|
||||||
|
|
||||||
if(id == json[i].mockedResponseId){
|
|
||||||
jsonIndex = i;
|
|
||||||
|
|
||||||
initializeMock(jsonIndex);
|
|
||||||
|
|
||||||
selectMessage(id);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function selectMessage(id){
|
|
||||||
const tiles = $('.tile');
|
|
||||||
|
|
||||||
tiles.removeClass("active");
|
|
||||||
|
|
||||||
$('.tile[tileid="'+id+'"]').addClass("active");
|
|
||||||
|
|
||||||
initializeHistory();
|
|
||||||
refreshHeaderTable(document.innerHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function generateMessageTileHtml(id, httpStatus, mediaType){
|
|
||||||
var innerHTML = '' +
|
|
||||||
'<div tileid="' + id + '" class="tile">' +
|
|
||||||
'<div class="content">' +
|
|
||||||
'<div class="display-space-between">' +
|
|
||||||
'<div class="centered-vertically">' +
|
|
||||||
'<p>Id: ' + id + '</p>' +
|
|
||||||
'<p>Status: ' + httpStatus + '</p>' +
|
|
||||||
'</div>' +
|
|
||||||
'<div>' +
|
|
||||||
'<button class="modification-button btn-tile"><i class="icon-cancel"></i></button>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>';
|
|
||||||
return innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const onbuild = function(){
|
|
||||||
loadCookies();
|
|
||||||
getData();
|
|
||||||
if(advancedDisplayed) {
|
|
||||||
changeAdvancedVisibility();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(onbuild);
|
|
||||||
|
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createRequestBody(){
|
||||||
|
|
||||||
function generateJson(){
|
|
||||||
var newJson =
|
var newJson =
|
||||||
{
|
{
|
||||||
clientUUID: json[jsonIndex].clientUUID,
|
clientUUID: json.clientUUID,
|
||||||
mockedResponseId: json[jsonIndex].mockedResponseId,
|
contentType: $('#typeSelector').val(),
|
||||||
mediaType: $('#typeSelector').val(),
|
|
||||||
messageBody: $('#bodyEditor').val(),
|
messageBody: $('#bodyEditor').val(),
|
||||||
httpStatus: $('#httpStatus').val(),
|
httpStatus: $('#httpStatus').val(),
|
||||||
httpHeaders: {},
|
httpHeaders: {},
|
||||||
};
|
};
|
||||||
newJson['httpHeaders'] = convertTableToJson();
|
newJson['httpHeaders'] = convertTableToJson();
|
||||||
|
|
||||||
json[jsonIndex] = newJson;
|
json = newJson;
|
||||||
return newJson;
|
return newJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,8 @@
|
|||||||
var historyJson = {};
|
var historyJson = {};
|
||||||
const maxIterations = 200;
|
const maxIterations = 200;
|
||||||
|
|
||||||
function filterHistory(){
|
function getHistoryData(){
|
||||||
var dateFrom = new Date($('#historyFrom').val() + 'T' + $('#historyTimeFrom').val());
|
$.getJSON(host + '/api/event/' + clientUUID, function(data){
|
||||||
|
|
||||||
var dateTo = new Date($('#historyTo').val() + 'T' + $('#historyTimeTo').val());
|
|
||||||
|
|
||||||
loadHistory(dateFrom, dateTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
const startSearch = function(){
|
|
||||||
filterHistory();
|
|
||||||
}
|
|
||||||
$('#btn-searchHistory').click(startSearch);
|
|
||||||
|
|
||||||
function loadHistory(dateFrom, dateTo){
|
|
||||||
|
|
||||||
var eventRequest = {
|
|
||||||
clientUUID : json[jsonIndex].clientUUID,
|
|
||||||
localDateTimeFrom : dateFrom,
|
|
||||||
localDateTimeTo : dateTo,
|
|
||||||
mockedResponseId : json[jsonIndex].mockedResponseId
|
|
||||||
};
|
|
||||||
$.ajax({
|
|
||||||
url: host + '/api/event',
|
|
||||||
type: 'POST',
|
|
||||||
data: JSON.stringify(eventRequest, null, 2),
|
|
||||||
contentType: "application/json"
|
|
||||||
}).done(function(data){
|
|
||||||
historyJson = data;
|
|
||||||
displayHistory();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLast24hHistoryData(){
|
|
||||||
$.getJSON(host + '/api/event/' + clientUUID + '/' + lastId, function(data){
|
|
||||||
historyJson = data;
|
historyJson = data;
|
||||||
displayHistory();
|
displayHistory();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function showHistory(){
|
|||||||
|
|
||||||
function initializeHistory(){
|
function initializeHistory(){
|
||||||
historyFilter.removeClass('active');
|
historyFilter.removeClass('active');
|
||||||
getLast24hHistoryData();
|
getHistoryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHeaders(){
|
function showHeaders(){
|
||||||
@@ -60,9 +60,9 @@ function showHeaders(){
|
|||||||
$('#headersTab').off('click');
|
$('#headersTab').off('click');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHeadersHistory(element){
|
function showHeadersHistory(record){
|
||||||
historyTable = '';
|
historyTable = '';
|
||||||
headers = parseHeaders(element.id)
|
headers = parseHeaders(record.id)
|
||||||
headers.forEach(
|
headers.forEach(
|
||||||
(value,key) => {
|
(value,key) => {
|
||||||
historyTable +=
|
historyTable +=
|
||||||
@@ -176,7 +176,7 @@ function focusOutTip(element){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function refreshHistoryRecords(){
|
function refreshHistoryRecords(){
|
||||||
getLast24hHistoryData();
|
getHistoryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
function hidTip(element){
|
function hidTip(element){
|
||||||
@@ -229,19 +229,5 @@ $('#btnSave').focusin(function(){focusInTip('btnSaveTip')});
|
|||||||
$('#btnSave').mouseleave(function(){hidTip('btnSaveTip')});
|
$('#btnSave').mouseleave(function(){hidTip('btnSaveTip')});
|
||||||
$('#btnSave').focusout(function(){focusOutTip('btnSaveTip')});
|
$('#btnSave').focusout(function(){focusOutTip('btnSaveTip')});
|
||||||
|
|
||||||
$('#new-tile').mouseover(function(){showTip('btn-newTileTip');});
|
|
||||||
$('#new-tile').mouseleave(function(){hidTip('btn-newTileTip')});
|
|
||||||
$('#new-tile').focusout(function(){focusOutTip('btn-newTileTip')});
|
|
||||||
|
|
||||||
$('#listItems').mouseover(function(){showTip('messagesTip');});
|
$('#listItems').mouseover(function(){showTip('messagesTip');});
|
||||||
$('#listItems').mouseleave(function(){hidTip('messagesTip')});
|
$('#listItems').mouseleave(function(){hidTip('messagesTip')});
|
||||||
|
|
||||||
|
|
||||||
$('#uuid-edit-field').mouseover(function(){ showTip('UUIDFieldTip') });
|
|
||||||
$('#uuid-edit-field').mouseleave(function(){ hidTip('UUIDFieldTip') });
|
|
||||||
|
|
||||||
$('#uuid-validation-strategy').mouseover(function(){ showTip('UUIDValidationStrategyTip') });
|
|
||||||
$('#uuid-validation-strategy').mouseleave(function(){ hidTip('UUIDValidationStrategyTip') });
|
|
||||||
|
|
||||||
$('#editableBlock').mouseover( function(){ showTip('UUIDEditionTip') } );
|
|
||||||
$('#editableBlock').mouseleave(function(){ hidTip('UUIDEditionTip') });
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="../assets/css/tools/mock/common.css" type="text/css">
|
<link rel="stylesheet" href="../assets/css/tools/mock/common.css" type="text/css">
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body onload="onLoad()">
|
||||||
<div class="popup-flex hiddable-container">
|
<div class="popup-flex hiddable-container">
|
||||||
<div class="popup-body" id="popup-body">
|
<div class="popup-body" id="popup-body">
|
||||||
<div class="popup-button-close-container">
|
<div class="popup-button-close-container">
|
||||||
@@ -43,36 +43,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1>MockedServices</h1>
|
<h1>MockedServices</h1>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<label for="uuid-input" class="block-display">UUID</label>
|
|
||||||
<div id="uuid-edit">
|
|
||||||
<div id="uuid-edit-field" class="bordered-field disabled">
|
|
||||||
<input id="uuid-input" disabled onfocusout="changeUUID(this);" value="UUID" />
|
|
||||||
<button onclick="copyUUIDToClipboard();" class="uuid-inputField-icon modification-button flex-item btn-copy action-button">
|
|
||||||
<span class="material-icons uuid-inputField-icon-span ">content_copy</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="editableBlock">
|
|
||||||
<input type="checkbox" onchange="changeEditionOfUUID(this)" name="editable" id="editable" value="false"/>
|
|
||||||
<label for="editable">Editable</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hiddable" id="uuid-validation-strategy">
|
|
||||||
<label><b>UUID generation strategy:</b></label>
|
|
||||||
|
|
||||||
<input type="radio" checked name="uuid-validation-type" value="new" id="generateNew"/>
|
|
||||||
<label for="generateNew">Generate new UUID</label>
|
|
||||||
|
|
||||||
<input type="radio" name="uuid-validation-type" value="restore" id="restore"/>
|
|
||||||
<label for="restore">Restore previous UUID</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<!-- h2 -->
|
<!-- h2 -->
|
||||||
<div id="basicItemData" class="hiddable active"><h2>Your Message</h2></div>
|
<div><h2>Your Message</h2></div>
|
||||||
<div id="advancedItemData" class="hiddable"><h2>Messaged id: <span id="mockedMessageId">1</span></h2></div>
|
|
||||||
|
|
||||||
<!-- link -->
|
<!-- link -->
|
||||||
<div>
|
<div>
|
||||||
@@ -95,7 +68,6 @@
|
|||||||
<option value="404">
|
<option value="404">
|
||||||
<option value="500">
|
<option value="500">
|
||||||
</datalist>
|
</datalist>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- content type -->
|
<!-- content type -->
|
||||||
<div class="max-width small-vertical-margin">
|
<div class="max-width small-vertical-margin">
|
||||||
@@ -155,25 +127,7 @@
|
|||||||
<!-- history -->
|
<!-- history -->
|
||||||
<div id="history" class="medium-vertical-margin tabcontent">
|
<div id="history" class="medium-vertical-margin tabcontent">
|
||||||
<div class="block-display max-width">
|
<div class="block-display max-width">
|
||||||
<button id="btn-history-filter" class="clickable-text highlight switch">
|
|
||||||
<span class="toggleIndicator"></span> filter
|
|
||||||
<button type="button" class="refresh-button" onclick="refreshHistoryRecords();" >↻</button>
|
<button type="button" class="refresh-button" onclick="refreshHistoryRecords();" >↻</button>
|
||||||
</button>
|
|
||||||
<div id ="history-filter" class="display-space-between max-width small-vertical-margin hiddable">
|
|
||||||
<div class="three-fourth-width display-space-evenly">
|
|
||||||
<div class="block-display half-width with-padding">
|
|
||||||
<label for="historyFrom" class="block-label">From</label>
|
|
||||||
<input id="historyFrom" type="date" class="bordered-field max-width with-padding">
|
|
||||||
<input id="historyTimeFrom" type="time" class="small-vertical-margin bordered-field max-width with-padding">
|
|
||||||
</div>
|
|
||||||
<div class="block-display half-width with-padding">
|
|
||||||
<label for="historyTo" class="block-label">To</label>
|
|
||||||
<input id="historyTo" type="date" class="bordered-field max-width with-padding">
|
|
||||||
<input id="historyTimeTo" type="time" class="small-vertical-margin bordered-field max-width with-padding">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button id="btn-searchHistory" class="quater-width action-button active small-margins">Search</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="max-width centered-content large-vertical-margin overflowedTableContent">
|
<div class="max-width centered-content large-vertical-margin overflowedTableContent">
|
||||||
<table id="historyTable" class="table-default">
|
<table id="historyTable" class="table-default">
|
||||||
@@ -195,18 +149,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="selectMenuContent" class="tool-extention">
|
|
||||||
<!-- header -->
|
|
||||||
<div>
|
|
||||||
<h2>Message List</h2>
|
|
||||||
</div>
|
|
||||||
<!-- tile list -->
|
|
||||||
<div id="listItems">
|
|
||||||
</div>
|
|
||||||
<div id="new-tile" class="max-width centered-content small-vertical-margin">
|
|
||||||
<button id="btn-newtile" class="modification-button btn-addtile"><i class="icon-plus"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="tooltip-window lite">
|
<div class="tooltip-window lite">
|
||||||
<div>
|
<div>
|
||||||
@@ -226,30 +168,6 @@
|
|||||||
<p>To save message, the message must be changed!</p>
|
<p>To save message, the message must be changed!</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-vertical-margin">
|
|
||||||
<div id="btn-newTileTip" class="tip">
|
|
||||||
<h3>Add new message</h3>
|
|
||||||
<p>This button adds new message.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="large-vertical-margin">
|
|
||||||
<div id="UUIDFieldTip" class="tip">
|
|
||||||
<h3>UUID</h3>
|
|
||||||
<p>UUID is an Unique ID that represents you in API. By UUID your messages is saved in database. You can change it to access your previous configuration of mocked messages</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="large-vertical-margin">
|
|
||||||
<div id="UUIDValidationStrategyTip" class="tip">
|
|
||||||
<h3>UUID Checking Strategy</h3>
|
|
||||||
<p>When you provide invalid UUID you can choose what do with it. You can generate new UUID or restore previous.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="large-vertical-margin">
|
|
||||||
<div id="UUIDEditionTip" class="tip">
|
|
||||||
<h3>UUID Edition</h3>
|
|
||||||
<p>Unlocks you ability to edit UUID</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="large-vertical-margin">
|
<div class="large-vertical-margin">
|
||||||
<div id="messagesTip" class="tip">
|
<div id="messagesTip" class="tip">
|
||||||
@@ -297,16 +215,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="overlay"></div>
|
<div id="overlay"></div>
|
||||||
<div id="modal-uuidChanged" class="modal">
|
|
||||||
<div class="header">
|
|
||||||
<div>Change UUID info<i class="r-exclamation"></i></div>
|
|
||||||
<button onclick="window.location.reload();">×</button>
|
|
||||||
</div>
|
|
||||||
<div id="changeUUIDSuccess" class="body hiddable uuid-modal-body">Your message UUID has been changed successfully.</div>
|
|
||||||
<div id="newUUID" class="body hiddable uuid-modal-body">You provided wrong UUID! <br> New UUID has been generated!</div>
|
|
||||||
<div id="restoredUUID" class="body hiddable uuid-modal-body">You provided wrong UUID! <br> Old UUID has been restored!</div>
|
|
||||||
<div id="noChgUUID" class="body hiddable uuid-modal-body">You doesn't provide any change to UUID!</div>
|
|
||||||
</div>
|
|
||||||
<div id="modal-confirm" class="modal">
|
<div id="modal-confirm" class="modal">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div>Message saved<i class="r-exclamation"></i></div>
|
<div>Message saved<i class="r-exclamation"></i></div>
|
||||||
@@ -321,9 +229,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="body">You haven't saved your message!<br> Do you want to save it?</div>
|
<div class="body">You haven't saved your message!<br> Do you want to save it?</div>
|
||||||
<div class="function">
|
<div class="function">
|
||||||
|
|
||||||
<button type = "button" onclick = "updateData()" value = "Display">Save</button>
|
<button type = "button" onclick = "updateData()" value = "Display">Save</button>
|
||||||
|
|
||||||
<button>No</button>
|
<button>No</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user