GUI -- Finished icons test page. Displays all icons and glyphs using Angular constructs.
Change-Id: I65d9195eb5434a49e5d8e6fac7ce3205a72d22dd
Showing
4 changed files
with
105 additions
and
9 deletions
... | @@ -21,15 +21,75 @@ | ... | @@ -21,15 +21,75 @@ |
21 | (function () { | 21 | (function () { |
22 | 'use strict'; | 22 | 'use strict'; |
23 | 23 | ||
24 | + // assuming the glyph is a square | ||
25 | + // div is a D3 selection of the <DIV> element into which icon should load | ||
26 | + // size is the size of the glyph | ||
27 | + // id is the symbol id | ||
28 | + // rer is the rectangle the glyph will be in's rounded corners | ||
29 | + // svgClass is the class name for your glyph | ||
30 | + function createGlyph(div, size, id, rer, svgClass) { | ||
31 | + var dim = size || 20, | ||
32 | + gid = id || 'unknown', | ||
33 | + rx = rer || 4, | ||
34 | + svgCls = svgClass || 'embeddedGlyph', | ||
35 | + svg, g; | ||
36 | + | ||
37 | + svg = div.append('svg').attr({ | ||
38 | + 'class': svgCls, | ||
39 | + width: dim, | ||
40 | + height: dim, | ||
41 | + viewBox: '0 0 ' + dim + ' ' + dim | ||
42 | + }); | ||
43 | + | ||
44 | + g = svg.append('g').attr({ | ||
45 | + 'class': 'glyph' | ||
46 | + }); | ||
47 | + | ||
48 | + g.append('rect').attr({ | ||
49 | + width: dim, | ||
50 | + height: dim, | ||
51 | + rx: rx | ||
52 | + }); | ||
53 | + | ||
54 | + g.append('use').attr({ | ||
55 | + width: dim, | ||
56 | + height: dim, | ||
57 | + 'class': 'glyph', | ||
58 | + 'xlink:href': '#' + gid | ||
59 | + }); | ||
60 | + | ||
61 | +} | ||
62 | + | ||
24 | angular.module('showIconsTest', ['onosSvg']) | 63 | angular.module('showIconsTest', ['onosSvg']) |
25 | 64 | ||
26 | .controller('OvShowIconsTest', ['$log', 'GlyphService', 'IconService', | 65 | .controller('OvShowIconsTest', ['$log', 'GlyphService', 'IconService', |
27 | function ($log, gs, icns) { | 66 | function ($log, gs, icns) { |
28 | var self = this; | 67 | var self = this; |
29 | - self.a = 1; | ||
30 | - self.b = 2; | ||
31 | 68 | ||
32 | - self.message = "Hi"; | 69 | + gs.init(); |
70 | + | ||
71 | + var div = d3.select('#showIcons'); | ||
72 | + | ||
73 | + // show device online and offline icons | ||
74 | + icns.loadEmbeddedIcon(div, 'deviceOnline', 50); | ||
75 | + div.append('br'); | ||
76 | + icns.loadEmbeddedIcon(div, 'deviceOffline', 50); | ||
77 | + | ||
78 | + var defs = d3.select('defs'); | ||
79 | + | ||
80 | + // show all glyphs in glyph library | ||
81 | + gs.loadDefs(defs, null, true); | ||
82 | + var list = gs.ids(), | ||
83 | + gDiv = d3.select('#showGlyphs'), | ||
84 | + ctr = 0; | ||
85 | + list.forEach(function (id) { | ||
86 | + createGlyph(gDiv, 50, id); | ||
87 | + ctr += 1; | ||
88 | + if(ctr/3 > 1) { | ||
89 | + ctr = 0; | ||
90 | + gDiv.append('p'); | ||
91 | + } | ||
92 | + }); | ||
33 | 93 | ||
34 | $log.log('OvShowIconsTest has been created'); | 94 | $log.log('OvShowIconsTest has been created'); |
35 | }]); | 95 | }]); | ... | ... |
... | @@ -28,17 +28,24 @@ | ... | @@ -28,17 +28,24 @@ |
28 | <script type="text/javascript" src="../tp/angular-route.js"></script> | 28 | <script type="text/javascript" src="../tp/angular-route.js"></script> |
29 | 29 | ||
30 | <script type="text/javascript" src="../tp/d3.js"></script> | 30 | <script type="text/javascript" src="../tp/d3.js"></script> |
31 | + <script type="text/javascript" src="../tp/jquery-2.1.1.min.js"></script> | ||
31 | 32 | ||
32 | <script type="text/javascript" src="../app/fw/util/util.js"></script> | 33 | <script type="text/javascript" src="../app/fw/util/util.js"></script> |
33 | <script type="text/javascript" src="../app/fw/util/fn.js"></script> | 34 | <script type="text/javascript" src="../app/fw/util/fn.js"></script> |
34 | <script type="text/javascript" src="../app/fw/util/theme.js"></script> | 35 | <script type="text/javascript" src="../app/fw/util/theme.js"></script> |
35 | <script type="text/javascript" src="../app/fw/util/keys.js"></script> | 36 | <script type="text/javascript" src="../app/fw/util/keys.js"></script> |
37 | + | ||
36 | <script type="text/javascript" src="../app/fw/svg/svg.js"></script> | 38 | <script type="text/javascript" src="../app/fw/svg/svg.js"></script> |
37 | <script type="text/javascript" src="../app/fw/svg/glyph.js"></script> | 39 | <script type="text/javascript" src="../app/fw/svg/glyph.js"></script> |
38 | <script type="text/javascript" src="../app/fw/svg/icon.js"></script> | 40 | <script type="text/javascript" src="../app/fw/svg/icon.js"></script> |
41 | + <script type="text/javascript" src="../app/fw/svg/geodata.js"></script> | ||
42 | + <script type="text/javascript" src="../app/fw/svg/map.js"></script> | ||
43 | + <script type="text/javascript" src="../app/fw/svg/zoom.js"></script> | ||
44 | + | ||
39 | <script type="text/javascript" src="show-icons-test.js"></script> | 45 | <script type="text/javascript" src="show-icons-test.js"></script> |
40 | 46 | ||
41 | <link rel="stylesheet" href="../app/common.css"> | 47 | <link rel="stylesheet" href="../app/common.css"> |
48 | + <link rel="stylesheet" href="../app/fw/svg/icon.css"> | ||
42 | 49 | ||
43 | <style> | 50 | <style> |
44 | html, | 51 | html, |
... | @@ -51,15 +58,31 @@ | ... | @@ -51,15 +58,31 @@ |
51 | h2 { | 58 | h2 { |
52 | color: darkred; | 59 | color: darkred; |
53 | } | 60 | } |
61 | + | ||
62 | + svg .glyph { | ||
63 | + stroke: none; | ||
64 | + fill: #123456; | ||
65 | + fill-rule: evenodd; | ||
66 | + } | ||
67 | + | ||
68 | + svg.embeddedGlyph .glyph rect { | ||
69 | + fill: #fff | ||
70 | + } | ||
71 | + | ||
54 | </style> | 72 | </style> |
55 | 73 | ||
56 | </head> | 74 | </head> |
57 | <!-- outline for using a controller in Angular --> | 75 | <!-- outline for using a controller in Angular --> |
58 | -<body class="light" ng-app="showIconsTest"> | 76 | +<body class="light" ng-app="showIconsTest" ng-controller="OvShowIconsTest as ctrl"> |
59 | - <h2>Showing Icons with Icon Service Angular</h2> | 77 | + <h2>Displaying Icons and Glyphs with Angular</h2> |
60 | - <div id="show-icons" ng-controller="OvShowIconsTest as ctrl"> | 78 | + <div id="showIcons"> |
61 | - <!--{{message}}--> | 79 | + <p>Show all icons in icon library:<br></p> |
62 | - <p>{{ctrl.a}} + {{ctrl.b}} = {{ctrl.a+ctrl.b}}</p> | 80 | + </div> |
81 | + <hr> | ||
82 | + <div id="showGlyphs"> | ||
83 | + <p>Show all glyphs in glyph library:</p> | ||
84 | + <p>(Displays checkMark and xMark too, because icons are built on top | ||
85 | + of glyphs.)</p> | ||
63 | </div> | 86 | </div> |
64 | 87 | ||
65 | 88 | ... | ... |
... | @@ -23,6 +23,14 @@ table.summary-list { | ... | @@ -23,6 +23,14 @@ table.summary-list { |
23 | font-size: 10pt; | 23 | font-size: 10pt; |
24 | } | 24 | } |
25 | 25 | ||
26 | +/* TODO: uncomment following lines for scrollable table */ | ||
27 | +/* Possible CSS style for creating a scrollable table */ | ||
28 | +/*table.summary-list tbody {*/ | ||
29 | + /*height: 100px;*/ | ||
30 | + /*overflow: auto;*/ | ||
31 | + /*display: block;*/ | ||
32 | +/*}*/ | ||
33 | + | ||
26 | table.summary-list th { | 34 | table.summary-list th { |
27 | padding: 5px; | 35 | padding: 5px; |
28 | } | 36 | } | ... | ... |
1 | <!-- Device partial HTML --> | 1 | <!-- Device partial HTML --> |
2 | <div id="ov-device"> | 2 | <div id="ov-device"> |
3 | <h2>Device View</h2> | 3 | <h2>Device View</h2> |
4 | - | 4 | +<!-- TODO: uncomment and test the thead and tbody tags for CSS styling --> |
5 | <table class="summary-list"> | 5 | <table class="summary-list"> |
6 | + <!-- <thead> --> | ||
6 | <tr> | 7 | <tr> |
7 | <th></th> | 8 | <th></th> |
8 | <th>ID</th> | 9 | <th>ID</th> |
... | @@ -10,6 +11,9 @@ | ... | @@ -10,6 +11,9 @@ |
10 | <th>Hardware Version</th> | 11 | <th>Hardware Version</th> |
11 | <th>Software Version</th> | 12 | <th>Software Version</th> |
12 | </tr> | 13 | </tr> |
14 | + <!-- </thead> --> | ||
15 | + | ||
16 | + <!-- <tbody> --> | ||
13 | <tr ng-repeat="dev in ctrl.deviceData"> | 17 | <tr ng-repeat="dev in ctrl.deviceData"> |
14 | <td><div icon icon-id="{{dev._iconid_available}}"></div></td> | 18 | <td><div icon icon-id="{{dev._iconid_available}}"></div></td> |
15 | <td>{{dev.id}}</td> | 19 | <td>{{dev.id}}</td> |
... | @@ -18,6 +22,7 @@ | ... | @@ -18,6 +22,7 @@ |
18 | <td>{{dev.sw}}</td> | 22 | <td>{{dev.sw}}</td> |
19 | <!-- add more property fields for table from device data --> | 23 | <!-- add more property fields for table from device data --> |
20 | </tr> | 24 | </tr> |
25 | + <!-- </tbody> --> | ||
21 | </table> | 26 | </table> |
22 | 27 | ||
23 | </div> | 28 | </div> | ... | ... |
-
Please register or login to post a comment