Removed unused files
This commit is contained in:
@@ -1,541 +0,0 @@
|
|||||||
var clientUUID = '';
|
|
||||||
var advancedDisplayed = false;
|
|
||||||
var json = {};
|
|
||||||
var jsonIndex = 0;
|
|
||||||
var lastId = 1;
|
|
||||||
var htable_row = 0;
|
|
||||||
var host = getDomain();
|
|
||||||
var dataModified = false;
|
|
||||||
const addMessageName = 'addMessage';
|
|
||||||
const loadMessageName = 'changeMessage';
|
|
||||||
const removeMessageName = 'removeMessage';
|
|
||||||
|
|
||||||
const C_UUID = 'mock-uuid';
|
|
||||||
const C_ID = 'last-displayed-id';
|
|
||||||
const C_ADV = 'advanced-mode';
|
|
||||||
|
|
||||||
const color_red = "#ff8f8f";
|
|
||||||
const color_grey = "#6b6b6b";
|
|
||||||
|
|
||||||
const setModified = function(){
|
|
||||||
setDataModified();
|
|
||||||
}
|
|
||||||
const setOrigin = function(){
|
|
||||||
setDataOrigin();
|
|
||||||
}
|
|
||||||
|
|
||||||
const getUpdate = function(){
|
|
||||||
updateData();
|
|
||||||
}
|
|
||||||
const dataRefresh = function(){
|
|
||||||
getData();
|
|
||||||
}
|
|
||||||
$('#btn-newtile').click(function(){callAddMessage()});
|
|
||||||
// $('#btn-addRow').click(function(){addRow()});
|
|
||||||
// $('#btn-save').click(getUpdate);
|
|
||||||
|
|
||||||
function getData(){
|
|
||||||
$.getJSON(host + '/api/mock/'+clientUUID, function(data) {
|
|
||||||
json = data;
|
|
||||||
checkUuid();
|
|
||||||
|
|
||||||
|
|
||||||
refreshData();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function checkUuid(){
|
|
||||||
if(clientUUID == null || clientUUID == undefined || clientUUID == ''){
|
|
||||||
clientUUID = json[0].clientUUID;
|
|
||||||
setCookie();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDomain(){
|
|
||||||
var url = window.location.href;
|
|
||||||
var arr = url.split("/");
|
|
||||||
var result = arr[0] + "//" + arr[2];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function httpStatusInvalid(){
|
|
||||||
value = $('#httpStatus').val();
|
|
||||||
return value == '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDataModified(){
|
|
||||||
if(httpStatusInvalid()){
|
|
||||||
$('#btn-save').removeClass('active');
|
|
||||||
$('#btn-save').off();
|
|
||||||
document.getElementById("httpStatus").style.backgroundColor = color_red;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dataModified = true;
|
|
||||||
$('#btn-save').addClass('active');
|
|
||||||
$('#btn-save').click(getUpdate);
|
|
||||||
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) {
|
|
||||||
var name = cname + '=';
|
|
||||||
var decodedCookie = decodeURIComponent(document.cookie);
|
|
||||||
var ca = decodedCookie.split(';');
|
|
||||||
for(var i = 0; i <ca.length; i++) {
|
|
||||||
var c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') {
|
|
||||||
c = c.substring(1);
|
|
||||||
}
|
|
||||||
if (c.indexOf(name) == 0) {
|
|
||||||
return c.substring(name.length, c.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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(){
|
|
||||||
var updatedJson = generateJson();
|
|
||||||
const dataSaved = function () {
|
|
||||||
setDataOrigin();
|
|
||||||
refreshData();
|
|
||||||
savedModalDisplay();
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
url: host + '/api/mock',
|
|
||||||
type: 'PUT',
|
|
||||||
data: JSON.stringify(updatedJson, null, 2),
|
|
||||||
contentType: "application/json",
|
|
||||||
}).done(dataSaved);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callAddMessage(){
|
|
||||||
if(dataModified){
|
|
||||||
setMethodToCall(addMessageName, null);
|
|
||||||
dataLossModalDisplay();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addMessage(){
|
|
||||||
$.ajax({
|
|
||||||
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>';
|
|
||||||
$('#messageLink').html(linkHtml);
|
|
||||||
$('#httpStatus').val(httpStatus);
|
|
||||||
$('#uuid-input').val(uuid);
|
|
||||||
$('#typeSelector').val(mediaType);
|
|
||||||
$('#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){
|
|
||||||
var innerHTML = buildHeaderMapHtml(headers);
|
|
||||||
refreshHeaderTable(innerHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshHeaderTable(html){
|
|
||||||
$('#headerMapTable').html(html);
|
|
||||||
$('.table-map').change(function(){setDataModified()});
|
|
||||||
$('.btn-hashmap').click(function(){
|
|
||||||
$(this).closest('tr').remove();
|
|
||||||
setDataModified();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildHeaderMapHtml(headers){
|
|
||||||
var innerHTML = '';
|
|
||||||
for(var key in headers){
|
|
||||||
innerHTML += buildRowHtml(key, headers[key]);
|
|
||||||
}
|
|
||||||
return innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addRow(key, value){
|
|
||||||
var headerMap = $('#headerMapTable');
|
|
||||||
var headersMapHtml = headerMap.html();
|
|
||||||
headersMapHtml += buildRowHtml(key, value);
|
|
||||||
refreshHeaderTable(headersMapHtml);
|
|
||||||
}
|
|
||||||
|
|
||||||
const newRowInput = function(){
|
|
||||||
const hName = $('#headerKeyInput');
|
|
||||||
const hValue = $('#headerValueInput');
|
|
||||||
if(checkIfInputValid(hName.val()) && checkIfInputValid(hValue.val())){
|
|
||||||
addRow(hName.val(), hValue.val());
|
|
||||||
hName.val(null);
|
|
||||||
hValue.val(null);
|
|
||||||
setDataModified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#btn-newRow').click(newRowInput);
|
|
||||||
|
|
||||||
function checkIfInputValid(input){
|
|
||||||
return !(input == '' || input == null || input == undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkIfHeaderEssential(key){
|
|
||||||
|
|
||||||
if( key == "Connection" || key == "Keep-Alive" || key == "Date" ){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildRowHtml(key, value){
|
|
||||||
|
|
||||||
if(checkIfHeaderEssential(key)){
|
|
||||||
return '' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td><input class="key data-field" value="' + key + '" readonly></td>' +
|
|
||||||
'<td><input class="data-field" value="' + value + '"></td>' +
|
|
||||||
'</tr>';
|
|
||||||
}
|
|
||||||
return '' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td><input class="key data-field" value="' + key + '"></td>' +
|
|
||||||
'<td><input class="data-field" value="' + value + '"></td>' +
|
|
||||||
'<td><button class="modification-button btn-hashmap"><i class="icon-cancel"></i></button></td>' +
|
|
||||||
'</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(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) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function generateJson(){
|
|
||||||
var newJson =
|
|
||||||
{
|
|
||||||
clientUUID: json[jsonIndex].clientUUID,
|
|
||||||
mockedResponseId: json[jsonIndex].mockedResponseId,
|
|
||||||
mediaType: $('#typeSelector').val(),
|
|
||||||
messageBody: $('#bodyEditor').val(),
|
|
||||||
httpStatus: $('#httpStatus').val(),
|
|
||||||
httpHeaders: {},
|
|
||||||
};
|
|
||||||
newJson['httpHeaders'] = convertTableToJson();
|
|
||||||
|
|
||||||
json[jsonIndex] = newJson;
|
|
||||||
return newJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function convertTableToJson(){
|
|
||||||
const rows = $('#headerMapTable').children();
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
const deleteParent = function(){
|
|
||||||
$(this).closest('div.tile').remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#test1').click(deleteParent);
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
var historyJson = {};
|
|
||||||
const maxIterations = 200;
|
|
||||||
|
|
||||||
function filterHistory(){
|
|
||||||
var dateFrom = new Date($('#historyFrom').val() + 'T' + $('#historyTimeFrom').val());
|
|
||||||
|
|
||||||
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;
|
|
||||||
displayHistory();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function historyToHtml(){
|
|
||||||
var innerHTML = '';
|
|
||||||
var iterations = historyJson.length <= maxIterations ? historyJson.length : maxIterations;
|
|
||||||
for(let i=0; i<iterations; i++){
|
|
||||||
let style = i%2==0 ? ' class="even"' : '';
|
|
||||||
innerHTML += '<tr' + style + '>' +
|
|
||||||
'<td>' + historyJson[i].dateTimeStamp + '</td>' +
|
|
||||||
'<td>' + historyJson[i].interfaceName + '</td>' +
|
|
||||||
'</tr>';
|
|
||||||
}
|
|
||||||
return innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayHistory(){
|
|
||||||
$('#historyTable tbody').html(historyToHtml());
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
var modalDisplayed = false;
|
|
||||||
var methodToCall = {
|
|
||||||
name: null,
|
|
||||||
id: null
|
|
||||||
};
|
|
||||||
|
|
||||||
const overlay = $('#overlay');
|
|
||||||
const savedModal = $('#modal-confirm');
|
|
||||||
const dataLossModal = $('#modal-query');
|
|
||||||
const uuidChangeModal = $('#modal-uuidChanged')
|
|
||||||
const dataLossModalYes = dataLossModal.children().eq(2).children().eq(0);
|
|
||||||
const dataLossModalNo = dataLossModal.children().eq(2).children().eq(1);
|
|
||||||
const allModals = $('.modal');
|
|
||||||
const btnModalClose = $('.modal button');
|
|
||||||
const closeModals = function() {
|
|
||||||
hideModal(allModals);
|
|
||||||
}
|
|
||||||
const savedModalDisplay = function() {
|
|
||||||
|
|
||||||
showModal(savedModal);
|
|
||||||
setTimeout(closeModals, 2000);
|
|
||||||
}
|
|
||||||
const dataLossModalDisplay = function(){
|
|
||||||
showModal(dataLossModal);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uuidChangeModalDisplay = function(addidionalMessage){
|
|
||||||
|
|
||||||
switch(addidionalMessage){
|
|
||||||
case "success":{
|
|
||||||
|
|
||||||
$(".uuid-modal-body").removeClass("active");
|
|
||||||
$("#changeUUIDSuccess").addClass("active");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "new":{
|
|
||||||
|
|
||||||
$(".uuid-modal-body").removeClass("active");
|
|
||||||
$("#newUUID").addClass("active");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "restore":{
|
|
||||||
|
|
||||||
$(".uuid-modal-body").removeClass("active");
|
|
||||||
$("#restoredUUID").addClass("active");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "noChg":{
|
|
||||||
|
|
||||||
$(".uuid-modal-body").removeClass("active");
|
|
||||||
$("#noChgUUID").addClass("active");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showModal(uuidChangeModal);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setMethodToCall(name, id){
|
|
||||||
methodToCall.name = name;
|
|
||||||
methodToCall.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dropChangesAndClose = function(){
|
|
||||||
callMethodByName(methodToCall)
|
|
||||||
hideModal(dataLossModal);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showModal(jmodal){
|
|
||||||
if(modalDisplayed) return;
|
|
||||||
overlay.addClass('active');
|
|
||||||
jmodal.addClass('active');
|
|
||||||
modalDisplayed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideModal(jmodal){
|
|
||||||
if(!modalDisplayed) return;
|
|
||||||
if ($(uuidChangeModal).hasClass('active')) window.location.reload();
|
|
||||||
overlay.removeClass('active');
|
|
||||||
jmodal.removeClass('active');
|
|
||||||
modalDisplayed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
btnModalClose.click(closeModals);
|
|
||||||
|
|
||||||
overlay.click(closeModals);
|
|
||||||
|
|
||||||
dataLossModalNo.click(closeModals);
|
|
||||||
dataLossModalYes.click(dropChangesAndClose);
|
|
||||||
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
var advancedVisibility = false;
|
|
||||||
var selectMenu = $("#selectMenuContent");
|
|
||||||
var advancedTab = $("#advanced");
|
|
||||||
var basicID = $("#basicItemData")
|
|
||||||
var advancedID = $("#advancedItemData");
|
|
||||||
var advancedUUIDOptions = $("#uuid-validation-strategy");
|
|
||||||
var focusedField = false;
|
|
||||||
function changeAdvancedVisibility(){
|
|
||||||
if(advancedVisibility){
|
|
||||||
selectMenu.removeClass('active');
|
|
||||||
advancedTab.removeClass('active');
|
|
||||||
advancedID.removeClass('active');
|
|
||||||
advancedUUIDOptions.removeClass('active');
|
|
||||||
basicID.addClass('active');
|
|
||||||
advancedVisibility = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
selectMenu.addClass('active');
|
|
||||||
advancedTab.addClass('active');
|
|
||||||
advancedID.addClass('active');
|
|
||||||
advancedUUIDOptions.addClass('active');
|
|
||||||
basicID.removeClass('active');
|
|
||||||
advancedVisibility = true;
|
|
||||||
}
|
|
||||||
setCookie();
|
|
||||||
}
|
|
||||||
|
|
||||||
const historyFilter = $('#history-filter');
|
|
||||||
const historyFilterSwitch = function(){
|
|
||||||
historyFilter.toggleClass('active');
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#optional").click(changeAdvancedVisibility);
|
|
||||||
$('#historyTab').click(showHistory);
|
|
||||||
$('#btn-history-filter').click(historyFilterSwitch);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const tabitem = $('.tabitem');
|
|
||||||
function showHistory(){
|
|
||||||
$('#headersTab').click(showHeaders);
|
|
||||||
tabitem.removeClass('active');
|
|
||||||
$('.tabcontent').removeClass('active');
|
|
||||||
$('#history').addClass('active');
|
|
||||||
$('#historyTab').addClass('active');
|
|
||||||
$('#historyTab').off('click');
|
|
||||||
initializeHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeHistory(){
|
|
||||||
historyFilter.removeClass('active');
|
|
||||||
getLast24hHistoryData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function showHeaders(){
|
|
||||||
$('#historyTab').click(showHistory);
|
|
||||||
tabitem.removeClass('active');
|
|
||||||
$('.tabcontent').removeClass('active');
|
|
||||||
$('#headers').addClass('active');
|
|
||||||
$('#headersTab').addClass('active');
|
|
||||||
$('#headersTab').off('click');
|
|
||||||
}
|
|
||||||
|
|
||||||
function focusInTip(element){
|
|
||||||
showTip(element);
|
|
||||||
focusedField = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function focusOutTip(element){
|
|
||||||
focusedField = false;
|
|
||||||
hidTip(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hidTip(element){
|
|
||||||
if(focusedField) return;
|
|
||||||
$('#'+element).removeClass('active');
|
|
||||||
}
|
|
||||||
|
|
||||||
function showTip(element){
|
|
||||||
if(focusedField) return;
|
|
||||||
$('.tip').removeClass('active');
|
|
||||||
$('#'+element).addClass('active');
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#messageLink').mouseover(function(){showTip('messageLinkTip')});
|
|
||||||
$('#messageLink').mouseleave(function(){hidTip('messageLinkTip')});
|
|
||||||
|
|
||||||
$('#httpStatus').mouseover(function(){showTip('httpStatusTip')});
|
|
||||||
$('#httpStatus').focusin(function(){focusInTip('httpStatusTip')});
|
|
||||||
$('#httpStatus').mouseleave(function(){hidTip('httpStatusTip')});
|
|
||||||
$('#httpStatus').focusout(function(){focusOutTip('httpStatusTip')});
|
|
||||||
|
|
||||||
$('#typeSelector').mouseover(function(){showTip('typeSelectorTip')});
|
|
||||||
$('#typeSelector').focusin(function(){focusInTip('typeSelectorTip')});
|
|
||||||
$('#typeSelector').mouseleave(function(){hidTip('typeSelectorTip')});
|
|
||||||
$('#typeSelector').focusout(function(){focusOutTip('typeSelectorTip')});
|
|
||||||
|
|
||||||
$('#bodyEditor').mouseover(function(){showTip('bodyEditorTip')});
|
|
||||||
$('#bodyEditor').focusin(function(){focusInTip('bodyEditorTip')});
|
|
||||||
$('#bodyEditor').mouseleave(function(){hidTip('bodyEditorTip')});
|
|
||||||
$('#bodyEditor').focusout(function(){focusOutTip('bodyEditorTip')});
|
|
||||||
|
|
||||||
$('#headersTab').mouseover(function(){showTip('headersTabTip')});
|
|
||||||
$('#headersTab').mouseleave(function(){hidTip('headersTabTip')});
|
|
||||||
|
|
||||||
$('#historyTab').mouseover(function(){showTip('historyTabTip')});
|
|
||||||
$('#historyTab').mouseleave(function(){hidTip('historyTabTip')});
|
|
||||||
|
|
||||||
$('#headerKeyInput').mouseover(function(){showTip('newHeaderTip')});
|
|
||||||
$('#headerKeyInput').focusin(function(){focusInTip('newHeaderTip')});
|
|
||||||
$('#headerKeyInput').mouseleave(function(){hidTip('newHeaderTip')});
|
|
||||||
$('#headerKeyInput').focusout(function(){focusOutTip('newHeaderTip')});
|
|
||||||
|
|
||||||
$('#headerValueInput').mouseover(function(){showTip('newHeaderTip')});
|
|
||||||
$('#headerValueInput').focusin(function(){focusInTip('newHeaderTip')});
|
|
||||||
$('#headerValueInput').mouseleave(function(){hidTip('newHeaderTip')});
|
|
||||||
$('#headerValueInput').focusout(function(){focusOutTip('newHeaderTip')});
|
|
||||||
|
|
||||||
$('#btnSave').mouseover(function(){showTip('btnSaveTip');});
|
|
||||||
$('#btnSave').focusin(function(){focusInTip('btnSaveTip')});
|
|
||||||
$('#btnSave').mouseleave(function(){hidTip('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').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') });
|
|
||||||
Reference in New Issue
Block a user