Thomas Vachuska

Preparing GUI resources for dynamic injection of contributed content. Ready to g…

…o, but for now disabled in web.xml.

Change-Id: I0751077702835e7572b20037ba6ddc1950be6037
......@@ -27,6 +27,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class UiExtension {
private static final String VIEW_PREFIX = "app/view/";
private final String prefix;
private final ClassLoader classLoader;
private final List<UiView> views;
......@@ -92,7 +94,7 @@ public class UiExtension {
* @return resource input stream
*/
public InputStream resource(String viewId, String path) {
InputStream is = classLoader.getResourceAsStream(viewId + "/" + path);
InputStream is = classLoader.getResourceAsStream(VIEW_PREFIX + viewId + "/" + path);
return is;
}
......
......@@ -64,10 +64,10 @@
<instructions>
<_wab>src/main/webapp/</_wab>
<Include-Resource>
src/main/webapp/index.html,
src/main/webapp/nav.html,
src/main/webapp/onos.js,
src/main/webapp/app/view,
WEB-INF/classes/index.html=src/main/webapp/index.html,
WEB-INF/classes/onos.js=src/main/webapp/onos.js,
WEB-INF/classes/nav.html=src/main/webapp/nav.html,
WEB-INF/classes/app/view=src/main/webapp/app/view,
{maven-resources}
</Include-Resource>
<Bundle-SymbolicName>
......
......@@ -34,7 +34,7 @@ import static com.google.common.io.ByteStreams.toByteArray;
/**
* Resource for serving the dynamically composed index.html.
*/
@Path("/index.html")
@Path("/")
public class MainIndexResource extends AbstractInjectionResource {
private static final String INDEX = "index.html";
......
......@@ -35,7 +35,7 @@ import static org.onosproject.ui.impl.MainViewResource.SCRIPT;
/**
* Resource for serving the dynamically composed onos.js.
*/
@Path("/onos.js")
@Path("/")
public class MainModuleResource extends AbstractInjectionResource {
private static final String MAIN_JS = "onos.js";
......
......@@ -35,7 +35,7 @@ import static com.google.common.io.ByteStreams.toByteArray;
/**
* Resource for serving the dynamically composed nav.html.
*/
@Path("/nav/nav.html")
@Path("/")
public class MainNavResource extends AbstractInjectionResource {
private static final String NAV_HTML = "nav.html";
......
<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/topoPanel.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>
......
<!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="dyn/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="'dyn/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>
<!-- Navigation partial HTML -->
<h2>Navigation</h2>
<h3>(Note - this is temporary)</h3>
<ul>
<!-- {INJECTED-VIEW-NAV-START} -->
<!-- {INJECTED-VIEW-NAV-END} -->
</ul>
/*
* 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.
*/
/*
ONOS GUI -- Main Application Module
*/
(function () {
'use strict';
// define core module dependencies here...
var coreDependencies = [
'ngRoute',
'onosMast',
'onosNav',
'onosUtil',
'onosSvg',
'onosRemote',
'onosLayer',
'onosWidget'
];
// view IDs.. note the first view listed is loaded at startup
var viewIds = [
// TODO: inject view IDs server side
// {INJECTED-VIEW-IDS-START}
'sample',
'topo',
'device',
// {INJECTED-VIEW-IDS-END}
// dummy entry
''
];
var viewDependencies = [];
viewIds.forEach(function (id) {
if (id) {
viewDependencies.push('ov' + capitalize(id));
}
});
var moduleDependencies = coreDependencies.concat(viewDependencies);
function capitalize(word) {
return word ? word[0].toUpperCase() + word.slice(1) : word;
}
angular.module('onosApp', moduleDependencies)
.controller('OnosCtrl', [
'$log', '$route', '$routeParams', '$location',
'KeyService', 'ThemeService', 'GlyphService', 'PanelService',
'FlashService', 'QuickHelpService',
function ($log, $route, $routeParams, $location,
ks, ts, gs, ps, flash, qhs) {
var self = this;
self.$route = $route;
self.$routeParams = $routeParams;
self.$location = $location;
self.version = '1.1.0';
// initialize services...
ts.init();
ks.installOn(d3.select('body'));
ks.bindQhs(qhs);
gs.init();
ps.init();
flash.initFlash();
qhs.initQuickHelp();
$log.log('OnosCtrl has been created');
$log.debug('route: ', self.$route);
$log.debug('routeParams: ', self.$routeParams);
$log.debug('location: ', self.$location);
}])
.config(['$routeProvider', function ($routeProvider) {
// If view ID not provided, route to the first view in the list.
$routeProvider
.otherwise({
redirectTo: '/' + viewIds[0]
});
function viewCtrlName(vid) {
return 'Ov' + capitalize(vid) + 'Ctrl';
}
function viewTemplateUrl(vid) {
return 'app/view/' + vid + '/' + vid + '.html';
}
// Add routes for each defined view.
viewIds.forEach(function (vid) {
if (vid) {
$routeProvider.when('/' + vid, {
controller: viewCtrlName(vid),
controllerAs: 'ctrl',
templateUrl: viewTemplateUrl(vid)
});
}
});
}]);
}());
The 'appext' directory is for "Application Extensions". That is to say,
this would be the path to applications contributing to the GUI.
Note that these applications are 'external' to the base GUI, i.e. would
be built and packaged in separate .jar/.war file. They would be installed
via server-side injection.
This directory is just a placeholder to reserve the path.
# The 'mock' directory contains code that can emulate the server-side of
# a web socket (probably using node.js) to facilitate the manual injection
# of (JSON structured) events, to aid in the development / debugging of
# client side code.
#
# Each subdirectory will be per-view event data.
#
# Placeholder for a mock topology view servlet (using node.js),
# so that we can inject test events...
This is so we don't have to pollute the client-side code with test stuff.