mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 02:11:38 +02:00
ONOS-6725: UI-Lion: NavItems.
Change-Id: I5fc8dd5a0d93a4315dfc0d012a3875ee41c7da23
This commit is contained in:
parent
3a50b0dbdb
commit
23f9c7b2a9
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<UiExtension> 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<UiView> 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<UiView> catViews) {
|
||||
|
@ -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<LionBundle> lionBundles = generateBundles(LION_BASE, LION_TAGS);
|
||||
|
||||
navLion = lionBundles.stream()
|
||||
.filter(f -> f.id().equals("core.fw.Nav")).findFirst().get();
|
||||
|
||||
List<UiView> 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<String> getUserNames() {
|
||||
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user