ONOS-1477 - GUI -- Added glyphs to nav menu.
Change-Id: Ifacd5d389bdc2bb5adc61182b8329de9e2557af2
Showing
5 changed files
with
64 additions
and
12 deletions
... | @@ -66,9 +66,10 @@ public class UiView { | ... | @@ -66,9 +66,10 @@ public class UiView { |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | + private final Category category; | ||
69 | private final String id; | 70 | private final String id; |
70 | private final String label; | 71 | private final String label; |
71 | - private final Category category; | 72 | + private final String iconId; |
72 | 73 | ||
73 | /** | 74 | /** |
74 | * Creates a new user interface view descriptor. The navigation item | 75 | * Creates a new user interface view descriptor. The navigation item |
... | @@ -79,9 +80,24 @@ public class UiView { | ... | @@ -79,9 +80,24 @@ public class UiView { |
79 | * @param label view label | 80 | * @param label view label |
80 | */ | 81 | */ |
81 | public UiView(Category category, String id, String label) { | 82 | public UiView(Category category, String id, String label) { |
83 | + this(category, id, label, null); | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * Creates a new user interface view descriptor. The navigation item | ||
88 | + * will appear in the navigation menu under the specified category, | ||
89 | + * with the specified icon adornment. | ||
90 | + * | ||
91 | + * @param category view category | ||
92 | + * @param id view identifier | ||
93 | + * @param label view label | ||
94 | + * @param iconId icon id | ||
95 | + */ | ||
96 | + public UiView(Category category, String id, String label, String iconId) { | ||
82 | this.category = category; | 97 | this.category = category; |
83 | this.id = id; | 98 | this.id = id; |
84 | this.label = label; | 99 | this.label = label; |
100 | + this.iconId = iconId; | ||
85 | } | 101 | } |
86 | 102 | ||
87 | /** | 103 | /** |
... | @@ -111,6 +127,15 @@ public class UiView { | ... | @@ -111,6 +127,15 @@ public class UiView { |
111 | return label; | 127 | return label; |
112 | } | 128 | } |
113 | 129 | ||
130 | + /** | ||
131 | + * Returns the icon ID. | ||
132 | + * | ||
133 | + * @return icon ID | ||
134 | + */ | ||
135 | + public String iconId() { | ||
136 | + return iconId; | ||
137 | + } | ||
138 | + | ||
114 | @Override | 139 | @Override |
115 | public int hashCode() { | 140 | public int hashCode() { |
116 | return Objects.hash(id); | 141 | return Objects.hash(id); |
... | @@ -134,6 +159,7 @@ public class UiView { | ... | @@ -134,6 +159,7 @@ public class UiView { |
134 | .add("category", category) | 159 | .add("category", category) |
135 | .add("id", id) | 160 | .add("id", id) |
136 | .add("label", label) | 161 | .add("label", label) |
162 | + .add("iconId", iconId) | ||
137 | .toString(); | 163 | .toString(); |
138 | } | 164 | } |
139 | } | 165 | } | ... | ... |
... | @@ -51,7 +51,9 @@ public class MainNavResource extends AbstractInjectionResource { | ... | @@ -51,7 +51,9 @@ public class MainNavResource extends AbstractInjectionResource { |
51 | private static final String HDR_FORMAT = | 51 | private static final String HDR_FORMAT = |
52 | "<div class=\"nav-hdr\">%s</div>\n"; | 52 | "<div class=\"nav-hdr\">%s</div>\n"; |
53 | private static final String NAV_FORMAT = | 53 | private static final String NAV_FORMAT = |
54 | - "<a ng-click=\"navCtrl.hideNav()\" href=\"#/%s\">%s</a>\n"; | 54 | + "<a ng-click=\"navCtrl.hideNav()\" href=\"#/%s\">%s %s</a>\n"; |
55 | + | ||
56 | + private static final String BLANK_GLYPH = "unknown"; | ||
55 | 57 | ||
56 | @GET | 58 | @GET |
57 | @Produces(MediaType.TEXT_HTML) | 59 | @Produces(MediaType.TEXT_HTML) |
... | @@ -110,7 +112,12 @@ public class MainNavResource extends AbstractInjectionResource { | ... | @@ -110,7 +112,12 @@ public class MainNavResource extends AbstractInjectionResource { |
110 | 112 | ||
111 | private void addCatItems(StringBuilder sb, List<UiView> catViews) { | 113 | private void addCatItems(StringBuilder sb, List<UiView> catViews) { |
112 | for (UiView view : catViews) { | 114 | for (UiView view : catViews) { |
113 | - sb.append(String.format(NAV_FORMAT, view.id(), view.label())); | 115 | + sb.append(String.format(NAV_FORMAT, view.id(), icon(view), view.label())); |
116 | + } | ||
114 | } | 117 | } |
118 | + | ||
119 | + private String icon(UiView view) { | ||
120 | + String gid = view.iconId() == null ? BLANK_GLYPH : view.iconId(); | ||
121 | + return "<div icon icon-id=\"" + gid + "\"></div>"; | ||
115 | } | 122 | } |
116 | } | 123 | } | ... | ... |
... | @@ -62,14 +62,16 @@ public class UiExtensionManager implements UiExtensionService, SpriteService { | ... | @@ -62,14 +62,16 @@ public class UiExtensionManager implements UiExtensionService, SpriteService { |
62 | 62 | ||
63 | // Creates core UI extension | 63 | // Creates core UI extension |
64 | private static UiExtension createCoreExtension() { | 64 | private static UiExtension createCoreExtension() { |
65 | - List<UiView> coreViews = of(new UiView(PLATFORM, "app", "Applications"), | 65 | + List<UiView> coreViews = of( |
66 | - new UiView(PLATFORM, "cluster", "Cluster Nodes"), | 66 | + new UiView(PLATFORM, "app", "Applications", "nav_apps"), |
67 | - new UiView(NETWORK, "topo", "Topology"), | 67 | + new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"), |
68 | - new UiView(NETWORK, "device", "Devices"), | 68 | + new UiView(NETWORK, "topo", "Topology", "nav_topo"), |
69 | + new UiView(NETWORK, "device", "Devices", "nav_devs"), | ||
69 | new UiViewHidden("flow"), | 70 | new UiViewHidden("flow"), |
70 | - new UiView(NETWORK, "link", "Links"), | 71 | + new UiView(NETWORK, "link", "Links", "nav_links"), |
71 | - new UiView(NETWORK, "host", "Hosts"), | 72 | + new UiView(NETWORK, "host", "Hosts", "nav_hosts"), |
72 | - new UiView(NETWORK, "intent", "Intents")); | 73 | + new UiView(NETWORK, "intent", "Intents", "nav_intents") |
74 | + ); | ||
73 | 75 | ||
74 | UiMessageHandlerFactory messageHandlerFactory = | 76 | UiMessageHandlerFactory messageHandlerFactory = |
75 | () -> ImmutableList.of( | 77 | () -> ImmutableList.of( | ... | ... |
... | @@ -56,7 +56,7 @@ | ... | @@ -56,7 +56,7 @@ |
56 | text-decoration: none; | 56 | text-decoration: none; |
57 | font-size: 14pt; | 57 | font-size: 14pt; |
58 | display: block; | 58 | display: block; |
59 | - padding: 8px 16px 6px 16px; | 59 | + padding: 8px 16px 6px 12px; |
60 | } | 60 | } |
61 | 61 | ||
62 | .light #nav a { | 62 | .light #nav a { |
... | @@ -75,3 +75,12 @@ | ... | @@ -75,3 +75,12 @@ |
75 | background-color: #777; | 75 | background-color: #777; |
76 | } | 76 | } |
77 | 77 | ||
78 | +#nav a div { | ||
79 | + display: inline-block; | ||
80 | + vertical-align: middle; | ||
81 | + padding-right: 4px; | ||
82 | +} | ||
83 | + | ||
84 | +#nav a div svg.embeddedIcon g.icon .glyph { | ||
85 | + fill: #c66; | ||
86 | +} | ... | ... |
... | @@ -47,7 +47,15 @@ | ... | @@ -47,7 +47,15 @@ |
47 | 47 | ||
48 | hostIcon_endstation: 'endstation', | 48 | hostIcon_endstation: 'endstation', |
49 | hostIcon_router: 'router', | 49 | hostIcon_router: 'router', |
50 | - hostIcon_bgpSpeaker: 'bgpSpeaker' | 50 | + hostIcon_bgpSpeaker: 'bgpSpeaker', |
51 | + | ||
52 | + nav_apps: 'bird', | ||
53 | + nav_cluster: 'node', | ||
54 | + nav_topo: 'unknown', // TODO: need a topology glyph | ||
55 | + nav_devs: 'switch', | ||
56 | + nav_links: 'ports', | ||
57 | + nav_hosts: 'endstation', | ||
58 | + nav_intents: 'relatedIntents' | ||
51 | }; | 59 | }; |
52 | 60 | ||
53 | function ensureIconLibDefs() { | 61 | function ensureIconLibDefs() { | ... | ... |
-
Please register or login to post a comment