Skip to content

Commit 506794c

Browse files
authored
Scale down TensorBoard UI within iframe (#14992)
1 parent 4dbc988 commit 506794c

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

src/client/tensorBoard/tensorBoardSession.ts

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,44 @@ export class TensorBoardSession {
258258
if (this.webviewPanel) {
259259
this.webviewPanel.webview.html = `<!DOCTYPE html>
260260
<html lang="en">
261-
<head>
262-
<meta charset="UTF-8">
263-
<meta http-equiv="Content-Security-Policy" content="default-src 'unsafe-inline'; frame-src ${this.url};">
264-
<iframe
265-
width="100%"
266-
height="800"
267-
sandbox="allow-scripts allow-forms allow-same-origin allow-pointer-lock"
268-
src="${this.url}"
269-
frameborder="0"
270-
allowfullscreen
271-
></iframe>
272-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
273-
<title>TensorBoard</title>
274-
</head>
261+
<head>
262+
<meta charset="UTF-8">
263+
<meta http-equiv="Content-Security-Policy" content="default-src 'unsafe-inline'; frame-src ${this.url};">
264+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
265+
<title>TensorBoard</title>
266+
</head>
267+
<body>
268+
<script type="text/javascript">
269+
function resizeFrame() {
270+
var f = window.document.getElementById('vscode-tensorboard-iframe');
271+
if (f) {
272+
f.style.height = window.innerHeight / 0.7 + "px";
273+
f.style.width = window.innerWidth / 0.7 + "px";
274+
}
275+
}
276+
window.addEventListener('resize', resizeFrame);
277+
</script>
278+
<iframe
279+
id="vscode-tensorboard-iframe"
280+
class="responsive-iframe"
281+
sandbox="allow-scripts allow-forms allow-same-origin allow-pointer-lock"
282+
src="${this.url}"
283+
frameborder="0"
284+
border="0"
285+
allowfullscreen
286+
></iframe>
287+
<style>
288+
.responsive-iframe {
289+
transform: scale(0.7);
290+
transform-origin: 0 0;
291+
position: absolute;
292+
top: 0;
293+
left: 0;
294+
overflow: hidden;
295+
display: block;
296+
}
297+
</style>
298+
</body>
275299
</html>`;
276300
}
277301
}

0 commit comments

Comments
 (0)