From 23f9c7b2a9e227c026ba3fdede93e83a2b0cd3b5 Mon Sep 17 00:00:00 2001 From: Simon Hunt Date: Mon, 10 Jul 2017 20:00:30 -0700 Subject: [PATCH] ONOS-6725: UI-Lion: NavItems. Change-Id: I5fc8dd5a0d93a4315dfc0d012a3875ee41c7da23 --- .../onosproject/cli/UiViewListCommand.java | 8 +-- .../onosproject/ui/UiExtensionService.java | 9 ++++ .../main/java/org/onosproject/ui/UiView.java | 25 +++------ .../ui/UiExtensionServiceAdapter.java | 7 +++ .../onosproject/ui/impl/MainNavResource.java | 10 ++-- .../ui/impl/UiExtensionManager.java | 52 ++++++++++++++----- .../ui/lion/core/view/Device.properties | 27 ++++++++++ .../ui/lion/core/view/Host.properties | 27 ++++++++++ .../ui/lion/core/view/Intent.properties | 27 ++++++++++ .../ui/lion/core/view/Link.properties | 27 ++++++++++ .../ui/lion/core/view/Partition.properties | 27 ++++++++++ .../ui/lion/core/view/Processor.properties | 27 ++++++++++ .../ui/lion/core/view/Settings.properties | 28 ++++++++++ .../ui/lion/core/view/Topo.properties | 25 +++++++++ .../ui/lion/core/view/Topo2.properties | 24 +++++++++ .../ui/lion/core/view/Tunnel.properties | 27 ++++++++++ 16 files changed, 337 insertions(+), 40 deletions(-) create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Device.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Host.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Intent.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Link.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Partition.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Processor.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Settings.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo2.properties create mode 100644 web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Tunnel.properties diff --git a/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java b/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java index 92d365b5b2..c23b6427e5 100644 --- a/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java +++ b/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java @@ -25,10 +25,10 @@ import org.onosproject.ui.UiExtensionService; import java.util.List; /** - * Lists all UI views. + * Lists all registered UI views. */ @Command(scope = "onos", name = "ui-views", - description = "Lists all UI views") + description = "Lists all registered UI views") public class UiViewListCommand extends AbstractShellCommand { private static final String FMT = "id=%s, category=%s, label=%s, icon=%s"; @@ -40,7 +40,7 @@ public class UiViewListCommand extends AbstractShellCommand { print("%s", json(service.getExtensions())); } else { service.getExtensions().forEach(ext -> ext.views() - .forEach(v -> print(FMT, v.id(), v.category().label(), + .forEach(v -> print(FMT, v.id(), v.category(), v.label(), v.iconId()))); } } @@ -51,7 +51,7 @@ public class UiViewListCommand extends AbstractShellCommand { extensions.forEach(ext -> ext.views() .forEach(v -> node.add(mapper.createObjectNode() .put("id", v.id()) - .put("category", v.category().label()) + .put("category", v.category().toString()) .put("label", v.label()) .put("icon", v.iconId())))); return node; diff --git a/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java b/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java index 79114e0d31..7946fe5b21 100644 --- a/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java +++ b/core/api/src/main/java/org/onosproject/ui/UiExtensionService.java @@ -15,6 +15,8 @@ */ package org.onosproject.ui; +import org.onosproject.ui.lion.LionBundle; + import java.util.List; /** @@ -50,4 +52,11 @@ public interface UiExtensionService { * @return contributing user interface extension */ UiExtension getViewExtension(String viewId); + + /** + * Returns the navigation pane localization bundle. + * + * @return the navigation localization bundle + */ + LionBundle getNavLionBundle(); } 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 4234e982e6..26ec73cd63 100644 --- a/core/api/src/main/java/org/onosproject/ui/UiView.java +++ b/core/api/src/main/java/org/onosproject/ui/UiView.java @@ -31,42 +31,29 @@ public class UiView { * Designates the navigation menu category. */ public enum Category { + // NOTE: human readable strings for the categories are now applied + // externally, with the appropriate localization bundle. /** * Represents platform related views. */ - PLATFORM("Platform"), + PLATFORM, /** * Represents network-control related views. */ - NETWORK("Network"), + NETWORK, /** * Represents miscellaneous views. */ - OTHER("Other"), + OTHER, /** * Represents views that do not show in the navigation menu. * This category should not be specified directly; rather, use * the {@link UiViewHidden} constructor instead of {@link UiView}. */ - HIDDEN("(hidden)"); - - private final String label; - - Category(String label) { - this.label = label; - } - - /** - * Returns the display label for the category. - * - * @return display label - */ - public String label() { - return label; - } + HIDDEN } private final Category category; diff --git a/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java b/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java index 76b6f52f1f..3555eaae42 100644 --- a/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java +++ b/core/api/src/test/java/org/onosproject/ui/UiExtensionServiceAdapter.java @@ -15,6 +15,8 @@ */ package org.onosproject.ui; +import org.onosproject.ui.lion.LionBundle; + import java.util.List; /** @@ -38,4 +40,9 @@ public class UiExtensionServiceAdapter implements UiExtensionService { public UiExtension getViewExtension(String viewId) { return null; } + + @Override + public LionBundle getNavLionBundle() { + return null; + } } 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 a8fed5f7e0..cbc173f21a 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 @@ -19,6 +19,7 @@ import org.onosproject.rest.AbstractInjectionResource; import org.onosproject.ui.UiExtension; import org.onosproject.ui.UiExtensionService; import org.onosproject.ui.UiView; +import org.onosproject.ui.lion.LionBundle; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -81,6 +82,7 @@ public class MainNavResource extends AbstractInjectionResource { // Produces an input stream of nav item injections from all extensions. private InputStream includeNavItems(UiExtensionService service) { List extensions = service.getExtensions(); + LionBundle navLion = service.getNavLionBundle(); StringBuilder sb = new StringBuilder("\n"); for (UiView.Category cat : UiView.Category.values()) { @@ -90,7 +92,7 @@ public class MainNavResource extends AbstractInjectionResource { List catViews = getViewsForCat(extensions, cat); if (!catViews.isEmpty()) { - addCatHeader(sb, cat); + addCatHeader(sb, cat, navLion); addCatItems(sb, catViews); } } @@ -109,8 +111,10 @@ public class MainNavResource extends AbstractInjectionResource { return views; } - private void addCatHeader(StringBuilder sb, UiView.Category cat) { - sb.append(String.format(HDR_FORMAT, cat.label())); + private void addCatHeader(StringBuilder sb, UiView.Category cat, + LionBundle navLion) { + String key = "cat_" + cat.name().toLowerCase(); + sb.append(String.format(HDR_FORMAT, navLion.getValue(key))); } private void addCatItems(StringBuilder sb, List catViews) { 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 7909498e64..7895751ecf 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 @@ -61,6 +61,7 @@ import org.onosproject.ui.UiViewHidden; import org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler; import org.onosproject.ui.impl.topo.Topo2ViewMessageHandler; import org.onosproject.ui.impl.topo.Traffic2Overlay; +import org.onosproject.ui.lion.LionBundle; import org.onosproject.ui.lion.LionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,25 +161,43 @@ public class UiExtensionManager Executors.newSingleThreadExecutor( Tools.groupedThreads("onos/ui-ext-manager", "event-handler", log)); - // Creates core UI extension + private LionBundle navLion; + + + private String lionNavText(String id) { + return navLion.getValue("nav_item_" + id); + } + + private UiView mkView(UiView.Category cat, String id, String iconId) { + return new UiView(cat, id, lionNavText(id), iconId); + } + private UiExtension createCoreExtension() { + List lionBundles = generateBundles(LION_BASE, LION_TAGS); + + navLion = lionBundles.stream() + .filter(f -> f.id().equals("core.fw.Nav")).findFirst().get(); + List coreViews = of( - new UiView(PLATFORM, "app", "Applications", "nav_apps"), - new UiView(PLATFORM, "settings", "Settings", "nav_settings"), - new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"), - new UiView(PLATFORM, "processor", "Packet Processors", "nav_processors"), - new UiView(PLATFORM, "partition", "Partitions", "nav_partitions"), - new UiView(NETWORK, "topo", "Topology", "nav_topo"), - new UiView(NETWORK, "topo2", "Topology 2", "nav_topo2"), - new UiView(NETWORK, "device", "Devices", "nav_devs"), + mkView(PLATFORM, "app", "nav_apps"), + mkView(PLATFORM, "settings", "nav_settings"), + mkView(PLATFORM, "cluster", "nav_cluster"), + mkView(PLATFORM, "processor", "nav_processors"), + mkView(PLATFORM, "partition", "nav_partitions"), + + mkView(NETWORK, "topo", "nav_topo"), + mkView(NETWORK, "topo2", "nav_topo2"), + mkView(NETWORK, "device", "nav_devs"), + new UiViewHidden("flow"), new UiViewHidden("port"), new UiViewHidden("group"), new UiViewHidden("meter"), - new UiView(NETWORK, "link", "Links", "nav_links"), - new UiView(NETWORK, "host", "Hosts", "nav_hosts"), - new UiView(NETWORK, "intent", "Intents", "nav_intents"), - new UiView(NETWORK, "tunnel", "Tunnels", "nav_tunnels") + + mkView(NETWORK, "link", "nav_links"), + mkView(NETWORK, "host", "nav_hosts"), + mkView(NETWORK, "intent", "nav_intents"), + mkView(NETWORK, "tunnel", "nav_tunnels") ); UiMessageHandlerFactory messageHandlerFactory = @@ -235,7 +254,7 @@ public class UiExtensionManager ); return new UiExtension.Builder(CL, coreViews) - .lionBundles(generateBundles(LION_BASE, LION_TAGS)) + .lionBundles(lionBundles) .messageHandlerFactory(messageHandlerFactory) .topoOverlayFactory(topoOverlayFactory) .topo2OverlayFactory(topo2OverlayFactory) @@ -316,6 +335,11 @@ public class UiExtensionManager return views.get(viewId); } + @Override + public synchronized LionBundle getNavLionBundle() { + return navLion; + } + @Override public Set getUserNames() { ImmutableSet.Builder builder = ImmutableSet.builder(); diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Device.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Device.properties new file mode 100644 index 0000000000..b9080bb53b --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Device.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_device=Devices + +# View title +title_devices=Devices diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Host.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Host.properties new file mode 100644 index 0000000000..b81facaa94 --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Host.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_host=Hosts + +# View title +title_hosts=Hosts diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Intent.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Intent.properties new file mode 100644 index 0000000000..a06c2f9cef --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Intent.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_intent=Intents + +# View title +title_intents=Intents diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Link.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Link.properties new file mode 100644 index 0000000000..75f14b7b6e --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Link.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_link=Links + +# View title +title_links=Links diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Partition.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Partition.properties new file mode 100644 index 0000000000..00a1efd4ff --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Partition.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_partition=Partitions + +# View title +title_partitions=Partitions diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Processor.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Processor.properties new file mode 100644 index 0000000000..d6fca032c0 --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Processor.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_processor=Packet Processors + +# View title +title_packet_processors=Packet Processors diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Settings.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Settings.properties new file mode 100644 index 0000000000..5873422f08 --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Settings.properties @@ -0,0 +1,28 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_settings=Settings + +# View title +title_component_settings=Component Settings + diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo.properties new file mode 100644 index 0000000000..21861cc798 --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo.properties @@ -0,0 +1,25 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_topo=Topology + diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo2.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo2.properties new file mode 100644 index 0000000000..678cf5df6d --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Topo2.properties @@ -0,0 +1,24 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_topo2=Topology 2 diff --git a/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Tunnel.properties b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Tunnel.properties new file mode 100644 index 0000000000..e3dcc36aa3 --- /dev/null +++ b/web/gui/src/main/resources/org/onosproject/ui/lion/core/view/Tunnel.properties @@ -0,0 +1,27 @@ +# +# Copyright 2017-present Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + + +# ========================================== +# | WIP -- Not Yet Ready For Translation | +# ========================================== + +# Text that appears in the navigation panel +nav_item_tunnel=Tunnels + +# View title +title_tunnels=Tunnels