-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add createMock function to mockManager.js and proxy.helper.js
- Loading branch information
Showing
9 changed files
with
127 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!-- generate html for electron --> | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Mockingbird Proxy create</title> | ||
|
||
<script src="../assets/library/jsoneditor.js"></script> | ||
<link rel="stylesheet" type="text/css" href="../assets/library/jsoneditor.css"> | ||
<link rel="stylesheet" type="text/css" href="../assets/styles/main.css"> | ||
<script src="./create.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container container-edit"> | ||
<div class="row top-bar"> | ||
<div class="col-6"> | ||
<div class="header"> | ||
<img src="../assets/logo/mocking-bird-proxy-logo.jpg" class="img-fluid" alt="" srcset=""> | ||
<h1>Mockingbird Proxy</h1> | ||
</div> | ||
</div> | ||
<div class="col-6 controller-json d-flex justify-content-end align-items-center "> | ||
<i class="bi bi-x-square-fill" onclick="goHome()"></i> | ||
<i class="bi bi-floppy-fill" onclick="createNewMock()"></i> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-12 controller-json"> | ||
</div> | ||
</div> | ||
<div id="jsoneditor"></div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const { ipcRenderer } = require('electron'); | ||
console.log('edit.js'); | ||
|
||
let editor = null; // Variabile globale per mantenere l'editor | ||
let jsonUpdated = null; // Variabile globale per mantenere il json aggiornato | ||
|
||
function openEditor(data) { | ||
const options = {}; | ||
const container = document.getElementById('jsoneditor'); | ||
|
||
// Pulisce il contenitore se l'editor esiste già | ||
if (editor) { | ||
editor.destroy(); | ||
} | ||
// Crea una nuova istanza dell'editor | ||
editor = new JSONEditor(container, options); | ||
editor.set(data); | ||
} | ||
const data = { | ||
"bypassCache": false, | ||
"method": "GET", | ||
"payload": {}, | ||
"targetUrl": "", | ||
"response": {}, | ||
"statusCode": 200, | ||
"timestamp": new Date().getTime() | ||
} | ||
document.addEventListener('DOMContentLoaded', () => { | ||
console.log('DOMContentLoaded'); | ||
openEditor(data); | ||
}); | ||
|
||
function goHome() { | ||
ipcRenderer.send('goHome'); | ||
} | ||
|
||
function createNewMock() { | ||
jsonUpdated = editor.get(); | ||
// check data | ||
if (!jsonUpdated.targetUrl) { | ||
alert('targetUrl is required'); | ||
return; | ||
} | ||
jsonUpdated.uuid = ''; | ||
console.log('jsonUpdated', jsonUpdated); | ||
ipcRenderer.send('createNewMock', jsonUpdated); | ||
} | ||
ipcRenderer.on('responseCreateNewMock', (event, data) => { | ||
console.log('responseSaveMock js', data); | ||
goHome(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters