ONOS-6725: UI-Lion: NavItems.

Change-Id: I5fc8dd5a0d93a4315dfc0d012a3875ee41c7da23
This commit is contained in:
Simon Hunt 2017-07-10 20:00:30 -07:00
parent 3a50b0dbdb
commit 23f9c7b2a9
16 changed files with 337 additions and 40 deletions

View File

@ -25,10 +25,10 @@ import org.onosproject.ui.UiExtensionService;
import java.util.List; import java.util.List;
/** /**
* Lists all UI views. * Lists all registered UI views.
*/ */
@Command(scope = "onos", name = "ui-views", @Command(scope = "onos", name = "ui-views",
description = "Lists all UI views") description = "Lists all registered UI views")
public class UiViewListCommand extends AbstractShellCommand { public class UiViewListCommand extends AbstractShellCommand {
private static final String FMT = "id=%s, category=%s, label=%s, icon=%s"; 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())); print("%s", json(service.getExtensions()));
} else { } else {
service.getExtensions().forEach(ext -> ext.views() 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()))); v.label(), v.iconId())));
} }
} }
@ -51,7 +51,7 @@ public class UiViewListCommand extends AbstractShellCommand {
extensions.forEach(ext -> ext.views() extensions.forEach(ext -> ext.views()
.forEach(v -> node.add(mapper.createObjectNode() .forEach(v -> node.add(mapper.createObjectNode()
.put("id", v.id()) .put("id", v.id())
.put("category", v.category().label()) .put("category", v.category().toString())
.put("label", v.label()) .put("label", v.label())
.put("icon", v.iconId())))); .put("icon", v.iconId()))));
return node; return node;

View File

@ -15,6 +15,8 @@
*/ */
package org.onosproject.ui; package org.onosproject.ui;
import org.onosproject.ui.lion.LionBundle;
import java.util.List; import java.util.List;
/** /**
@ -50,4 +52,11 @@ public interface UiExtensionService {
* @return contributing user interface extension * @return contributing user interface extension
*/ */
UiExtension getViewExtension(String viewId); UiExtension getViewExtension(String viewId);
/**
* Returns the navigation pane localization bundle.
*
* @return the navigation localization bundle
*/
LionBundle getNavLionBundle();
} }

View File

@ -31,42 +31,29 @@ public class UiView {
* Designates the navigation menu category. * Designates the navigation menu category.
*/ */
public enum Category { public enum Category {
// NOTE: human readable strings for the categories are now applied
// externally, with the appropriate localization bundle.
/** /**
* Represents platform related views. * Represents platform related views.
*/ */
PLATFORM("Platform"), PLATFORM,
/** /**
* Represents network-control related views. * Represents network-control related views.
*/ */
NETWORK("Network"), NETWORK,
/** /**
* Represents miscellaneous views. * Represents miscellaneous views.
*/ */
OTHER("Other"), OTHER,
/** /**
* Represents views that do not show in the navigation menu. * Represents views that do not show in the navigation menu.
* This category should not be specified directly; rather, use * This category should not be specified directly; rather, use
* the {@link UiViewHidden} constructor instead of {@link UiView}. * the {@link UiViewHidden} constructor instead of {@link UiView}.
*/ */
HIDDEN("(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;
}
} }
private final Category category; private final Category category;

View File

@ -15,6 +15,8 @@
*/ */
package org.onosproject.ui; package org.onosproject.ui;
import org.onosproject.ui.lion.LionBundle;
import java.util.List; import java.util.List;
/** /**
@ -38,4 +40,9 @@ public class UiExtensionServiceAdapter implements UiExtensionService {
public UiExtension getViewExtension(String viewId) { public UiExtension getViewExtension(String viewId) {
return null; return null;
} }
@Override
public LionBundle getNavLionBundle() {
return null;
}
} }

View File

@ -19,6 +19,7 @@ import org.onosproject.rest.AbstractInjectionResource;
import org.onosproject.ui.UiExtension; import org.onosproject.ui.UiExtension;
import org.onosproject.ui.UiExtensionService; import org.onosproject.ui.UiExtensionService;
import org.onosproject.ui.UiView; import org.onosproject.ui.UiView;
import org.onosproject.ui.lion.LionBundle;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; 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. // Produces an input stream of nav item injections from all extensions.
private InputStream includeNavItems(UiExtensionService service) { private InputStream includeNavItems(UiExtensionService service) {
List<UiExtension> extensions = service.getExtensions(); List<UiExtension> extensions = service.getExtensions();
LionBundle navLion = service.getNavLionBundle();
StringBuilder sb = new StringBuilder("\n"); StringBuilder sb = new StringBuilder("\n");
for (UiView.Category cat : UiView.Category.values()) { for (UiView.Category cat : UiView.Category.values()) {
@ -90,7 +92,7 @@ public class MainNavResource extends AbstractInjectionResource {
List<UiView> catViews = getViewsForCat(extensions, cat); List<UiView> catViews = getViewsForCat(extensions, cat);
if (!catViews.isEmpty()) { if (!catViews.isEmpty()) {
addCatHeader(sb, cat); addCatHeader(sb, cat, navLion);
addCatItems(sb, catViews); addCatItems(sb, catViews);
} }
} }
@ -109,8 +111,10 @@ public class MainNavResource extends AbstractInjectionResource {
return views; return views;
} }
private void addCatHeader(StringBuilder sb, UiView.Category cat) { private void addCatHeader(StringBuilder sb, UiView.Category cat,
sb.append(String.format(HDR_FORMAT, cat.label())); LionBundle navLion) {
String key = "cat_" + cat.name().toLowerCase();
sb.append(String.format(HDR_FORMAT, navLion.getValue(key)));
} }
private void addCatItems(StringBuilder sb, List<UiView> catViews) { private void addCatItems(StringBuilder sb, List<UiView> catViews) {

View File

@ -61,6 +61,7 @@ import org.onosproject.ui.UiViewHidden;
import org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler; import org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler;
import org.onosproject.ui.impl.topo.Topo2ViewMessageHandler; import org.onosproject.ui.impl.topo.Topo2ViewMessageHandler;
import org.onosproject.ui.impl.topo.Traffic2Overlay; import org.onosproject.ui.impl.topo.Traffic2Overlay;
import org.onosproject.ui.lion.LionBundle;
import org.onosproject.ui.lion.LionUtils; import org.onosproject.ui.lion.LionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -160,25 +161,43 @@ public class UiExtensionManager
Executors.newSingleThreadExecutor( Executors.newSingleThreadExecutor(
Tools.groupedThreads("onos/ui-ext-manager", "event-handler", log)); 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() { private UiExtension createCoreExtension() {
List<LionBundle> lionBundles = generateBundles(LION_BASE, LION_TAGS);
navLion = lionBundles.stream()
.filter(f -> f.id().equals("core.fw.Nav")).findFirst().get();
List<UiView> coreViews = of( List<UiView> coreViews = of(
new UiView(PLATFORM, "app", "Applications", "nav_apps"), mkView(PLATFORM, "app", "nav_apps"),
new UiView(PLATFORM, "settings", "Settings", "nav_settings"), mkView(PLATFORM, "settings", "nav_settings"),
new UiView(PLATFORM, "cluster", "Cluster Nodes", "nav_cluster"), mkView(PLATFORM, "cluster", "nav_cluster"),
new UiView(PLATFORM, "processor", "Packet Processors", "nav_processors"), mkView(PLATFORM, "processor", "nav_processors"),
new UiView(PLATFORM, "partition", "Partitions", "nav_partitions"), mkView(PLATFORM, "partition", "nav_partitions"),
new UiView(NETWORK, "topo", "Topology", "nav_topo"),
new UiView(NETWORK, "topo2", "Topology 2", "nav_topo2"), mkView(NETWORK, "topo", "nav_topo"),
new UiView(NETWORK, "device", "Devices", "nav_devs"), mkView(NETWORK, "topo2", "nav_topo2"),
mkView(NETWORK, "device", "nav_devs"),
new UiViewHidden("flow"), new UiViewHidden("flow"),
new UiViewHidden("port"), new UiViewHidden("port"),
new UiViewHidden("group"), new UiViewHidden("group"),
new UiViewHidden("meter"), new UiViewHidden("meter"),
new UiView(NETWORK, "link", "Links", "nav_links"),
new UiView(NETWORK, "host", "Hosts", "nav_hosts"), mkView(NETWORK, "link", "nav_links"),
new UiView(NETWORK, "intent", "Intents", "nav_intents"), mkView(NETWORK, "host", "nav_hosts"),
new UiView(NETWORK, "tunnel", "Tunnels", "nav_tunnels") mkView(NETWORK, "intent", "nav_intents"),
mkView(NETWORK, "tunnel", "nav_tunnels")
); );
UiMessageHandlerFactory messageHandlerFactory = UiMessageHandlerFactory messageHandlerFactory =
@ -235,7 +254,7 @@ public class UiExtensionManager
); );
return new UiExtension.Builder(CL, coreViews) return new UiExtension.Builder(CL, coreViews)
.lionBundles(generateBundles(LION_BASE, LION_TAGS)) .lionBundles(lionBundles)
.messageHandlerFactory(messageHandlerFactory) .messageHandlerFactory(messageHandlerFactory)
.topoOverlayFactory(topoOverlayFactory) .topoOverlayFactory(topoOverlayFactory)
.topo2OverlayFactory(topo2OverlayFactory) .topo2OverlayFactory(topo2OverlayFactory)
@ -316,6 +335,11 @@ public class UiExtensionManager
return views.get(viewId); return views.get(viewId);
} }
@Override
public synchronized LionBundle getNavLionBundle() {
return navLion;
}
@Override @Override
public Set<String> getUserNames() { public Set<String> getUserNames() {
ImmutableSet.Builder<String> builder = ImmutableSet.builder(); ImmutableSet.Builder<String> builder = ImmutableSet.builder();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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