1
0
mirror of https://github.com/gusaul/grpcox.git synced 2025-04-23 15:35:36 +00:00

feat(client): store metadata on save or save as

This commit is contained in:
ananrafs 2023-08-15 12:59:25 +07:00
parent 6feae4127c
commit f899a5fc05

View File

@ -43,7 +43,9 @@ function getReqResData() {
const selectFunction = document.getElementById("select-function").value; const selectFunction = document.getElementById("select-function").value;
const responseHTML = document.getElementById("json-response").innerHTML; const responseHTML = document.getElementById("json-response").innerHTML;
const schemaProtoHTML = document.getElementById("schema-proto").innerHTML; const schemaProtoHTML = document.getElementById("schema-proto").innerHTML;
const metadata = document.getElementById("ctx-metadata-switch").checked ? document.querySelector('div#ctx-metadata-table > table > tbody').innerHTML : "";
editor = ace.edit("editor"); editor = ace.edit("editor");
return { return {
server_target: serverTarget, server_target: serverTarget,
selected_service: selectService, selected_service: selectService,
@ -51,6 +53,7 @@ function getReqResData() {
raw_request: editor.getValue(), raw_request: editor.getValue(),
response_html: responseHTML, response_html: responseHTML,
schema_proto_html: schemaProtoHTML, schema_proto_html: schemaProtoHTML,
raw_metadata: metadata,
} }
} }
@ -66,6 +69,10 @@ function setReqResData(data) {
$('#schema-proto').html(data.schema_proto_html); $('#schema-proto').html(data.schema_proto_html);
$('#json-response').html(data.response_html); $('#json-response').html(data.response_html);
$('#response').show(); $('#response').show();
if (!!data.raw_metadata) {
$('#ctx-metadata-switch').trigger("click");
$('#ctx-metadata-table > table > tbody').html(data.raw_metadata);
}
} }
function resetReqResData() { function resetReqResData() {
@ -74,6 +81,8 @@ function resetReqResData() {
$('#choose-function').hide(); $('#choose-function').hide();
$('#body-request').hide(); $('#body-request').hide();
$('#response').hide(); $('#response').hide();
$('#ctx-metadata-switch').prop('checked', false);
$('#ctx-metadata-input').hide();
} }
async function renderRequestList() { async function renderRequestList() {