Skip to content
Snippets Groups Projects
Commit b4c78c42 authored by Jack Hu's avatar Jack Hu
Browse files

format messages better

parent 1cab257a
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,8 @@ ...@@ -59,7 +59,8 @@
const grpcJsonData = data["grpc"]; const grpcJsonData = data["grpc"];
document.getElementById('results').replaceChildren(jsonToTable("REST", restJsonData)); document.getElementById('results').replaceChildren(jsonToTable("REST", restJsonData));
document.getElementById('results').appendChild(jsonToTable("gRPC", grpcJsonData)); document.getElementById('results').appendChild(jsonToTable("gRPC", grpcJsonData));
document.getElementById('messages').replaceChildren(concatAllMessages(restJsonData, grpcJsonData)); document.getElementById('messages').replaceChildren(concatAllMessages("REST", restJsonData));
document.getElementById('messages').appendChild(concatAllMessages("gRPC", grpcJsonData));
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
...@@ -98,16 +99,18 @@ ...@@ -98,16 +99,18 @@
return div; return div;
} }
function concatAllMessages(...jsonData) { function concatAllMessages(title, jsonData) {
const div = document.createElement('div'); const div = document.createElement('div');
for (const data of jsonData) { const h = document.createElement('h2');
for (const [k, v] of Object.entries(data)) { h.textContent = title;
const p = document.createElement('p'); div.appendChild(h);
p.textContent = `${k}: ${v["message"]}`; for (const [k, v] of Object.entries(jsonData)) {
p.className = v["ok"] ? 'success' : 'fail'; const p = document.createElement('p');
div.appendChild(p); p.textContent = `${k}: ${v["message"]}`;
} p.className = v["ok"] ? 'success' : 'fail';
div.appendChild(p);
} }
return div; return div;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment