use of org.onosproject.ui.UiExtension in project onos by opennetworkinglab.
the class UiExtensionManager method 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(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 UiViewHidden("pipeconf"), mkView(NETWORK, "link", "nav_links"), mkView(NETWORK, "host", "nav_hosts"), mkView(NETWORK, "intent", "nav_intents"));
UiMessageHandlerFactory messageHandlerFactory = () -> ImmutableList.of(new UserPreferencesMessageHandler(), new TopologyViewMessageHandler(), new Topo2ViewMessageHandler(), new Topo2TrafficMessageHandler(), new MapSelectorMessageHandler(), new DeviceViewMessageHandler(), new LinkViewMessageHandler(), new HostViewMessageHandler(), new FlowViewMessageHandler(), new PortViewMessageHandler(), new GroupViewMessageHandler(), new MeterViewMessageHandler(), new IntentViewMessageHandler(), new ApplicationViewMessageHandler(), new SettingsViewMessageHandler(), new ClusterViewMessageHandler(), new ProcessorViewMessageHandler(), new PartitionViewMessageHandler(), new PipeconfViewMessageHandler());
UiTopoOverlayFactory topoOverlayFactory = () -> ImmutableList.of(new TrafficOverlay(), new ProtectedIntentOverlay());
UiTopo2OverlayFactory topo2OverlayFactory = () -> ImmutableList.of(new Traffic2Overlay());
UiTopoMapFactory topoMapFactory = () -> ImmutableList.of(new UiTopoMap("australia", "Australia", "*australia", 1.0), new UiTopoMap("americas", "North, Central and South America", "*americas", 0.7), new UiTopoMap("n_america", "North America", "*n_america", 0.9), new UiTopoMap("s_america", "South America", "*s_america", 0.9), new UiTopoMap("usa", "United States", "*continental_us", 1.3), new UiTopoMap("bayareaGEO", "Bay Area, California", "*bayarea", 1.0), new UiTopoMap("europe", "Europe", "*europe", 10.0), new UiTopoMap("italy", "Italy", "*italy", 0.8), new UiTopoMap("uk", "United Kingdom and Ireland", "*uk", 2.0), new UiTopoMap("japan", "Japan", "*japan", 0.8), new UiTopoMap("s_korea", "South Korea", "*s_korea", 0.75), new UiTopoMap("taiwan", "Taiwan", "*taiwan", 0.7), new UiTopoMap("africa", "Africa", "*africa", 0.7), new UiTopoMap("oceania", "Oceania", "*oceania", 0.7), new UiTopoMap("asia", "Asia", "*asia", 0.7));
return new UiExtension.Builder(CL, coreViews).lionBundles(lionBundles).messageHandlerFactory(messageHandlerFactory).topoOverlayFactory(topoOverlayFactory).topo2OverlayFactory(topo2OverlayFactory).topoMapFactory(topoMapFactory).resourcePath(CORE).ui2().build();
}
use of org.onosproject.ui.UiExtension in project onos by opennetworkinglab.
the class NavResource method getNavigation.
@GET
@Path("uiextensions")
@Produces(MediaType.APPLICATION_JSON)
public Response getNavigation() throws JsonProcessingException {
UiExtensionService service = get(UiExtensionService.class);
UiViewSerializer serializer = new UiViewSerializer(UiView.class);
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule("UiViewSerializer");
module.addSerializer(serializer);
mapper.registerModule(module);
StringBuilder sb = new StringBuilder("[");
boolean first = true;
for (UiExtension uiExt : service.getExtensions()) {
for (UiView view : uiExt.views()) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(mapper.writeValueAsString(view));
}
}
sb.append("]");
return ok(sb.toString()).build();
}
use of org.onosproject.ui.UiExtension in project onos by opennetworkinglab.
the class MainNavResource method includeNavItems.
// 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()) {
if (cat == UiView.Category.HIDDEN) {
continue;
}
List<UiView> catViews = getViewsForCat(extensions, cat);
if (!catViews.isEmpty()) {
addCatHeader(sb, cat, navLion);
addCatItems(sb, catViews);
}
}
return new ByteArrayInputStream(sb.toString().getBytes());
}
use of org.onosproject.ui.UiExtension in project onos by opennetworkinglab.
the class MainViewResource method getViewResource.
@Path("{view}/{resource}")
@GET
public Response getViewResource(@PathParam("view") String viewId, @PathParam("resource") String resource) throws IOException {
UiExtensionService service = get(UiExtensionService.class);
UiExtension extension = service.getViewExtension(viewId);
return extension != null ? Response.ok(extension.resource(viewId, resource)).header(CONTENT_TYPE, contentType(resource)).build() : Response.status(Response.Status.NOT_FOUND).build();
}
use of org.onosproject.ui.UiExtension in project onos by opennetworkinglab.
the class UiViewListCommand method json.
private JsonNode json(List<UiExtension> extensions) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode node = mapper.createArrayNode();
extensions.forEach(ext -> ext.views().forEach(v -> node.add(mapper.createObjectNode().put("id", v.id()).put("category", v.category().toString()).put("label", v.label()).put("icon", v.iconId()))));
return node;
}
Aggregations