GUI Topo -- Badges - Fixed glyph positioning. Added CSS for info/warn/error statuses.
Change-Id: I9e37863a3425df9a9ecd2d20f5526e4f63c6ad00
Showing
11 changed files
with
151 additions
and
8 deletions
| ... | @@ -427,6 +427,39 @@ html[data-platform='iPad'] #topo-p-detail { | ... | @@ -427,6 +427,39 @@ html[data-platform='iPad'] #topo-p-detail { |
| 427 | fill: #f90; | 427 | fill: #f90; |
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | +/* Badges */ | ||
| 431 | +/* (... works for both light and dark themes...) */ | ||
| 432 | +#ov-topo svg .node .badge circle { | ||
| 433 | + stroke: #aaa; | ||
| 434 | +} | ||
| 435 | + | ||
| 436 | +#ov-topo svg .node .badge.badgeInfo circle { | ||
| 437 | + fill: #ccf; | ||
| 438 | +} | ||
| 439 | + | ||
| 440 | +#ov-topo svg .node .badge.badgeWarn circle { | ||
| 441 | + fill: #da2; | ||
| 442 | +} | ||
| 443 | + | ||
| 444 | +#ov-topo svg .node .badge.badgeError circle { | ||
| 445 | + fill: #e44; | ||
| 446 | +} | ||
| 447 | + | ||
| 448 | +#ov-topo svg .node .badge use { | ||
| 449 | + fill: white; | ||
| 450 | +} | ||
| 451 | + | ||
| 452 | +#ov-topo svg .node .badge.badgeInfo use { | ||
| 453 | + fill: #448; | ||
| 454 | +} | ||
| 455 | + | ||
| 456 | +#ov-topo svg .node .badge text { | ||
| 457 | + fill: white; | ||
| 458 | +} | ||
| 459 | + | ||
| 460 | +#ov-topo svg .node .badge.badgeInfo text { | ||
| 461 | + fill: #448; | ||
| 462 | +} | ||
| 430 | 463 | ||
| 431 | /* Host Nodes */ | 464 | /* Host Nodes */ |
| 432 | 465 | ... | ... |
| ... | @@ -57,7 +57,8 @@ | ... | @@ -57,7 +57,8 @@ |
| 57 | }, | 57 | }, |
| 58 | badgeConfig = { | 58 | badgeConfig = { |
| 59 | radius: 12, | 59 | radius: 12, |
| 60 | - yoff: 5 | 60 | + yoff: 5, |
| 61 | + gdelta: 10 | ||
| 61 | }, | 62 | }, |
| 62 | icfg; | 63 | icfg; |
| 63 | 64 | ||
| ... | @@ -207,7 +208,8 @@ | ... | @@ -207,7 +208,8 @@ |
| 207 | dim = icfg.device.dim, | 208 | dim = icfg.device.dim, |
| 208 | box, dx, dy, bsel, | 209 | box, dx, dy, bsel, |
| 209 | bdg = d.badge, | 210 | bdg = d.badge, |
| 210 | - bcr = badgeConfig.radius; | 211 | + bcr = badgeConfig.radius, |
| 212 | + bcgd = badgeConfig.gdelta; | ||
| 211 | 213 | ||
| 212 | node.select('text') | 214 | node.select('text') |
| 213 | .text(label) | 215 | .text(label) |
| ... | @@ -235,6 +237,8 @@ | ... | @@ -235,6 +237,8 @@ |
| 235 | 237 | ||
| 236 | // handle badge, if defined | 238 | // handle badge, if defined |
| 237 | if (bdg) { | 239 | if (bdg) { |
| 240 | + node.select('g.badge').remove(); | ||
| 241 | + | ||
| 238 | bsel = node.append('g') | 242 | bsel = node.append('g') |
| 239 | .classed('badge', true) | 243 | .classed('badge', true) |
| 240 | .classed(badgeStatus(bdg), true) | 244 | .classed(badgeStatus(bdg), true) |
| ... | @@ -251,8 +255,9 @@ | ... | @@ -251,8 +255,9 @@ |
| 251 | } else if (bdg.gid) { | 255 | } else if (bdg.gid) { |
| 252 | bsel.append('use') | 256 | bsel.append('use') |
| 253 | .attr({ | 257 | .attr({ |
| 254 | - width: bcr * 2, | 258 | + width: bcgd * 2, |
| 255 | - height: bcr * 2, | 259 | + height: bcgd * 2, |
| 260 | + transform: sus.translate(-bcgd, -bcgd), | ||
| 256 | 'xlink:href': '#' + bdg.gid | 261 | 'xlink:href': '#' + bdg.gid |
| 257 | }); | 262 | }); |
| 258 | 263 | ... | ... |
| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | { | 5 | { |
| 6 | "id": "of:0000000000000001", | 6 | "id": "of:0000000000000001", |
| 7 | "badge": { | 7 | "badge": { |
| 8 | - "status": "e", | 8 | + "status": "i", |
| 9 | "gid": "xMark", | 9 | "gid": "xMark", |
| 10 | "msg": "x marks the spot" | 10 | "msg": "x marks the spot" |
| 11 | } | 11 | } |
| ... | @@ -14,7 +14,40 @@ | ... | @@ -14,7 +14,40 @@ |
| 14 | "id": "of:0000000000000002", | 14 | "id": "of:0000000000000002", |
| 15 | "badge": { | 15 | "badge": { |
| 16 | "status": "w", | 16 | "status": "w", |
| 17 | - "txt": "7" | 17 | + "gid": "crown", |
| 18 | + "msg": "it's good to be the King" | ||
| 19 | + } | ||
| 20 | + }, | ||
| 21 | + { | ||
| 22 | + "id": "of:0000000000000003", | ||
| 23 | + "badge": { | ||
| 24 | + "status": "e", | ||
| 25 | + "gid": "chain", | ||
| 26 | + "msg": "the weakest link" | ||
| 27 | + } | ||
| 28 | + }, | ||
| 29 | + { | ||
| 30 | + "id": "of:0000000000000004", | ||
| 31 | + "badge": { | ||
| 32 | + "status": "i", | ||
| 33 | + "txt": "1", | ||
| 34 | + "msg": "singular sensation" | ||
| 35 | + } | ||
| 36 | + }, | ||
| 37 | + { | ||
| 38 | + "id": "of:0000000000000005", | ||
| 39 | + "badge": { | ||
| 40 | + "status": "w", | ||
| 41 | + "txt": "42", | ||
| 42 | + "msg": "life, the universe, and everything!" | ||
| 43 | + } | ||
| 44 | + }, | ||
| 45 | + { | ||
| 46 | + "id": "of:0000000000000006", | ||
| 47 | + "badge": { | ||
| 48 | + "status": "e", | ||
| 49 | + "txt": "99", | ||
| 50 | + "msg": "cadbury's flake" | ||
| 18 | } | 51 | } |
| 19 | } | 52 | } |
| 20 | ], | 53 | ], |
| ... | @@ -23,7 +56,7 @@ | ... | @@ -23,7 +56,7 @@ |
| 23 | { | 56 | { |
| 24 | "css": "primary", | 57 | "css": "primary", |
| 25 | "id": "of:0000000000000001/5-of:0000000000000002/7", | 58 | "id": "of:0000000000000001/5-of:0000000000000002/7", |
| 26 | - "label": "Antz!" | 59 | + "label": "Foo!" |
| 27 | } | 60 | } |
| 28 | ] | 61 | ] |
| 29 | } | 62 | } | ... | ... |
| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | ], | 4 | ], |
| 5 | "title": "Demo adding badges", | 5 | "title": "Demo adding badges", |
| 6 | "params": { | 6 | "params": { |
| 7 | - "lastAuto": 5 | 7 | + "lastAuto": 9 |
| 8 | }, | 8 | }, |
| 9 | "description": [ | 9 | "description": [ |
| 10 | "Demonstrate the device badging feature." | 10 | "Demonstrate the device badging feature." | ... | ... |
-
Please register or login to post a comment