blob: 8e84ba843a65869adc188249653909899a48a128 [file] [log] [blame]
Sean Condon0c577f62018-11-18 22:40:05 +00001<!--
Sean Condon91481822019-01-01 13:56:14 +00002~ Copyright 2019-present Open Networking Foundation
Sean Condon0c577f62018-11-18 22:40:05 +00003~
4~ Licensed under the Apache License, Version 2.0 (the "License");
5~ you may not use this file except in compliance with the License.
6~ You may obtain a copy of the License at
7~
8~ http://www.apache.org/licenses/LICENSE-2.0
9~
10~ Unless required by applicable law or agreed to in writing, software
11~ distributed under the License is distributed on an "AS IS" BASIS,
12~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13~ See the License for the specific language governing permissions and
14~ limitations under the License.
15-->
Sean Condon50855cf2018-12-23 15:37:42 +000016<svg:defs xmlns:svg="http://www.w3.org/2000/svg">
17 <!-- Template explanation: Define an SVG Filter that in
Sean Condon1ae15802019-03-02 09:07:18 +000018 line 0) creates a box big enough to accommodate the drop shadow
Sean Condon50855cf2018-12-23 15:37:42 +000019 line 1) render the target object in to a bit map and apply a blur to it
20 based on its alpha channel
21 line 2) take that blurred layer and shift it down and to the right by 4
22 line 3) Merge this blurred and shifted layer and overlay it with the
23 original target object
24 -->
Sean Condon1ae15802019-03-02 09:07:18 +000025 <!-- Template explanation: Define a colour gradient that can be used in icons -->
Sean Condon50855cf2018-12-23 15:37:42 +000026 <svg:linearGradient id="diagonal_blue" x1="0%" y1="0%" x2="100%" y2="100%">
Sean Condonb2c483c2019-01-16 20:28:55 +000027 <svg:stop offset= "0%" style="stop-color: #7fabdb;" />
28 <svg:stop offset= "100%" style="stop-color: #5b99d2;" />
Sean Condon50855cf2018-12-23 15:37:42 +000029 </svg:linearGradient>
30</svg:defs>
31<!-- Template explanation: Creates an SVG Group and in
32 line 1) transform it to the position calculated by the d3 force graph engine
Sean Condon1ae15802019-03-02 09:07:18 +000033 and scale it inversely to the zoom level
Sean Condon50855cf2018-12-23 15:37:42 +000034 line 2) Give it various CSS styles depending on attributes
35 line 3) When it is clicked, call the method that toggles the selection and
36 emits an event.
37 Other child objects have their own description
38-->
39<svg:g xmlns:svg="http://www.w3.org/2000/svg"
Sean Condon0c577f62018-11-18 22:40:05 +000040 [attr.transform]="'translate(' + device?.x + ',' + device?.y + '), scale(' + scale + ')'"
41 [ngClass]="['node', 'device', device.online?'online':'', selected?'selected':'']"
Sean Condond88f3662019-04-03 16:35:30 +010042 (click)="toggleSelected(device, $event)">
Sean Condon50855cf2018-12-23 15:37:42 +000043 <svg:desc>Device {{device.id}}</svg:desc>
44 <!-- Template explanation: Creates an SVG Rectangle and in
45 line 1) set a css style and shift so that it's centred
46 line 2) set the initial width and height - width changes with label
47 line 3) link to the animation 'deviceLabelToggle', pass in to it a width
48 calculated from the width of the text, and additional padding at the end
49 line 4) Apply the filter defined above to this rectangle (even as its
50 width changes
51 -->
52 <svg:rect
53 class="node-container" x="-18" y="-18"
54 width="36" height="36"
Thomas Vachuskaa1b624e2020-07-31 14:20:32 -070055 [@deviceLabelToggle]="{ value: labelToggle, params: {txtWidth: (36 + labelTextLen() + (labelTextLen() > 0 ? 10 : 0))+'px' }}">
Sean Condon0c577f62018-11-18 22:40:05 +000056 </svg:rect>
Sean Condon50855cf2018-12-23 15:37:42 +000057 <!-- Template explanation: Creates an SVG Rectangle slightly smaller and
58 overlaid on the above. This is the blue box, and its width and height does
59 not change
60 -->
Sean Condon058804c2019-04-16 09:41:52 +010061 <svg:rect x="-16" y="-16" width="32" height="32" [ngStyle]="{'fill': panelColor}">
Sean Condon0c577f62018-11-18 22:40:05 +000062 </svg:rect>
Sean Condon590b34b2019-12-04 18:44:37 +000063 <!-- Create an L shaped bracket on bottom left of icon if it has either grid or geo location-->
Sean Condon9de21352019-04-06 19:22:27 +010064 <svg:path *ngIf="device.location && device.location.locType != 'none'"
Sean Condon590b34b2019-12-04 18:44:37 +000065 d="M-15 12 v3 h3" class="bracket">
66 </svg:path>
67 <!-- Create an L shaped bracket on top right of icon if it has been pinned or has fixed location-->
Sean Condon9de21352019-04-06 19:22:27 +010068 <svg:path *ngIf="device.fx != null"
Sean Condon590b34b2019-12-04 18:44:37 +000069 d="M15 -12 v-3 h-3" class="bracket">
70 </svg:path>
Sean Condon50855cf2018-12-23 15:37:42 +000071 <!-- Template explanation: Creates an SVG Text element and in
72 line 1) make it left aligned and slightly down and to the right of the last rect
73 line 2) set its text length to be the calculated value - see that function
74 line 3) because of kerning the actual text might be shorter or longer than
75 the pre-calculated value - if so change the spacing between the letters
76 (and not the letter width to compensate)
77 line 4) link to the animation deviceLabelToggleTxt, so that the text appears
78 in gently
79 line 5) The text will be one of 3 values - blank, the id or the name
80 -->
Thomas Vachuskaedb437a2020-02-27 14:25:58 -080081 <!-- [attr.textLength]= "labelTextLen()"-->
82 <!-- lengthAdjust= "spacing"-->
Sean Condon50855cf2018-12-23 15:37:42 +000083 <svg:text
84 text-anchor="start" y="0.3em" x="22"
Sean Condon50855cf2018-12-23 15:37:42 +000085 [@deviceLabelToggleTxt]="labelToggle">
Sean Condon0c577f62018-11-18 22:40:05 +000086 {{ labelToggle == 0 ? '': labelToggle == 1 ? device.id:device.props.name }}
87 </svg:text>
Sean Condon59d31372019-02-02 20:07:00 +000088 <svg:use [attr.xlink:href]="'#' + deviceIcon()" width="36" height="36" x="-18" y="-18">
Sean Condon021f0fa2018-12-06 23:31:11 -080089 </svg:use>
Sean Condon590b34b2019-12-04 18:44:37 +000090 <svg:g *ngIf="badge" onos-badgesvg [badge]="badge"></svg:g>
Sean Condond88f3662019-04-03 16:35:30 +010091</svg:g>