GUI -- Added category to the UiView abstraction.
Change-Id: I55fff4d242e8d6b8d8ce3d25e8f9355dc0ef976a
diff --git a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfUi.java b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfUi.java
index 5d7132d..1f31672 100644
--- a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfUi.java
+++ b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfUi.java
@@ -39,6 +39,7 @@
import java.util.Set;
import static java.util.Collections.synchronizedSet;
+import static org.onosproject.ui.UiView.Category.OTHER;
/**
* Mechanism to stream data to the GUI.
@@ -52,7 +53,7 @@
private final Set<StreamingControl> handlers = synchronizedSet(new HashSet<>());
- private List<UiView> views = ImmutableList.of(new UiView("intentPerf", "Intent Performance"));
+ private List<UiView> views = ImmutableList.of(new UiView(OTHER, "intentPerf", "Intent Performance"));
private UiExtension uiExtension = new UiExtension(views, this::newHandlers,
getClass().getClassLoader());
diff --git a/core/api/src/main/java/org/onosproject/ui/UiView.java b/core/api/src/main/java/org/onosproject/ui/UiView.java
index 2f2bc0e..6e3a1a2 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiView.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiView.java
@@ -24,21 +24,68 @@
*/
public class UiView {
+ /**
+ * Designates navigation menu category.
+ */
+ public enum Category {
+ /**
+ * Represents platform related views.
+ */
+ PLATFORM("Platform"),
+
+ /**
+ * Represents network-control related views.
+ */
+ NETWORK("Network"),
+
+ /**
+ * Represents miscellaneous views.
+ */
+ OTHER("Other");
+
+ private final String label;
+
+ Category(String label) {
+ this.label = label;
+ }
+
+ /**
+ * Returns display label for the category.
+ *
+ * @return display label
+ */
+ public String label() {
+ return label;
+ }
+ }
+
private final String id;
private final String label;
+ private final Category category;
/**
* Creates a new user interface view descriptor.
*
- * @param id view identifier
- * @param label view label
+ * @param category view category
+ * @param id view identifier
+ * @param label view label
*/
- public UiView(String id, String label) {
+ public UiView(Category category, String id, String label) {
+ this.category = category;
this.id = id;
this.label = label;
}
/**
+ * Returns the navigation category.
+ *
+ * @return navigation category
+ */
+ public Category category() {
+ return category;
+ }
+
+ /**
* Returns the view identifier.
*
* @return view id
@@ -76,6 +123,7 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
+ .add("category", category)
.add("id", id)
.add("label", label)
.toString();
diff --git a/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java b/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java
index e1fc855..072404e 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiViewHidden.java
@@ -26,10 +26,10 @@
/**
* Creates a new user interface hidden view descriptor.
*
- * @param id view identifier
+ * @param id view identifier
*/
public UiViewHidden(String id) {
- super(id, null);
+ super(Category.OTHER, id, null);
}
@Override
diff --git a/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java b/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java
index 3bd9797..efc0261 100644
--- a/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java
+++ b/core/api/src/test/java/org/onosproject/ui/UiExtensionTest.java
@@ -22,6 +22,7 @@
import static com.google.common.io.ByteStreams.toByteArray;
import static org.junit.Assert.*;
+import static org.onosproject.ui.UiView.Category.OTHER;
/**
* Tests the default user interface extension descriptor.
@@ -30,26 +31,27 @@
@Test
public void basics() throws IOException {
- UiExtension ext = new UiExtension(ImmutableList.of(new UiView("foo", "Foo View")),
+ UiExtension ext = new UiExtension(ImmutableList.of(new UiView(OTHER, "foo", "Foo View")),
null,
getClass().getClassLoader());
String css = new String(toByteArray(ext.css()));
assertTrue("incorrect css stream", css.contains("foo-css"));
String js = new String(toByteArray(ext.js()));
assertTrue("incorrect js stream", js.contains("foo-js"));
- assertEquals("incorrect views stream", "foo", ext.views().get(0).id());
+ assertEquals("incorrect view id", "foo", ext.views().get(0).id());
+ assertEquals("incorrect view category", OTHER, ext.views().get(0).category());
assertNull("incorrect handler factory", ext.messageHandlerFactory());
}
@Test
public void withPath() throws IOException {
- UiExtension ext = new UiExtension(ImmutableList.of(new UiView("foo", "Foo View")),
+ UiExtension ext = new UiExtension(ImmutableList.of(new UiView(OTHER, "foo", "Foo View")),
null, "custom", getClass().getClassLoader());
String css = new String(toByteArray(ext.css()));
assertTrue("incorrect css stream", css.contains("custom-css"));
String js = new String(toByteArray(ext.js()));
assertTrue("incorrect js stream", js.contains("custom-js"));
- assertEquals("incorrect views stream", "foo", ext.views().get(0).id());
+ assertEquals("incorrect view id", "foo", ext.views().get(0).id());
assertNull("incorrect handler factory", ext.messageHandlerFactory());
}
}
\ No newline at end of file
diff --git a/tools/test/cells/tom b/tools/test/cells/tom
index a48933b..28d3172 100644
--- a/tools/test/cells/tom
+++ b/tools/test/cells/tom
@@ -4,4 +4,4 @@
export OC1="192.168.56.11"
export OC2="192.168.56.12"
export OC3="192.168.56.13"
-export OCN="192.168.56.14"
+export OCN="192.168.56.7"
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/MainNavResource.java b/web/gui/src/main/java/org/onosproject/ui/impl/MainNavResource.java
index be229d3..853dd94 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/MainNavResource.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/MainNavResource.java
@@ -44,7 +44,6 @@
private static final String INJECT_VIEW_ITEMS_START = "<!-- {INJECTED-VIEW-NAV-START} -->";
private static final String INJECT_VIEW_ITEMS_END = "<!-- {INJECTED-VIEW-NAV-END} -->";
-
private static final String NAV_FORMAT =
"<a ng-click=\"navCtrl.hideNav()\" href=\"#/%s\">%s</a>\n";
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
index 2f1a2e2..a924dba 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
@@ -38,6 +38,8 @@
import static com.google.common.collect.ImmutableList.of;
import static java.util.stream.Collectors.toSet;
+import static org.onosproject.ui.UiView.Category.NETWORK;
+import static org.onosproject.ui.UiView.Category.PLATFORM;
/**
* Manages the user interface extensions.
@@ -60,14 +62,14 @@
// Creates core UI extension
private static UiExtension createCoreExtension() {
- List<UiView> coreViews = of(new UiView("topo", "Topology"),
- new UiView("device", "Devices"),
+ List<UiView> coreViews = of(new UiView(PLATFORM, "app", "Applications"),
+ new UiView(PLATFORM, "cluster", "Cluster Nodes"),
+ new UiView(NETWORK, "topo", "Topology"),
+ new UiView(NETWORK, "device", "Devices"),
new UiViewHidden("flow"),
- new UiView("link", "Links"),
- new UiView("host", "Hosts"),
- new UiView("intent", "Intents"),
- new UiView("app", "Applications"),
- new UiView("cluster", "Cluster Nodes"));
+ new UiView(NETWORK, "link", "Links"),
+ new UiView(NETWORK, "host", "Hosts"),
+ new UiView(NETWORK, "intent", "Intents"));
UiMessageHandlerFactory messageHandlerFactory =
() -> ImmutableList.of(
diff --git a/web/gui/src/main/webapp/onos.js b/web/gui/src/main/webapp/onos.js
index d478a2a..5d534e3 100644
--- a/web/gui/src/main/webapp/onos.js
+++ b/web/gui/src/main/webapp/onos.js
@@ -106,7 +106,7 @@
// If view ID not provided, route to the first view in the list.
$routeProvider
.otherwise({
- redirectTo: '/' + viewIds[0]
+ redirectTo: '/topo'
});
function viewCtrlName(vid) {