Preparing GUI resources for dynamic injection of contributed content. Ready to g…
…o, but for now disabled in web.xml. Change-Id: I0751077702835e7572b20037ba6ddc1950be6037
Showing
13 changed files
with
16 additions
and
288 deletions
... | @@ -27,6 +27,8 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -27,6 +27,8 @@ import static com.google.common.base.Preconditions.checkNotNull; |
27 | */ | 27 | */ |
28 | public class UiExtension { | 28 | public class UiExtension { |
29 | 29 | ||
30 | + private static final String VIEW_PREFIX = "app/view/"; | ||
31 | + | ||
30 | private final String prefix; | 32 | private final String prefix; |
31 | private final ClassLoader classLoader; | 33 | private final ClassLoader classLoader; |
32 | private final List<UiView> views; | 34 | private final List<UiView> views; |
... | @@ -92,7 +94,7 @@ public class UiExtension { | ... | @@ -92,7 +94,7 @@ public class UiExtension { |
92 | * @return resource input stream | 94 | * @return resource input stream |
93 | */ | 95 | */ |
94 | public InputStream resource(String viewId, String path) { | 96 | public InputStream resource(String viewId, String path) { |
95 | - InputStream is = classLoader.getResourceAsStream(viewId + "/" + path); | 97 | + InputStream is = classLoader.getResourceAsStream(VIEW_PREFIX + viewId + "/" + path); |
96 | return is; | 98 | return is; |
97 | } | 99 | } |
98 | 100 | ... | ... |
... | @@ -64,10 +64,10 @@ | ... | @@ -64,10 +64,10 @@ |
64 | <instructions> | 64 | <instructions> |
65 | <_wab>src/main/webapp/</_wab> | 65 | <_wab>src/main/webapp/</_wab> |
66 | <Include-Resource> | 66 | <Include-Resource> |
67 | - src/main/webapp/index.html, | 67 | + WEB-INF/classes/index.html=src/main/webapp/index.html, |
68 | - src/main/webapp/nav.html, | 68 | + WEB-INF/classes/onos.js=src/main/webapp/onos.js, |
69 | - src/main/webapp/onos.js, | 69 | + WEB-INF/classes/nav.html=src/main/webapp/nav.html, |
70 | - src/main/webapp/app/view, | 70 | + WEB-INF/classes/app/view=src/main/webapp/app/view, |
71 | {maven-resources} | 71 | {maven-resources} |
72 | </Include-Resource> | 72 | </Include-Resource> |
73 | <Bundle-SymbolicName> | 73 | <Bundle-SymbolicName> | ... | ... |
... | @@ -34,7 +34,7 @@ import static com.google.common.io.ByteStreams.toByteArray; | ... | @@ -34,7 +34,7 @@ import static com.google.common.io.ByteStreams.toByteArray; |
34 | /** | 34 | /** |
35 | * Resource for serving the dynamically composed index.html. | 35 | * Resource for serving the dynamically composed index.html. |
36 | */ | 36 | */ |
37 | -@Path("/index.html") | 37 | +@Path("/") |
38 | public class MainIndexResource extends AbstractInjectionResource { | 38 | public class MainIndexResource extends AbstractInjectionResource { |
39 | 39 | ||
40 | private static final String INDEX = "index.html"; | 40 | private static final String INDEX = "index.html"; | ... | ... |
... | @@ -35,7 +35,7 @@ import static org.onosproject.ui.impl.MainViewResource.SCRIPT; | ... | @@ -35,7 +35,7 @@ import static org.onosproject.ui.impl.MainViewResource.SCRIPT; |
35 | /** | 35 | /** |
36 | * Resource for serving the dynamically composed onos.js. | 36 | * Resource for serving the dynamically composed onos.js. |
37 | */ | 37 | */ |
38 | -@Path("/onos.js") | 38 | +@Path("/") |
39 | public class MainModuleResource extends AbstractInjectionResource { | 39 | public class MainModuleResource extends AbstractInjectionResource { |
40 | 40 | ||
41 | private static final String MAIN_JS = "onos.js"; | 41 | private static final String MAIN_JS = "onos.js"; | ... | ... |
... | @@ -35,7 +35,7 @@ import static com.google.common.io.ByteStreams.toByteArray; | ... | @@ -35,7 +35,7 @@ import static com.google.common.io.ByteStreams.toByteArray; |
35 | /** | 35 | /** |
36 | * Resource for serving the dynamically composed nav.html. | 36 | * Resource for serving the dynamically composed nav.html. |
37 | */ | 37 | */ |
38 | -@Path("/nav/nav.html") | 38 | +@Path("/") |
39 | public class MainNavResource extends AbstractInjectionResource { | 39 | public class MainNavResource extends AbstractInjectionResource { |
40 | 40 | ||
41 | private static final String NAV_HTML = "nav.html"; | 41 | private static final String NAV_HTML = "nav.html"; | ... | ... |
1 | <script src="app/view/sample/sample.js"></script> | 1 | <script src="app/view/sample/sample.js"></script> |
2 | <script src="app/view/topo/topo.js"></script> | 2 | <script src="app/view/topo/topo.js"></script> |
3 | <script src="app/view/topo/topoEvent.js"></script> | 3 | <script src="app/view/topo/topoEvent.js"></script> |
4 | +<script src="app/view/topo/topoFilter.js"></script> | ||
4 | <script src="app/view/topo/topoForce.js"></script> | 5 | <script src="app/view/topo/topoForce.js"></script> |
5 | -<script src="app/view/topo/topoPanel.js"></script> | ||
6 | <script src="app/view/topo/topoInst.js"></script> | 6 | <script src="app/view/topo/topoInst.js"></script> |
7 | +<script src="app/view/topo/topoModel.js"></script> | ||
8 | +<script src="app/view/topo/topoOblique.js"></script> | ||
9 | +<script src="app/view/topo/topoPanel.js"></script> | ||
10 | +<script src="app/view/topo/topoSelect.js"></script> | ||
11 | +<script src="app/view/topo/topoTraffic.js"></script> | ||
7 | <script src="app/view/device/device.js"></script> | 12 | <script src="app/view/device/device.js"></script> | ... | ... |
1 | -<!DOCTYPE html> | ||
2 | -<!-- | ||
3 | -~ Copyright 2014,2015 Open Networking Laboratory | ||
4 | -~ | ||
5 | -~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | -~ you may not use this file except in compliance with the License. | ||
7 | -~ You may obtain a copy of the License at | ||
8 | -~ | ||
9 | -~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | -~ | ||
11 | -~ Unless required by applicable law or agreed to in writing, software | ||
12 | -~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | -~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | -~ See the License for the specific language governing permissions and | ||
15 | -~ limitations under the License. | ||
16 | ---> | ||
17 | -<html> | ||
18 | -<head> | ||
19 | - <meta charset="utf-8"> | ||
20 | - <link rel="shortcut icon" href="../data/img/onos-logo.png"> | ||
21 | - <title>ONOS Angular</title> | ||
22 | - | ||
23 | - <!-- Third party library code included here --> | ||
24 | - <!--TODO: use minified versions, once debugging is complete --> | ||
25 | - <script src="tp/angular.js"></script> | ||
26 | - <script src="tp/angular-route.js"></script> | ||
27 | - | ||
28 | - <script src="tp/d3.js"></script> | ||
29 | - <script src="tp/topojson.v1.min.js"></script> | ||
30 | - | ||
31 | - <!-- ONOS UI Framework included here --> | ||
32 | - <!-- TODO: use a single catenated-minified file here --> | ||
33 | - <script src="dyn/onos.js"></script> | ||
34 | - <script src="app/directives.js"></script> | ||
35 | - | ||
36 | - <script src="app/fw/util/util.js"></script> | ||
37 | - <script src="app/fw/util/fn.js"></script> | ||
38 | - <script src="app/fw/util/random.js"></script> | ||
39 | - <script src="app/fw/util/theme.js"></script> | ||
40 | - <script src="app/fw/util/keys.js"></script> | ||
41 | - | ||
42 | - <script src="app/fw/mast/mast.js"></script> | ||
43 | - <script src="app/fw/nav/nav.js"></script> | ||
44 | - | ||
45 | - <script src="app/fw/svg/svg.js"></script> | ||
46 | - <script src="app/fw/svg/glyph.js"></script> | ||
47 | - <script src="app/fw/svg/icon.js"></script> | ||
48 | - <script src="app/fw/svg/geodata.js"></script> | ||
49 | - <script src="app/fw/svg/map.js"></script> | ||
50 | - <script src="app/fw/svg/zoom.js"></script> | ||
51 | - <script src="app/fw/svg/svgUtil.js"></script> | ||
52 | - | ||
53 | - <script src="app/fw/remote/remote.js"></script> | ||
54 | - <script src="app/fw/remote/urlfn.js"></script> | ||
55 | - <script src="app/fw/remote/rest.js"></script> | ||
56 | - <script src="app/fw/remote/websocket.js"></script> | ||
57 | - <script src="app/fw/remote/wsevent.js"></script> | ||
58 | - | ||
59 | - <script src="app/fw/widget/widget.js"></script> | ||
60 | - <script src="app/fw/widget/table.js"></script> | ||
61 | - <script src="app/fw/widget/toolbar.js"></script> | ||
62 | - <script src="app/fw/widget/button.js"></script> | ||
63 | - | ||
64 | - <script src="app/fw/layer/layer.js"></script> | ||
65 | - <script src="app/fw/layer/panel.js"></script> | ||
66 | - <script src="app/fw/layer/flash.js"></script> | ||
67 | - <script src="app/fw/layer/quickhelp.js"></script> | ||
68 | - <script src="app/fw/layer/veil.js"></script> | ||
69 | - | ||
70 | - <!-- Framework and library stylesheets included here --> | ||
71 | - <!-- TODO: use a single catenated-minified file here --> | ||
72 | - <link rel="stylesheet" href="app/onos.css"> | ||
73 | - <link rel="stylesheet" href="app/common.css"> | ||
74 | - <link rel="stylesheet" href="app/fw/mast/mast.css"> | ||
75 | - <link rel="stylesheet" href="app/fw/svg/glyph.css"> | ||
76 | - <link rel="stylesheet" href="app/fw/svg/icon.css"> | ||
77 | - <link rel="stylesheet" href="app/fw/layer/panel.css"> | ||
78 | - <link rel="stylesheet" href="app/fw/layer/flash.css"> | ||
79 | - <link rel="stylesheet" href="app/fw/layer/quickhelp.css"> | ||
80 | - <link rel="stylesheet" href="app/fw/layer/veil.css"> | ||
81 | - <link rel="stylesheet" href="app/fw/nav/nav.css"> | ||
82 | - | ||
83 | - <!-- This is where contributed javascript will get injected --> | ||
84 | - <!-- {INJECTED-JAVASCRIPT-START} --> | ||
85 | - <script src="app/view/sample/sample.js"></script> | ||
86 | - <script src="app/view/topo/topo.js"></script> | ||
87 | - <script src="app/view/topo/topoEvent.js"></script> | ||
88 | - <script src="app/view/topo/topoFilter.js"></script> | ||
89 | - <script src="app/view/topo/topoForce.js"></script> | ||
90 | - <script src="app/view/topo/topoInst.js"></script> | ||
91 | - <script src="app/view/topo/topoModel.js"></script> | ||
92 | - <script src="app/view/topo/topoOblique.js"></script> | ||
93 | - <script src="app/view/topo/topoPanel.js"></script> | ||
94 | - <script src="app/view/topo/topoSelect.js"></script> | ||
95 | - <script src="app/view/topo/topoTraffic.js"></script> | ||
96 | - <script src="app/view/device/device.js"></script> | ||
97 | - <!-- {INJECTED-JAVASCRIPT-END} --> | ||
98 | - | ||
99 | - | ||
100 | - <!-- This is where contributed stylesheets will get injected --> | ||
101 | - <!-- {INJECTED-STYLESHEETS-START} --> | ||
102 | - <link rel="stylesheet" href="app/view/sample/sample.css"> | ||
103 | - <link rel="stylesheet" href="app/view/topo/topo.css"> | ||
104 | - <link rel="stylesheet" href="app/view/device/device.css"> | ||
105 | - <!-- TODO: inject style-sheet refs server-side --> | ||
106 | - <!-- {INJECTED-STYLESHEETS-END} --> | ||
107 | - | ||
108 | -</head> | ||
109 | -<body class="light" ng-app="onosApp"> | ||
110 | -<div id="frame" ng-controller="OnosCtrl as onosCtrl"> | ||
111 | - <div id="mast" | ||
112 | - ng-controller="MastCtrl as mastCtrl" | ||
113 | - ng-include="'app/fw/mast/mast.html'"></div> | ||
114 | - | ||
115 | - <div id="view" ng-view></div> | ||
116 | - | ||
117 | - <div id="nav" | ||
118 | - ng-controller="NavCtrl as navCtrl" | ||
119 | - ng-include="'dyn/nav/nav.html'"></div> | ||
120 | - | ||
121 | - <div id="floatpanels"></div> | ||
122 | - <div id="alerts"></div> | ||
123 | - <div id="flash"></div> | ||
124 | - <div id="quickhelp"></div> | ||
125 | - <div id="veil" | ||
126 | - resize | ||
127 | - ng-style="resizeWithOffset(0, 0)"></div> | ||
128 | -</div> | ||
129 | -</body> | ||
130 | -</html> |
1 | -/* | ||
2 | - * Copyright 2014,2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | - | ||
17 | -/* | ||
18 | - ONOS GUI -- Main Application Module | ||
19 | - */ | ||
20 | - | ||
21 | -(function () { | ||
22 | - 'use strict'; | ||
23 | - | ||
24 | - // define core module dependencies here... | ||
25 | - var coreDependencies = [ | ||
26 | - 'ngRoute', | ||
27 | - 'onosMast', | ||
28 | - 'onosNav', | ||
29 | - 'onosUtil', | ||
30 | - 'onosSvg', | ||
31 | - 'onosRemote', | ||
32 | - 'onosLayer', | ||
33 | - 'onosWidget' | ||
34 | - ]; | ||
35 | - | ||
36 | - // view IDs.. note the first view listed is loaded at startup | ||
37 | - var viewIds = [ | ||
38 | - // TODO: inject view IDs server side | ||
39 | - // {INJECTED-VIEW-IDS-START} | ||
40 | - 'sample', | ||
41 | - 'topo', | ||
42 | - 'device', | ||
43 | - // {INJECTED-VIEW-IDS-END} | ||
44 | - | ||
45 | - // dummy entry | ||
46 | - '' | ||
47 | - ]; | ||
48 | - | ||
49 | - var viewDependencies = []; | ||
50 | - | ||
51 | - viewIds.forEach(function (id) { | ||
52 | - if (id) { | ||
53 | - viewDependencies.push('ov' + capitalize(id)); | ||
54 | - } | ||
55 | - }); | ||
56 | - | ||
57 | - var moduleDependencies = coreDependencies.concat(viewDependencies); | ||
58 | - | ||
59 | - function capitalize(word) { | ||
60 | - return word ? word[0].toUpperCase() + word.slice(1) : word; | ||
61 | - } | ||
62 | - | ||
63 | - angular.module('onosApp', moduleDependencies) | ||
64 | - | ||
65 | - .controller('OnosCtrl', [ | ||
66 | - '$log', '$route', '$routeParams', '$location', | ||
67 | - 'KeyService', 'ThemeService', 'GlyphService', 'PanelService', | ||
68 | - 'FlashService', 'QuickHelpService', | ||
69 | - | ||
70 | - function ($log, $route, $routeParams, $location, | ||
71 | - ks, ts, gs, ps, flash, qhs) { | ||
72 | - var self = this; | ||
73 | - | ||
74 | - self.$route = $route; | ||
75 | - self.$routeParams = $routeParams; | ||
76 | - self.$location = $location; | ||
77 | - self.version = '1.1.0'; | ||
78 | - | ||
79 | - // initialize services... | ||
80 | - ts.init(); | ||
81 | - ks.installOn(d3.select('body')); | ||
82 | - ks.bindQhs(qhs); | ||
83 | - gs.init(); | ||
84 | - ps.init(); | ||
85 | - flash.initFlash(); | ||
86 | - qhs.initQuickHelp(); | ||
87 | - | ||
88 | - $log.log('OnosCtrl has been created'); | ||
89 | - | ||
90 | - $log.debug('route: ', self.$route); | ||
91 | - $log.debug('routeParams: ', self.$routeParams); | ||
92 | - $log.debug('location: ', self.$location); | ||
93 | - }]) | ||
94 | - | ||
95 | - .config(['$routeProvider', function ($routeProvider) { | ||
96 | - // If view ID not provided, route to the first view in the list. | ||
97 | - $routeProvider | ||
98 | - .otherwise({ | ||
99 | - redirectTo: '/' + viewIds[0] | ||
100 | - }); | ||
101 | - | ||
102 | - function viewCtrlName(vid) { | ||
103 | - return 'Ov' + capitalize(vid) + 'Ctrl'; | ||
104 | - } | ||
105 | - | ||
106 | - function viewTemplateUrl(vid) { | ||
107 | - return 'app/view/' + vid + '/' + vid + '.html'; | ||
108 | - } | ||
109 | - | ||
110 | - // Add routes for each defined view. | ||
111 | - viewIds.forEach(function (vid) { | ||
112 | - if (vid) { | ||
113 | - $routeProvider.when('/' + vid, { | ||
114 | - controller: viewCtrlName(vid), | ||
115 | - controllerAs: 'ctrl', | ||
116 | - templateUrl: viewTemplateUrl(vid) | ||
117 | - }); | ||
118 | - } | ||
119 | - }); | ||
120 | - }]); | ||
121 | -}()); |
1 | -The 'appext' directory is for "Application Extensions". That is to say, | ||
2 | -this would be the path to applications contributing to the GUI. | ||
3 | - | ||
4 | -Note that these applications are 'external' to the base GUI, i.e. would | ||
5 | -be built and packaged in separate .jar/.war file. They would be installed | ||
6 | -via server-side injection. | ||
7 | - | ||
8 | -This directory is just a placeholder to reserve the path. |
5.61 KB
1 | -# The 'mock' directory contains code that can emulate the server-side of | ||
2 | -# a web socket (probably using node.js) to facilitate the manual injection | ||
3 | -# of (JSON structured) events, to aid in the development / debugging of | ||
4 | -# client side code. | ||
5 | -# | ||
6 | -# Each subdirectory will be per-view event data. | ||
7 | -# |
-
Please register or login to post a comment