Browse Source

KSP template fixes

mj-deploy
Standa Lukeš 4 years ago
parent
commit
5298dae17f
  1. 1
      frontend/src/App.svelte
  2. 4
      frontend/src/Graph.svelte
  3. 8
      frontend/src/GraphNode.svelte
  4. 3
      server/Ksp.WebServer/Controllers/GrafikPageController.cs

1
frontend/src/App.svelte

@ -31,7 +31,6 @@
</style> </style>
<main> <main>
<h1>Cool graf</h1>
<!-- <!--
<svg height=200 width=200> <svg height=200 width=200>
<GraphNode task="null" /> <GraphNode task="null" />

4
frontend/src/Graph.svelte

@ -41,7 +41,7 @@
}) // This provide the id of a node }) // This provide the id of a node
.links(edges) // and this the list of links .links(edges) // and this the list of links
) )
.force("charge", d3.forceManyBody().strength(-500)) // This adds repulsion between nodes. Play with the -400 for the repulsion strength .force("charge", d3.forceManyBody().strength(-400)) // This adds repulsion between nodes. Play with the -400 for the repulsion strength
.force("x", d3.forceX()) // attracts elements to the zero X coord .force("x", d3.forceX()) // attracts elements to the zero X coord
.force("y", d3.forceY()) // attracts elements to the zero Y coord .force("y", d3.forceY()) // attracts elements to the zero Y coord
.on("tick", ticked) .on("tick", ticked)
@ -57,7 +57,7 @@
<style> <style>
div { div {
height: 75vh; height: 100vh;
width: 100%; width: 100%;
} }
</style> </style>

8
frontend/src/GraphNode.svelte

@ -28,7 +28,7 @@
</script> </script>
<style> <style>
:global(g):hover > ellipse { g:hover > ellipse {
fill: #ffb3a2 fill: #ffb3a2
} }
ellipse { ellipse {
@ -37,11 +37,7 @@
</style> </style>
<g on:mouseenter={enter} on:mouseleave={leave}> <g on:mouseenter={enter} on:mouseleave={leave}>
{#if !hovering} <ellipse rx={ellipse_rx} ry={ellipse_ry} {cx} {cy} />
<ellipse rx={ellipse_rx} ry={ellipse_ry} {cx} {cy} />
{:else}
<ellipse rx={ellipse_rx} ry={ellipse_ry} {cx} {cy} />
{/if}
<text <text
bind:this={text_element} bind:this={text_element}
x={cx} x={cx}

3
server/Ksp.WebServer/Controllers/GrafikPageController.cs

@ -55,7 +55,8 @@ namespace Ksp.WebServer.Controllers
var innerBody = grafik.Body; var innerBody = grafik.Body;
innerBody.Replace(kspTemplate.Body); innerBody.Replace(kspTemplate.Body);
var page = grafik.Body.QuerySelector("#page"); var page = grafik.Body.QuerySelector("#page");
page.Replace(innerBody.ChildNodes.ToArray()); page.InnerHtml = "";
page.AppendNodes(innerBody.ChildNodes.ToArray());
foreach(var headElement in kspTemplate.Head.QuerySelectorAll("link, script")) foreach(var headElement in kspTemplate.Head.QuerySelectorAll("link, script"))
{ {