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>
<main>
<h1>Cool graf</h1>
<!--
<svg height=200 width=200>
<GraphNode task="null" />

4
frontend/src/Graph.svelte

@ -41,7 +41,7 @@
}) // This provide the id of a node
.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("y", d3.forceY()) // attracts elements to the zero Y coord
.on("tick", ticked)
@ -57,7 +57,7 @@
<style>
div {
height: 75vh;
height: 100vh;
width: 100%;
}
</style>

8
frontend/src/GraphNode.svelte

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

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

@ -55,7 +55,8 @@ namespace Ksp.WebServer.Controllers
var innerBody = grafik.Body;
innerBody.Replace(kspTemplate.Body);
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"))
{