-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and color SVG Lines based on intention permissions
- Loading branch information
Showing
6 changed files
with
244 additions
and
88 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
ui-v2/app/components/topology-metrics/down-lines/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{{on-window 'resize' (action this.getIconPositions)}} | ||
|
||
{{#if (gt @lines.length 0)}} | ||
<svg | ||
{{did-insert this.getIconPositions}} | ||
viewBox={{concat @view.x ' ' @view.y ' ' @view.width ' ' @view.height}} | ||
preserveAspectRatio="none" | ||
> | ||
<defs> | ||
<marker id="allow-dot" viewBox="-2 -2 15 15" refX="6" refY="6" markerWidth="6" markerHeight="6"> | ||
<circle | ||
cx="6" | ||
cy="6" | ||
r="6" | ||
/> | ||
</marker> | ||
<marker id="allow-arrow" viewBox="-1 -1 12 12" refX="5" refY="5" | ||
markerWidth="6" markerHeight="6" | ||
orient="auto-start-reverse"> | ||
<polygon points="0 0 10 5 0 10" /> | ||
</marker> | ||
<marker id="deny-dot" viewBox="-2 -2 15 15" refX="6" refY="6" markerWidth="6" markerHeight="6"> | ||
<circle | ||
cx="6" | ||
cy="6" | ||
r="6" | ||
/> | ||
</marker> | ||
<marker id="deny-arrow" viewBox="-1 -1 12 12" refX="5" refY="5" | ||
markerWidth="6" markerHeight="6" | ||
orient="auto-start-reverse"> | ||
<polygon points="0 0 10 5 0 10" /> | ||
</marker> | ||
</defs> | ||
{{#each @lines as |line|}} | ||
{{#if (eq line.permission 'deny')}} | ||
<path | ||
id={{line.id}} | ||
d={{svg-curve line.dest src=line.src}} | ||
marker-start="url(#deny-dot)" | ||
marker-end="url(#deny-arrow)" | ||
data-permission={{line.permission}} | ||
/> | ||
{{else}} | ||
<path | ||
id={{line.id}} | ||
d={{svg-curve line.dest src=line.src}} | ||
marker-start="url(#allow-dot)" | ||
marker-end="url(#allow-arrow)" | ||
data-permission={{line.permission}} | ||
/> | ||
{{/if}} | ||
{{/each}} | ||
</svg> | ||
{{/if}} | ||
|
||
<TopologyMetrics::Icon | ||
@positions={{this.iconPositions}} | ||
@items={{@items}} | ||
/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class TopoloyMetricsLines extends Component { | ||
@tracked iconPositions; | ||
|
||
@action | ||
getIconPositions() { | ||
const view = this.args.view; | ||
const lines = [...document.querySelectorAll('#downstream-lines path')]; | ||
|
||
this.iconPositions = lines.map(item => { | ||
const pathLen = parseFloat(item.getTotalLength()); | ||
const thirdLen = item.getPointAtLength(Math.ceil(pathLen / 3)); | ||
|
||
return { | ||
id: item.id, | ||
x: thirdLen.x - view.x, | ||
y: thirdLen.y - view.y, | ||
}; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{{on-window 'resize' (action this.getIconPositions)}} | ||
|
||
{{#if (gt @lines.length 0)}} | ||
<svg | ||
{{did-insert this.getIconPositions}} | ||
viewBox={{concat @center.x ' ' @view.y ' ' @view.width ' ' @view.height}} | ||
preserveAspectRatio="none" | ||
> | ||
<defs> | ||
<marker id="allow-dot" viewBox="-2 -2 15 15" refX="6" refY="6" markerWidth="6" markerHeight="6"> | ||
<circle | ||
cx="6" | ||
cy="6" | ||
r="6" | ||
/> | ||
</marker> | ||
<marker id="allow-arrow" viewBox="-1 -1 12 12" refX="5" refY="5" | ||
markerWidth="6" markerHeight="6" | ||
orient="auto-start-reverse"> | ||
<polygon points="0 0 10 5 0 10" /> | ||
</marker> | ||
<marker id="deny-dot" viewBox="-2 -2 15 15" refX="6" refY="6" markerWidth="6" markerHeight="6"> | ||
<circle | ||
cx="6" | ||
cy="6" | ||
r="6" | ||
/> | ||
</marker> | ||
<marker id="deny-arrow" viewBox="-1 -1 12 12" refX="5" refY="5" | ||
markerWidth="6" markerHeight="6" | ||
orient="auto-start-reverse"> | ||
<polygon points="0 0 10 5 0 10" /> | ||
</marker> | ||
</defs> | ||
{{#each @lines as |line|}} | ||
{{#if (eq line.permission 'deny')}} | ||
<path | ||
id={{line.id}} | ||
d={{svg-curve line.dest src=line.src}} | ||
marker-start="url(#deny-dot)" | ||
marker-end="url(#deny-arrow)" | ||
data-permission={{line.permission}} | ||
/> | ||
{{else}} | ||
<path | ||
id={{line.id}} | ||
d={{svg-curve line.dest src=line.src}} | ||
marker-start="url(#allow-dot)" | ||
marker-end="url(#allow-arrow)" | ||
data-permission={{line.permission}} | ||
/> | ||
{{/if}} | ||
{{/each}} | ||
</svg> | ||
{{/if}} | ||
|
||
<TopologyMetrics::Icon | ||
@positions={{this.iconPositions}} | ||
@items={{@items}} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class TopoloyMetricsLines extends Component { | ||
@tracked iconPositions; | ||
|
||
@action | ||
getIconPositions() { | ||
const center = this.args.center; | ||
const lines = [...document.querySelectorAll('#upstream-lines path')]; | ||
|
||
this.iconPositions = lines.map(item => { | ||
const pathLen = parseFloat(item.getTotalLength()); | ||
const partLen = item.getPointAtLength(Math.ceil(pathLen * 0.666)); | ||
return { | ||
id: item.id, | ||
x: partLen.x - center.x, | ||
y: partLen.y - center.y * 0.81, | ||
}; | ||
}); | ||
} | ||
} |