Thomas Vachuska

Promoting new GUI resources into place; still hidden behind legacy redirect though.

Change-Id: If1f25cd7297b93374f492474eb321da16e9995ec
......@@ -63,7 +63,13 @@
<configuration>
<instructions>
<_wab>src/main/webapp/</_wab>
<Include-Resource>src/main/webapp/app/view,{maven-resources}</Include-Resource>
<Include-Resource>
src/main/webapp/index.html,
src/main/webapp/nav.html,
src/main/webapp/onos.js,
src/main/webapp/app/view,
{maven-resources}
</Include-Resource>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
......
......@@ -34,10 +34,10 @@ import static com.google.common.io.ByteStreams.toByteArray;
/**
* Resource for serving the dynamically composed index.html.
*/
@Path("/")
@Path("/index.html")
public class MainIndexResource extends AbstractInjectionResource {
private static final String INDEX = "templates/index-template.html";
private static final String INDEX = "index.html";
private static final String INJECT_CSS_START = "<!-- {INJECTED-STYLESHEETS-START} -->";
private static final String INJECT_CSS_END = "<!-- {INJECTED-STYLESHEETS-END} -->";
......
/*
* Copyright 2015 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.
*/
package org.onosproject.ui.impl;
import org.onosproject.ui.UiExtension;
import org.onosproject.ui.UiExtensionService;
import org.onosproject.ui.UiView;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import static com.google.common.collect.ImmutableList.of;
import static com.google.common.io.ByteStreams.toByteArray;
import static org.onosproject.ui.impl.MainViewResource.SCRIPT;
/**
* Resource for serving the dynamically composed onos.js.
*/
@Path("/onos.js")
public class MainModuleResource extends AbstractInjectionResource {
private static final String MAIN_JS = "onos.js";
private static final String INJECT_VIEW_IDS_START = "// {INJECTED-VIEW-IDS-START}";
private static final String INJECT_VIEW_IDS_END = "// {INJECTED-VIEW-IDS-END}";
@GET
@Produces(SCRIPT)
public Response getMainModule() throws IOException {
UiExtensionService service = get(UiExtensionService.class);
InputStream jsTemplate = getClass().getClassLoader().getResourceAsStream(MAIN_JS);
String js = new String(toByteArray(jsTemplate));
int p1s = split(js, 0, INJECT_VIEW_IDS_START);
int p1e = split(js, 0, INJECT_VIEW_IDS_END);
int p2s = split(js, p1e, null);
StreamEnumeration streams =
new StreamEnumeration(of(stream(js, 0, p1s),
includeViewIds(service),
stream(js, p1e, p2s)));
return Response.ok(new SequenceInputStream(streams)).build();
}
// Produces an input stream including view id injections from all extensions.
private InputStream includeViewIds(UiExtensionService service) {
StringBuilder sb = new StringBuilder("\n");
for (UiExtension extension : service.getExtensions()) {
for (UiView view : extension.views()) {
sb.append(" '").append(view.id()).append("',");
}
}
return new ByteArrayInputStream(sb.toString().getBytes());
}
}
......@@ -31,19 +31,14 @@ import java.io.SequenceInputStream;
import static com.google.common.collect.ImmutableList.of;
import static com.google.common.io.ByteStreams.toByteArray;
import static org.onosproject.ui.impl.MainViewResource.SCRIPT;
/**
* Resource for serving the dynamically composed onos.js.
* Resource for serving the dynamically composed nav.html.
*/
@Path("/")
public class MainExtResource extends AbstractInjectionResource {
@Path("/nav/nav.html")
public class MainNavResource extends AbstractInjectionResource {
private static final String MAIN_JS = "templates/onos-template.js";
private static final String NAV_HTML = "templates/nav-template.html";
private static final String INJECT_VIEW_IDS_START = "// {INJECTED-VIEW-IDS-START}";
private static final String INJECT_VIEW_IDS_END = "// {INJECTED-VIEW-IDS-END}";
private static final String NAV_HTML = "nav.html";
private static final String INJECT_VIEW_ITEMS_START = "<!-- {INJECTED-VIEW-NAV-START} -->";
private static final String INJECT_VIEW_ITEMS_END = "<!-- {INJECTED-VIEW-NAV-END} -->";
......@@ -52,38 +47,6 @@ public class MainExtResource extends AbstractInjectionResource {
private static final String NAV_FORMAT =
" <li> <a ng-click=\"navCtrl.hideNav()\" href=\"#/%s\">%s</a></li>";
@Path("/onos.js")
@GET
@Produces(SCRIPT)
public Response getMainModule() throws IOException {
UiExtensionService service = get(UiExtensionService.class);
InputStream jsTemplate = getClass().getClassLoader().getResourceAsStream(MAIN_JS);
String js = new String(toByteArray(jsTemplate));
int p1s = split(js, 0, INJECT_VIEW_IDS_START);
int p1e = split(js, 0, INJECT_VIEW_IDS_END);
int p2s = split(js, p1e, null);
StreamEnumeration streams =
new StreamEnumeration(of(stream(js, 0, p1s),
includeViewIds(service),
stream(js, p1e, p2s)));
return Response.ok(new SequenceInputStream(streams)).build();
}
// Produces an input stream including view id injections from all extensions.
private InputStream includeViewIds(UiExtensionService service) {
StringBuilder sb = new StringBuilder("\n");
for (UiExtension extension : service.getExtensions()) {
for (UiView view : extension.views()) {
sb.append(" '").append(view.id()).append("',");
}
}
return new ByteArrayInputStream(sb.toString().getBytes());
}
@Path("/nav/nav.html")
@GET
@Produces(MediaType.TEXT_HTML)
public Response getNavigation() throws IOException {
......
......@@ -78,14 +78,33 @@
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.classnames</param-name>
<param-value>org.onosproject.ui.impl.MainExtResource</param-value>
<param-value>org.onosproject.ui.impl.MainModuleResource</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Main Module</servlet-name>
<url-pattern>/dyn/*</url-pattern>
<url-pattern>/onos.js</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Nav Module</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.classnames</param-name>
<param-value>org.onosproject.ui.impl.MainNavResource</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Nav Module</servlet-name>
<url-pattern>/nav.html</url-pattern>
</servlet-mapping>
<servlet>
......
<!-- Masthead partial HTML -->
<img class="logo" src="../data/img/onos-logo.png" ng-click="mastCtrl.toggleNav()">
<img class="logo" src="data/img/onos-logo.png" ng-click="mastCtrl.toggleNav()">
<span class="title">Open Network Operating System</span>
<div id="mast-right"></div>
......
......@@ -59,7 +59,7 @@
// internal state
var cache = d3.map(),
bundledUrlPrefix = '../data/map/';
bundledUrlPrefix = 'data/map/';
function getUrl(id) {
if (id[0] === '*') {
......
<!DOCTYPE html>
<!--
~ Copyright 2014,2015 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.
-->
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="../data/img/onos-logo.png">
<title>ONOS Angular</title>
<!-- Third party library code included here -->
<!--TODO: use minified versions, once debugging is complete -->
<script src="../tp/angular.js"></script>
<script src="../tp/angular-route.js"></script>
<script src="../tp/d3.js"></script>
<script src="../tp/topojson.v1.min.js"></script>
<!-- ONOS UI Framework included here -->
<!-- TODO: use a single catenated-minified file here -->
<script src="onos.js"></script>
<script src="directives.js"></script>
<script src="fw/util/util.js"></script>
<script src="fw/util/fn.js"></script>
<script src="fw/util/random.js"></script>
<script src="fw/util/theme.js"></script>
<script src="fw/util/keys.js"></script>
<script src="fw/mast/mast.js"></script>
<script src="fw/nav/nav.js"></script>
<script src="fw/svg/svg.js"></script>
<script src="fw/svg/glyph.js"></script>
<script src="fw/svg/icon.js"></script>
<script src="fw/svg/geodata.js"></script>
<script src="fw/svg/map.js"></script>
<script src="fw/svg/zoom.js"></script>
<script src="fw/svg/svgUtil.js"></script>
<script src="fw/remote/remote.js"></script>
<script src="fw/remote/urlfn.js"></script>
<script src="fw/remote/rest.js"></script>
<script src="fw/remote/websocket.js"></script>
<script src="fw/remote/wsevent.js"></script>
<script src="fw/widget/widget.js"></script>
<script src="fw/widget/table.js"></script>
<script src="fw/widget/toolbar.js"></script>
<script src="fw/widget/button.js"></script>
<script src="fw/layer/layer.js"></script>
<script src="fw/layer/panel.js"></script>
<script src="fw/layer/flash.js"></script>
<script src="fw/layer/quickhelp.js"></script>
<script src="fw/layer/veil.js"></script>
<!-- Framework and library stylesheets included here -->
<!-- TODO: use a single catenated-minified file here -->
<link rel="stylesheet" href="onos.css">
<link rel="stylesheet" href="common.css">
<link rel="stylesheet" href="fw/mast/mast.css">
<link rel="stylesheet" href="fw/svg/glyph.css">
<link rel="stylesheet" href="fw/svg/icon.css">
<link rel="stylesheet" href="fw/layer/panel.css">
<link rel="stylesheet" href="fw/layer/flash.css">
<link rel="stylesheet" href="fw/layer/quickhelp.css">
<link rel="stylesheet" href="fw/layer/veil.css">
<link rel="stylesheet" href="fw/nav/nav.css">
<!-- This is where contributed javascript will get injected -->
<!-- {INJECTED-JAVASCRIPT-START} -->
<script src="view/sample/sample.js"></script>
<script src="view/topo/topo.js"></script>
<script src="view/topo/topoEvent.js"></script>
<script src="view/topo/topoFilter.js"></script>
<script src="view/topo/topoForce.js"></script>
<script src="view/topo/topoInst.js"></script>
<script src="view/topo/topoModel.js"></script>
<script src="view/topo/topoOblique.js"></script>
<script src="view/topo/topoPanel.js"></script>
<script src="view/topo/topoSelect.js"></script>
<script src="view/topo/topoTraffic.js"></script>
<script src="view/device/device.js"></script>
<!-- {INJECTED-JAVASCRIPT-END} -->
<!-- This is where contributed stylesheets will get injected -->
<!-- {INJECTED-STYLESHEETS-START} -->
<link rel="stylesheet" href="view/sample/sample.css">
<link rel="stylesheet" href="view/topo/topo.css">
<link rel="stylesheet" href="view/device/device.css">
<!-- TODO: inject style-sheet refs server-side -->
<!-- {INJECTED-STYLESHEETS-END} -->
</head>
<body class="light" ng-app="onosApp">
<div id="frame" ng-controller="OnosCtrl as onosCtrl">
<div id="mast"
ng-controller="MastCtrl as mastCtrl"
ng-include="'fw/mast/mast.html'"></div>
<div id="view" ng-view></div>
<div id="nav"
ng-controller="NavCtrl as navCtrl"
ng-include="'fw/nav/nav.html'"></div>
<div id="floatpanels"></div>
<div id="alerts"></div>
<div id="flash"></div>
<div id="quickhelp"></div>
<div id="veil"
resize
ng-style="resizeWithOffset(0, 0)"></div>
</div>
</body>
</html>
......@@ -2,7 +2,7 @@
<div id="ov-sample">
<h2> A Sample View </h2>
<img class="logo" src="../data/img/onos-logo.png">
<img class="logo" src="data/img/onos-logo.png">
<p>
This is a <i>view</i> distinct from the Topology viewer,
......
<!DOCTYPE html>
<!--
~ Copyright 2014,2015 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.
-->
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="data/img/onos-logo.png">
<title>ONOS Angular</title>
<!-- Third party library code included here -->
<!--TODO: use minified versions, once debugging is complete -->
<script src="tp/angular.js"></script>
<script src="tp/angular-route.js"></script>
<script src="tp/d3.js"></script>
<script src="tp/topojson.v1.min.js"></script>
<!-- ONOS UI Framework included here -->
<!-- TODO: use a single catenated-minified file here -->
<script src="onos.js"></script>
<script src="app/directives.js"></script>
<script src="app/fw/util/util.js"></script>
<script src="app/fw/util/fn.js"></script>
<script src="app/fw/util/random.js"></script>
<script src="app/fw/util/theme.js"></script>
<script src="app/fw/util/keys.js"></script>
<script src="app/fw/mast/mast.js"></script>
<script src="app/fw/nav/nav.js"></script>
<script src="app/fw/svg/svg.js"></script>
<script src="app/fw/svg/glyph.js"></script>
<script src="app/fw/svg/icon.js"></script>
<script src="app/fw/svg/geodata.js"></script>
<script src="app/fw/svg/map.js"></script>
<script src="app/fw/svg/zoom.js"></script>
<script src="app/fw/svg/svgUtil.js"></script>
<script src="app/fw/remote/remote.js"></script>
<script src="app/fw/remote/urlfn.js"></script>
<script src="app/fw/remote/rest.js"></script>
<script src="app/fw/remote/websocket.js"></script>
<script src="app/fw/remote/wsevent.js"></script>
<script src="app/fw/widget/widget.js"></script>
<script src="app/fw/widget/table.js"></script>
<script src="app/fw/widget/toolbar.js"></script>
<script src="app/fw/widget/button.js"></script>
<script src="app/fw/layer/layer.js"></script>
<script src="app/fw/layer/panel.js"></script>
<script src="app/fw/layer/flash.js"></script>
<script src="app/fw/layer/quickhelp.js"></script>
<script src="app/fw/layer/veil.js"></script>
<!-- Framework and library stylesheets included here -->
<!-- TODO: use a single catenated-minified file here -->
<link rel="stylesheet" href="app/onos.css">
<link rel="stylesheet" href="app/common.css">
<link rel="stylesheet" href="app/fw/mast/mast.css">
<link rel="stylesheet" href="app/fw/svg/glyph.css">
<link rel="stylesheet" href="app/fw/svg/icon.css">
<link rel="stylesheet" href="app/fw/layer/panel.css">
<link rel="stylesheet" href="app/fw/layer/flash.css">
<link rel="stylesheet" href="app/fw/layer/quickhelp.css">
<link rel="stylesheet" href="app/fw/layer/veil.css">
<link rel="stylesheet" href="app/fw/nav/nav.css">
<!-- This is where contributed javascript will get injected -->
<!-- {INJECTED-JAVASCRIPT-START} -->
<script src="app/view/sample/sample.js"></script>
<script src="app/view/topo/topo.js"></script>
<script src="app/view/topo/topoEvent.js"></script>
<script src="app/view/topo/topoFilter.js"></script>
<script src="app/view/topo/topoForce.js"></script>
<script src="app/view/topo/topoInst.js"></script>
<script src="app/view/topo/topoModel.js"></script>
<script src="app/view/topo/topoOblique.js"></script>
<script src="app/view/topo/topoPanel.js"></script>
<script src="app/view/topo/topoSelect.js"></script>
<script src="app/view/topo/topoTraffic.js"></script>
<script src="app/view/device/device.js"></script>
<!-- {INJECTED-JAVASCRIPT-END} -->
<!-- This is where contributed stylesheets will get injected -->
<!-- {INJECTED-STYLESHEETS-START} -->
<link rel="stylesheet" href="app/view/sample/sample.css">
<link rel="stylesheet" href="app/view/topo/topo.css">
<link rel="stylesheet" href="app/view/device/device.css">
<!-- TODO: inject style-sheet refs server-side -->
<!-- {INJECTED-STYLESHEETS-END} -->
</head>
<body class="light" ng-app="onosApp">
<div id="frame" ng-controller="OnosCtrl as onosCtrl">
<div id="mast"
ng-controller="MastCtrl as mastCtrl"
ng-include="'app/fw/mast/mast.html'"></div>
<div id="view" ng-view></div>
<div id="nav"
ng-controller="NavCtrl as navCtrl"
ng-include="'nav.html'"></div>
<div id="floatpanels"></div>
<div id="alerts"></div>
<div id="flash"></div>
<div id="quickhelp"></div>
<div id="veil"
resize
ng-style="resizeWithOffset(0, 0)"></div>
</div>
</body>
</html>
......@@ -3,7 +3,9 @@
<h3>(Note - this is temporary)</h3>
<ul>
<!-- {INJECTED-VIEW-NAV-START} -->
<li> <a ng-click="navCtrl.hideNav()" href="#/sample">Sample View</a></li>
<li> <a ng-click="navCtrl.hideNav()" href="#/topo">Topology View</a></li>
<li> <a ng-click="navCtrl.hideNav()" href="#/device">Device View</a></li>
<!-- {INJECTED-VIEW-NAV-END} -->
</ul>
......
......@@ -104,7 +104,7 @@
}
function viewTemplateUrl(vid) {
return 'view/' + vid + '/' + vid + '.html';
return 'app/view/' + vid + '/' + vid + '.html';
}
// Add routes for each defined view.
......
......@@ -51,7 +51,7 @@ describe('factory: fw/svg/geodata.js', function() {
promise = gds.fetchTopoData(id);
expect(promise.meta).toBeDefined();
expect(promise.meta.id).toBe(id);
expect(promise.meta.url).toBe('../data/map/foo.json');
expect(promise.meta.url).toBe('data/map/foo.json');
});
it('should treat an external id as the url itself', function () {
......